ChibiOS  21.6.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  if (sdp->state == SD_STOP) {
94 #if PLATFORM_SERIAL_USE_USART1 == TRUE
95  if (&SD1 == sdp) {
96 
97  }
98 #endif
99  }
100  /* Configures the peripheral.*/
101  (void)config; /* Warning suppression, remove this.*/
102 }
103 
104 /**
105  * @brief Low level serial driver stop.
106  * @details De-initializes the USART, stops the associated clock, resets the
107  * interrupt vector.
108  *
109  * @param[in] sdp pointer to a @p SerialDriver object
110  *
111  * @notapi
112  */
114 
115  if (sdp->state == SD_READY) {
116 #if PLATFORM_SERIAL_USE_USART1 == TRUE
117  if (&SD1 == sdp) {
118 
119  }
120 #endif
121  }
122 }
123 
124 #endif /* HAL_USE_SERIAL == TRUE */
125 
126 /** @} */
SD1
SerialDriver SD1
USART1 serial driver identifier.
Definition: hal_serial_lld.c:39
SD_READY
@ SD_READY
Definition: hal_serial.h:91
hal.h
HAL subsystem header.
sd_lld_stop
void sd_lld_stop(SerialDriver *sdp)
Low level serial driver stop.
Definition: hal_serial_lld.c:113
sdObjectInit
void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify)
Initializes a generic serial driver object.
Definition: hal_serial.c:158
SD_STOP
@ SD_STOP
Definition: hal_serial.h:90
SerialDriver
Full duplex serial driver class.
Definition: hal_serial.h:123
default_config
static const SerialConfig default_config
Driver default configuration.
Definition: hal_serial_lld.c:49
sd_lld_start
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config)
Low level serial driver configuration and (re)start.
Definition: hal_serial_lld.c:87
sd_lld_init
void sd_lld_init(void)
Low level serial driver initialization.
Definition: hal_serial_lld.c:70
SerialConfig
PLATFORM Serial Driver configuration structure.
Definition: hal_serial_lld.h:68