ChibiOS  21.6.0
hal_sio_lld.c
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.c
19  * @brief PLATFORM SIO subsystem low level driver source.
20  *
21  * @addtogroup SIO
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_SIO == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /**
38  * @brief SIO1 driver identifier.
39  */
40 #if (PLATFORM_SIO_USE_SIO1 == TRUE) || defined(__DOXYGEN__)
42 #endif
43 
44 /*===========================================================================*/
45 /* Driver local variables and types. */
46 /*===========================================================================*/
47 
48 /*===========================================================================*/
49 /* Driver local functions. */
50 /*===========================================================================*/
51 
52 /*===========================================================================*/
53 /* Driver interrupt handlers. */
54 /*===========================================================================*/
55 
56 /*===========================================================================*/
57 /* Driver exported functions. */
58 /*===========================================================================*/
59 
60 /**
61  * @brief Low level SIO driver initialization.
62  *
63  * @notapi
64  */
65 void sio_lld_init(void) {
66 
67 #if PLATFORM_SIO_USE_SIO1 == TRUE
68  /* Driver initialization.*/
70 #endif
71 }
72 
73 /**
74  * @brief Configures and activates the SIO peripheral.
75  *
76  * @param[in] siop pointer to the @p SIODriver object
77  * @return The operation status.
78  * @retval false if the driver has been correctly started.
79  * @retval true if an error occurred.
80  *
81  * @notapi
82  */
83 bool sio_lld_start(SIODriver *siop) {
84 
85  if (siop->state == SIO_STOP) {
86  /* Enables the peripheral.*/
87 #if PLATFORM_SIO_USE_SIO1 == TRUE
88  if (&SIOD1 == siop) {
89 
90  }
91 #endif
92  }
93  /* Configures the peripheral.*/
94 
95  return false;
96 }
97 
98 /**
99  * @brief Deactivates the SIO peripheral.
100  *
101  * @param[in] siop pointer to the @p SIODriver object
102  *
103  * @notapi
104  */
105 void sio_lld_stop(SIODriver *siop) {
106 
107  if (siop->state == SIO_READY) {
108  /* Resets the peripheral.*/
109 
110  /* Disables the peripheral.*/
111 #if PLATFORM_SIO_USE_SIO1 == TRUE
112  if (&SIOD1 == siop) {
113 
114  }
115 #endif
116  }
117 }
118 
119 /**
120  * @brief Starts a SIO operation.
121  *
122  * @param[in] siop pointer to an @p SIODriver structure
123  *
124  * @api
125  */
127 
128  (void)siop;
129 }
130 
131 /**
132  * @brief Stops an ongoing SIO operation, if any.
133  *
134  * @param[in] siop pointer to an @p SIODriver structure
135  *
136  * @api
137  */
139 
140  (void)siop;
141 }
142 
143 /**
144  * @brief Return the pending SIO events flags.
145  *
146  * @param[in] siop pointer to the @p SIODriver object
147  * @return The pending event flags.
148  *
149  * @notapi
150  */
152  sio_events_mask_t evtmask = 0U;
153 
154  (void)siop;
155 
156  return evtmask;
157 }
158 
159 /**
160  * @brief Reads data from the RX FIFO.
161  * @details The function is not blocking, it writes frames until there
162  * is space available without waiting.
163  *
164  * @param[in] siop pointer to an @p SIODriver structure
165  * @param[in] buffer pointer to the buffer for read frames
166  * @param[in] n maximum number of frames to be read
167  * @return The number of frames copied from the buffer.
168  * @retval 0 if the TX FIFO is full.
169  */
170 size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n) {
171 
172  (void)siop;
173  (void)buffer;
174 
175  return n;
176 }
177 
178 /**
179  * @brief Writes data into the TX FIFO.
180  * @details The function is not blocking, it writes frames until there
181  * is space available without waiting.
182  *
183  * @param[in] siop pointer to an @p SIODriver structure
184  * @param[in] buffer pointer to the buffer for read frames
185  * @param[in] n maximum number of frames to be written
186  * @return The number of frames copied from the buffer.
187  * @retval 0 if the TX FIFO is full.
188  */
189 size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n) {
190 
191  (void)siop;
192  (void)buffer;
193 
194  return n;
195 }
196 
197 /**
198  * @brief Returns one frame from the RX FIFO.
199  * @note If the FIFO is empty then the returned value is unpredictable.
200  *
201  * @param[in] siop pointer to the @p SIODriver object
202  * @return The frame from RX FIFO.
203  *
204  * @notapi
205  */
207  msg_t msg = (msg_t)0;
208 
209  (void)siop;
210 
211  return msg;
212 }
213 
214 /**
215  * @brief Pushes one frame into the TX FIFO.
216  * @note If the FIFO is full then the behavior is unpredictable.
217  *
218  * @param[in] siop pointer to the @p SIODriver object
219  * @param[in] data frame to be written
220  *
221  * @notapi
222  */
223 void sio_lld_put(SIODriver *siop, uint_fast16_t data) {
224 
225  (void)siop;
226  (void)data;
227 }
228 
229 /**
230  * @brief Control operation on a serial port.
231  *
232  * @param[in] siop pointer to the @p SIODriver object
233  * @param[in] operation control operation code
234  * @param[in,out] arg operation argument
235  *
236  * @return The control operation status.
237  * @retval MSG_OK in case of success.
238  * @retval MSG_TIMEOUT in case of operation timeout.
239  * @retval MSG_RESET in case of operation reset.
240  *
241  * @notapi
242  */
243 msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg) {
244 
245  (void)siop;
246  (void)operation;
247  (void)arg;
248 
249  return MSG_OK;
250 }
251 
252 #endif /* HAL_USE_SIO == TRUE */
253 
254 /** @} */
hal.h
HAL subsystem header.
sio_lld_init
void sio_lld_init(void)
Low level SIO driver initialization.
Definition: hal_sio_lld.c:65
sio_lld_put
void sio_lld_put(SIODriver *siop, uint_fast16_t data)
Pushes one frame into the TX FIFO.
Definition: hal_sio_lld.c:223
SIO_READY
@ SIO_READY
Definition: hal_sio.h:120
sio_lld_get_and_clear_events
sio_events_mask_t sio_lld_get_and_clear_events(SIODriver *siop)
Return the pending SIO events flags.
Definition: hal_sio_lld.c:151
msg_t
int32_t msg_t
Definition: chearly.h:88
sio_lld_control
msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg)
Control operation on a serial port.
Definition: hal_sio_lld.c:243
sioObjectInit
void sioObjectInit(SIODriver *siop)
Initializes the standard part of a SIODriver structure.
Definition: hal_sio.c:225
sio_lld_stop
void sio_lld_stop(SIODriver *siop)
Deactivates the SIO peripheral.
Definition: hal_sio_lld.c:105
sio_lld_get
msg_t sio_lld_get(SIODriver *siop)
Returns one frame from the RX FIFO.
Definition: hal_sio_lld.c:206
MSG_OK
#define MSG_OK
Normal wakeup message.
Definition: chschd.h:39
hal_sio_driver::state
siostate_t state
Driver state.
Definition: hal_sio.h:166
SIO_STOP
@ SIO_STOP
Definition: hal_sio.h:119
sio_lld_start_operation
void sio_lld_start_operation(SIODriver *siop)
Starts a SIO operation.
Definition: hal_sio_lld.c:126
sio_lld_read
size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n)
Reads data from the RX FIFO.
Definition: hal_sio_lld.c:170
hal_sio_driver
Structure representing a SIO driver.
Definition: hal_sio.h:156
sio_lld_start
bool sio_lld_start(SIODriver *siop)
Configures and activates the SIO peripheral.
Definition: hal_sio_lld.c:83
sio_lld_stop_operation
void sio_lld_stop_operation(SIODriver *siop)
Stops an ongoing SIO operation, if any.
Definition: hal_sio_lld.c:138
sio_lld_write
size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n)
Writes data into the TX FIFO.
Definition: hal_sio_lld.c:189
sio_events_mask_t
uint32_t sio_events_mask_t
Type of a SIO events mask.
Definition: hal_sio_lld.h:63
SIOD1
SIODriver SIOD1
SIO1 driver identifier.
Definition: hal_sio_lld.c:41