ChibiOS/HAL  6.1.0
hal_serial_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_serial_lld.c
19  * @brief PLATFORM serial subsystem low level driver source.
20  *
21  * @addtogroup SERIAL
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /** @brief USART1 serial driver identifier.*/
38 #if (PLATFORM_SERIAL_USE_USART1 == TRUE) || defined(__DOXYGEN__)
40 #endif
41 
42 /*===========================================================================*/
43 /* Driver local variables and types. */
44 /*===========================================================================*/
45 
46 /**
47  * @brief Driver default configuration.
48  */
49 static const SerialConfig default_config = {
50  38400
51 };
52 
53 /*===========================================================================*/
54 /* Driver local functions. */
55 /*===========================================================================*/
56 
57 /*===========================================================================*/
58 /* Driver interrupt handlers. */
59 /*===========================================================================*/
60 
61 /*===========================================================================*/
62 /* Driver exported functions. */
63 /*===========================================================================*/
64 
65 /**
66  * @brief Low level serial driver initialization.
67  *
68  * @notapi
69  */
70 void sd_lld_init(void) {
71 
72 #if PLATFORM_SERIAL_USE_USART1 == TRUE
73  sdObjectInit(&SD1, NULL, notify1);
74 #endif
75 }
76 
77 /**
78  * @brief Low level serial driver configuration and (re)start.
79  *
80  * @param[in] sdp pointer to a @p SerialDriver object
81  * @param[in] config the architecture-dependent serial driver configuration.
82  * If this parameter is set to @p NULL then a default
83  * configuration is used.
84  *
85  * @notapi
86  */
87 void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
88 
89  if (config == NULL) {
90  config = &default_config;
91  }
92 
93 
94  if (sdp->state == SD_STOP) {
95 #if PLATFORM_SERIAL_USE_USART1 == TRUE
96  if (&SD1 == sdp) {
97 
98  }
99 #endif
100  }
101  /* Configures the peripheral.*/
102  (void)config; /* Warning suppression, remove this.*/
103 }
104 
105 /**
106  * @brief Low level serial driver stop.
107  * @details De-initializes the USART, stops the associated clock, resets the
108  * interrupt vector.
109  *
110  * @param[in] sdp pointer to a @p SerialDriver object
111  *
112  * @notapi
113  */
115 
116  if (sdp->state == SD_READY) {
117 #if PLATFORM_SERIAL_USE_USART1 == TRUE
118  if (&SD1 == sdp) {
119 
120  }
121 #endif
122  }
123 }
124 
125 #endif /* HAL_USE_SERIAL == TRUE */
126 
127 /** @} */
HAL subsystem header.
SerialDriver SD1
USART1 serial driver identifier.
void sd_lld_init(void)
Low level serial driver initialization.
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config)
Low level serial driver configuration and (re)start.
Full duplex serial driver class.
Definition: hal_serial.h:123
void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify)
Initializes a generic full duplex driver object.
Definition: hal_serial.c:158
void sd_lld_stop(SerialDriver *sdp)
Low level serial driver stop.
static const SerialConfig default_config
Driver default configuration.
PLATFORM Serial Driver configuration structure.