SPI外挂Flash模拟U盘demo
\*****************************************************************\
1.该demo在AT32F403A系列芯片上实现外挂SPI FLASH模拟U盘;
2.使用的SPI为AT32F403A系列的SPI1;
3.使用时将附件解压到AT32官方BSP如下目录即可:
BSP Project\AT_STATRT_F403A\Examples\USB_Device
main函数处理流程如下:
#include "usb_lib.h"
#include "hw_config.h"
#include "usb_pwr.h"
#include "at32_board.h"
#include "mass_mal.h"
extern uint32_t Data_Buffer[];
int main(void)
{
uint8_t u8FlashLed = LED4;
/*AT START F4xx board initialize
* Include LED, Button
*/
AT32_Board_Init();
/*USB GPIO configure*/
AT32_USB_GPIO_init();
/*Enable USB Interrut*/
USB_Interrupts_Config();
/*Set USB Clock, USB Clock must 48MHz and clock source is HSE or HSI*/
Set_USBClock(USBCLK_FROM_HSE);
/*init SD card*/
if ( MAL_Init(0) != MAL_OK )
{
/*no SD Card connect*/
u8FlashLed = LED2;
}
/*if use USB SRAM_Size = 768 Byte, default is 512 Byte*/
/* USB protocol and register initialize*/
USB_Init();
while(1)
{
Delay_ms(500);
AT32_LEDn_Toggle((LED_Type)u8FlashLed);
}
}
|