
- CHIBIOS USB SERIAL EXAMPLE HOW TO
- CHIBIOS USB SERIAL EXAMPLE SERIAL
Code explanation :Īs you have seen we are using PB10 and PB11 for the UART with an alternate function as we did in the PWM tutorial. In the general case scenario where you have to activate/deactivate a driver (call it driver x), you have to look in the mcuconf.h file for the block about this driver x, in this block you will see its instances and parameters, then simply activate the one you want by defining its use as TRUE or deactivate it by defining its use as FALSE.
CHIBIOS USB SERIAL EXAMPLE SERIAL
What we want to do is to use the serial driver of USART3 (we could have used any other, but i am sure that this one is not activated in the demo folder we copied).įirst open mcuconf.h, then activate the serial driver for USART3 as in the picture below :
CHIBIOS USB SERIAL EXAMPLE HOW TO
Makefile : helps to compile your code (manages dependencies and where to find all the source code)įor now we are only going to see how to mess with the mcuconf.h file. halconf.h : chooses and configures the peripherals used by the application. chconf.h : chooses and configures the services used by chibiOS kernel in the application. Messing with mcuconf.h :Īs you may have seen, there are other files tha main.c in the sample folder: You’re perfectly right, if you didn’t activate USART3 this code won’t work, we will see how to do it in the next paragraph. WAIIIT !!! This code is not compiling, i have an error with this SD3 of yours : it doesn’t exist ! This code sends the string « Hello World ! » every 0.5 seconds on USART3 of the board, using the serial driver SD3. SdWrite(&SD3, (uint8_t *) data, strlen(data)) // Writes "Hello World in the UART output SdStart(&SD3, &uartCfg) // starts the serial driver with uartCfg as a configĬhar data = "Hello World ! \n \r" /* we create the string "Hello World!", \n means go to the next line PalSetPadMode(GPIOB, 11, PAL_MODE_ALTERNATE(7)) // used function : USART3_RX PalSetPadMode(GPIOB, 10, PAL_MODE_ALTERNATE(7)) // used function : USART3_TX , but it is already implicitely called in halInit() */ * sdInit() should be used as we see in the SerialDriver state machine HalInit() // initialize Hardware Abstraction LayerĬhSysInit() // initialize ChibiOS kernel Now that you know how to configure the devices and what the serial driver does, let’s put it in practice.