|
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_SPI_Wrapper |
| Struct that keeps variables for the data buffers, a pointer to the SPI peripheral, the and a pointer to the transmission end callback routine. More... | |
Functions | |
| uint8_t | HIERODULE_SPI_GetNextByte (HIERODULE_SPI_Wrapper *Wrapper) |
| Fetches the next byte in the RX ring buffer. | |
| void | HIERODULE_SPI_TransmitByte (HIERODULE_SPI_Wrapper *Wrapper, uint8_t Byte) |
| Writes a byte into the data register of the SPI peripheral. | |
| HIERODULE_SPI_Wrapper ** | HIERODULE_SPI_InitWrapper (SPI_TypeDef *_SPI, uint8_t Mode, uint16_t RX_BufferSize, void(*TC_Handler)(void)) |
| Initializes a wrapper for the specified SPI peripheral. | |
| void | HIERODULE_SPI_ReleaseWrapper (HIERODULE_SPI_Wrapper *Wrapper) |
| Frees the memory allocated to an SPI wrapper. | |
| void | HIERODULE_SPI_TransmitPackage (HIERODULE_SPI_Wrapper *Wrapper, uint8_t *TX_Buffer, uint32_t Size) |
| Starts a transmission as the master. | |
| void | SPI1_IRQHandler (void) |
| SPI1 IRQ implementation. | |
| void | SPI2_IRQHandler (void) |
| SPI2 IRQ implementation. Requires the device specific macro __STM32F103xB_H or __STM32F401xC_H to be defined. | |
| void | SPI3_IRQHandler (void) |
| SPI3 IRQ implementation. Requires the device specific macro __STM32F401xC_H to be defined. | |
Consists of general SPI comm routines, a SPI wrapper initalizer and typedefs for module 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.
| uint8_t HIERODULE_SPI_GetNextByte | ( | HIERODULE_SPI_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the SPI wrapper. |
RX_New and RX_Index are also updated on call, to revolve the ring buffer, so as to say.
Definition at line 94 of file hierodule_spi.c.
References HIERODULE_USB_Wrapper::RX_Buffer, HIERODULE_USB_Wrapper::RX_BufferSize, HIERODULE_USB_Wrapper::RX_Index, HIERODULE_USB_Wrapper::RX_New, and Wrapper.
| HIERODULE_SPI_Wrapper ** HIERODULE_SPI_InitWrapper | ( | SPI_TypeDef * | _SPI, |
| uint8_t | Mode, | ||
| uint16_t | RX_BufferSize, | ||
| void(* | TC_Handler )(void) ) |
| _SPI | SPI peripheral of the wrapper. |
| Mode | 1 For master, 0 for slave. |
| RX_BufferSize | Ring buffer length. |
| TC_Handler | Pointer to callback function to be called on a completed transmission. |
The ring buffer gets a new address allocated to it and is filled with null characters.
The wrapper pointer gets a new address allocated, to be freed at some future point via HIERODULE_SPI_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 SPI peripheral specified.
Definition at line 123 of file hierodule_spi.c.
References Enable(), HIERODULE_SPI_TransmitByte(), HIERODULE_USB_Wrapper::RX_Index, SPI1_Wrapper, SPI2_Wrapper, SPI3_Wrapper, and Wrapper.
| void HIERODULE_SPI_ReleaseWrapper | ( | HIERODULE_SPI_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the SPI wrapper. |
Buffer address also gets freed.
Using a released SPI wrapper or its fields may result in unexpected behavior.
Keep in mind this clears up the SPI wrapper pointer in this file scope; it is recommended to free your double pointer to the wrapper, likewise.
Definition at line 193 of file hierodule_spi.c.
References HIERODULE_USB_Wrapper::RX_Buffer, and Wrapper.
| void HIERODULE_SPI_TransmitByte | ( | HIERODULE_SPI_Wrapper * | Wrapper, |
| uint8_t | Byte ) |
| Wrapper | Pointer to the SPI wrapper. |
| Byte | Byte to be written into the data register. |
Self-explanatory code, nothing to elaborate.
Definition at line 114 of file hierodule_spi.c.
References Wrapper.
Referenced by HIERODULE_SPI_InitWrapper(), and SPI_IRQ_Handler().
| void HIERODULE_SPI_TransmitPackage | ( | HIERODULE_SPI_Wrapper * | Wrapper, |
| uint8_t * | TX_Buffer, | ||
| uint32_t | Size ) |
| Wrapper | Pointer to the SPI wrapper. |
| TX_Buffer | Byte array to be transmitted. |
| Size | Number of bytes to be transmitted. |
Transmission won't commence if Size is zero.
Definition at line 204 of file hierodule_spi.c.
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 286 of file hierodule_spi.c.
References SPI1_Wrapper, and SPI_IRQ_Handler().
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 299 of file hierodule_spi.c.
References SPI2_Wrapper, and SPI_IRQ_Handler().
|
extern |
Self-explanatory code, nothing to elaborate.
Definition at line 314 of file hierodule_spi.c.
References SPI3_Wrapper, and SPI_IRQ_Handler().