ChibiOS  21.6.0
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 Type of a SIO events mask.
62  */
63 typedef uint32_t sio_events_mask_t;
64 
65 /*===========================================================================*/
66 /* Driver macros. */
67 /*===========================================================================*/
68 
69 /**
70  * @brief Low level fields of the SIO driver structure.
71  */
72 #define sio_lld_driver_fields \
73  uint32_t dummy
74 
75 /**
76  * @brief Low level fields of the SIO configuration structure.
77  */
78 #define sio_lld_config_fields \
79  uint32_t dummy
80 
81 /**
82  * @brief Determines the state of the RX FIFO.
83  *
84  * @param[in] siop pointer to the @p SIODriver object
85  * @return The RX FIFO state.
86  * @retval false if RX FIFO is not empty
87  * @retval true if RX FIFO is empty
88  *
89  * @notapi
90  */
91 #define sio_lld_is_rx_empty(siop) false
92 
93 /**
94  * @brief Determines the state of the TX FIFO.
95  *
96  * @param[in] siop pointer to the @p SIODriver object
97  * @return The TX FIFO state.
98  * @retval false if TX FIFO is not full
99  * @retval true if TX FIFO is full
100  *
101  * @notapi
102  */
103 #define sio_lld_is_tx_full(siop) false
104 
105 /**
106  * @brief Determines the transmission state.
107  *
108  * @param[in] siop pointer to the @p SIODriver object
109  * @return The TX FIFO state.
110  * @retval false if transmission is idle
111  * @retval true if transmission is ongoing
112  *
113  * @notapi
114  */
115 #define sio_lld_is_tx_ongoing(siop) false
116 
117 /*===========================================================================*/
118 /* External declarations. */
119 /*===========================================================================*/
120 
121 #if (PLATFORM_SIO_USE_SIO1 == TRUE) && !defined(__DOXYGEN__)
122 extern SIODriver SIOD1;
123 #endif
124 
125 #ifdef __cplusplus
126 extern "C" {
127 #endif
128 void sio_lld_init(void);
129 bool sio_lld_start(SIODriver *siop);
130 void sio_lld_stop(SIODriver *siop);
134 size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n);
135 size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n);
137 void sio_lld_put(SIODriver *siop, uint_fast16_t data);
138 msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg);
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif /* HAL_USE_SIO == TRUE */
144 
145 #endif /* HAL_SIO_LLD_H */
146 
147 /** @} */
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_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
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
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