Part 2: Hardware (This part)
Hardware
I finally built a PCB that works great and even helped me to track down a nasty bug (took me a while, too. Hang on here with me, I'm actually going to tell you about it because it's fun).But now, hardware.
Before
|
After
|
#elif defined (USE_STM32303C_EVAL) #include "stm32f30x.h" #include "stm32303c_eval.h" #include "stm32303c_eval_spi_sd.h" #endif | #elif defined (USE_STM32303C_EVAL) || defined (USE_STM32F3_DISCOVERY) #include "stm32f30x.h" #if defined (USE_STM32F3_DISCOVERY) #include "stm32f3_discovery.h" #define Button_KEY BUTTON_USER #define Mode_EXTI BUTTON_MODE_EXTI #define LED1 LED5 #define LED2 LED6 #define KEY_BUTTON_EXTI_LINE USER_BUTTON_EXTI_LINE #else #include "stm32303c_eval.h" #include "stm32303c_eval_spi_sd.h" #endif //#ifdef (USE_STM32F3_DISCOVERY) #endif |
Before
|
After
|
uint16_t MAL_Init(uint8_t lun) { uint16_t status = MAL_OK; switch (lun) { case 0: Status = SD_Init(); break; #ifdef USE_STM3210E_EVAL case 1: NAND_Init(); break; #endif default: return MAL_FAIL; } return status; } |
uint16_t MAL_Init(uint8_t lun) { #ifndef USE_STM32F3_DISCOVERY uint16_t status = MAL_OK; switch (lun) { case 0: Status = SD_Init(); break; #ifdef USE_STM3210E_EVAL case 1: NAND_Init(); break; #endif default: return MAL_FAIL; } return status; #else return MAL_OK; #endif //#ifndef USE_STM32F3_DISCOVERY } |
Before
|
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS) void EXTI0_IRQHandler(void) #elif defined (STM32F37X) void EXTI2_TS_IRQHandler(void) #else void EXTI9_5_IRQHandler(void) #endif |
After
|
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS) || defined(USE_STM32F3_DISCOVERY) void EXTI0_IRQHandler(void) #elif defined (STM32F37X) void EXTI2_TS_IRQHandler(void) #else void EXTI9_5_IRQHandler(void) #endif |
Endpoints
Endpoints can be described as sources or sinks of data. As the bus is host centric, endpoints occur at the end of the communications channel at the USB function. At the software layer, your device driver may send a packet to your devices EP1 for example. As the data is flowing out from the host, it will end up in the EP1 OUT buffer. Your firmware will then at its leisure read this data. If it wants to return data, the function cannot simply write to the bus as the bus is controlled by the host. Therefore it writes data to EP1 IN which sits in the buffer until such time when the host sends a IN packet to that endpoint requesting the data. Endpoints can also be seen as the interface between the hardware of the function device and the firmware running on the function device.
All devices must support endpoint zero. This is the endpoint which receives all of the devices control and status requests during enumeration and throughout the duration while the device is operational on the bus.
![]() |
| If you hold you mouse over a conflict sign, you'll see what's the problem |
| Power HD 1501 Analog Servo |