ChibiOS/HAL 9.0.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/* Driver macros. */
62/*===========================================================================*/
63
64/**
65 * @brief Low level fields of the SIO driver structure.
66 */
67#define sio_lld_driver_fields \
68 uint32_t dummy;
69
70/**
71 * @brief Low level fields of the SIO configuration structure.
72 */
73#define sio_lld_config_fields \
74 uint32_t dummy;
75
76/**
77 * @brief Determines the state of the RX FIFO.
78 *
79 * @param[in] siop pointer to the @p SIODriver object
80 * @return The RX FIFO state.
81 * @retval false if RX FIFO is not empty
82 * @retval true if RX FIFO is empty
83 *
84 * @notapi
85 */
86/*lint -e506 -e774 [2.1, 14.3] It is a constant because this is a template file.*/
87#define sio_lld_is_rx_empty(siop) false
88
89/**
90 * @brief Determines the activity state of the receiver.
91 *
92 * @param[in] siop pointer to the @p SIODriver object
93 * @return The RX activity state.
94 * @retval false if RX is in active state.
95 * @retval true if RX is in idle state.
96 *
97 * @notapi
98 */
99/*lint -e506 -e774 [2.1, 14.3] It is a constant because this is a template file.*/
100#define sio_lld_is_rx_idle(siop) false
101
102/**
103 * @brief Determines if RX has pending error events to be read and cleared.
104 * @note Only error and protocol errors are handled, data events are not
105 * considered.
106 *
107 * @param[in] siop pointer to the @p SIODriver object
108 * @return The RX error events.
109 * @retval false if RX has no pending events
110 * @retval true if RX has pending events
111 *
112 * @notapi
113 */
114/*lint -e506 -e774 [2.1, 14.3] It is a constant because this is a template file.*/
115#define sio_lld_has_rx_errors(siop) false
116
117/**
118 * @brief Determines the state of the TX FIFO.
119 *
120 * @param[in] siop pointer to the @p SIODriver object
121 * @return The TX FIFO state.
122 * @retval false if TX FIFO is not full
123 * @retval true if TX FIFO is full
124 *
125 * @notapi
126 */
127/*lint -e506 -e774 [2.1, 14.3] It is a constant because this is a template file.*/
128#define sio_lld_is_tx_full(siop) false
129
130/**
131 * @brief Determines the transmission state.
132 *
133 * @param[in] siop pointer to the @p SIODriver object
134 * @return The TX FIFO state.
135 * @retval false if transmission is idle
136 * @retval true if transmission is ongoing
137 *
138 * @notapi
139 */
140/*lint -e506 -e774 [2.1, 14.3] It is a constant because this is a template file.*/
141#define sio_lld_is_tx_ongoing(siop) false
142
143/*===========================================================================*/
144/* External declarations. */
145/*===========================================================================*/
146
147#if (PLATFORM_SIO_USE_SIO1 == TRUE) && !defined(__DOXYGEN__)
148extern SIODriver SIOD1;
149#endif
150
151#ifdef __cplusplus
152extern "C" {
153#endif
154 void sio_lld_init(void);
156 void sio_lld_stop(SIODriver *siop);
161 size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n);
162 size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n);
164 void sio_lld_put(SIODriver *siop, uint_fast16_t data);
165 msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg);
167#ifdef __cplusplus
168}
169#endif
170
171#endif /* HAL_USE_SIO == TRUE */
172
173#endif /* HAL_SIO_LLD_H */
174
175/** @} */
int32_t msg_t
Type of a message.
Definition osal.h:159
msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg)
Control operation on a serial port.
struct hal_sio_driver SIODriver
Type of structure representing a SIO driver.
Definition hal_sio.h:138
sioevents_t sio_lld_get_events(SIODriver *siop)
Returns the pending SIO event flags.
msg_t sio_lld_get(SIODriver *siop)
Returns one frame from the RX FIFO.
void sio_lld_put(SIODriver *siop, uint_fast16_t data)
Pushes one frame into the TX FIFO.
SIODriver SIOD1
SIO1 driver identifier.
Definition hal_sio_lld.c:41
void sio_lld_stop(SIODriver *siop)
Deactivates the SIO peripheral.
sioevents_t sio_lld_get_and_clear_errors(SIODriver *siop)
Get and clears SIO error event flags.
void sio_lld_serve_interrupt(SIODriver *siop)
Serves an UART interrupt.
void sio_lld_init(void)
Low level SIO driver initialization.
Definition hal_sio_lld.c:65
eventflags_t sioevents_t
Type of event flags.
Definition hal_sio.h:133
sioevents_t sio_lld_get_and_clear_events(SIODriver *siop)
Get and clears SIO event flags.
void sio_lld_update_enable_flags(SIODriver *siop)
Enable flags change notification.
msg_t sio_lld_start(SIODriver *siop)
Configures and activates the SIO peripheral.
Definition hal_sio_lld.c:81
size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n)
Reads data from the RX FIFO.
size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n)
Writes data into the TX FIFO.