Embedded Wireless Framework
ewf_interface_win32_com.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_interface_win32_com__h__included__
10 #define __ewf_interface_win32_com__h__included__
11 
12 #include "ewf_interface.h"
13 
14 #include <windows.h>
15 #include <tchar.h>
16 #include <stdio.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /************************************************************************/
34 #ifndef EWF_INTERFACE_WIN32_COM_CONFIG_RX_BUFFER_SIZE
35 #define EWF_INTERFACE_WIN32_COM_CONFIG_RX_BUFFER_SIZE (1)
36 #endif
37 
38 #ifndef EWF_INTERFACE_WIN32_COM_CONFIG_RESPONSE_QUEUE_SIZE
39 #define EWF_INTERFACE_WIN32_COM_CONFIG_RESPONSE_QUEUE_SIZE (8)
40 #endif
41 
42 #ifndef EWF_INTERFACE_WIN32_COM_CONFIG_URC_QUEUE_SIZE
43 #define EWF_INTERFACE_WIN32_COM_CONFIG_URC_QUEUE_SIZE (8)
44 #endif
45 
52 {
53  HANDLE hComm;
54  const char* com_port_cstr;
55  BYTE buffer[EWF_INTERFACE_WIN32_COM_CONFIG_RX_BUFFER_SIZE];
56  DWORD BaudRate;
57  BYTE ByteSize;
58  BYTE Parity;
59  BYTE StopBits;
60  OVERLAPPED osReader;
61  OVERLAPPED osWrite;
62 
64 
69 
74 
78 ewf_result ewf_interface_win32_com_hardware_send(ewf_interface* interface_ptr, const uint8_t* buffer_ptr, uint32_t buffer_length);
79 
83 ewf_result ewf_interface_win32_com_hardware_receive(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t* buffer_length_ptr, bool wait);
84 
85 #ifdef EWF_PARAMETER_CHECKING
86 #define EWF_INTERFACE_WIN32_COM_INITIALIZE_HEADER(interface_ptr) \
87 do { \
88 (interface_ptr)->struct_magic = EWF_INTERFACE_STRUCT_MAGIC; \
89 (interface_ptr)->struct_size = EWF_INTERFACE_STRUCT_SIZE; \
90 (interface_ptr)->struct_version = EWF_INTERFACE_VERSION; \
91 (interface_ptr)->struct_type = EWF_INTERFACE_TYPE_WIN32_COM; \
92 } while(0)
93 #else
94 #define EWF_INTERFACE_WIN32_COM_INITIALIZE_HEADER(interface_ptr)
95 #endif /* EWF_PARAMETER_CHECKING */
96 
107 #define EWF_INTERFACE_WIN32_COM_STATIC_DECLARE(interface_ptr, interface_name_symb, com_port_cstr_param, BaudRate_param, ByteSize_param, Parity_param, StopBits_param) \
108 do { \
109 static ewf_interface_win32_com ewf_interface_win32_com__implementation__##interface_name_symb = {0}; \
110 static ewf_interface ewf_interface_win32_com__interface__##interface_name_symb = {0}; \
111 ewf_interface_win32_com__implementation__##interface_name_symb.hComm = NULL; \
112 ewf_interface_win32_com__implementation__##interface_name_symb.com_port_cstr = com_port_cstr_param; \
113 ewf_interface_win32_com__implementation__##interface_name_symb.BaudRate = BaudRate_param; \
114 ewf_interface_win32_com__implementation__##interface_name_symb.ByteSize = ByteSize_param; \
115 ewf_interface_win32_com__implementation__##interface_name_symb.Parity = Parity_param; \
116 ewf_interface_win32_com__implementation__##interface_name_symb.StopBits = StopBits_param; \
117 EWF_PLATFORM_QUEUE_STATIC_DECLARE( \
118  ewf_interface_win32_com__interface__##interface_name_symb.response_queue_ptr, \
119  ewf_interface_win32_com__response_queue__##interface_name_symb, \
120  ewf_interface_message, \
121  EWF_INTERFACE_WIN32_COM_CONFIG_RESPONSE_QUEUE_SIZE); \
122 EWF_PLATFORM_QUEUE_STATIC_DECLARE( \
123  ewf_interface_win32_com__interface__##interface_name_symb.urc_queue_ptr, \
124  ewf_interface_win32_com__urc_queue__##interface_name_symb, \
125  ewf_interface_message, \
126  EWF_INTERFACE_WIN32_COM_CONFIG_URC_QUEUE_SIZE); \
127 ewf_interface_win32_com__interface__##interface_name_symb.hardware_start = ewf_interface_win32_com_hardware_start; \
128 ewf_interface_win32_com__interface__##interface_name_symb.hardware_stop = ewf_interface_win32_com_hardware_stop; \
129 ewf_interface_win32_com__interface__##interface_name_symb.hardware_send = ewf_interface_win32_com_hardware_send; \
130 ewf_interface_win32_com__interface__##interface_name_symb.hardware_receive = ewf_interface_win32_com_hardware_receive; \
131 ewf_interface_win32_com__interface__##interface_name_symb.implementation_ptr = &(ewf_interface_win32_com__implementation__##interface_name_symb); \
132 interface_ptr = &(ewf_interface_win32_com__interface__##interface_name_symb); \
133 EWF_INTERFACE_WIN32_COM_INITIALIZE_HEADER(interface_ptr); \
134 } while(0)
135 
136 /************************************************************************/
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* __ewf_interface_win32_com__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_win32_com_hardware_receive(ewf_interface *interface_ptr, uint8_t *buffer_ptr, uint32_t *buffer_length_ptr, bool wait)
Receive a buffer using the WIN32 COM hardware interface.
Definition: ewf_interface_win32_com.c:194
ewf_result ewf_interface_win32_com_hardware_send(ewf_interface *interface_ptr, const uint8_t *buffer_ptr, uint32_t buffer_length)
Send a buffer using the WIN32 COM hardware interface.
Definition: ewf_interface_win32_com.c:126
struct _ewf_interface_win32_com ewf_interface_win32_com
the WIN32 COM host interface implementation data structure type
ewf_result ewf_interface_win32_com_hardware_start(ewf_interface *interface_ptr)
Start the WIN32 COM hardware interface.
Definition: ewf_interface_win32_com.c:21
ewf_result ewf_interface_win32_com_hardware_stop(ewf_interface *interface_ptr)
Stop the WIN32 COM hardware interface.
Definition: ewf_interface_win32_com.c:102
the WIN32 COM host interface implementation data structure type
Definition: ewf_interface_win32_com.h:52
The interface structure definition.
Definition: ewf_interface.h:66