ChibiOS/HAL  6.1.0
hal_uart_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_uart_lld.c
19  * @brief PLATFORM UART subsystem low level driver source.
20  *
21  * @addtogroup UART
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_UART == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /**
38  * @brief UART1 driver identifier.
39  */
40 #if (PLATFORM_UART_USE_UART1 == 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 UART driver initialization.
62  *
63  * @notapi
64  */
65 void uart_lld_init(void) {
66 
67 #if PLATFORM_UART_USE_UART1 == TRUE
68  /* Driver initialization.*/
69  uartObjectInit(&UARTD1);
70 #endif
71 }
72 
73 /**
74  * @brief Configures and activates the UART peripheral.
75  *
76  * @param[in] uartp pointer to the @p UARTDriver object
77  *
78  * @notapi
79  */
80 void uart_lld_start(UARTDriver *uartp) {
81 
82  if (uartp->state == UART_STOP) {
83  /* Enables the peripheral.*/
84 #if PLATFORM_UART_USE_UART1 == TRUE
85  if (&UARTD1 == uartp) {
86 
87  }
88 #endif
89  }
90  /* Configures the peripheral.*/
91 
92 }
93 
94 /**
95  * @brief Deactivates the UART peripheral.
96  *
97  * @param[in] uartp pointer to the @p UARTDriver object
98  *
99  * @notapi
100  */
101 void uart_lld_stop(UARTDriver *uartp) {
102 
103  if (uartp->state == UART_READY) {
104  /* Resets the peripheral.*/
105 
106  /* Disables the peripheral.*/
107 #if PLATFORM_UART_USE_UART1 == TRUE
108  if (&UARTD1 == uartp) {
109 
110  }
111 #endif
112  }
113 }
114 
115 /**
116  * @brief Starts a transmission on the UART peripheral.
117  * @note The buffers are organized as uint8_t arrays for data sizes below
118  * or equal to 8 bits else it is organized as uint16_t arrays.
119  *
120  * @param[in] uartp pointer to the @p UARTDriver object
121  * @param[in] n number of data frames to send
122  * @param[in] txbuf the pointer to the transmit buffer
123  *
124  * @notapi
125  */
126 void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf) {
127 
128  (void)uartp;
129  (void)n;
130  (void)txbuf;
131 
132 }
133 
134 /**
135  * @brief Stops any ongoing transmission.
136  * @note Stopping a transmission also suppresses the transmission callbacks.
137  *
138  * @param[in] uartp pointer to the @p UARTDriver object
139  *
140  * @return The number of data frames not transmitted by the
141  * stopped transmit operation.
142  *
143  * @notapi
144  */
146 
147  (void)uartp;
148 
149  return 0;
150 }
151 
152 /**
153  * @brief Starts a receive operation on the UART peripheral.
154  * @note The buffers are organized as uint8_t arrays for data sizes below
155  * or equal to 8 bits else it is organized as uint16_t arrays.
156  *
157  * @param[in] uartp pointer to the @p UARTDriver object
158  * @param[in] n number of data frames to send
159  * @param[out] rxbuf the pointer to the receive buffer
160  *
161  * @notapi
162  */
163 void uart_lld_start_receive(UARTDriver *uartp, size_t n, void *rxbuf) {
164 
165  (void)uartp;
166  (void)n;
167  (void)rxbuf;
168 
169 }
170 
171 /**
172  * @brief Stops any ongoing receive operation.
173  * @note Stopping a receive operation also suppresses the receive callbacks.
174  *
175  * @param[in] uartp pointer to the @p UARTDriver object
176  *
177  * @return The number of data frames not received by the
178  * stopped receive operation.
179  *
180  * @notapi
181  */
183 
184  (void)uartp;
185 
186  return 0;
187 }
188 
189 #endif /* HAL_USE_UART == TRUE */
190 
191 /** @} */
void uart_lld_start(UARTDriver *uartp)
Configures and activates the UART peripheral.
Definition: hal_uart_lld.c:80
size_t uart_lld_stop_receive(UARTDriver *uartp)
Stops any ongoing receive operation.
Definition: hal_uart_lld.c:182
HAL subsystem header.
size_t uart_lld_stop_send(UARTDriver *uartp)
Stops any ongoing transmission.
Definition: hal_uart_lld.c:145
void uart_lld_stop(UARTDriver *uartp)
Deactivates the UART peripheral.
Definition: hal_uart_lld.c:101
void uart_lld_start_receive(UARTDriver *uartp, size_t n, void *rxbuf)
Starts a receive operation on the UART peripheral.
Definition: hal_uart_lld.c:163
void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf)
Starts a transmission on the UART peripheral.
Definition: hal_uart_lld.c:126
void uart_lld_init(void)
Low level UART driver initialization.
Definition: hal_uart_lld.c:65
uartstate_t state
Driver state.
Definition: hal_uart_lld.h:133
UARTDriver UARTD1
UART1 driver identifier.
Definition: hal_uart_lld.c:41
void uartObjectInit(UARTDriver *uartp)
Initializes the standard part of a UARTDriver structure.
Definition: hal_uart.c:68
Structure representing an UART driver.
Definition: hal_uart_lld.h:129