diff options
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_serial_lld.c')
-rw-r--r-- | lib/chibios/os/hal/templates/hal_serial_lld.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_serial_lld.c b/lib/chibios/os/hal/templates/hal_serial_lld.c new file mode 100644 index 000000000..276d4b8f9 --- /dev/null +++ b/lib/chibios/os/hal/templates/hal_serial_lld.c | |||
@@ -0,0 +1,126 @@ | |||
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__) | ||
39 | SerialDriver SD1; | ||
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 | */ | ||
113 | void sd_lld_stop(SerialDriver *sdp) { | ||
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 | /** @} */ | ||