USART Library has been updated!
Today I’ve modified USART library.
My library uses receive interrupt. After that, it just save data into cyclic buffer. User actually don’t know when that happen. Today, I was working on some project, where I need to know exact time, when data arrived on USART.
For that purpose, I’ve modified USART library.
To be able to know exact time when data arrived, you have to add defines in your defines.h file:
1 2 3 4 5 6 7 8 9 10 11 |
//Enable custom receive interrupt handler for each USART //Enable for USART1 and so on //Put only this defines, you want to use #define TM_USART1_USE_CUSTOM_IRQ #define TM_USART2_USE_CUSTOM_IRQ #define TM_USART3_USE_CUSTOM_IRQ #define TM_UART4_USE_CUSTOM_IRQ #define TM_UART5_USE_CUSTOM_IRQ #define TM_USART6_USE_CUSTOM_IRQ #define TM_UART7_USE_CUSTOM_IRQ #define TM_UART8_USE_CUSTOM_IRQ |
Then, you have to manually create a function inside your project somewhere (let’s say in main.c) called:
1 2 3 4 5 6 7 8 9 |
//This is your custom handler function. //It is called from my USART library. //Change USART1 to your U(S)ARTx you will use //If you have more USARTS, you have to create more of this functions with corresponding names //Parameter c is a received character void TM_USART1_ReceiveHandler(uint8_t c) { //Do your stuff here when byte is received } |
Note: If you activate custom receive interrupt handler, than incoming byte is not saved into cyclic buffer anymore!
USART library for all USART peripherals
Recent comments