Hilscher netX microcontroller driver
V0.0.5.0
Documentation of the netX driver package
|
The UART driver, defined by DRV_UART_HANDLE_T. More...
Data Structures | |
struct | DRV_UART_CONFIGURATION_T |
The configuration of the driver. More... | |
struct | DRV_UART_HANDLE_T |
The handle of the driver. More... | |
Macros | |
#define | DRV_HANDLE_CHECK(handle) |
#define | DRV_UART_IRQHandler_Generator(id, _) DRV_Default_IRQHandler_Function_Generator(DRV_UART_IRQ_HANDLER ## id,DRV_UART_IRQ_Inline_Handler,DRV_UART_DEVICE_ID_UART ## id) |
Functions | |
static void | DRV_UART_Flush_DMA_Callback_Rx (void *ptDriverHandle, DRV_UART_HANDLE_T *const ptDriver) |
static void | DRV_UART_Flush_DMA_Callback_Tx (void *ptDriverHandle, DRV_UART_HANDLE_T *const ptDriver) |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_Init (DRV_UART_HANDLE_T *const ptDriver) |
Initializes the uart device and handle by the given configuration. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_DeInit (DRV_UART_HANDLE_T *const ptDriver) |
Deinitializes the uart device and handle. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_Transmit (DRV_UART_HANDLE_T *const ptDriver, uint8_t const *const data, size_t size) |
Performs a transmission of the given size of the data array via the given uart. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_Receive (DRV_UART_HANDLE_T *const ptDriver, uint8_t *const data, size_t size) |
Receives the given size and stores it into data via the given uart. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_TransmitReceive (DRV_UART_HANDLE_T *const ptDriver, uint8_t *const txData, uint8_t *const rxData, size_t size) |
Transmits and receives data of given size via the given uart. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_PutChar (DRV_UART_HANDLE_T *const ptDriver, unsigned char const cData) |
Transmits a single char via the given uart. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_GetChar (DRV_UART_HANDLE_T *const ptDriver, unsigned char *const pcData) |
Receives a single char via the given uart. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_Abort (DRV_UART_HANDLE_T *const ptDriver) |
Aborts any transmissions on the given uart. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_GetState (DRV_UART_HANDLE_T *const ptDriver, DRV_UART_STATE_E *const ptState) |
The driver and device state are returned by this function. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_GetRxState (DRV_UART_HANDLE_T *const ptDriver, DRV_UART_STATE_E *const ptState) |
The driver and device state are returned by this function. More... | |
DRV_STATUS_E | DRV_UART_HANDLE_T::DRV_UART_GetTxState (DRV_UART_HANDLE_T *const ptDriver, DRV_UART_STATE_E *const ptState) |
The driver and device state are returned by this function. More... | |
__STATIC_FORCEINLINE uint32_t | DRV_UART_HANDLE_T::DRV_UART_GetRxCounter (DRV_UART_HANDLE_T *const ptDriver) |
This function returns the amount of bytes received. More... | |
__STATIC_FORCEINLINE uint32_t | DRV_UART_HANDLE_T::DRV_UART_GetTxCounter (DRV_UART_HANDLE_T *const ptDriver) |
This function returns the amount of bytes transmitted. More... | |
__STATIC_FORCEINLINE uint8_t volatile * | DRV_UART_HANDLE_T::DRV_UART_GetStaticBuffer (DRV_UART_HANDLE_T *const ptDriver) |
This function returns the static buffer. More... | |
__STATIC_INLINE void | DRV_UART_HANDLE_T::DRV_UART_Flush_Buffers (DRV_UART_HANDLE_T *const ptDriver) |
This function shall flush the software and hardware buffers of the device. More... | |
__STATIC_INLINE void | DRV_UART_HANDLE_T::DRV_UART_IRQ_Inline_Handler (DRV_UART_DEVICE_ID_E const eDeviceID) |
Variables | |
static DRV_UART_DEVICE_T *const | s_apDeviceAddressTable [DRV_UART_DEVICE_COUNT] = DRV_UART_DEVICE_LIST |
Table of the device addresses. More... | |
static DRV_DMAC_PERIPHERAL_E const | s_apDeviceDmacTable [DRV_UART_DEVICE_COUNT] = DRV_UART_DEVICE_DMA_LIST |
Table of the device associated dmac channels. More... | |
static IRQn_Type const | s_apHandleIRQnTable [DRV_UART_DEVICE_COUNT] = DRV_UART_DEVICE_IRQ_LIST |
Table of the IRQ vector numbers. More... | |
static DRV_UART_HANDLE_T * | s_apHandleAddressTable [DRV_UART_DEVICE_COUNT] = { 0 } |
Used for mapping the handle to an interrupt. More... | |
The UART driver, defined by DRV_UART_HANDLE_T.
The UART
#define DRV_HANDLE_CHECK | ( | handle | ) |
Define for checking the consistency of the handle or static representation of the driver.
Definition at line 63 of file netx_drv_uart.c.
#define DRV_UART_IRQHandler_Generator | ( | id, | |
_ | |||
) | DRV_Default_IRQHandler_Function_Generator(DRV_UART_IRQ_HANDLER ## id,DRV_UART_IRQ_Inline_Handler,DRV_UART_DEVICE_ID_UART ## id) |
The generator define for generating irq handler source code.
Definition at line 1053 of file netx_drv_uart.c.
enum DRV_UART_BAUDRATE_E |
Enumeration of useful uart baudrates.
Definition at line 58 of file netx_drv_uart.h.
Enumeration of useful uart baudrate mode.
Definition at line 45 of file netx_drv_uart.h.
Enumeration of of the line control parameters as mask.
Definition at line 111 of file netx_drv_uart.h.
enum DRV_UART_LOOP_BACK_E |
Enumeration of the loop back state.
Enumerator | |
---|---|
DRV_UART_LOOP_BACK_INACTIVE |
Loopback is inactive |
DRV_UART_LOOP_BACK_ACTIVE |
Loopback is active for testing purposes only |
DRV_UART_LOOP_BACK_MAX |
Boundary check value |
Definition at line 125 of file netx_drv_uart.h.
Enumeration of the rts control parameters as mask.
Definition at line 162 of file netx_drv_uart.h.
enum DRV_UART_STATE_E |
Enumeration of uart device states.
Definition at line 77 of file netx_drv_uart.h.
Enumeration of the transmit modes availabe as mask.
Enumerator | |
---|---|
DRV_UART_TX_MODE_MASK_DEFAULT |
Transmit is active. |
DRV_UART_TX_MODE_MASK_RECEIVE_ONLY |
Receive only. |
DRV_UART_TX_MODE_MASK_RTS_ACTIVE |
Use RTS. |
DRV_UART_TX_MODE_MASK |
Masks bits choseable. |
Definition at line 178 of file netx_drv_uart.h.
enum DRV_UART_WATERMARK_E |
Enumeration of the loop back state.
Definition at line 135 of file netx_drv_uart.h.
Enumeration of the available uart word lenghts.
Definition at line 96 of file netx_drv_uart.h.
DRV_STATUS_E DRV_UART_Abort | ( | DRV_UART_HANDLE_T *const | ptDriver | ) |
Aborts any transmissions on the given uart.
The abort method will abort a uart transmission in progress.
If one uses the RxCallback, the interrupt conditions will be masked out. One has to actively receive again afterwards to enable it.
[in,out] | ptDriver | The given handle of the drivers class |
Definition at line 830 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_DeInit | ( | DRV_UART_HANDLE_T *const | ptDriver | ) |
Deinitializes the uart device and handle.
The deinitialize function is supposed to reset the handle, the device and disable the interrupt signaling. The handle might be used afterwards again for initializing a UART device driver handle.
[in,out] | ptDriver | The ptDriver to be initialized |
Definition at line 285 of file netx_drv_uart.c.
|
private |
This function shall flush the software and hardware buffers of the device.
This function is the hardware closest layer of the uart driver. The handle contains some variables defining the software buffer state. This state shall be equalized in this function. The transmit buffer is transfered to the transmit fifo of the device from the actual counter position to the given size. The receive fifo of the device is written to the current counter position until the given size is reached. If there is no buffer given, the function will transmit the dummy pattern specified in the attributes, and receives what is contained in the receive fifo but discard it.
[in,out] | ptDriver | The given handle of the drivers class |
Definition at line 315 of file netx_drv_uart.c.
|
static |
This callback is used in dma operation mode. It is registered in the dmac api to get informed if the dma finished copying.
Definition at line 85 of file netx_drv_uart.c.
|
static |
This callback is used in dma operation mode. It is registered in the dmac api to get informed if the dma finished copying.
Definition at line 100 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_GetChar | ( | DRV_UART_HANDLE_T *const | ptDriver, |
unsigned char *const | pcData | ||
) |
Receives a single char via the given uart.
The get character method will get the next character from the device. This is possible if there is no buffer content to be received.
This method is blocking.
[in,out] | ptDriver | The given handle of the drivers class |
[out] | pcData | The pointer to the character to be received |
Definition at line 777 of file netx_drv_uart.c.
__STATIC_FORCEINLINE uint32_t DRV_UART_GetRxCounter | ( | DRV_UART_HANDLE_T *const | ptDriver | ) |
This function returns the amount of bytes received.
The function is defined as inline. It only returns the RxBufferCounter located in the handle. The RxBufferCounter is 0 if it is full or empty. The complete callback was issued in case it is full. Because while the complete callback is called, the counter is not reset, one is able to get the amount of data received.
[in,out] | ptDriver | The given handle of the drivers class |
Definition at line 310 of file netx_drv_uart.h.
DRV_STATUS_E DRV_UART_GetRxState | ( | DRV_UART_HANDLE_T *const | ptDriver, |
DRV_UART_STATE_E *const | ptState | ||
) |
The driver and device state are returned by this function.
The get state method will check if the driver is busy in the receive patht and it will return the state of the device. One is able to skip the state by providing a null pointer.
[in,out] | ptDriver | The given handle of the drivers class |
[out] | ptState | The pointer to where the state of the device given will be stored. |
Definition at line 915 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_GetState | ( | DRV_UART_HANDLE_T *const | ptDriver, |
DRV_UART_STATE_E *const | ptState | ||
) |
The driver and device state are returned by this function.
The get state method will check if the driver is busy and it will return the state of the device. One is able to skip the state by providing a null pointer.
[in,out] | ptDriver | The given handle of the drivers class |
[out] | ptState | The pointer to where the state of the device given will be stored. |
Definition at line 887 of file netx_drv_uart.c.
__STATIC_FORCEINLINE uint8_t volatile * DRV_UART_GetStaticBuffer | ( | DRV_UART_HANDLE_T *const | ptDriver | ) |
This function returns the static buffer.
The function is defined as inline. It returns the rx buffer received statically. The buffer content is only valid inside the fnRxCallback. The DRV_UART_GetRxCounter defines the ammount of received bytes.
[in,out] | ptDriver | The given handle of the drivers class |
Definition at line 352 of file netx_drv_uart.h.
__STATIC_FORCEINLINE uint32_t DRV_UART_GetTxCounter | ( | DRV_UART_HANDLE_T *const | ptDriver | ) |
This function returns the amount of bytes transmitted.
The function is defined as inline. It only returns the TxBufferCounter located in the handle. The TxBufferCounter is 0 if it is full or empty. The complete callback was issued in case it is full. Because while the complete callback is called, the counter is not reset, one is able to get the amount of data received.
[in,out] | ptDriver | The given handle of the drivers class |
Definition at line 331 of file netx_drv_uart.h.
DRV_STATUS_E DRV_UART_GetTxState | ( | DRV_UART_HANDLE_T *const | ptDriver, |
DRV_UART_STATE_E *const | ptState | ||
) |
The driver and device state are returned by this function.
The get state method will check if the driver is busy in the transmit path and it will return the state of the device. One is able to skip the state by providing a null pointer.
[in,out] | ptDriver | The given handle of the drivers class |
[out] | ptState | The pointer to where the state of the device given will be stored. |
Definition at line 942 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_Init | ( | DRV_UART_HANDLE_T *const | ptDriver | ) |
Initializes the uart device and handle by the given configuration.
The function takes a DRV_UART_HANDLE_T pointer which contains a DRV_UART_CONFIGURATION_T structure. Those structure contains the configuration/initialization parameters of the device. While most attributes have valid default behavior, it is necessary to configure at least the DRV_UART_DEVICE_ID_E and some others.
The UARTs initialize function forces the initialization of the UART peripheral and the handle. The driver lock is set and the given parameters in the DRV_UART_CONFIGURATION_T structure are checked if there are parameter combinations not feasible. If everything is ok, the Buffers will be reset and the configuration registers are written, regarding the given attributes. At last the lock will be released.
[out] | ptDriver | The ptDriver to be |
Definition at line 126 of file netx_drv_uart.c.
__STATIC_INLINE void DRV_UART_IRQ_Inline_Handler | ( | DRV_UART_DEVICE_ID_E const | eDeviceID | ) |
The interrupt handler of the uart device driver.
[in] | eDeviceID | The device calling the interrupt |
Definition at line 966 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_PutChar | ( | DRV_UART_HANDLE_T *const | ptDriver, |
unsigned char const | cData | ||
) |
Transmits a single char via the given uart.
The put character method will put a character down to the device so that it is transmitted. This is possible if there is no buffer content to be transmitted.
This method is blocking.
[in,out] | ptDriver | The given handle of the drivers class |
[in] | cData | The character to be transmitted |
Definition at line 729 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_Receive | ( | DRV_UART_HANDLE_T *const | ptDriver, |
uint8_t *const | data, | ||
size_t | size | ||
) |
Receives the given size and stores it into data via the given uart.
The receive function is associated with the job to receive data of the given size via the UART initialized on the given context to the given position.
In polling mode it is blocking and in irq and dma it is non blocking.
[in,out] | ptDriver | The given handle of the drivers class |
[out] | data | The pointer to the data to be received |
[in] | size | The size of the data buffers |
Definition at line 494 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_Transmit | ( | DRV_UART_HANDLE_T *const | ptDriver, |
uint8_t const *const | data, | ||
size_t | size | ||
) |
Performs a transmission of the given size of the data array via the given uart.
The transmit function is associated with the job to transmit the given data of the given size via the UART initialized on the given context.
In polling mode it is blocking and in irq and dma it is non blocking.
[in,out] | ptDriver | The given handle of the drivers class |
[in] | data | The pointer to the data to be transmitted |
[in] | size | The size of the data buffers |
Definition at line 394 of file netx_drv_uart.c.
DRV_STATUS_E DRV_UART_TransmitReceive | ( | DRV_UART_HANDLE_T *const | ptDriver, |
uint8_t *const | txData, | ||
uint8_t *const | rxData, | ||
size_t | size | ||
) |
Transmits and receives data of given size via the given uart.
The transmit receive function is associated with the job to transmit and receive the given data of the given size via the UART initialized on the given context and receive the data to the given position.
In polling mode it is blocking and in irq and dma it is non blocking.
[in,out] | ptDriver | The given handle of the drivers class |
[in] | txData | The pointer to the data to be transmitted |
[out] | rxData | The pointer to the data to be received |
[in] | size | The size of the data buffers |
Definition at line 596 of file netx_drv_uart.c.
|
static |
Table of the device addresses.
Used to identify the device addresses by the device id.
Definition at line 39 of file netx_drv_uart.c.
|
static |
Table of the device associated dmac channels.
Used to identify the device dmac channels by the device id.
Definition at line 45 of file netx_drv_uart.c.
|
static |
Used for mapping the handle to an interrupt.
Threadsafe and reentrant because its is only written in normal context an used in interrupt context of the specific interrupt.
Definition at line 57 of file netx_drv_uart.c.
|
static |
Table of the IRQ vector numbers.
Used to identify the interrupt channels by the device id.
Definition at line 51 of file netx_drv_uart.c.