ChibiOS/HAL  7.0.3
hal_sio_lld.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 /**
18  * @file hal_sio_lld.h
19  * @brief PLATFORM SIO subsystem low level driver header.
20  *
21  * @addtogroup SIO
22  * @{
23  */
24 
25 #ifndef HAL_SIO_LLD_H
26 #define HAL_SIO_LLD_H
27 
28 #if (HAL_USE_SIO == TRUE) || defined(__DOXYGEN__)
29 
30 /*===========================================================================*/
31 /* Driver constants. */
32 /*===========================================================================*/
33 
34 /*===========================================================================*/
35 /* Driver pre-compile time settings. */
36 /*===========================================================================*/
37 
38 /**
39  * @name PLATFORM configuration options
40  * @{
41  */
42 /**
43  * @brief SIO driver enable switch.
44  * @details If set to @p TRUE the support for SIO1 is included.
45  * @note The default is @p FALSE.
46  */
47 #if !defined(PLATFORM_SIO_USE_SIO1) || defined(__DOXYGEN__)
48 #define PLATFORM_SIO_USE_SIO1 FALSE
49 #endif
50 /** @} */
51 
52 /*===========================================================================*/
53 /* Derived constants and error checks. */
54 /*===========================================================================*/
55 
56 /*===========================================================================*/
57 /* Driver data structures and types. */
58 /*===========================================================================*/
59 
60 /**
61  * @brief SIO driver condition flags type.
62  */
63 typedef uint32_t sioflags_t;
64 
65 /**
66  * @brief Generic SIO notification callback type.
67  *
68  * @param[in] siop pointer to the @p SIODriver object
69  */
70 typedef void (*siocb_t)(SIODriver *siop);
71 
72 /**
73  * @brief Receive error SIO notification callback type.
74  *
75  * @param[in] siop pointer to the @p SIODriver object triggering the
76  * callback
77  * @param[in] e receive error mask
78  */
79 typedef void (*sioecb_t)(SIODriver *siop, sioflags_t e);
80 
81 /**
82  * @brief Driver configuration structure.
83  * @note Implementations may extend this structure to contain more,
84  * architecture dependent, fields.
85  */
87  /**
88  * @brief Receive buffer filled callback.
89  * @note Can be @p NULL.
90  */
92  /**
93  * @brief End of transmission buffer callback.
94  * @note Can be @p NULL.
95  */
97  /**
98  * @brief Physical end of transmission callback.
99  * @note Can be @p NULL.
100  */
102  /**
103  * @brief Receive event callback.
104  * @note Can be @p NULL.
105  */
107  /* End of the mandatory fields.*/
108 };
109 
110 /**
111  * @brief Structure representing a SIO driver.
112  * @note Implementations may extend this structure to contain more,
113  * architecture dependent, fields.
114  */
116  /**
117  * @brief Driver state.
118  */
120  /**
121  * @brief Current configuration data.
122  */
124 #if defined(SIO_DRIVER_EXT_FIELDS)
125  SIO_DRIVER_EXT_FIELDS
126 #endif
127  /* End of the mandatory fields.*/
128 };
129 
130 /*===========================================================================*/
131 /* Driver macros. */
132 /*===========================================================================*/
133 
134 /**
135  * @brief Determines the state of the RX FIFO.
136  *
137  * @param[in] siop pointer to the @p SIODriver object
138  * @return The RX FIFO state.
139  * @retval false if RX FIFO is not empty
140  * @retval true if RX FIFO is empty
141  *
142  * @notapi
143  */
144 #define sio_lld_rx_is_empty(siop) true
145 
146 /**
147  * @brief Determines the state of the TX FIFO.
148  *
149  * @param[in] siop pointer to the @p SIODriver object
150  * @return The TX FIFO state.
151  * @retval false if TX FIFO is not full
152  * @retval true if TX FIFO is full
153  *
154  * @notapi
155  */
156 #define sio_lld_tx_is_full(siop) true
157 
158 /**
159  * @brief Returns one frame from the RX FIFO.
160  * @note If the FIFO is empty then the returned value is unpredictable.
161  *
162  * @param[in] siop pointer to the @p SIODriver object
163  * @return The frame from RX FIFO.
164  *
165  * @notapi
166  */
167 #define sio_lld_rx_get(siop)
168 
169 /**
170  * @brief Pushes one frame into the TX FIFO.
171  * @note If the FIFO is full then the behavior is unpredictable.
172  *
173  * @param[in] siop pointer to the @p SIODriver object
174  * @param[in] data frame to be written
175  *
176  * @notapi
177  */
178 #define sio_lld_tx_put(siop, data)
179 
180 /*===========================================================================*/
181 /* External declarations. */
182 /*===========================================================================*/
183 
184 #if (PLATFORM_SIO_USE_SIO1 == TRUE) && !defined(__DOXYGEN__)
185 extern SIODriver SIOD1;
186 #endif
187 
188 #ifdef __cplusplus
189 extern "C" {
190 #endif
191  void sio_lld_init(void);
192  void sio_lld_start(SIODriver *siop);
193  void sio_lld_stop(SIODriver *siop);
194  size_t sio_lld_read(SIODriver *siop, void *buffer, size_t size);
195  size_t sio_lld_write(SIODriver *siop, const void *buffer, size_t size);
196  msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg);
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 #endif /* HAL_USE_SIO == TRUE */
202 
203 #endif /* HAL_SIO_LLD_H */
204 
205 /** @} */
void sio_lld_init(void)
Low level SIO driver initialization.
Definition: hal_sio_lld.c:65
Structure representing a SIO driver.
Definition: hal_sio_lld.h:115
siostate_t
Driver state machine possible states.
Definition: hal_sio.h:78
const SIOConfig * config
Current configuration data.
Definition: hal_sio_lld.h:123
void(* sioecb_t)(SIODriver *siop, sioflags_t e)
Receive error SIO notification callback type.
Definition: hal_sio_lld.h:79
siocb_t txnf_cb
End of transmission buffer callback.
Definition: hal_sio_lld.h:96
int32_t msg_t
Type of a message.
Definition: osal.h:160
SIODriver SIOD1
SIO1 driver identifier.
Definition: hal_sio_lld.c:41
siostate_t state
Driver state.
Definition: hal_sio_lld.h:119
void sio_lld_stop(SIODriver *siop)
Deactivates the SIO peripheral.
Definition: hal_sio_lld.c:101
void sio_lld_start(SIODriver *siop)
Configures and activates the SIO peripheral.
Definition: hal_sio_lld.c:80
siocb_t rxne_cb
Receive buffer filled callback.
Definition: hal_sio_lld.h:91
sioecb_t rxevt_cb
Receive event callback.
Definition: hal_sio_lld.h:106
siocb_t txend_cb
Physical end of transmission callback.
Definition: hal_sio_lld.h:101
msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg)
Control operation on a serial port.
Definition: hal_sio_lld.c:129
void(* siocb_t)(SIODriver *siop)
Generic SIO notification callback type.
Definition: hal_sio_lld.h:70
Driver configuration structure.
Definition: hal_sio_lld.h:86
uint32_t sioflags_t
SIO driver condition flags type.
Definition: hal_sio_lld.h:63