Embedded Wireless Framework
ewf_interface_stm32_uart.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_interface_stm32_uart__h__included__
10 #define __ewf_interface_stm32_uart__h__included__
11 
12 #include "ewf_interface.h"
13 
14 #if (USE_HAL_UART_REGISTER_CALLBACKS != 1)
15 #error UART register callbacks must be enabled for this interface
16 #endif
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /************************************************************************/
34 #ifndef EWF_INTERFACE_STM32_UART_CONFIG_UART_RX_QUEUE_SIZE
35 #define EWF_INTERFACE_STM32_UART_CONFIG_UART_RX_QUEUE_SIZE (256 * 8)
36 #endif
37 
38 #ifndef EWF_INTERFACE_STM32_UART_CONFIG_RESPONSE_QUEUE_SIZE
39 #define EWF_INTERFACE_STM32_UART_CONFIG_RESPONSE_QUEUE_SIZE (8)
40 #endif
41 
42 #ifndef EWF_INTERFACE_STM32_UART_CONFIG_URC_QUEUE_SIZE
43 #define EWF_INTERFACE_STM32_UART_CONFIG_URC_QUEUE_SIZE (8)
44 #endif
45 
52 {
53  UART_HandleTypeDef* uart_handle_ptr;
54  ewf_platform_queue* rx_queue_ptr;
55  uint8_t rx_buffer[sizeof(uint8_t)];
56 
58 
63 
68 
72 ewf_result ewf_interface_stm32_uart_hardware_send(ewf_interface* interface_ptr, const uint8_t* buffer_ptr, uint32_t buffer_length);
73 
77 ewf_result ewf_interface_stm32_uart_hardware_receive(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t* buffer_length_ptr, bool wait);
78 
79 #ifdef EWF_PARAMETER_CHECKING
80 #define EWF_INTERFACE_STM32_UART_INITIALIZE_HEADER(interface_ptr) \
81 do { \
82 (interface_ptr)->struct_magic = EWF_INTERFACE_STRUCT_MAGIC; \
83 (interface_ptr)->struct_size = EWF_INTERFACE_STRUCT_SIZE; \
84 (interface_ptr)->struct_version = EWF_INTERFACE_VERSION; \
85 (interface_ptr)->struct_type = EWF_INTERFACE_TYPE_STM32_UART; \
86 } while(0)
87 #else
88 #define EWF_INTERFACE_STM32_UART_INITIALIZE_HEADER(interface_ptr)
89 #endif /* EWF_PARAMETER_CHECKING */
90 
96 #define EWF_INTERFACE_STM32_UART_STATIC_DECLARE(interface_ptr, interface_name_symb, uart_handle_ptr_param) \
97 do { \
98 static ewf_interface_stm32_uart ewf_interface_stm32_uart__implementation__##interface_name_symb = {0}; \
99 static ewf_interface ewf_interface_stm32_uart__interface__##interface_name_symb = {0}; \
100 ewf_interface_stm32_uart__implementation__##interface_name_symb.uart_handle_ptr = uart_handle_ptr_param; \
101 EWF_PLATFORM_QUEUE_STATIC_DECLARE( \
102  ewf_interface_stm32_uart__implementation__##interface_name_symb.rx_queue_ptr, \
103  ewf_interface_stm32_uart__uart_rx_queue__##interface_name_symb, \
104  uint8_t, \
105  EWF_INTERFACE_STM32_UART_CONFIG_UART_RX_QUEUE_SIZE); \
106 EWF_PLATFORM_QUEUE_STATIC_DECLARE( \
107  ewf_interface_stm32_uart__interface__##interface_name_symb.response_queue_ptr, \
108  ewf_interface_stm32_uart__response_queue__##interface_name_symb, \
109  ewf_interface_message, \
110  EWF_INTERFACE_STM32_UART_CONFIG_RESPONSE_QUEUE_SIZE); \
111 EWF_PLATFORM_QUEUE_STATIC_DECLARE( \
112  ewf_interface_stm32_uart__interface__##interface_name_symb.urc_queue_ptr, \
113  ewf_interface_stm32_uart__urc_queue__##interface_name_symb, \
114  ewf_interface_message, \
115  EWF_INTERFACE_STM32_UART_CONFIG_URC_QUEUE_SIZE); \
116 ewf_interface_stm32_uart__interface__##interface_name_symb.hardware_start = ewf_interface_stm32_uart_hardware_start; \
117 ewf_interface_stm32_uart__interface__##interface_name_symb.hardware_stop = ewf_interface_stm32_uart_hardware_stop; \
118 ewf_interface_stm32_uart__interface__##interface_name_symb.hardware_send = ewf_interface_stm32_uart_hardware_send; \
119 ewf_interface_stm32_uart__interface__##interface_name_symb.hardware_receive = ewf_interface_stm32_uart_hardware_receive; \
120 ewf_interface_stm32_uart__interface__##interface_name_symb.implementation_ptr = &(ewf_interface_stm32_uart__implementation__##interface_name_symb); \
121 interface_ptr = &(ewf_interface_stm32_uart__interface__##interface_name_symb); \
122 EWF_INTERFACE_STM32_UART_INITIALIZE_HEADER(interface_ptr); \
123 } while(0)
124 
125 /************************************************************************/
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* __ewf_interface_stm32_uart__h__included__ */
The Embedded Wireless Framework host interface API.
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
ewf_result ewf_interface_stm32_uart_hardware_start(ewf_interface *interface_ptr)
Start the STM32 UART hardware interface.
Definition: ewf_interface_stm32_uart.c:51
ewf_result ewf_interface_stm32_uart_hardware_receive(ewf_interface *interface_ptr, uint8_t *buffer_ptr, uint32_t *buffer_length_ptr, bool wait)
Receive a buffer using the STM32 UART hardware interface.
Definition: ewf_interface_stm32_uart.c:106
ewf_result ewf_interface_stm32_uart_hardware_stop(ewf_interface *interface_ptr)
Stop the STM32 UART hardware interface.
Definition: ewf_interface_stm32_uart.c:74
ewf_result ewf_interface_stm32_uart_hardware_send(ewf_interface *interface_ptr, const uint8_t *buffer_ptr, uint32_t buffer_length)
Send a buffer using the STM32 UART hardware interface.
Definition: ewf_interface_stm32_uart.c:90
struct _ewf_interface_stm32_uart ewf_interface_stm32_uart
The STM32 UART host interface implementation data structure type.
The STM32 UART host interface implementation data structure type.
Definition: ewf_interface_stm32_uart.h:52
The interface structure definition.
Definition: ewf_interface.h:66
The platform queue structure.
Definition: ewf_platform_bare_metal.h:74