|
Hierodule 1.6.2
Utility module set for STM32 MCUs
|
Elements of the module that are not confined to the scope of the compilation unit. Perfectly corresponds to the module's header file, except the IRQ handlers. More...
Data Structures | |
| struct | HIERODULE_USART_Wrapper |
| Struct that keeps variables for the ring buffer, a pointer to the USART peripheral and a pointer to the ISR for RXNE. More... | |
Functions | |
| HIERODULE_USART_Wrapper ** | HIERODULE_USART_InitWrapper (USART_TypeDef *USART, uint16_t RX_BufferSize, void(*RX_Handler)(uint8_t)) |
| Initializes a wrapper for the specified USART peripheral. | |
| void | HIERODULE_USART_ReleaseWrapper (HIERODULE_USART_Wrapper *Wrapper) |
| Frees the memory allocated to a USART wrapper and clears USART status flags and control bits. | |
| void | HIERODULE_USART_Enable_IT_RXNE (HIERODULE_USART_Wrapper *Wrapper) |
| Enables the RX not empty interrupt of the USART peripheral , also enables the RE bit of the control register.. | |
| void | HIERODULE_USART_Disable_IT_RXNE (HIERODULE_USART_Wrapper *Wrapper) |
| Disables the RX not empty interrupt of the USART peripheral , also disables the RE bit of the control register.. | |
| uint32_t | HIERODULE_USART_IsActiveFlag_RXNE (HIERODULE_USART_Wrapper *Wrapper) |
| Checks the RX not empty interrupt flag of the USART peripheral. | |
| uint32_t | HIERODULE_USART_IsActiveFlag_TXE (HIERODULE_USART_Wrapper *Wrapper) |
| Checks the TX is empty interrupt flag of the USART peripheral. | |
| uint8_t | HIERODULE_USART_GetNextByte (HIERODULE_USART_Wrapper *Wrapper) |
| Fetches the next byte in the ring buffer. | |
| void | HIERODULE_USART_TransmitByte (HIERODULE_USART_Wrapper *Wrapper, uint8_t Byte) |
| Transmits a single byte. | |
| void | HIERODULE_USART_TransmitString (HIERODULE_USART_Wrapper *Wrapper, char *String) |
| Transmits a string. | |
| void | USART1_IRQHandler (void) |
| USART1 IRQ implementation. | |
| void | USART2_IRQHandler (void) |
| USART2 IRQ implementation. Requires the device specific macro __STM32F103xB_H or __STM32F401xC_H to be defined. | |
| void | USART3_IRQHandler (void) |
| USART3 IRQ implementation. Requires the device specific macro __STM32F103xB_H to be defined. | |
| void | USART6_IRQHandler (void) |
| USART6 IRQ implementation. Requires the device specific macro __STM32F401xC_H to be defined. | |
Consists of general USART comm routines, a USART wrapper initalizer, a function to get the next byte in the ring buffer and a typedef to be used for the wrapper routines.
Device-specific macro constants and type definitions are imported with an include directive to main.h, where the device driver headers are assumed to be included.
stddef.h and stdlib.h also included for NULL and malloc/free, respectively.
| void HIERODULE_USART_Disable_IT_RXNE | ( | HIERODULE_USART_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the USART wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 195 of file hierodule_usart.c.
References Wrapper.
| void HIERODULE_USART_Enable_IT_RXNE | ( | HIERODULE_USART_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the USART wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 187 of file hierodule_usart.c.
References Wrapper.
| uint8_t HIERODULE_USART_GetNextByte | ( | HIERODULE_USART_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the USART wrapper. |
RX_New and RX_Index are also updated on call, to revolve the ring buffer, so as to say.
Definition at line 233 of file hierodule_usart.c.
References HIERODULE_USB_Wrapper::RX_Buffer, HIERODULE_USB_Wrapper::RX_BufferSize, HIERODULE_USB_Wrapper::RX_Index, HIERODULE_USB_Wrapper::RX_New, and Wrapper.
Referenced by USART_IRQHandler().
| HIERODULE_USART_Wrapper ** HIERODULE_USART_InitWrapper | ( | USART_TypeDef * | USART, |
| uint16_t | RX_BufferSize, | ||
| void(* | RX_Handler )(uint8_t) ) |
| USART | USART peripheral of the wrapper. |
| RX_BufferSize | Length of the ring buffer array. |
| RX_Handler | Pointer to the ISR for RXNE. |
The ring buffer gets a new address allocated to it.
The ring buffer is filled with null characters.
Disables the RE bit of the control register, as well as the RXNE flag in the status register.
The wrapper pointer gets a new address allocated, to be freed at some future point via HIERODULE_USART_ReleaseWrapper, hence the reason a pointer is used for the wrapper; likewise, a double pointer is used to return it by reference.
Device specific checks are performed for the USART peripheral specified.
Definition at line 87 of file hierodule_usart.c.
References HIERODULE_USB_Wrapper::RX_Index, USART1_Wrapper, USART2_Wrapper, USART3_Wrapper, USART6_Wrapper, and Wrapper.
| uint32_t HIERODULE_USART_IsActiveFlag_RXNE | ( | HIERODULE_USART_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the USART wrapper. |
USART_ISR_RXNE/USART_SR_RXNE bit is isolated from the register with its bitmask and compared to the same bitmask instead of shifting since the amount of shift would depend on the bitmask.
Definition at line 203 of file hierodule_usart.c.
References Wrapper.
Referenced by HIERODULE_USART_TransmitByte(), and USART_IRQHandler().
| uint32_t HIERODULE_USART_IsActiveFlag_TXE | ( | HIERODULE_USART_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the USART wrapper. |
USART_ISR_TXE/USART_SR_TXE bit is isolated from the register with its bitmask and compared to the same bitmask instead of shifting since the amount of shift would depend on the bitmask.
Definition at line 217 of file hierodule_usart.c.
References Wrapper.
Referenced by HIERODULE_USART_TransmitByte().
| void HIERODULE_USART_ReleaseWrapper | ( | HIERODULE_USART_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the USART wrapper. |
Ring buffer address is also freed.
Using a released USART wrapper or its fields may result in unexpected behavior.
Keep in mind this clears up the USART wrapper pointer in this file scope; it is recommended to free your double pointer to the wrapper, likewise.
Definition at line 164 of file hierodule_usart.c.
References HIERODULE_USB_Wrapper::RX_Buffer, and Wrapper.
| void HIERODULE_USART_TransmitByte | ( | HIERODULE_USART_Wrapper * | Wrapper, |
| uint8_t | Byte ) |
| Wrapper | Pointer to the USART wrapper. |
| Byte | to be transmitted. |
Will block until both RDR and TDR are empty, which means it's safe to write to the transmit data register.
TE flag in the USART control register is assumed to be already set.
Definition at line 255 of file hierodule_usart.c.
References HIERODULE_USART_IsActiveFlag_RXNE(), HIERODULE_USART_IsActiveFlag_TXE(), and Wrapper.
Referenced by HIERODULE_USART_TransmitString().
| void HIERODULE_USART_TransmitString | ( | HIERODULE_USART_Wrapper * | Wrapper, |
| char * | String ) |
| Wrapper | Pointer to the USART wrapper. |
| String | to be transmitted. |
Basically calls HIERODULE_USART_TransmitByte for each byte in the string until a null character shows up.
TE flag in the USART control register is assumed to be already set.
Definition at line 279 of file hierodule_usart.c.
References HIERODULE_USART_TransmitByte(), and Wrapper.
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 350 of file hierodule_usart.c.
References USART1_Wrapper, and USART_IRQHandler().
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 362 of file hierodule_usart.c.
References USART2_Wrapper, and USART_IRQHandler().
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 375 of file hierodule_usart.c.
References USART3_Wrapper, and USART_IRQHandler().
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 388 of file hierodule_usart.c.
References USART6_Wrapper, and USART_IRQHandler().