pasterwhite.blogg.se

Touchchip usb reader stm32 driver
Touchchip usb reader stm32 driver










  1. #Touchchip usb reader stm32 driver full size#
  2. #Touchchip usb reader stm32 driver code#

Now the project is ready for compiling and programming the MCU! If we connect STM32 to the PC, we'll see a new USB Mass storage device in our system. Where '10' is a timeout value for read/write operations. HAL_SD_WriteBlocks(&hsd, buf, blk_addr, (uint32_t) blk_len, 10) HAL_SD_ReadBlocks(&hsd, buf, blk_addr, (uint32_t) blk_len, 10) HAL_SD_ReadBlocks() and HAL_SD_WriteBlocks() functions' prototypes have been changed in the newest STM32CubeMx versions.

#Touchchip usb reader stm32 driver code#

We've just added the code which will read/write data from/to SD-card connected to SDIO interface. HAL_SD_WriteBlocks(&hsd, (uint32_t*)buf, (uint64_t)(blk_addr * BLOCK_SIZE), BLOCK_SIZE, blk_len) HAL_SD_ReadBlocks(&hsd, (uint32_t*)buf, (uint64_t)(blk_addr * BLOCK_SIZE), BLOCK_SIZE, blk_len) *block_num = SDCardInfo.CardCapacity / BLOCK_SIZE We should just divide the total size by the size of one block: int8_t STORAGE_GetCapacity_FS (uint8_t lun, uint32_t *block_num, uint16_t *block_size) STORAGE_GetCapacity_FS() should return the block size and the number of blocks, and now we can calculate it. So, they should be defined in usbd_storage_if.c file too: extern SD_HandleTypeDef hsd Įxtern HAL_SD_CardInfoTypedef SDCardInfo This function takes two arguments which are defined in the main.c file.

#Touchchip usb reader stm32 driver full size#

To get SD-card full size we can use HAL_SD_Get_CardInfo(). Secondly, STORAGE_GetCapacity_FS() function has to be modified.

touchchip usb reader stm32 driver

Let's edit some of them in order to make our device working! Firstly, we should correct the block size: #define BLOCK_SIZE 512 STMCubeMx doesn't fill this functions, so they are empty.

touchchip usb reader stm32 driver

Thus, we should edit usbd_storage_if.c file, where all the functions needed for USB interface are located: STORAGE_Init_FS, HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_RESET) Īs you see, Cube has already initialised SDIO and USB, but it doesn't take care about relations between these units. Firstly, I'll reset the output state of USB_DISCONNECT_PIN: /* Initialize all configured peripherals */ When the generation is finished, the project is ready for programming the MCU, but we have to make some modifications in the source files. In principle, after that all units are configured properly, so we can start the project generation process!












Touchchip usb reader stm32 driver