ChibiOS 21.11.4
hal_serial_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_serial_lld.h
19 * @brief PLATFORM serial subsystem low level driver header.
20 *
21 * @addtogroup SERIAL
22 * @{
23 */
24
25#ifndef HAL_SERIAL_LLD_H
26#define HAL_SERIAL_LLD_H
27
28#if (HAL_USE_SERIAL == 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 USART1 driver enable switch.
44 * @details If set to @p TRUE the support for USART1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_SERIAL_USE_USART1) || defined(__DOXYGEN__)
48#define PLATFORM_SERIAL_USE_USART1 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 PLATFORM Serial Driver configuration structure.
62 * @details An instance of this structure must be passed to @p sdStart()
63 * in order to configure and start a serial driver operations.
64 * @note This structure content is architecture dependent, each driver
65 * implementation defines its own version and the custom static
66 * initializers.
67 */
68typedef struct hal_serial_config {
69 /**
70 * @brief Bit rate.
71 */
72 uint32_t speed;
73 /* End of the mandatory fields.*/
75
76/**
77 * @brief @p SerialDriver specific data.
78 */
79#define _serial_driver_data \
80 _base_asynchronous_channel_data \
81 /* Driver state.*/ \
82 sdstate_t state; \
83 /* Input queue.*/ \
84 input_queue_t iqueue; \
85 /* Output queue.*/ \
86 output_queue_t oqueue; \
87 /* Input circular buffer.*/ \
88 uint8_t ib[SERIAL_BUFFERS_SIZE]; \
89 /* Output circular buffer.*/ \
90 uint8_t ob[SERIAL_BUFFERS_SIZE]; \
91 /* End of the mandatory fields.*/
92
93/*===========================================================================*/
94/* Driver macros. */
95/*===========================================================================*/
96
97/*===========================================================================*/
98/* External declarations. */
99/*===========================================================================*/
100
101#if (PLATFORM_SERIAL_USE_USART1 == TRUE) && !defined(__DOXYGEN__)
102extern SerialDriver SD1;
103#endif
104
105#ifdef __cplusplus
106extern "C" {
107#endif
108 void sd_lld_init(void);
109 void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
110 void sd_lld_stop(SerialDriver *sdp);
111#ifdef __cplusplus
112}
113#endif
114
115#endif /* HAL_USE_SERIAL == TRUE */
116
117#endif /* HAL_SERIAL_LLD_H */
118
119/** @} */
SerialDriver SD1
USART1 serial driver identifier.
struct hal_serial_driver SerialDriver
Structure representing a serial driver.
Definition hal_serial.h:97
struct hal_serial_config SerialConfig
PLATFORM Serial Driver configuration structure.
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config)
Low level serial driver configuration and (re)start.
void sd_lld_init(void)
Low level serial driver initialization.
void sd_lld_stop(SerialDriver *sdp)
Low level serial driver stop.
PLATFORM Serial Driver configuration structure.
uint32_t speed
Bit rate.