13 #include "usbd_flash_if.h"
48 const uint8_t* USBD_DFU_StringDesc[MAX_USED_MEMORY_MEDIA] = {
53 uint8_t MAL_Buffer[TRANSFER_SIZE];
59 static uint8_t DFU_MAL_CheckAddr (uint32_t Addr);
75 for(memIdx = 0; memIdx < MAX_USED_MEMORY_MEDIA; memIdx++)
78 if (tMALTab[memIdx]->pMAL_Init != NULL)
80 tMALTab[memIdx]->pMAL_Init();
97 for(memIdx = 0; memIdx < MAX_USED_MEMORY_MEDIA; memIdx++)
100 if (tMALTab[memIdx]->pMAL_DeInit != NULL)
102 tMALTab[memIdx]->pMAL_DeInit();
116 uint32_t memIdx = DFU_MAL_CheckAddr(Addr);
119 if (IS_PROTECTED_AREA(Addr))
124 if (memIdx < MAX_USED_MEMORY_MEDIA)
127 if (tMALTab[memIdx]->pMAL_Erase != NULL)
129 return tMALTab[memIdx]->pMAL_Erase(Addr);
150 uint32_t memIdx = DFU_MAL_CheckAddr(Addr);
153 if (IS_PROTECTED_AREA(Addr))
158 if (memIdx < MAX_USED_MEMORY_MEDIA)
161 if (tMALTab[memIdx]->pMAL_Write != NULL)
163 return tMALTab[memIdx]->pMAL_Write(Addr, Len);
188 memIdx = DFU_MAL_CheckAddr(Addr);
191 if (memIdx < MAX_USED_MEMORY_MEDIA)
194 if (tMALTab[memIdx]->pMAL_Read != NULL)
196 return tMALTab[memIdx]->pMAL_Read(Addr, Len);
218 uint32_t memIdx = DFU_MAL_CheckAddr(Addr);
220 if (memIdx < MAX_USED_MEMORY_MEDIA)
224 SET_POLLING_TIMEOUT(tMALTab[memIdx]->WriteTimeout);
228 SET_POLLING_TIMEOUT(tMALTab[memIdx]->EraseTimeout);
244 static uint8_t DFU_MAL_CheckAddr (uint32_t Addr)
249 for(memIdx = 0; memIdx < MAX_USED_MEMORY_MEDIA; memIdx++)
252 if (tMALTab[memIdx]->pMAL_CheckAdd(Addr) == MAL_OK)
259 return (MAX_USED_MEMORY_MEDIA);
uint8_t DFU_MAL_DeInit(void)
Deinitialize the memory media on the GD32.
uint8_t DFU_MAL_Write(uint32_t Addr, uint32_t Len)
Write data to sectors of memory.
uint8_t DFU_MAL_GetStatus(uint32_t Addr, uint8_t Cmd, uint8_t *buffer)
Get the status of a given memory and store in buffer.
uint8_t * DFU_MAL_Read(uint32_t Addr, uint32_t Len)
Read data from sectors of memory.
uint8_t DFU_MAL_Erase(uint32_t Addr)
Erase a memory sector.
USB DFU device media access layer header file.
uint8_t DFU_MAL_Init(void)
Initialize the memory media on the GD32.