/** ************************************************************************** * @file msc_diskio.h * @version v2.1.1 * @date 2022-07-22 * @brief usb mass storage disk interface header file ************************************************************************** * Copyright notice & Disclaimer * * The software Board Support Package (BSP) that is made available to * download from Artery official website is the copyrighted work of Artery. * Artery authorizes customers to use, copy, and distribute the BSP * software and its related documentation for the purpose of design and * development in conjunction with Artery microcontrollers. Use of the * software is governed by this copyright notice and the following disclaimer. * * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. * ************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MSC_DISKIO_H #define __MSC_DISKIO_H #ifdef __cplusplus extern "C" { #endif #include "usb_conf.h" /** @addtogroup AT32F415_periph_examples * @{ */ /** @addtogroup 415_USB_device_msc * @{ */ #define INTERNAL_FLASH_LUN 0 #define SPI_FLASH_LUN 1 #define SD_LUN 2 #define DFU_FLASH_APP_ADDR_START 0x08008000 #define DAT_FLASH_APP_ADDR_START 0x00000000 #define SECTOR_SIZE_1K 1024 #define SECTOR_SIZE_2K 2048 #define SECTOR_SIZE_4K 4096 uint8_t *get_inquiry(uint8_t lun); int8_t msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len); int8_t msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len); int8_t msc_disk_capacity(uint8_t lun, uint32_t *blk_nbr, uint32_t *blk_size); uint8_t flash_Erase(uint32_t read_addr); void flash_read(uint32_t read_addr, uint8_t *p_buffer, uint16_t num_read); uint8_t flash_write(uint32_t write_addr, uint8_t *p_buffer, uint16_t num_Write); void Flash_Test(void); /** * @} */ enum { UFI_MODE_IDEL = 0, UFI_MODE_NORMAL, UFI_MODE_SET_INFO, UFI_MODE_DOWN_INFO, UFI_MODE_DOWN_START, UFI_MODE_DOWN_ABORT, UFI_MODE_DOWN_FINISH, UFI_MODE_DOWN_VERIFY, UFI_MODE_READ_INNER_FLASH, UFI_MODE_READ_EXTER_FLASH, UFI_MODE_ERASE_INNER_FLASH, UFI_MODE_ERASE_EXTER_FLASH, UFI_MODE_GET_VERSION, UFI_MODE_SYNCHRONOUS, UFI_MODE_REBOOT, }; typedef struct { uint8_t header[5]; uint8_t cmd[3]; uint8_t pdata[512]; }iap_struct_type; typedef struct { uint8_t sign[4]; uint32_t iFileSize; uint32_t iFileCRC; uint32_t iFilePacket; uint32_t eFileSize; uint32_t eFileCRC; uint32_t eFilePacket; }iap_info_struct_type; extern iap_info_struct_type DL_Info ; typedef enum { IAP_STATE_IDEL = 0, IAP_STATE_DOWNLOAD_PACKET, IAP_STATE_VERIFY_PACKET, IAP_STATE_MODIFY_PARAME, IAP_STATE_REBOOT, }iap_state_machine; extern iap_state_machine IAP_CURR_STATE; /** * @} */ #ifdef __cplusplus } #endif #endif