aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/templates
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/templates')
-rw-r--r--lib/chibios/os/hal/templates/board/board.c24
-rw-r--r--lib/chibios/os/hal/templates/board/board.h40
-rw-r--r--lib/chibios/os/hal/templates/board/board.mk5
-rw-r--r--lib/chibios/os/hal/templates/hal_adc_lld.c141
-rw-r--r--lib/chibios/os/hal/templates/hal_adc_lld.h130
-rw-r--r--lib/chibios/os/hal/templates/hal_can_lld.c257
-rw-r--r--lib/chibios/os/hal/templates/hal_can_lld.h275
-rw-r--r--lib/chibios/os/hal/templates/hal_crypto_lld.c1346
-rw-r--r--lib/chibios/os/hal/templates/hal_crypto_lld.h376
-rw-r--r--lib/chibios/os/hal/templates/hal_dac_lld.c167
-rw-r--r--lib/chibios/os/hal/templates/hal_dac_lld.h137
-rw-r--r--lib/chibios/os/hal/templates/hal_efl_lld.c365
-rw-r--r--lib/chibios/os/hal/templates/hal_efl_lld.h110
-rw-r--r--lib/chibios/os/hal/templates/hal_gpt_lld.c163
-rw-r--r--lib/chibios/os/hal/templates/hal_gpt_lld.h154
-rw-r--r--lib/chibios/os/hal/templates/hal_i2c_lld.c187
-rw-r--r--lib/chibios/os/hal/templates/hal_i2c_lld.h152
-rw-r--r--lib/chibios/os/hal/templates/hal_i2s_lld.c137
-rw-r--r--lib/chibios/os/hal/templates/hal_i2s_lld.h102
-rw-r--r--lib/chibios/os/hal/templates/hal_icu_lld.c187
-rw-r--r--lib/chibios/os/hal/templates/hal_icu_lld.h193
-rw-r--r--lib/chibios/os/hal/templates/hal_lld.c60
-rw-r--r--lib/chibios/os/hal/templates/hal_lld.h82
-rw-r--r--lib/chibios/os/hal/templates/hal_mac_lld.c313
-rw-r--r--lib/chibios/os/hal/templates/hal_mac_lld.h181
-rw-r--r--lib/chibios/os/hal/templates/hal_pal_lld.c85
-rw-r--r--lib/chibios/os/hal/templates/hal_pal_lld.h444
-rw-r--r--lib/chibios/os/hal/templates/hal_pwm_lld.c220
-rw-r--r--lib/chibios/os/hal/templates/hal_pwm_lld.h215
-rw-r--r--lib/chibios/os/hal/templates/hal_rtc_lld.c153
-rw-r--r--lib/chibios/os/hal/templates/hal_rtc_lld.h149
-rw-r--r--lib/chibios/os/hal/templates/hal_sdc_lld.c328
-rw-r--r--lib/chibios/os/hal/templates/hal_sdc_lld.h180
-rw-r--r--lib/chibios/os/hal/templates/hal_serial_lld.c126
-rw-r--r--lib/chibios/os/hal/templates/hal_serial_lld.h119
-rw-r--r--lib/chibios/os/hal/templates/hal_sio_lld.c140
-rw-r--r--lib/chibios/os/hal/templates/hal_sio_lld.h205
-rw-r--r--lib/chibios/os/hal/templates/hal_spi_lld.c263
-rw-r--r--lib/chibios/os/hal/templates/hal_spi_lld.h120
-rw-r--r--lib/chibios/os/hal/templates/hal_st_lld.c67
-rw-r--r--lib/chibios/os/hal/templates/hal_st_lld.h141
-rw-r--r--lib/chibios/os/hal/templates/hal_trng_lld.c140
-rw-r--r--lib/chibios/os/hal/templates/hal_trng_lld.h101
-rw-r--r--lib/chibios/os/hal/templates/hal_uart_lld.c191
-rw-r--r--lib/chibios/os/hal/templates/hal_uart_lld.h202
-rw-r--r--lib/chibios/os/hal/templates/hal_usb_lld.c390
-rw-r--r--lib/chibios/os/hal/templates/hal_usb_lld.h383
-rw-r--r--lib/chibios/os/hal/templates/hal_wdg_lld.c104
-rw-r--r--lib/chibios/os/hal/templates/hal_wdg_lld.h113
-rw-r--r--lib/chibios/os/hal/templates/hal_wspi_lld.c208
-rw-r--r--lib/chibios/os/hal/templates/hal_wspi_lld.h119
-rw-r--r--lib/chibios/os/hal/templates/halconf.h531
-rw-r--r--lib/chibios/os/hal/templates/mcuconf.h30
-rw-r--r--lib/chibios/os/hal/templates/osal/osal.c411
-rw-r--r--lib/chibios/os/hal/templates/osal/osal.h690
-rw-r--r--lib/chibios/os/hal/templates/osal/osal.mk9
-rw-r--r--lib/chibios/os/hal/templates/platform.mk111
57 files changed, 11972 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/board/board.c b/lib/chibios/os/hal/templates/board/board.c
new file mode 100644
index 000000000..123dfb1ce
--- /dev/null
+++ b/lib/chibios/os/hal/templates/board/board.c
@@ -0,0 +1,24 @@
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#include "hal.h"
18
19/**
20 * @brief Board-specific initialization code.
21 * @note You can add your board-specific code here.
22 */
23void boardInit(void) {
24}
diff --git a/lib/chibios/os/hal/templates/board/board.h b/lib/chibios/os/hal/templates/board/board.h
new file mode 100644
index 000000000..9aeba7c8f
--- /dev/null
+++ b/lib/chibios/os/hal/templates/board/board.h
@@ -0,0 +1,40 @@
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#ifndef BOARD_H
18#define BOARD_H
19
20/*
21 * Setup for a generic board.
22 */
23
24/*
25 * Board identifier.
26 */
27#define BOARD_GENERIC
28#define BOARD_NAME "Generic Board"
29
30#if !defined(_FROM_ASM_)
31#ifdef __cplusplus
32extern "C" {
33#endif
34 void boardInit(void);
35#ifdef __cplusplus
36}
37#endif
38#endif /* _FROM_ASM_ */
39
40#endif /* BOARD_H */
diff --git a/lib/chibios/os/hal/templates/board/board.mk b/lib/chibios/os/hal/templates/board/board.mk
new file mode 100644
index 000000000..27724a903
--- /dev/null
+++ b/lib/chibios/os/hal/templates/board/board.mk
@@ -0,0 +1,5 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/templates/board/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/templates/board
diff --git a/lib/chibios/os/hal/templates/hal_adc_lld.c b/lib/chibios/os/hal/templates/hal_adc_lld.c
new file mode 100644
index 000000000..a2b2511c3
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_adc_lld.c
@@ -0,0 +1,141 @@
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_adc_lld.c
19 * @brief PLATFORM ADC subsystem low level driver source.
20 *
21 * @addtogroup ADC
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_ADC == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief ADC1 driver identifier.
39 */
40#if (PLATFORM_ADC_USE_ADC1 == TRUE) || defined(__DOXYGEN__)
41ADCDriver ADCD1;
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 ADC driver initialization.
62 *
63 * @notapi
64 */
65void adc_lld_init(void) {
66
67#if PLATFORM_ADC_USE_ADC1 == TRUE
68 /* Driver initialization.*/
69 adcObjectInit(&ADCD1);
70#endif
71}
72
73/**
74 * @brief Configures and activates the ADC peripheral.
75 *
76 * @param[in] adcp pointer to the @p ADCDriver object
77 *
78 * @notapi
79 */
80void adc_lld_start(ADCDriver *adcp) {
81
82 if (adcp->state == ADC_STOP) {
83 /* Enables the peripheral.*/
84#if PLATFORM_ADC_USE_ADC1 == TRUE
85 if (&ADCD1 == adcp) {
86
87 }
88#endif
89 }
90 /* Configures the peripheral.*/
91
92}
93
94/**
95 * @brief Deactivates the ADC peripheral.
96 *
97 * @param[in] adcp pointer to the @p ADCDriver object
98 *
99 * @notapi
100 */
101void adc_lld_stop(ADCDriver *adcp) {
102
103 if (adcp->state == ADC_READY) {
104 /* Resets the peripheral.*/
105
106 /* Disables the peripheral.*/
107#if PLATFORM_ADC_USE_ADC1 == TRUE
108 if (&ADCD1 == adcp) {
109
110 }
111#endif
112 }
113}
114
115/**
116 * @brief Starts an ADC conversion.
117 *
118 * @param[in] adcp pointer to the @p ADCDriver object
119 *
120 * @notapi
121 */
122void adc_lld_start_conversion(ADCDriver *adcp) {
123
124 (void)adcp;
125}
126
127/**
128 * @brief Stops an ongoing conversion.
129 *
130 * @param[in] adcp pointer to the @p ADCDriver object
131 *
132 * @notapi
133 */
134void adc_lld_stop_conversion(ADCDriver *adcp) {
135
136 (void)adcp;
137}
138
139#endif /* HAL_USE_ADC == TRUE */
140
141/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_adc_lld.h b/lib/chibios/os/hal/templates/hal_adc_lld.h
new file mode 100644
index 000000000..056824e47
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_adc_lld.h
@@ -0,0 +1,130 @@
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_adc_lld.h
19 * @brief PLATFORM ADC subsystem low level driver header.
20 *
21 * @addtogroup ADC
22 * @{
23 */
24
25#ifndef HAL_ADC_LLD_H
26#define HAL_ADC_LLD_H
27
28#if (HAL_USE_ADC == 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 ADC1 driver enable switch.
44 * @details If set to @p TRUE the support for ADC1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_ADC_USE_ADC1) || defined(__DOXYGEN__)
48#define PLATFORM_ADC_USE_ADC1 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 ADC sample data type.
62 */
63typedef uint16_t adcsample_t;
64
65/**
66 * @brief Channels number in a conversion group.
67 */
68typedef uint16_t adc_channels_num_t;
69
70/**
71 * @brief Possible ADC failure causes.
72 * @note Error codes are architecture dependent and should not relied
73 * upon.
74 */
75typedef enum {
76 ADC_ERR_DMAFAILURE = 0, /**< DMA operations failure. */
77 ADC_ERR_OVERFLOW = 1, /**< ADC overflow condition. */
78 ADC_ERR_AWD = 2 /**< Analog watchdog triggered. */
79} adcerror_t;
80
81/*===========================================================================*/
82/* Driver macros. */
83/*===========================================================================*/
84
85/**
86 * @brief Low level fields of the ADC driver structure.
87 */
88#define adc_lld_driver_fields \
89 /* Dummy field, it is not needed.*/ \
90 uint32_t dummy
91
92/**
93 * @brief Low level fields of the ADC configuration structure.
94 */
95#define adc_lld_config_fields \
96 /* Dummy configuration, it is not needed.*/ \
97 uint32_t dummy
98
99/**
100 * @brief Low level fields of the ADC configuration structure.
101 */
102#define adc_lld_configuration_group_fields \
103 /* Dummy configuration, it is not needed.*/ \
104 uint32_t dummy
105
106/*===========================================================================*/
107/* External declarations. */
108/*===========================================================================*/
109
110#if (PLATFORM_ADC_USE_ADC1 == TRUE) && !defined(__DOXYGEN__)
111extern ADCDriver ADCD1;
112#endif
113
114#ifdef __cplusplus
115extern "C" {
116#endif
117 void adc_lld_init(void);
118 void adc_lld_start(ADCDriver *adcp);
119 void adc_lld_stop(ADCDriver *adcp);
120 void adc_lld_start_conversion(ADCDriver *adcp);
121 void adc_lld_stop_conversion(ADCDriver *adcp);
122#ifdef __cplusplus
123}
124#endif
125
126#endif /* HAL_USE_ADC == TRUE */
127
128#endif /* HAL_ADC_LLD_H */
129
130/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_can_lld.c b/lib/chibios/os/hal/templates/hal_can_lld.c
new file mode 100644
index 000000000..971f904ac
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_can_lld.c
@@ -0,0 +1,257 @@
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_can_lld.c
19 * @brief PLATFORM CAN subsystem low level driver source.
20 *
21 * @addtogroup CAN
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief CAN1 driver identifier.
39 */
40#if (PLATFORM_CAN_USE_CAN1 == TRUE) || defined(__DOXYGEN__)
41CANDriver CAND1;
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 CAN driver initialization.
62 *
63 * @notapi
64 */
65void can_lld_init(void) {
66
67#if PLATFORM_CAN_USE_CAN1 == TRUE
68 /* Driver initialization.*/
69 canObjectInit(&CAND1);
70#endif
71}
72
73/**
74 * @brief Configures and activates the CAN peripheral.
75 *
76 * @param[in] canp pointer to the @p CANDriver object
77 *
78 * @notapi
79 */
80void can_lld_start(CANDriver *canp) {
81
82 if (canp->state == CAN_STOP) {
83 /* Enables the peripheral.*/
84#if PLATFORM_CAN_USE_CAN1 == TRUE
85 if (&CAND1 == canp) {
86
87 }
88#endif
89 }
90 /* Configures the peripheral.*/
91
92}
93
94/**
95 * @brief Deactivates the CAN peripheral.
96 *
97 * @param[in] canp pointer to the @p CANDriver object
98 *
99 * @notapi
100 */
101void can_lld_stop(CANDriver *canp) {
102
103 if (canp->state == CAN_READY) {
104 /* Resets the peripheral.*/
105
106 /* Disables the peripheral.*/
107#if PLATFORM_CAN_USE_CAN1 == TRUE
108 if (&CAND1 == canp) {
109
110 }
111#endif
112 }
113}
114
115/**
116 * @brief Determines whether a frame can be transmitted.
117 *
118 * @param[in] canp pointer to the @p CANDriver object
119 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
120 *
121 * @return The queue space availability.
122 * @retval false no space in the transmit queue.
123 * @retval true transmit slot available.
124 *
125 * @notapi
126 */
127bool can_lld_is_tx_empty(CANDriver *canp, canmbx_t mailbox) {
128
129 (void)canp;
130
131 switch (mailbox) {
132 case CAN_ANY_MAILBOX:
133 return false;
134 case 1:
135 return false;
136 case 2:
137 return false;
138 case 3:
139 return false;
140 default:
141 return false;
142 }
143}
144
145/**
146 * @brief Inserts a frame into the transmit queue.
147 *
148 * @param[in] canp pointer to the @p CANDriver object
149 * @param[in] ctfp pointer to the CAN frame to be transmitted
150 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
151 *
152 * @notapi
153 */
154void can_lld_transmit(CANDriver *canp,
155 canmbx_t mailbox,
156 const CANTxFrame *ctfp) {
157
158 (void)canp;
159 (void)mailbox;
160 (void)ctfp;
161
162}
163
164/**
165 * @brief Determines whether a frame has been received.
166 *
167 * @param[in] canp pointer to the @p CANDriver object
168 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
169 *
170 * @return The queue space availability.
171 * @retval false no space in the transmit queue.
172 * @retval true transmit slot available.
173 *
174 * @notapi
175 */
176bool can_lld_is_rx_nonempty(CANDriver *canp, canmbx_t mailbox) {
177
178 (void)canp;
179 (void)mailbox;
180
181 switch (mailbox) {
182 case CAN_ANY_MAILBOX:
183 return false;
184 case 1:
185 return false;
186 case 2:
187 return false;
188 default:
189 return false;
190 }
191}
192
193/**
194 * @brief Receives a frame from the input queue.
195 *
196 * @param[in] canp pointer to the @p CANDriver object
197 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
198 * @param[out] crfp pointer to the buffer where the CAN frame is copied
199 *
200 * @notapi
201 */
202void can_lld_receive(CANDriver *canp,
203 canmbx_t mailbox,
204 CANRxFrame *crfp) {
205
206 (void)canp;
207 (void)mailbox;
208 (void)crfp;
209
210}
211
212/**
213 * @brief Tries to abort an ongoing transmission.
214 *
215 * @param[in] canp pointer to the @p CANDriver object
216 * @param[in] mailbox mailbox number
217 *
218 * @notapi
219 */
220void can_lld_abort(CANDriver *canp,
221 canmbx_t mailbox) {
222
223 (void)canp;
224 (void)mailbox;
225}
226
227#if (CAN_USE_SLEEP_MODE == TRUE) || defined(__DOXYGEN__)
228/**
229 * @brief Enters the sleep mode.
230 *
231 * @param[in] canp pointer to the @p CANDriver object
232 *
233 * @notapi
234 */
235void can_lld_sleep(CANDriver *canp) {
236
237 (void)canp;
238
239}
240
241/**
242 * @brief Enforces leaving the sleep mode.
243 *
244 * @param[in] canp pointer to the @p CANDriver object
245 *
246 * @notapi
247 */
248void can_lld_wakeup(CANDriver *canp) {
249
250 (void)canp;
251
252}
253#endif /* CAN_USE_SLEEP_MOD == TRUEE */
254
255#endif /* HAL_USE_CAN == TRUE */
256
257/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_can_lld.h b/lib/chibios/os/hal/templates/hal_can_lld.h
new file mode 100644
index 000000000..624c7bf24
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_can_lld.h
@@ -0,0 +1,275 @@
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_can_lld.h
19 * @brief PLATFORM CAN subsystem low level driver header.
20 *
21 * @addtogroup CAN
22 * @{
23 */
24
25#ifndef HAL_CAN_LLD_H
26#define HAL_CAN_LLD_H
27
28#if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @brief Number of transmit mailboxes.
36 */
37#define CAN_TX_MAILBOXES 1
38
39/**
40 * @brief Number of receive mailboxes.
41 */
42#define CAN_RX_MAILBOXES 1
43
44/*===========================================================================*/
45/* Driver pre-compile time settings. */
46/*===========================================================================*/
47
48/**
49 * @name PLATFORM configuration options
50 * @{
51 */
52/**
53 * @brief CAN1 driver enable switch.
54 * @details If set to @p TRUE the support for CAN1 is included.
55 * @note The default is @p FALSE.
56 */
57#if !defined(PLATFORM_CAN_USE_CAN1) || defined(__DOXYGEN__)
58#define PLATFORM_CAN_USE_CAN1 FALSE
59#endif
60/** @} */
61
62/*===========================================================================*/
63/* Derived constants and error checks. */
64/*===========================================================================*/
65
66/*===========================================================================*/
67/* Driver data structures and types. */
68/*===========================================================================*/
69
70/**
71 * @brief Type of a structure representing an CAN driver.
72 */
73typedef struct CANDriver CANDriver;
74
75/**
76 * @brief Type of a transmission mailbox index.
77 */
78typedef uint32_t canmbx_t;
79
80#if defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
81/**
82 * @brief Type of a CAN notification callback.
83 *
84 * @param[in] canp pointer to the @p CANDriver object triggering the
85 * callback
86 * @param[in] flags flags associated to the mailbox callback
87 */
88typedef void (*can_callback_t)(CANDriver *canp, uint32_t flags);
89#endif
90
91/**
92 * @brief CAN transmission frame.
93 * @note Accessing the frame data as word16 or word32 is not portable because
94 * machine data endianness, it can be still useful for a quick filling.
95 */
96typedef struct {
97 /*lint -save -e46 [6.1] Standard types are fine too.*/
98 uint8_t DLC:4; /**< @brief Data length. */
99 uint8_t RTR:1; /**< @brief Frame type. */
100 uint8_t IDE:1; /**< @brief Identifier type. */
101 union {
102 uint32_t SID:11; /**< @brief Standard identifier.*/
103 uint32_t EID:29; /**< @brief Extended identifier.*/
104 uint32_t _align1;
105 };
106 /*lint -restore*/
107 union {
108 uint8_t data8[8]; /**< @brief Frame data. */
109 uint16_t data16[4]; /**< @brief Frame data. */
110 uint32_t data32[2]; /**< @brief Frame data. */
111 };
112} CANTxFrame;
113
114/**
115 * @brief CAN received frame.
116 * @note Accessing the frame data as word16 or word32 is not portable because
117 * machine data endianness, it can be still useful for a quick filling.
118 */
119typedef struct {
120 /*lint -save -e46 [6.1] Standard types are fine too.*/
121 uint8_t FMI; /**< @brief Filter id. */
122 uint16_t TIME; /**< @brief Time stamp. */
123 uint8_t DLC:4; /**< @brief Data length. */
124 uint8_t RTR:1; /**< @brief Frame type. */
125 uint8_t IDE:1; /**< @brief Identifier type. */
126 union {
127 uint32_t SID:11; /**< @brief Standard identifier.*/
128 uint32_t EID:29; /**< @brief Extended identifier.*/
129 uint32_t _align1;
130 };
131 /*lint -restore*/
132 union {
133 uint8_t data8[8]; /**< @brief Frame data. */
134 uint16_t data16[4]; /**< @brief Frame data. */
135 uint32_t data32[2]; /**< @brief Frame data. */
136 };
137} CANRxFrame;
138
139/**
140 * @brief Driver configuration structure.
141 */
142typedef struct {
143 /* End of the mandatory fields.*/
144 uint32_t dummy;
145} CANConfig;
146
147/**
148 * @brief Structure representing an CAN driver.
149 */
150struct CANDriver {
151 /**
152 * @brief Driver state.
153 */
154 canstate_t state;
155 /**
156 * @brief Current configuration data.
157 */
158 const CANConfig *config;
159 /**
160 * @brief Transmission threads queue.
161 */
162 threads_queue_t txqueue;
163 /**
164 * @brief Receive threads queue.
165 */
166 threads_queue_t rxqueue;
167#if (CAN_ENFORCE_USE_CALLBACKS == FALSE) || defined (__DOXYGEN__)
168 /**
169 * @brief One or more frames become available.
170 * @note After broadcasting this event it will not be broadcasted again
171 * until the received frames queue has been completely emptied. It
172 * is <b>not</b> broadcasted for each received frame. It is
173 * responsibility of the application to empty the queue by
174 * repeatedly invoking @p chReceive() when listening to this event.
175 * This behavior minimizes the interrupt served by the system
176 * because CAN traffic.
177 * @note The flags associated to the listeners will indicate which
178 * receive mailboxes become non-empty.
179 */
180 event_source_t rxfull_event;
181 /**
182 * @brief One or more transmission mailbox become available.
183 * @note The flags associated to the listeners will indicate which
184 * transmit mailboxes become empty.
185 */
186 event_source_t txempty_event;
187 /**
188 * @brief A CAN bus error happened.
189 * @note The flags associated to the listeners will indicate the
190 * error(s) that have occurred.
191 */
192 event_source_t error_event;
193#if (CAN_USE_SLEEP_MODE == TRUE) || defined (__DOXYGEN__)
194 /**
195 * @brief Entering sleep state event.
196 */
197 event_source_t sleep_event;
198 /**
199 * @brief Exiting sleep state event.
200 */
201 event_source_t wakeup_event;
202#endif
203#else /* CAN_ENFORCE_USE_CALLBACKS == TRUE */
204 /**
205 * @brief One or more frames become available.
206 * @note After calling this function it will not be called again
207 * until the received frames queue has been completely emptied. It
208 * is <b>not</b> called for each received frame. It is
209 * responsibility of the application to empty the queue by
210 * repeatedly invoking @p chTryReceiveI().
211 * This behavior minimizes the interrupt served by the system
212 * because CAN traffic.
213 */
214 can_callback_t rxfull_cb;
215 /**
216 * @brief One or more transmission mailbox become available.
217 * @note The flags associated to the callback will indicate which
218 * transmit mailboxes become empty.
219 */
220 can_callback_t txempty_cb;
221 /**
222 * @brief A CAN bus error happened.
223 */
224 can_callback_t error_cb;
225#if (CAN_USE_SLEEP_MODE == TRUE) || defined (__DOXYGEN__)
226 /**
227 * @brief Exiting sleep state.
228 */
229 can_callback_t wakeup_cb;
230#endif
231#endif
232 /* End of the mandatory fields.*/
233};
234
235/*===========================================================================*/
236/* Driver macros. */
237/*===========================================================================*/
238
239/*===========================================================================*/
240/* External declarations. */
241/*===========================================================================*/
242
243#if (PLATFORM_CAN_USE_CAN1 == TRUE) && !defined(__DOXYGEN__)
244extern CANDriver CAND1;
245#endif
246
247#ifdef __cplusplus
248extern "C" {
249#endif
250 void can_lld_init(void);
251 void can_lld_start(CANDriver *canp);
252 void can_lld_stop(CANDriver *canp);
253 bool can_lld_is_tx_empty(CANDriver *canp, canmbx_t mailbox);
254 void can_lld_transmit(CANDriver *canp,
255 canmbx_t mailbox,
256 const CANTxFrame *ctfp);
257 bool can_lld_is_rx_nonempty(CANDriver *canp, canmbx_t mailbox);
258 void can_lld_receive(CANDriver *canp,
259 canmbx_t mailbox,
260 CANRxFrame *crfp);
261 void can_lld_abort(CANDriver *canp,
262 canmbx_t mailbox);
263#if CAN_USE_SLEEP_MODE == TRUE
264 void can_lld_sleep(CANDriver *canp);
265 void can_lld_wakeup(CANDriver *canp);
266#endif
267#ifdef __cplusplus
268}
269#endif
270
271#endif /* HAL_USE_CAN == TRUE */
272
273#endif /* HAL_CAN_LLD_H */
274
275/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_crypto_lld.c b/lib/chibios/os/hal/templates/hal_crypto_lld.c
new file mode 100644
index 000000000..b4f5c9909
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_crypto_lld.c
@@ -0,0 +1,1346 @@
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_crypto_lld.c
19 * @brief PLATFORM cryptographic subsystem low level driver source.
20 *
21 * @addtogroup CRYPTO
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/** @brief CRY1 driver identifier.*/
38#if PLATFORM_CRY_USE_CRY1 || defined(__DOXYGEN__)
39CRYDriver CRYD1;
40#endif
41
42/*===========================================================================*/
43/* Driver local variables and types. */
44/*===========================================================================*/
45
46/*===========================================================================*/
47/* Driver local functions. */
48/*===========================================================================*/
49
50/*===========================================================================*/
51/* Driver interrupt handlers. */
52/*===========================================================================*/
53
54/*===========================================================================*/
55/* Driver exported functions. */
56/*===========================================================================*/
57
58/**
59 * @brief Low level crypto driver initialization.
60 *
61 * @notapi
62 */
63void cry_lld_init(void) {
64
65}
66
67/**
68 * @brief Configures and activates the crypto peripheral.
69 *
70 * @param[in] cryp pointer to the @p CRYDriver object
71 *
72 * @notapi
73 */
74void cry_lld_start(CRYDriver *cryp) {
75
76 if (cryp->state == CRY_STOP) {
77
78 }
79}
80
81/**
82 * @brief Deactivates the crypto peripheral.
83 *
84 * @param[in] cryp pointer to the @p CRYDriver object
85 *
86 * @notapi
87 */
88void cry_lld_stop(CRYDriver *cryp) {
89
90 if (cryp->state == CRY_READY) {
91
92 }
93}
94
95#if (CRY_LLD_SUPPORTS_AES == TRUE) || defined(__DOXYGEN__)
96/**
97 * @brief Initializes the AES transient key.
98 * @note It is the underlying implementation to decide which key sizes are
99 * allowable.
100 *
101 * @param[in] cryp pointer to the @p CRYDriver object
102 * @param[in] size key size in bytes
103 * @param[in] keyp pointer to the key data
104 * @return The operation status.
105 * @retval CRY_NOERROR if the operation succeeded.
106 * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
107 * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
108 * the specified algorithm.
109 *
110 * @notapi
111 */
112cryerror_t cry_lld_aes_loadkey(CRYDriver *cryp,
113 size_t size,
114 const uint8_t *keyp) {
115
116 (void)cryp;
117 (void)size;
118 (void)keyp;
119
120 return CRY_ERR_INV_ALGO;
121}
122
123/**
124 * @brief Encryption of a single block using AES.
125 * @note The implementation of this function must guarantee that it can
126 * be called from any context.
127 *
128 * @param[in] cryp pointer to the @p CRYDriver object
129 * @param[in] key_id the key to be used for the operation, zero is
130 * the transient key, other values are keys stored
131 * in an unspecified way
132 * @param[in] in buffer containing the input plaintext
133 * @param[out] out buffer for the output ciphertext
134 * @return The operation status.
135 * @retval CRY_NOERROR if the operation succeeded.
136 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
137 * device instance.
138 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
139 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
140 * or refers to an empty key slot.
141 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
142 * dependent.
143 *
144 * @notapi
145 */
146cryerror_t cry_lld_encrypt_AES(CRYDriver *cryp,
147 crykey_t key_id,
148 const uint8_t *in,
149 uint8_t *out) {
150
151 (void)cryp;
152 (void)key_id;
153 (void)in;
154 (void)out;
155
156 return CRY_ERR_INV_ALGO;
157}
158
159/**
160 * @brief Decryption of a single block using AES.
161 * @note The implementation of this function must guarantee that it can
162 * be called from any context.
163 *
164 * @param[in] cryp pointer to the @p CRYDriver object
165 * @param[in] key_id the key to be used for the operation, zero is
166 * the transient key, other values are keys stored
167 * in an unspecified way
168 * @param[in] in buffer containing the input ciphertext
169 * @param[out] out buffer for the output plaintext
170 * @return The operation status.
171 * @retval CRY_NOERROR if the operation succeeded.
172 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
173 * device instance.
174 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
175 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
176 * or refers to an empty key slot.
177 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
178 * dependent.
179 *
180 * @notapi
181 */
182cryerror_t cry_lld_decrypt_AES(CRYDriver *cryp,
183 crykey_t key_id,
184 const uint8_t *in,
185 uint8_t *out) {
186
187 (void)cryp;
188 (void)key_id;
189 (void)in;
190 (void)out;
191
192 return CRY_ERR_INV_ALGO;
193}
194#endif
195
196#if (CRY_LLD_SUPPORTS_AES_ECB == TRUE) || defined(__DOXYGEN__)
197/**
198 * @brief Encryption operation using AES-ECB.
199 * @note The function operates on data buffers whose length is a multiple
200 * of an AES block, this means that padding must be done by the
201 * caller.
202 *
203 * @param[in] cryp pointer to the @p CRYDriver object
204 * @param[in] key_id the key to be used for the operation, zero is
205 * the transient key, other values are keys stored
206 * in an unspecified way
207 * @param[in] size size of both buffers, this number must be a
208 * multiple of 16
209 * @param[in] in buffer containing the input plaintext
210 * @param[out] out buffer for the output ciphertext
211 * @return The operation status.
212 * @retval CRY_NOERROR if the operation succeeded.
213 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
214 * device instance.
215 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
216 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
217 * or refers to an empty key slot.
218 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
219 * dependent.
220 *
221 * @notapi
222 */
223cryerror_t cry_lld_encrypt_AES_ECB(CRYDriver *cryp,
224 crykey_t key_id,
225 size_t size,
226 const uint8_t *in,
227 uint8_t *out) {
228
229 (void)cryp;
230 (void)key_id;
231 (void)size;
232 (void)in;
233 (void)out;
234
235 return CRY_ERR_INV_ALGO;
236}
237
238/**
239 * @brief Decryption operation using AES-ECB.
240 * @note The function operates on data buffers whose length is a multiple
241 * of an AES block, this means that padding must be done by the
242 * caller.
243 *
244 * @param[in] cryp pointer to the @p CRYDriver object
245 * @param[in] key_id the key to be used for the operation, zero is
246 * the transient key, other values are keys stored
247 * in an unspecified way
248 * @param[in] size size of both buffers, this number must be a
249 * multiple of 16
250 * @param[in] in buffer containing the input plaintext
251 * @param[out] out buffer for the output ciphertext
252 * @return The operation status.
253 * @retval CRY_NOERROR if the operation succeeded.
254 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
255 * device instance.
256 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
257 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
258 * or refers to an empty key slot.
259 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
260 * dependent.
261 *
262 * @notapi
263 */
264cryerror_t cry_lld_decrypt_AES_ECB(CRYDriver *cryp,
265 crykey_t key_id,
266 size_t size,
267 const uint8_t *in,
268 uint8_t *out) {
269
270 (void)cryp;
271 (void)key_id;
272 (void)size;
273 (void)in;
274 (void)out;
275
276 return CRY_ERR_INV_ALGO;
277}
278#endif
279
280#if (CRY_LLD_SUPPORTS_AES_CBC == TRUE) || defined(__DOXYGEN__)
281/**
282 * @brief Encryption operation using AES-CBC.
283 * @note The function operates on data buffers whose length is a multiple
284 * of an AES block, this means that padding must be done by the
285 * caller.
286 *
287 * @param[in] cryp pointer to the @p CRYDriver object
288 * @param[in] key_id the key to be used for the operation, zero is
289 * the transient key, other values are keys stored
290 * in an unspecified way
291 * @param[in] size size of both buffers, this number must be a
292 * multiple of 16
293 * @param[in] in buffer containing the input plaintext
294 * @param[out] out buffer for the output ciphertext
295 * @param[in] iv 128 bits initial vector
296 * @return The operation status.
297 * @retval CRY_NOERROR if the operation succeeded.
298 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
299 * device instance.
300 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
301 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
302 * or refers to an empty key slot.
303 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
304 * dependent.
305 *
306 * @notapi
307 */
308cryerror_t cry_lld_encrypt_AES_CBC(CRYDriver *cryp,
309 crykey_t key_id,
310 size_t size,
311 const uint8_t *in,
312 uint8_t *out,
313 const uint8_t *iv) {
314
315 (void)cryp;
316 (void)key_id;
317 (void)size;
318 (void)in;
319 (void)out;
320 (void)iv;
321
322 return CRY_ERR_INV_ALGO;
323}
324
325/**
326 * @brief Decryption operation using AES-CBC.
327 * @note The function operates on data buffers whose length is a multiple
328 * of an AES block, this means that padding must be done by the
329 * caller.
330 *
331 * @param[in] cryp pointer to the @p CRYDriver object
332 * @param[in] key_id the key to be used for the operation, zero is
333 * the transient key, other values are keys stored
334 * in an unspecified way
335 * @param[in] size size of both buffers, this number must be a
336 * multiple of 16
337 * @param[in] in buffer containing the input plaintext
338 * @param[out] out buffer for the output ciphertext
339 * @param[in] iv 128 bits initial vector
340 * @return The operation status.
341 * @retval CRY_NOERROR if the operation succeeded.
342 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
343 * device instance.
344 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
345 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
346 * or refers to an empty key slot.
347 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
348 * dependent.
349 *
350 * @notapi
351 */
352cryerror_t cry_lld_decrypt_AES_CBC(CRYDriver *cryp,
353 crykey_t key_id,
354 size_t size,
355 const uint8_t *in,
356 uint8_t *out,
357 const uint8_t *iv) {
358
359 (void)cryp;
360 (void)key_id;
361 (void)size;
362 (void)in;
363 (void)out;
364 (void)iv;
365
366 return CRY_ERR_INV_ALGO;
367}
368#endif
369
370#if (CRY_LLD_SUPPORTS_AES_CFB == TRUE) || defined(__DOXYGEN__)
371/**
372 * @brief Encryption operation using AES-CFB.
373 * @note This is a stream cipher, there are no size restrictions.
374 *
375 * @param[in] cryp pointer to the @p CRYDriver object
376 * @param[in] key_id the key to be used for the operation, zero is
377 * the transient key, other values are keys stored
378 * in an unspecified way
379 * @param[in] size size of both buffers
380 * @param[in] in buffer containing the input plaintext
381 * @param[out] out buffer for the output ciphertext
382 * @param[in] iv 128 bits initial vector
383 * @return The operation status.
384 * @retval CRY_NOERROR if the operation succeeded.
385 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
386 * device instance.
387 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
388 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
389 * or refers to an empty key slot.
390 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
391 * dependent.
392 *
393 * @notapi
394 */
395cryerror_t cry_lld_encrypt_AES_CFB(CRYDriver *cryp,
396 crykey_t key_id,
397 size_t size,
398 const uint8_t *in,
399 uint8_t *out,
400 const uint8_t *iv) {
401
402 (void)cryp;
403 (void)key_id;
404 (void)size;
405 (void)in;
406 (void)out;
407 (void)iv;
408
409 return CRY_ERR_INV_ALGO;
410}
411
412/**
413 * @brief Decryption operation using AES-CFB.
414 * @note This is a stream cipher, there are no size restrictions.
415 *
416 * @param[in] cryp pointer to the @p CRYDriver object
417 * @param[in] key_id the key to be used for the operation, zero is
418 * the transient key, other values are keys stored
419 * in an unspecified way
420 * @param[in] size size of both buffers
421 * @param[in] in buffer containing the input plaintext
422 * @param[out] out buffer for the output ciphertext
423 * @param[in] iv 128 bits initial vector
424 * @return The operation status.
425 * @retval CRY_NOERROR if the operation succeeded.
426 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
427 * device instance.
428 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
429 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
430 * or refers to an empty key slot.
431 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
432 * dependent.
433 *
434 * @notapi
435 */
436cryerror_t cry_lld_decrypt_AES_CFB(CRYDriver *cryp,
437 crykey_t key_id,
438 size_t size,
439 const uint8_t *in,
440 uint8_t *out,
441 const uint8_t *iv) {
442
443 (void)cryp;
444 (void)key_id;
445 (void)size;
446 (void)in;
447 (void)out;
448 (void)iv;
449
450 return CRY_ERR_INV_ALGO;
451}
452#endif
453
454#if (CRY_LLD_SUPPORTS_AES_CTR == TRUE) || defined(__DOXYGEN__)
455/**
456 * @brief Encryption operation using AES-CTR.
457 * @note This is a stream cipher, there are no size restrictions.
458 *
459 * @param[in] cryp pointer to the @p CRYDriver object
460 * @param[in] key_id the key to be used for the operation, zero is
461 * the transient key, other values are keys stored
462 * in an unspecified way
463 * @param[in] size size of both buffers
464 * @param[in] in buffer containing the input plaintext
465 * @param[out] out buffer for the output ciphertext
466 * @param[in] iv 128 bits initial vector + counter, it contains
467 * a 96 bits IV and a 32 bits counter
468 * @return The operation status.
469 * @retval CRY_NOERROR if the operation succeeded.
470 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
471 * device instance.
472 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
473 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
474 * or refers to an empty key slot.
475 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
476 * dependent.
477 *
478 * @notapi
479 */
480cryerror_t cry_lld_encrypt_AES_CTR(CRYDriver *cryp,
481 crykey_t key_id,
482 size_t size,
483 const uint8_t *in,
484 uint8_t *out,
485 const uint8_t *iv) {
486
487 (void)cryp;
488 (void)key_id;
489 (void)size;
490 (void)in;
491 (void)out;
492 (void)iv;
493
494 return CRY_ERR_INV_ALGO;
495}
496
497/**
498 * @brief Decryption operation using AES-CTR.
499 * @note This is a stream cipher, there are no size restrictions.
500 *
501 * @param[in] cryp pointer to the @p CRYDriver object
502 * @param[in] key_id the key to be used for the operation, zero is
503 * the transient key, other values are keys stored
504 * in an unspecified way
505 * @param[in] size size of both buffers
506 * @param[in] in buffer containing the input ciphertext
507 * @param[out] out buffer for the output plaintext
508 * @param[in] iv 128 bits initial vector + counter, it contains
509 * a 96 bits IV and a 32 bits counter
510 * @return The operation status.
511 * @retval CRY_NOERROR if the operation succeeded.
512 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
513 * device instance.
514 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
515 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
516 * or refers to an empty key slot.
517 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
518 * dependent.
519 *
520 * @notapi
521 */
522cryerror_t cry_lld_decrypt_AES_CTR(CRYDriver *cryp,
523 crykey_t key_id,
524 size_t size,
525 const uint8_t *in,
526 uint8_t *out,
527 const uint8_t *iv) {
528
529 (void)cryp;
530 (void)key_id;
531 (void)size;
532 (void)in;
533 (void)out;
534 (void)iv;
535
536 return CRY_ERR_INV_ALGO;
537}
538#endif
539
540#if (CRY_LLD_SUPPORTS_AES_GCM == TRUE) || defined(__DOXYGEN__)
541/**
542 * @brief Encryption operation using AES-GCM.
543 * @note This is a stream cipher, there are no size restrictions.
544 *
545 * @param[in] cryp pointer to the @p CRYDriver object
546 * @param[in] key_id the key to be used for the operation, zero is
547 * the transient key, other values are keys stored
548 * in an unspecified way
549 * @param[in] auth_size size of the data buffer to be authenticated
550 * @param[in] auth_in buffer containing the data to be authenticated
551 * @param[in] text_size size of the text buffer
552 * @param[in] text_in buffer containing the input plaintext
553 * @param[out] text_out buffer for the output ciphertext
554 * @param[in] iv 128 bits input vector
555 * @param[in] tag_size size of the authentication tag, this number
556 * must be between 1 and 16
557 * @param[out] tag_out buffer for the generated authentication tag
558 * @return The operation status.
559 * @retval CRY_NOERROR if the operation succeeded.
560 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
561 * device instance.
562 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
563 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
564 * or refers to an empty key slot.
565 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
566 * dependent.
567 *
568 * @notapi
569 */
570cryerror_t cry_lld_encrypt_AES_GCM(CRYDriver *cryp,
571 crykey_t key_id,
572 size_t auth_size,
573 const uint8_t *auth_in,
574 size_t text_size,
575 const uint8_t *text_in,
576 uint8_t *text_out,
577 const uint8_t *iv,
578 size_t tag_size,
579 uint8_t *tag_out) {
580
581 (void)cryp;
582 (void)key_id;
583 (void)auth_size;
584 (void)auth_in;
585 (void)text_size;
586 (void)text_in;
587 (void)text_out;
588 (void)iv;
589 (void)tag_size;
590 (void)tag_out;
591
592 return CRY_ERR_INV_ALGO;
593}
594
595/**
596 * @brief Decryption operation using AES-GCM.
597 * @note This is a stream cipher, there are no size restrictions.
598 *
599 * @param[in] cryp pointer to the @p CRYDriver object
600 * @param[in] key_id the key to be used for the operation, zero is
601 * the transient key, other values are keys stored
602 * in an unspecified way
603 * @param[in] auth_size size of the data buffer to be authenticated
604 * @param[in] auth_in buffer containing the data to be authenticated
605 * @param[in] text_size size of the text buffer
606 * @param[in] text_in buffer containing the input plaintext
607 * @param[out] text_out buffer for the output ciphertext
608 * @param[in] iv 128 bits input vector
609 * @param[in] tag_size size of the authentication tag, this number
610 * must be between 1 and 16
611 * @param[in] tag_in buffer for the generated authentication tag
612 * @return The operation status.
613 * @retval CRY_NOERROR if the operation succeeded.
614 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
615 * device instance.
616 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
617 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
618 * or refers to an empty key slot.
619 * @retval CRY_ERR_AUTH_FAILED authentication failed
620 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
621 * dependent.
622 *
623 * @notapi
624 */
625cryerror_t cry_lld_decrypt_AES_GCM(CRYDriver *cryp,
626 crykey_t key_id,
627 size_t auth_size,
628 const uint8_t *auth_in,
629 size_t text_size,
630 const uint8_t *text_in,
631 uint8_t *text_out,
632 const uint8_t *iv,
633 size_t tag_size,
634 const uint8_t *tag_in) {
635
636 (void)cryp;
637 (void)key_id;
638 (void)auth_size;
639 (void)auth_in;
640 (void)text_size;
641 (void)text_in;
642 (void)text_out;
643 (void)iv;
644 (void)tag_size;
645 (void)tag_in;
646
647 return CRY_ERR_INV_ALGO;
648}
649#endif
650
651#if (CRY_LLD_SUPPORTS_DES == TRUE) || defined(__DOXYGEN__)
652/**
653 * @brief Initializes the DES transient key.
654 * @note It is the underlying implementation to decide which key sizes are
655 * allowable.
656 *
657 * @param[in] cryp pointer to the @p CRYDriver object
658 * @param[in] size key size in bytes
659 * @param[in] keyp pointer to the key data
660 * @return The operation status.
661 * @retval CRY_NOERROR if the operation succeeded.
662 * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
663 * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
664 * the specified algorithm.
665 *
666 * @notapi
667 */
668cryerror_t cry_lld_des_loadkey(CRYDriver *cryp,
669 size_t size,
670 const uint8_t *keyp) {
671
672 (void)cryp;
673 (void)size;
674 (void)keyp;
675
676 return CRY_ERR_INV_ALGO;
677}
678
679/**
680 * @brief Encryption of a single block using (T)DES.
681 * @note The implementation of this function must guarantee that it can
682 * be called from any context.
683 *
684 * @param[in] cryp pointer to the @p CRYDriver object
685 * @param[in] key_id the key to be used for the operation, zero is
686 * the transient key, other values are keys stored
687 * in an unspecified way
688 * @param[in] in buffer containing the input plaintext
689 * @param[out] out buffer for the output ciphertext
690 * @return The operation status.
691 * @retval CRY_NOERROR if the operation succeeded.
692 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
693 * device instance.
694 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
695 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
696 * or refers to an empty key slot.
697 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
698 * dependent.
699 *
700 * @notapi
701 */
702cryerror_t cry_lld_encrypt_DES(CRYDriver *cryp,
703 crykey_t key_id,
704 const uint8_t *in,
705 uint8_t *out) {
706
707 (void)cryp;
708 (void)key_id;
709 (void)in;
710 (void)out;
711
712 return CRY_ERR_INV_ALGO;
713}
714
715/**
716 * @brief Decryption of a single block using (T)DES.
717 * @note The implementation of this function must guarantee that it can
718 * be called from any context.
719 *
720 *
721 * @param[in] cryp pointer to the @p CRYDriver object
722 * @param[in] key_id the key to be used for the operation, zero is
723 * the transient key, other values are keys stored
724 * in an unspecified way
725 * @param[in] in buffer containing the input ciphertext
726 * @param[out] out buffer for the output plaintext
727 * @return The operation status.
728 * @retval CRY_NOERROR if the operation succeeded.
729 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
730 * device instance.
731 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
732 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
733 * or refers to an empty key slot.
734 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
735 * dependent.
736 *
737 * @notapi
738 */
739cryerror_t cry_lld_decrypt_DES(CRYDriver *cryp,
740 crykey_t key_id,
741 const uint8_t *in,
742 uint8_t *out) {
743
744 (void)cryp;
745 (void)key_id;
746 (void)in;
747 (void)out;
748
749 return CRY_ERR_INV_ALGO;
750}
751#endif
752
753#if (CRY_LLD_SUPPORTS_DES_ECB == TRUE) || defined(__DOXYGEN__)
754/**
755 * @brief Encryption operation using (T)DES-ECB.
756 * @note The function operates on data buffers whose length is a multiple
757 * of an DES block, this means that padding must be done by the
758 * caller.
759 *
760 * @param[in] cryp pointer to the @p CRYDriver object
761 * @param[in] key_id the key to be used for the operation, zero is
762 * the transient key, other values are keys stored
763 * in an unspecified way
764 * @param[in] size size of the plaintext buffer, this number must
765 * be a multiple of 8
766 * @param[in] in buffer containing the input plaintext
767 * @param[out] out buffer for the output ciphertext
768 * @return The operation status.
769 * @retval CRY_NOERROR if the operation succeeded.
770 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
771 * device instance.
772 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
773 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
774 * or refers to an empty key slot.
775 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
776 * dependent.
777 *
778 * @notapi
779 */
780cryerror_t cry_lld_encrypt_DES_ECB(CRYDriver *cryp,
781 crykey_t key_id,
782 size_t size,
783 const uint8_t *in,
784 uint8_t *out) {
785
786 (void)cryp;
787 (void)key_id;
788 (void)size;
789 (void)in;
790 (void)out;
791
792 return CRY_ERR_INV_ALGO;
793}
794
795/**
796 * @brief Decryption operation using (T)DES-ECB.
797 * @note The function operates on data buffers whose length is a multiple
798 * of an DES block, this means that padding must be done by the
799 * caller.
800 *
801 * @param[in] cryp pointer to the @p CRYDriver object
802 * @param[in] key_id the key to be used for the operation, zero is
803 * the transient key, other values are keys stored
804 * in an unspecified way
805 * @param[in] size size of the plaintext buffer, this number must
806 * be a multiple of 8
807 * @param[in] in buffer containing the input ciphertext
808 * @param[out] out buffer for the output plaintext
809 * @return T he operation status.
810 * @retval CRY_NOERROR if the operation succeeded.
811 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
812 * device instance.
813 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
814 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
815 * or refers to an empty key slot.
816 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
817 * dependent.
818 *
819 * @notapi
820 */
821cryerror_t cry_lld_decrypt_DES_ECB(CRYDriver *cryp,
822 crykey_t key_id,
823 size_t size,
824 const uint8_t *in,
825 uint8_t *out) {
826
827 (void)cryp;
828 (void)key_id;
829 (void)size;
830 (void)in;
831 (void)out;
832
833 return CRY_ERR_INV_ALGO;
834}
835#endif
836
837#if (CRY_LLD_SUPPORTS_DES_CBC == TRUE) || defined(__DOXYGEN__)
838/**
839 * @brief Encryption operation using (T)DES-CBC.
840 * @note The function operates on data buffers whose length is a multiple
841 * of an DES block, this means that padding must be done by the
842 * caller.
843 *
844 * @param[in] cryp pointer to the @p CRYDriver object
845 * @param[in] key_id the key to be used for the operation, zero is
846 * the transient key, other values are keys stored
847 * in an unspecified way
848 * @param[in] size size of the plaintext buffer, this number must
849 * be a multiple of 8
850 * @param[in] in buffer containing the input plaintext
851 * @param[out] out buffer for the output ciphertext
852 * @param[in] iv 64 bits input vector
853 * @return The operation status.
854 * @retval CRY_NOERROR if the operation succeeded.
855 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
856 * device instance.
857 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
858 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
859 * or refers to an empty key slot.
860 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
861 * dependent.
862 *
863 * @notapi
864 */
865cryerror_t cry_lld_encrypt_DES_CBC(CRYDriver *cryp,
866 crykey_t key_id,
867 size_t size,
868 const uint8_t *in,
869 uint8_t *out,
870 const uint8_t *iv) {
871
872 (void)cryp;
873 (void)key_id;
874 (void)size;
875 (void)in;
876 (void)out;
877 (void)iv;
878
879 return CRY_ERR_INV_ALGO;
880}
881
882/**
883 * @brief Decryption operation using (T)DES-CBC.
884 * @note The function operates on data buffers whose length is a multiple
885 * of an DES block, this means that padding must be done by the
886 * caller.
887 *
888 * @param[in] cryp pointer to the @p CRYDriver object
889 * @param[in] key_id the key to be used for the operation, zero is
890 * the transient key, other values are keys stored
891 * in an unspecified way
892 * @param[in] size size of the plaintext buffer, this number must
893 * be a multiple of 8
894 * @param[in] in buffer containing the input ciphertext
895 * @param[out] out buffer for the output plaintext
896 * @param[in] iv 64 bits input vector
897 * @return The operation status.
898 * @retval CRY_NOERROR if the operation succeeded.
899 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
900 * device instance.
901 * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
902 * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
903 * or refers to an empty key slot.
904 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
905 * dependent.
906 *
907 * @notapi
908 */
909cryerror_t cry_lld_decrypt_DES_CBC(CRYDriver *cryp,
910 crykey_t key_id,
911 size_t size,
912 const uint8_t *in,
913 uint8_t *out,
914 const uint8_t *iv) {
915
916 (void)cryp;
917 (void)key_id;
918 (void)size;
919 (void)in;
920 (void)out;
921 (void)iv;
922
923 return CRY_ERR_INV_ALGO;
924}
925#endif
926
927#if (CRY_LLD_SUPPORTS_SHA1 == TRUE) || defined(__DOXYGEN__)
928/**
929 * @brief Hash initialization using SHA1.
930 * @note Use of this algorithm is not recommended because proven weak.
931 *
932 * @param[in] cryp pointer to the @p CRYDriver object
933 * @param[out] sha1ctxp pointer to a SHA1 context to be initialized
934 * @retval CRY_NOERROR if the operation succeeded.
935 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
936 * device instance.
937 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
938 * dependent.
939 *
940 * @notapi
941 */
942cryerror_t cry_lld_SHA1_init(CRYDriver *cryp, SHA1Context *sha1ctxp) {
943
944 (void)cryp;
945 (void)sha1ctxp;
946
947 return CRY_ERR_INV_ALGO;
948}
949
950/**
951 * @brief Hash update using SHA1.
952 * @note Use of this algorithm is not recommended because proven weak.
953 *
954 * @param[in] cryp pointer to the @p CRYDriver object
955 * @param[in] sha1ctxp pointer to a SHA1 context
956 * @param[in] size size of input buffer
957 * @param[in] in buffer containing the input text
958 * @return The operation status.
959 * @retval CRY_NOERROR if the operation succeeded.
960 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
961 * device instance.
962 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
963 * dependent.
964 *
965 * @notapi
966 */
967cryerror_t cry_lld_SHA1_update(CRYDriver *cryp, SHA1Context *sha1ctxp,
968 size_t size, const uint8_t *in) {
969
970 (void)cryp;
971 (void)sha1ctxp;
972 (void)size;
973 (void)in;
974
975 return CRY_ERR_INV_ALGO;
976}
977
978/**
979 * @brief Hash finalization using SHA1.
980 * @note Use of this algorithm is not recommended because proven weak.
981 *
982 * @param[in] cryp pointer to the @p CRYDriver object
983 * @param[in] sha1ctxp pointer to a SHA1 context
984 * @param[out] out 160 bits output buffer
985 * @return The operation status.
986 * @retval CRY_NOERROR if the operation succeeded.
987 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
988 * device instance.
989 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
990 * dependent.
991 *
992 * @notapi
993 */
994cryerror_t cry_lld_SHA1_final(CRYDriver *cryp, SHA1Context *sha1ctxp,
995 uint8_t *out) {
996
997 (void)cryp;
998 (void)sha1ctxp;
999 (void)out;
1000
1001 return CRY_ERR_INV_ALGO;
1002}
1003#endif
1004
1005#if (CRY_LLD_SUPPORTS_SHA256 == TRUE) || defined(__DOXYGEN__)
1006/**
1007 * @brief Hash initialization using SHA256.
1008 *
1009 * @param[in] cryp pointer to the @p CRYDriver object
1010 * @param[out] sha256ctxp pointer to a SHA256 context to be initialized
1011 * @retval CRY_NOERROR if the operation succeeded.
1012 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1013 * device instance.
1014 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1015 * dependent.
1016 *
1017 * @notapi
1018 */
1019cryerror_t cry_lld_SHA256_init(CRYDriver *cryp, SHA256Context *sha256ctxp) {
1020
1021 (void)cryp;
1022 (void)sha256ctxp;
1023
1024 return CRY_ERR_INV_ALGO;
1025}
1026
1027/**
1028 * @brief Hash update using SHA256.
1029 *
1030 * @param[in] cryp pointer to the @p CRYDriver object
1031 * @param[in] sha256ctxp pointer to a SHA256 context
1032 * @param[in] size size of input buffer
1033 * @param[in] in buffer containing the input text
1034 * @return The operation status.
1035 * @retval CRY_NOERROR if the operation succeeded.
1036 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1037 * device instance.
1038 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1039 * dependent.
1040 *
1041 * @notapi
1042 */
1043cryerror_t cry_lld_SHA256_update(CRYDriver *cryp, SHA256Context *sha256ctxp,
1044 size_t size, const uint8_t *in) {
1045
1046 (void)cryp;
1047 (void)sha256ctxp;
1048 (void)size;
1049 (void)in;
1050
1051 return CRY_ERR_INV_ALGO;
1052}
1053
1054/**
1055 * @brief Hash finalization using SHA256.
1056 *
1057 * @param[in] cryp pointer to the @p CRYDriver object
1058 * @param[in] sha256ctxp pointer to a SHA256 context
1059 * @param[out] out 256 bits output buffer
1060 * @return The operation status.
1061 * @retval CRY_NOERROR if the operation succeeded.
1062 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1063 * device instance.
1064 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1065 * dependent.
1066 *
1067 * @notapi
1068 */
1069cryerror_t cry_lld_SHA256_final(CRYDriver *cryp, SHA256Context *sha256ctxp,
1070 uint8_t *out) {
1071
1072 (void)cryp;
1073 (void)sha256ctxp;
1074 (void)out;
1075
1076 return CRY_ERR_INV_ALGO;
1077}
1078#endif
1079
1080#if (CRY_LLD_SUPPORTS_SHA512 == TRUE) || defined(__DOXYGEN__)
1081/**
1082 * @brief Hash initialization using SHA512.
1083 *
1084 * @param[in] cryp pointer to the @p CRYDriver object
1085 * @param[out] sha512ctxp pointer to a SHA512 context to be initialized
1086 * @retval CRY_NOERROR if the operation succeeded.
1087 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1088 * device instance.
1089 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1090 * dependent.
1091 *
1092 * @notapi
1093 */
1094cryerror_t cry_lld_SHA512_init(CRYDriver *cryp, SHA512Context *sha512ctxp) {
1095
1096 (void)cryp;
1097 (void)sha512ctxp;
1098
1099 return CRY_ERR_INV_ALGO;
1100}
1101
1102/**
1103 * @brief Hash update using SHA512.
1104 *
1105 * @param[in] cryp pointer to the @p CRYDriver object
1106 * @param[in] sha512ctxp pointer to a SHA512 context
1107 * @param[in] size size of input buffer
1108 * @param[in] in buffer containing the input text
1109 * @return The operation status.
1110 * @retval CRY_NOERROR if the operation succeeded.
1111 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1112 * device instance.
1113 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1114 * dependent.
1115 *
1116 * @notapi
1117 */
1118cryerror_t cry_lld_SHA512_update(CRYDriver *cryp, SHA512Context *sha512ctxp,
1119 size_t size, const uint8_t *in) {
1120
1121 (void)cryp;
1122 (void)sha512ctxp;
1123 (void)size;
1124 (void)in;
1125
1126 return CRY_ERR_INV_ALGO;
1127}
1128
1129/**
1130 * @brief Hash finalization using SHA512.
1131 *
1132 * @param[in] cryp pointer to the @p CRYDriver object
1133 * @param[in] sha512ctxp pointer to a SHA512 context
1134 * @param[out] out 512 bits output buffer
1135 * @return The operation status.
1136 * @retval CRY_NOERROR if the operation succeeded.
1137 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1138 * device instance.
1139 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1140 * dependent.
1141 *
1142 * @notapi
1143 */
1144cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp,
1145 uint8_t *out) {
1146
1147 (void)cryp;
1148 (void)sha512ctxp;
1149 (void)out;
1150
1151 return CRY_ERR_INV_ALGO;
1152}
1153#endif
1154
1155#if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__)
1156/**
1157 * @brief Initializes the HMAC transient key.
1158 * @note It is the underlying implementation to decide which key sizes are
1159 * allowable.
1160 *
1161 * @param[in] cryp pointer to the @p CRYDriver object
1162 * @param[in] size key size in bytes
1163 * @param[in] keyp pointer to the key data
1164 * @return The operation status.
1165 * @retval CRY_NOERROR if the operation succeeded.
1166 * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
1167 * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
1168 * the specified algorithm.
1169 *
1170 * @notapi
1171 */
1172cryerror_t cry_lld_hmac_loadkey(CRYDriver *cryp,
1173 size_t size,
1174 const uint8_t *keyp) {
1175
1176 (void)cryp;
1177 (void)size;
1178 (void)keyp;
1179
1180 return CRY_ERR_INV_ALGO;
1181}
1182
1183/**
1184 * @brief Hash initialization using HMAC_SHA256.
1185 *
1186 * @param[in] cryp pointer to the @p CRYDriver object
1187 * @param[out] hmacsha256ctxp pointer to a HMAC_SHA256 context to be
1188 * initialized
1189 * @return The operation status.
1190 * @retval CRY_NOERROR if the operation succeeded.
1191 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1192 * device instance.
1193 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1194 * dependent.
1195 *
1196 * @notapi
1197 */
1198cryerror_t cry_lld_HMACSHA256_init(CRYDriver *cryp,
1199 HMACSHA256Context *hmacsha256ctxp) {
1200
1201 (void)cryp;
1202 (void)hmacsha256ctxp;
1203
1204 return CRY_ERR_INV_ALGO;
1205}
1206
1207/**
1208 * @brief Hash update using HMAC.
1209 *
1210 * @param[in] cryp pointer to the @p CRYDriver object
1211 * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context
1212 * @param[in] size size of input buffer
1213 * @param[in] in buffer containing the input text
1214 * @return The operation status.
1215 * @retval CRY_NOERROR if the operation succeeded.
1216 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1217 * device instance.
1218 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1219 * dependent.
1220 *
1221 * @notapi
1222 */
1223cryerror_t cry_lld_HMACSHA256_update(CRYDriver *cryp,
1224 HMACSHA256Context *hmacsha256ctxp,
1225 size_t size,
1226 const uint8_t *in) {
1227
1228 (void)cryp;
1229 (void)hmacsha256ctxp;
1230 (void)size;
1231 (void)in;
1232
1233 return CRY_ERR_INV_ALGO;
1234}
1235
1236/**
1237 * @brief Hash finalization using HMAC.
1238 *
1239 * @param[in] cryp pointer to the @p CRYDriver object
1240 * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context
1241 * @param[out] out 256 bits output buffer
1242 * @return The operation status.
1243 * @retval CRY_NOERROR if the operation succeeded.
1244 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1245 * device instance.
1246 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1247 * dependent.
1248 *
1249 * @notapi
1250 */
1251cryerror_t cry_lld_HMACSHA256_final(CRYDriver *cryp,
1252 HMACSHA256Context *hmacsha256ctxp,
1253 uint8_t *out) {
1254
1255 (void)cryp;
1256 (void)hmacsha256ctxp;
1257 (void)out;
1258
1259 return CRY_ERR_INV_ALGO;
1260}
1261#endif
1262
1263#if (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || defined(__DOXYGEN__)
1264/**
1265 * @brief Hash initialization using HMAC_SHA512.
1266 *
1267 * @param[in] cryp pointer to the @p CRYDriver object
1268 * @param[out] hmacsha512ctxp pointer to a HMAC_SHA512 context to be
1269 * initialized
1270 * @return The operation status.
1271 * @retval CRY_NOERROR if the operation succeeded.
1272 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1273 * device instance.
1274 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1275 * dependent.
1276 *
1277 * @notapi
1278 */
1279cryerror_t cry_lld_HMACSHA512_init(CRYDriver *cryp,
1280 HMACSHA512Context *hmacsha512ctxp) {
1281
1282 (void)cryp;
1283 (void)hmacsha512ctxp;
1284
1285 return CRY_ERR_INV_ALGO;
1286}
1287
1288/**
1289 * @brief Hash update using HMAC.
1290 *
1291 * @param[in] cryp pointer to the @p CRYDriver object
1292 * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context
1293 * @param[in] size size of input buffer
1294 * @param[in] in buffer containing the input text
1295 * @return The operation status.
1296 * @retval CRY_NOERROR if the operation succeeded.
1297 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1298 * device instance.
1299 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1300 * dependent.
1301 *
1302 * @notapi
1303 */
1304cryerror_t cry_lld_HMACSHA512_update(CRYDriver *cryp,
1305 HMACSHA512Context *hmacsha512ctxp,
1306 size_t size,
1307 const uint8_t *in) {
1308
1309 (void)cryp;
1310 (void)hmacsha512ctxp;
1311 (void)size;
1312 (void)in;
1313
1314 return CRY_ERR_INV_ALGO;
1315}
1316
1317/**
1318 * @brief Hash finalization using HMAC.
1319 *
1320 * @param[in] cryp pointer to the @p CRYDriver object
1321 * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context
1322 * @param[out] out 512 bits output buffer
1323 * @return The operation status.
1324 * @retval CRY_NOERROR if the operation succeeded.
1325 * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1326 * device instance.
1327 * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1328 * dependent.
1329 *
1330 * @notapi
1331 */
1332cryerror_t cry_lld_HMACSHA512_final(CRYDriver *cryp,
1333 HMACSHA512Context *hmacsha512ctxp,
1334 uint8_t *out) {
1335
1336 (void)cryp;
1337 (void)hmacsha512ctxp;
1338 (void)out;
1339
1340 return CRY_ERR_INV_ALGO;
1341}
1342#endif
1343
1344#endif /* HAL_USE_CRY == TRUE */
1345
1346/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_crypto_lld.h b/lib/chibios/os/hal/templates/hal_crypto_lld.h
new file mode 100644
index 000000000..8b1842c1f
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_crypto_lld.h
@@ -0,0 +1,376 @@
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_crypto_lld.h
19 * @brief PLATFORM cryptographic subsystem low level driver header.
20 *
21 * @addtogroup CRYPTO
22 * @{
23 */
24
25#ifndef HAL_CRYPTO_LLD_H
26#define HAL_CRYPTO_LLD_H
27
28#if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @name Driver capability switches
36 * @{
37 */
38#define CRY_LLD_SUPPORTS_AES TRUE
39#define CRY_LLD_SUPPORTS_AES_ECB TRUE
40#define CRY_LLD_SUPPORTS_AES_CBC TRUE
41#define CRY_LLD_SUPPORTS_AES_CFB TRUE
42#define CRY_LLD_SUPPORTS_AES_CTR TRUE
43#define CRY_LLD_SUPPORTS_AES_GCM TRUE
44#define CRY_LLD_SUPPORTS_DES TRUE
45#define CRY_LLD_SUPPORTS_DES_ECB TRUE
46#define CRY_LLD_SUPPORTS_DES_CBC TRUE
47#define CRY_LLD_SUPPORTS_SHA1 TRUE
48#define CRY_LLD_SUPPORTS_SHA256 TRUE
49#define CRY_LLD_SUPPORTS_SHA512 TRUE
50#define CRY_LLD_SUPPORTS_HMAC_SHA256 TRUE
51#define CRY_LLD_SUPPORTS_HMAC_SHA512 TRUE
52/** @} */
53
54/*===========================================================================*/
55/* Driver pre-compile time settings. */
56/*===========================================================================*/
57
58/**
59 * @name PLATFORM configuration options
60 * @{
61 */
62/**
63 * @brief CRY1 driver enable switch.
64 * @details If set to @p TRUE the support for CRY1 is included.
65 * @note The default is @p FALSE.
66 */
67#if !defined(PLATFORM_CRY_USE_CRY1) || defined(__DOXYGEN__)
68#define PLATFORM_CRY_USE_CRY1 FALSE
69#endif
70/** @} */
71
72/*===========================================================================*/
73/* Derived constants and error checks. */
74/*===========================================================================*/
75
76/*===========================================================================*/
77/* Driver data structures and types. */
78/*===========================================================================*/
79
80/**
81 * @brief CRY key identifier type.
82 */
83typedef uint32_t crykey_t;
84
85/**
86 * @brief Type of a structure representing an CRY driver.
87 */
88typedef struct CRYDriver CRYDriver;
89
90/**
91 * @brief Driver configuration structure.
92 * @note It could be empty on some architectures.
93 */
94typedef struct {
95 uint32_t dummy;
96} CRYConfig;
97
98/**
99 * @brief Structure representing an CRY driver.
100 */
101struct CRYDriver {
102 /**
103 * @brief Driver state.
104 */
105 crystate_t state;
106 /**
107 * @brief Current configuration data.
108 */
109 const CRYConfig *config;
110#if defined(CRY_DRIVER_EXT_FIELDS)
111 CRY_DRIVER_EXT_FIELDS
112#endif
113 /* End of the mandatory fields.*/
114};
115
116#if (CRY_LLD_SUPPORTS_SHA1 == TRUE) || defined(__DOXYGEN__)
117/**
118 * @brief Type of a SHA1 context.
119 */
120typedef struct {
121 uint32_t dummy;
122} SHA1Context;
123#endif
124
125#if (CRY_LLD_SUPPORTS_SHA256 == TRUE) || defined(__DOXYGEN__)
126/**
127 * @brief Type of a SHA256 context.
128 */
129typedef struct {
130 uint32_t dummy;
131} SHA256Context;
132#endif
133
134#if (CRY_LLD_SUPPORTS_SHA512 == TRUE) || defined(__DOXYGEN__)
135/**
136 * @brief Type of a SHA512 context.
137 */
138typedef struct {
139 uint32_t dummy;
140} SHA512Context;
141#endif
142
143#if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__)
144/**
145 * @brief Type of a HMAC_SHA256 context.
146 */
147typedef struct {
148 uint32_t dummy;
149} HMACSHA256Context;
150#endif
151
152#if (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || defined(__DOXYGEN__)
153/**
154 * @brief Type of a HMAC_SHA512 context.
155 */
156typedef struct {
157 uint32_t dummy;
158} HMACSHA512Context;
159#endif
160
161/*===========================================================================*/
162/* Driver macros. */
163/*===========================================================================*/
164
165/*===========================================================================*/
166/* External declarations. */
167/*===========================================================================*/
168
169#if (PLATFORM_CRY_USE_CRY1 == TRUE) && !defined(__DOXYGEN__)
170extern CRYDriver CRYD1;
171#endif
172
173#ifdef __cplusplus
174extern "C" {
175#endif
176 void cry_lld_init(void);
177 void cry_lld_start(CRYDriver *cryp);
178 void cry_lld_stop(CRYDriver *cryp);
179#if (CRY_LLD_SUPPORTS_AES == TRUE) || \
180 (CRY_LLD_SUPPORTS_AES_ECB == TRUE) || \
181 (CRY_LLD_SUPPORTS_AES_CBC == TRUE) || \
182 (CRY_LLD_SUPPORTS_AES_CFB == TRUE) || \
183 (CRY_LLD_SUPPORTS_AES_CTR == TRUE) || \
184 (CRY_LLD_SUPPORTS_AES_GCM == TRUE) || \
185 defined(__DOXYGEN__)
186 cryerror_t cry_lld_aes_loadkey(CRYDriver *cryp,
187 size_t size,
188 const uint8_t *keyp);
189#endif
190#if (CRY_LLD_SUPPORTS_AES == TRUE) || defined(__DOXYGEN__)
191 cryerror_t cry_lld_encrypt_AES(CRYDriver *cryp,
192 crykey_t key_id,
193 const uint8_t *in,
194 uint8_t *out);
195 cryerror_t cry_lld_decrypt_AES(CRYDriver *cryp,
196 crykey_t key_id,
197 const uint8_t *in,
198 uint8_t *out);
199#endif
200#if (CRY_LLD_SUPPORTS_AES_ECB == TRUE) || defined(__DOXYGEN__)
201 cryerror_t cry_lld_encrypt_AES_ECB(CRYDriver *cryp,
202 crykey_t key_id,
203 size_t size,
204 const uint8_t *in,
205 uint8_t *out);
206 cryerror_t cry_lld_decrypt_AES_ECB(CRYDriver *cryp,
207 crykey_t key_id,
208 size_t size,
209 const uint8_t *in,
210 uint8_t *out);
211#endif
212#if (CRY_LLD_SUPPORTS_AES_CBC == TRUE) || defined(__DOXYGEN__)
213 cryerror_t cry_lld_encrypt_AES_CBC(CRYDriver *cryp,
214 crykey_t key_id,
215 size_t size,
216 const uint8_t *in,
217 uint8_t *out,
218 const uint8_t *iv);
219 cryerror_t cry_lld_decrypt_AES_CBC(CRYDriver *cryp,
220 crykey_t key_id,
221 size_t size,
222 const uint8_t *in,
223 uint8_t *out,
224 const uint8_t *iv);
225#endif
226#if (CRY_LLD_SUPPORTS_AES_CFB == TRUE) || defined(__DOXYGEN__)
227 cryerror_t cry_lld_encrypt_AES_CFB(CRYDriver *cryp,
228 crykey_t key_id,
229 size_t size,
230 const uint8_t *in,
231 uint8_t *out,
232 const uint8_t *iv);
233 cryerror_t cry_lld_decrypt_AES_CFB(CRYDriver *cryp,
234 crykey_t key_id,
235 size_t size,
236 const uint8_t *in,
237 uint8_t *out,
238 const uint8_t *iv);
239#endif
240#if (CRY_LLD_SUPPORTS_AES_CTR == TRUE) || defined(__DOXYGEN__)
241 cryerror_t cry_lld_encrypt_AES_CTR(CRYDriver *cryp,
242 crykey_t key_id,
243 size_t size,
244 const uint8_t *in,
245 uint8_t *out,
246 const uint8_t *iv);
247 cryerror_t cry_lld_decrypt_AES_CTR(CRYDriver *cryp,
248 crykey_t key_id,
249 size_t size,
250 const uint8_t *in,
251 uint8_t *out,
252 const uint8_t *iv);
253#endif
254#if (CRY_LLD_SUPPORTS_AES_GCM == TRUE) || defined(__DOXYGEN__)
255 cryerror_t cry_lld_encrypt_AES_GCM(CRYDriver *cryp,
256 crykey_t key_id,
257 size_t auth_size,
258 const uint8_t *auth_in,
259 size_t text_size,
260 const uint8_t *text_in,
261 uint8_t *text_out,
262 const uint8_t *iv,
263 size_t tag_size,
264 uint8_t *tag_out);
265 cryerror_t cry_lld_decrypt_AES_GCM(CRYDriver *cryp,
266 crykey_t key_id,
267 size_t auth_size,
268 const uint8_t *auth_in,
269 size_t text_size,
270 const uint8_t *text_in,
271 uint8_t *text_out,
272 const uint8_t *iv,
273 size_t tag_size,
274 const uint8_t *tag_in);
275#endif
276#if (CRY_LLD_SUPPORTS_DES == TRUE) || \
277 (CRY_LLD_SUPPORTS_DES_ECB == TRUE) || \
278 (CRY_LLD_SUPPORTS_DES_CBC == TRUE) || \
279 defined(__DOXYGEN__)
280 cryerror_t cry_lld_des_loadkey(CRYDriver *cryp,
281 size_t size,
282 const uint8_t *keyp);
283#endif
284#if (CRY_LLD_SUPPORTS_DES == TRUE) || defined(__DOXYGEN__)
285 cryerror_t cry_lld_encrypt_DES(CRYDriver *cryp,
286 crykey_t key_id,
287 const uint8_t *in,
288 uint8_t *out);
289 cryerror_t cry_lld_decrypt_DES(CRYDriver *cryp,
290 crykey_t key_id,
291 const uint8_t *in,
292 uint8_t *out);
293#endif
294#if (CRY_LLD_SUPPORTS_DES_ECB == TRUE) || defined(__DOXYGEN__)
295 cryerror_t cry_lld_encrypt_DES_ECB(CRYDriver *cryp,
296 crykey_t key_id,
297 size_t size,
298 const uint8_t *in,
299 uint8_t *out);
300 cryerror_t cry_lld_decrypt_DES_ECB(CRYDriver *cryp,
301 crykey_t key_id,
302 size_t size,
303 const uint8_t *in,
304 uint8_t *out);
305#endif
306#if (CRY_LLD_SUPPORTS_DES_CBC == TRUE) || defined(__DOXYGEN__)
307 cryerror_t cry_lld_encrypt_DES_CBC(CRYDriver *cryp,
308 crykey_t key_id,
309 size_t size,
310 const uint8_t *in,
311 uint8_t *out,
312 const uint8_t *iv);
313 cryerror_t cry_lld_decrypt_DES_CBC(CRYDriver *cryp,
314 crykey_t key_id,
315 size_t size,
316 const uint8_t *in,
317 uint8_t *out,
318 const uint8_t *iv);
319#endif
320#if (CRY_LLD_SUPPORTS_SHA1 == TRUE) || defined(__DOXYGEN__)
321 cryerror_t cry_lld_SHA1_init(CRYDriver *cryp, SHA1Context *sha1ctxp);
322 cryerror_t cry_lld_SHA1_update(CRYDriver *cryp, SHA1Context *sha1ctxp,
323 size_t size, const uint8_t *in);
324 cryerror_t cry_lld_SHA1_final(CRYDriver *cryp, SHA1Context *sha1ctxp,
325 uint8_t *out);
326#endif
327#if (CRY_LLD_SUPPORTS_SHA256 == TRUE) || defined(__DOXYGEN__)
328 cryerror_t cry_lld_SHA256_init(CRYDriver *cryp, SHA256Context *sha256ctxp);
329 cryerror_t cry_lld_SHA256_update(CRYDriver *cryp, SHA256Context *sha256ctxp,
330 size_t size, const uint8_t *in);
331 cryerror_t cry_lld_SHA256_final(CRYDriver *cryp, SHA256Context *sha256ctxp,
332 uint8_t *out);
333#endif
334#if (CRY_LLD_SUPPORTS_SHA512 == TRUE) || defined(__DOXYGEN__)
335 cryerror_t cry_lld_SHA512_init(CRYDriver *cryp, SHA512Context *sha512ctxp);
336 cryerror_t cry_lld_SHA512_update(CRYDriver *cryp, SHA512Context *sha512ctxp,
337 size_t size, const uint8_t *in);
338 cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp,
339 uint8_t *out);
340#endif
341#if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || \
342 (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || \
343 defined(__DOXYGEN__)
344 cryerror_t cry_lld_hmac_loadkey(CRYDriver *cryp,
345 size_t size,
346 const uint8_t *keyp);
347#endif
348#if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__)
349 cryerror_t cry_lld_HMACSHA256_init(CRYDriver *cryp,
350 HMACSHA256Context *hmacsha256ctxp);
351 cryerror_t cry_lld_HMACSHA256_update(CRYDriver *cryp,
352 HMACSHA256Context *hmacsha256ctxp,
353 size_t size, const uint8_t *in);
354 cryerror_t cry_lld_HMACSHA256_final(CRYDriver *cryp,
355 HMACSHA256Context *hmacsha256ctxp,
356 uint8_t *out);
357#endif
358#if (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || defined(__DOXYGEN__)
359 cryerror_t cry_lld_HMACSHA512_init(CRYDriver *cryp,
360 HMACSHA512Context *hmacsha512ctxp);
361 cryerror_t cry_lld_HMACSHA512_update(CRYDriver *cryp,
362 HMACSHA512Context *hmacsha512ctxp,
363 size_t size, const uint8_t *in);
364 cryerror_t cry_lld_HMACSHA512_final(CRYDriver *cryp,
365 HMACSHA512Context *hmacsha512ctxp,
366 uint8_t *out);
367#endif
368#ifdef __cplusplus
369}
370#endif
371
372#endif /* HAL_USE_CRY == TRUE */
373
374#endif /* HAL_CRYPTO_LLD_H */
375
376/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_dac_lld.c b/lib/chibios/os/hal/templates/hal_dac_lld.c
new file mode 100644
index 000000000..13f325b56
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_dac_lld.c
@@ -0,0 +1,167 @@
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_dac_lld.c
19 * @brief PLATFORM DAC subsystem low level driver source.
20 *
21 * @addtogroup DAC
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/** @brief DAC1 driver identifier.*/
38#if (PLATFORM_DAC_USE_DAC1 == TRUE) || defined(__DOXYGEN__)
39DACDriver DACD1;
40#endif
41
42/*===========================================================================*/
43/* Driver local variables. */
44/*===========================================================================*/
45
46/*===========================================================================*/
47/* Driver local functions. */
48/*===========================================================================*/
49
50/*===========================================================================*/
51/* Driver interrupt handlers. */
52/*===========================================================================*/
53
54/*===========================================================================*/
55/* Driver exported functions. */
56/*===========================================================================*/
57
58/**
59 * @brief Low level DAC driver initialization.
60 *
61 * @notapi
62 */
63void dac_lld_init(void) {
64
65#if PLATFORM_DAC_USE_DAC1 == TRUE
66 dacObjectInit(&DACD1);
67#endif
68}
69
70/**
71 * @brief Configures and activates the DAC peripheral.
72 *
73 * @param[in] dacp pointer to the @p DACDriver object
74 *
75 * @notapi
76 */
77void dac_lld_start(DACDriver *dacp) {
78
79 /* If the driver is in DAC_STOP state then a full initialization is
80 required.*/
81 if (dacp->state == DAC_STOP) {
82 /* Enabling the clock source.*/
83#if PLATFORM_DAC_USE_DAC1 == TRUE
84 if (&DACD1 == dacp) {
85
86 }
87#endif
88 }
89}
90
91/**
92 * @brief Deactivates the DAC peripheral.
93 *
94 * @param[in] dacp pointer to the @p DACDriver object
95 *
96 * @notapi
97 */
98void dac_lld_stop(DACDriver *dacp) {
99
100 /* If in ready state then disables the DAC clock.*/
101 if (dacp->state == DAC_READY) {
102
103#if PLATFORM_DAC_USE_DAC1 == TRUE
104 if (&DACD1 == dacp) {
105
106 }
107#endif
108 }
109}
110
111/**
112 * @brief Outputs a value directly on a DAC channel.
113 *
114 * @param[in] dacp pointer to the @p DACDriver object
115 * @param[in] channel DAC channel number
116 * @param[in] sample value to be output
117 *
118 * @api
119 */
120void dac_lld_put_channel(DACDriver *dacp,
121 dacchannel_t channel,
122 dacsample_t sample) {
123
124 (void)dacp;
125 (void)channel;
126 (void)sample;
127}
128
129/**
130 * @brief Starts a DAC conversion.
131 * @details Starts an asynchronous conversion operation.
132 * @note In @p DAC_DHRM_8BIT_RIGHT mode the parameters passed to the
133 * callback are wrong because two samples are packed in a single
134 * dacsample_t element. This will not be corrected, do not rely
135 * on those parameters.
136 * @note In @p DAC_DHRM_8BIT_RIGHT_DUAL mode two samples are treated
137 * as a single 16 bits sample and packed into a single dacsample_t
138 * element. The num_channels must be set to one in the group
139 * conversion configuration structure.
140 *
141 * @param[in] dacp pointer to the @p DACDriver object
142 *
143 * @notapi
144 */
145void dac_lld_start_conversion(DACDriver *dacp) {
146
147 (void)dacp;
148}
149
150/**
151 * @brief Stops an ongoing conversion.
152 * @details This function stops the currently ongoing conversion and returns
153 * the driver in the @p DAC_READY state. If there was no conversion
154 * being processed then the function does nothing.
155 *
156 * @param[in] dacp pointer to the @p DACDriver object
157 *
158 * @iclass
159 */
160void dac_lld_stop_conversion(DACDriver *dacp) {
161
162 (void)dacp;
163}
164
165#endif /* HAL_USE_DAC == TRUE */
166
167/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_dac_lld.h b/lib/chibios/os/hal/templates/hal_dac_lld.h
new file mode 100644
index 000000000..7bfccda7a
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_dac_lld.h
@@ -0,0 +1,137 @@
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_dac_lld.h
19 * @brief PLATFORM DAC subsystem low level driver header.
20 *
21 * @addtogroup DAC
22 * @{
23 */
24
25#ifndef HAL_DAC_LLD_H
26#define HAL_DAC_LLD_H
27
28#if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @brief Maximum number of DAC channels per unit.
36 */
37#define DAC_MAX_CHANNELS 2
38
39/*===========================================================================*/
40/* Driver pre-compile time settings. */
41/*===========================================================================*/
42
43/**
44 * @name Configuration options
45 * @{
46 */
47/**
48 * @brief DAC1 CH1 driver enable switch.
49 * @details If set to @p TRUE the support for DAC1 channel 1 is included.
50 * @note The default is @p FALSE.
51 */
52#if !defined(PLATFORM_DAC_USE_DAC1) || defined(__DOXYGEN__)
53#define PLATFORM_DAC_USE_DAC1 FALSE
54#endif
55/** @} */
56
57/*===========================================================================*/
58/* Derived constants and error checks. */
59/*===========================================================================*/
60
61/*===========================================================================*/
62/* Driver data structures and types. */
63/*===========================================================================*/
64
65/**
66 * @brief Type of a DAC channel index.
67 */
68typedef uint32_t dacchannel_t;
69
70/**
71 * @brief Type representing a DAC sample.
72 */
73typedef uint16_t dacsample_t;
74
75/**
76 * @brief Possible DAC failure causes.
77 * @note Error codes are architecture dependent and should not relied
78 * upon.
79 */
80typedef enum {
81 DAC_ERR_DMAFAILURE = 0, /**< DMA operations failure. */
82 DAC_ERR_UNDERFLOW = 1 /**< DAC overflow condition. */
83} dacerror_t;
84
85/*===========================================================================*/
86/* Driver macros. */
87/*===========================================================================*/
88
89/**
90 * @brief Low level fields of the DAC driver structure.
91 */
92#define dac_lld_driver_fields \
93 /* Dummy field, it is not needed.*/ \
94 uint32_t dummy
95
96/**
97 * @brief Low level fields of the DAC configuration structure.
98 */
99#define dac_lld_config_fields \
100 /* Dummy configuration, it is not needed.*/ \
101 uint32_t dummy
102
103/**
104 * @brief Low level fields of the DAC group configuration structure.
105 */
106#define dac_lld_conversion_group_fields \
107 /* Dummy configuration, it is not needed.*/ \
108 uint32_t dummy
109
110/*===========================================================================*/
111/* External declarations. */
112/*===========================================================================*/
113
114#if (PLATFORM_DAC_USE_DAC1 == TRUE) && !defined(__DOXYGEN__)
115extern DACDriver DACD1;
116#endif
117
118#ifdef __cplusplus
119extern "C" {
120#endif
121 void dac_lld_init(void);
122 void dac_lld_start(DACDriver *dacp);
123 void dac_lld_stop(DACDriver *dacp);
124 void dac_lld_put_channel(DACDriver *dacp,
125 dacchannel_t channel,
126 dacsample_t sample);
127 void dac_lld_start_conversion(DACDriver *dacp);
128 void dac_lld_stop_conversion(DACDriver *dacp);
129#ifdef __cplusplus
130}
131#endif
132
133#endif /* HAL_USE_DAC == TRUE */
134
135#endif /* HAL_DAC_LLD_H */
136
137/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_efl_lld.c b/lib/chibios/os/hal/templates/hal_efl_lld.c
new file mode 100644
index 000000000..6ec053e54
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_efl_lld.c
@@ -0,0 +1,365 @@
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_efl_lld.c
19 * @brief PLATFORM Embedded Flash subsystem low level driver source.
20 *
21 * @addtogroup HAL_EFL
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_EFL == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief EFL1 driver identifier.
39 */
40#if (PLATFORM_EFL_USE_EFL1 == TRUE) || defined(__DOXYGEN__)
41EFlashDriver EFLD1;
42#endif
43
44/*===========================================================================*/
45/* Driver local variables and types. */
46/*===========================================================================*/
47
48static const flash_descriptor_t efl_lld_descriptor = {
49 .attributes = FLASH_ATTR_ERASED_IS_ONE |
50 FLASH_ATTR_MEMORY_MAPPED |
51 FLASH_ATTR_ECC_CAPABLE |
52 FLASH_ATTR_ECC_ZERO_LINE_CAPABLE,
53 .page_size = 0,
54 .sectors_count = 0,
55 .sectors = NULL,
56 .sectors_size = 0,
57 .address = (uint8_t *)0,
58 .size = 0
59};
60
61/*===========================================================================*/
62/* Driver local functions. */
63/*===========================================================================*/
64
65/*===========================================================================*/
66/* Driver interrupt handlers. */
67/*===========================================================================*/
68
69/*===========================================================================*/
70/* Driver exported functions. */
71/*===========================================================================*/
72
73/**
74 * @brief Low level Embedded Flash driver initialization.
75 *
76 * @notapi
77 */
78void efl_lld_init(void) {
79
80#if PLATFORM_EFL_USE_EFL1 == TRUE
81 /* Driver initialization.*/
82 eflObjectInit(&EFLD1);
83#endif
84}
85
86/**
87 * @brief Configures and activates the Embedded Flash peripheral.
88 *
89 * @param[in] eflp pointer to a @p EFlashDriver structure
90 *
91 * @notapi
92 */
93void efl_lld_start(EFlashDriver *eflp) {
94
95 if (eflp->state == FLASH_STOP) {
96 /* Enables the peripheral.*/
97#if PLATFORM_EFL_USE_EFL1 == TRUE
98 if (&EFLD1 == eflp) {
99
100 }
101#endif
102 }
103 /* Configures the peripheral.*/
104
105}
106
107/**
108 * @brief Deactivates the Embedded Flash peripheral.
109 *
110 * @param[in] eflp pointer to a @p EFlashDriver structure
111 *
112 * @notapi
113 */
114void efl_lld_stop(EFlashDriver *eflp) {
115
116 if (eflp->state == FLASH_READY) {
117 /* Resets the peripheral.*/
118
119 /* Disables the peripheral.*/
120#if PLATFORM_EFL_USE_EFL1 == TRUE
121 if (&EFLD1 == eflp) {
122
123 }
124#endif
125 }
126}
127
128/**
129 * @brief Gets the flash descriptor structure.
130 *
131 * @param[in] instance pointer to a @p EFlashDriver instance
132 * @return A flash device descriptor.
133 *
134 * @notapi
135 */
136const flash_descriptor_t *efl_lld_get_descriptor(void *instance) {
137
138 (void)instance;
139
140 return &efl_lld_descriptor;
141}
142
143/**
144 * @brief Read operation.
145 *
146 * @param[in] instance pointer to a @p EFlashDriver instance
147 * @param[in] offset flash offset
148 * @param[in] n number of bytes to be read
149 * @param[out] rp pointer to the data buffer
150 * @return An error code.
151 * @retval FLASH_NO_ERROR if there is no erase operation in progress.
152 * @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
153 * @retval FLASH_ERROR_READ if the read operation failed.
154 * @retval FLASH_ERROR_HW_FAILURE if access to the memory failed.
155 *
156 * @notapi
157 */
158flash_error_t efl_lld_read(void *instance, flash_offset_t offset,
159 size_t n, uint8_t *rp) {
160 EFlashDriver *devp = (EFlashDriver *)instance;
161 flash_error_t err = FLASH_NO_ERROR;
162
163 osalDbgCheck((instance != NULL) && (rp != NULL) && (n > 0U));
164 osalDbgCheck(((size_t)offset + n) <= (size_t)efl_lld_descriptor.size);
165 osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
166 "invalid state");
167
168 /* No reading while erasing.*/
169 if (devp->state == FLASH_ERASE) {
170 return FLASH_BUSY_ERASING;
171 }
172
173 /* FLASH_READY state while the operation is performed.*/
174 devp->state = FLASH_READ;
175
176 /* IMPLEMENT */
177
178 /* Ready state again.*/
179 devp->state = FLASH_READY;
180
181 return err;
182
183}
184
185/**
186 * @brief Program operation.
187 * @note The device supports ECC, it is only possible to write erased
188 * pages once except when writing all zeroes.
189 *
190 * @param[in] instance pointer to a @p EFlashDriver instance
191 * @param[in] offset flash offset
192 * @param[in] n number of bytes to be programmed
193 * @param[in] pp pointer to the data buffer
194 * @return An error code.
195 * @retval FLASH_NO_ERROR if there is no erase operation in progress.
196 * @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
197 * @retval FLASH_ERROR_PROGRAM if the program operation failed.
198 * @retval FLASH_ERROR_HW_FAILURE if access to the memory failed.
199 *
200 * @notapi
201 */
202flash_error_t efl_lld_program(void *instance, flash_offset_t offset,
203 size_t n, const uint8_t *pp) {
204 EFlashDriver *devp = (EFlashDriver *)instance;
205 flash_error_t err = FLASH_NO_ERROR;
206
207 osalDbgCheck((instance != NULL) && (pp != NULL) && (n > 0U));
208 osalDbgCheck(((size_t)offset + n) <= (size_t)efl_lld_descriptor.size);
209
210 osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
211 "invalid state");
212
213 /* No programming while erasing.*/
214 if (devp->state == FLASH_ERASE) {
215 return FLASH_BUSY_ERASING;
216 }
217
218 /* FLASH_PGM state while the operation is performed.*/
219 devp->state = FLASH_PGM;
220
221 /* IMPLEMENT */
222
223 /* Ready state again.*/
224 devp->state = FLASH_READY;
225
226 return err;
227}
228
229/**
230 * @brief Starts a whole-device erase operation.
231 * @note This function only erases bank 2 if it is present. Bank 1 is not
232 * touched because it is where the program is running on.
233 * Pages on bank 1 can be individually erased.
234 *
235 * @param[in] instance pointer to a @p EFlashDriver instance
236 * @return An error code.
237 * @retval FLASH_NO_ERROR if there is no erase operation in progress.
238 * @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
239 * @retval FLASH_ERROR_HW_FAILURE if access to the memory failed.
240 *
241 * @notapi
242 */
243flash_error_t efl_lld_start_erase_all(void *instance) {
244 EFlashDriver *devp = (EFlashDriver *)instance;
245
246 osalDbgCheck(instance != NULL);
247 osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
248 "invalid state");
249
250 /* No erasing while erasing.*/
251 if (devp->state == FLASH_ERASE) {
252 return FLASH_BUSY_ERASING;
253 }
254
255 /* FLASH_PGM state while the operation is performed.*/
256 devp->state = FLASH_ERASE;
257
258 /* IMPLEMENT */
259
260 return FLASH_NO_ERROR;
261}
262
263/**
264 * @brief Starts an sector erase operation.
265 *
266 * @param[in] instance pointer to a @p EFlashDriver instance
267 * @param[in] sector sector to be erased
268 * @return An error code.
269 * @retval FLASH_NO_ERROR if there is no erase operation in progress.
270 * @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
271 * @retval FLASH_ERROR_HW_FAILURE if access to the memory failed.
272 *
273 * @notapi
274 */
275flash_error_t efl_lld_start_erase_sector(void *instance,
276 flash_sector_t sector) {
277 EFlashDriver *devp = (EFlashDriver *)instance;
278
279 osalDbgCheck(instance != NULL);
280 osalDbgCheck(sector < efl_lld_descriptor.sectors_count);
281 osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
282 "invalid state");
283
284 /* No erasing while erasing.*/
285 if (devp->state == FLASH_ERASE) {
286 return FLASH_BUSY_ERASING;
287 }
288
289 /* FLASH_PGM state while the operation is performed.*/
290 devp->state = FLASH_ERASE;
291
292 /* IMPLEMENT */
293
294 return FLASH_NO_ERROR;
295}
296
297/**
298 * @brief Queries the driver for erase operation progress.
299 *
300 * @param[in] instance pointer to a @p EFlashDriver instance
301 * @param[out] msec recommended time, in milliseconds, that
302 * should be spent before calling this
303 * function again, can be @p NULL
304 * @return An error code.
305 * @retval FLASH_NO_ERROR if there is no erase operation in progress.
306 * @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
307 * @retval FLASH_ERROR_ERASE if the erase operation failed.
308 * @retval FLASH_ERROR_HW_FAILURE if access to the memory failed.
309 *
310 * @api
311 */
312flash_error_t efl_lld_query_erase(void *instance, uint32_t *msec) {
313 EFlashDriver *devp = (EFlashDriver *)instance;
314 flash_error_t err = FLASH_NO_ERROR;
315
316 (void)msec;
317
318 /* If there is an erase in progress then the device must be checked.*/
319 if (devp->state == FLASH_ERASE) {
320
321 /* IMPLEMENT */
322
323 }
324
325 return err;
326}
327
328/**
329 * @brief Returns the erase state of a sector.
330 *
331 * @param[in] instance pointer to a @p EFlashDriver instance
332 * @param[in] sector sector to be verified
333 * @return An error code.
334 * @retval FLASH_NO_ERROR if the sector is erased.
335 * @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
336 * @retval FLASH_ERROR_VERIFY if the verify operation failed.
337 * @retval FLASH_ERROR_HW_FAILURE if access to the memory failed.
338 *
339 * @notapi
340 */
341flash_error_t efl_lld_verify_erase(void *instance, flash_sector_t sector) {
342 EFlashDriver *devp = (EFlashDriver *)instance;
343 flash_error_t err = FLASH_NO_ERROR;
344
345 osalDbgCheck(instance != NULL);
346 osalDbgCheck(sector < efl_lld_descriptor.sectors_count);
347 osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
348 "invalid state");
349
350 /* No verifying while erasing.*/
351 if (devp->state == FLASH_ERASE) {
352 return FLASH_BUSY_ERASING;
353 }
354
355 /* IMPLEMENT */
356
357 /* Ready state again.*/
358 devp->state = FLASH_READY;
359
360 return err;
361}
362
363#endif /* HAL_USE_EFL == TRUE */
364
365/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_efl_lld.h b/lib/chibios/os/hal/templates/hal_efl_lld.h
new file mode 100644
index 000000000..07cc95ea1
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_efl_lld.h
@@ -0,0 +1,110 @@
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_efl_lld.h
19 * @brief PLATFORM Embedded Flash subsystem low level driver header.
20 *
21 * @addtogroup HAL_EFL
22 * @{
23 */
24
25#ifndef HAL_EFL_LLD_H
26#define HAL_EFL_LLD_H
27
28#if (HAL_USE_EFL == 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 EFL1 driver enable switch.
44 * @details If set to @p TRUE the support for EFL1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_EFL_USE_EFL1) || defined(__DOXYGEN__)
48#define PLATFORM_EFL_USE_EFL1 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/* Driver macros. */
62/*===========================================================================*/
63
64/**
65 * @brief Low level fields of the embedded flash driver structure.
66 */
67#define efl_lld_driver_fields \
68 /* Dummy field, it is not needed.*/ \
69 uint32_t dummy
70
71/**
72 * @brief Low level fields of the embedded flash configuration structure.
73 */
74#define efl_lld_config_fields \
75 /* Dummy configuration, it is not needed.*/ \
76 uint32_t dummy
77
78/*===========================================================================*/
79/* External declarations. */
80/*===========================================================================*/
81
82#if (PLATFORM_EFL_USE_EFL1 == TRUE) && !defined(__DOXYGEN__)
83extern EFlashDriver EFLD1;
84#endif
85
86#ifdef __cplusplus
87extern "C" {
88#endif
89 void efl_lld_init(void);
90 void efl_lld_start(EFlashDriver *eflp);
91 void efl_lld_stop(EFlashDriver *eflp);
92 const flash_descriptor_t *efl_lld_get_descriptor(void *instance);
93 flash_error_t efl_lld_read(void *instance, flash_offset_t offset,
94 size_t n, uint8_t *rp);
95 flash_error_t efl_lld_program(void *instance, flash_offset_t offset,
96 size_t n, const uint8_t *pp);
97 flash_error_t efl_lld_start_erase_all(void *instance);
98 flash_error_t efl_lld_start_erase_sector(void *instance,
99 flash_sector_t sector);
100 flash_error_t efl_lld_query_erase(void *instance, uint32_t *msec);
101 flash_error_t efl_lld_verify_erase(void *instance, flash_sector_t sector);
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* HAL_USE_EFL == TRUE */
107
108#endif /* HAL_EFL_LLD_H */
109
110/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_gpt_lld.c b/lib/chibios/os/hal/templates/hal_gpt_lld.c
new file mode 100644
index 000000000..327e0eb7c
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_gpt_lld.c
@@ -0,0 +1,163 @@
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_gpt_lld.c
19 * @brief PLATFORM GPT subsystem low level driver source.
20 *
21 * @addtogroup GPT
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief GPTD1 driver identifier.
39 */
40#if (PLATFORM_GPT_USE_GPT1 == TRUE) || defined(__DOXYGEN__)
41GPTDriver GPTD1;
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 GPT driver initialization.
62 *
63 * @notapi
64 */
65void gpt_lld_init(void) {
66
67#if PLATFORM_GPT_USE_GPT1 == TRUE
68 /* Driver initialization.*/
69 gptObjectInit(&GPTD1);
70#endif
71}
72
73/**
74 * @brief Configures and activates the GPT peripheral.
75 *
76 * @param[in] gptp pointer to the @p GPTDriver object
77 *
78 * @notapi
79 */
80void gpt_lld_start(GPTDriver *gptp) {
81
82 if (gptp->state == GPT_STOP) {
83 /* Enables the peripheral.*/
84#if PLATFORM_GPT_USE_GPT1 == TRUE
85 if (&GPTD1 == gptp) {
86
87 }
88#endif
89 }
90 /* Configures the peripheral.*/
91
92}
93
94/**
95 * @brief Deactivates the GPT peripheral.
96 *
97 * @param[in] gptp pointer to the @p GPTDriver object
98 *
99 * @notapi
100 */
101void gpt_lld_stop(GPTDriver *gptp) {
102
103 if (gptp->state == GPT_READY) {
104 /* Resets the peripheral.*/
105
106 /* Disables the peripheral.*/
107#if PLATFORM_GPT_USE_GPT1 == TRUE
108 if (&GPTD1 == gptp) {
109
110 }
111#endif
112 }
113}
114
115/**
116 * @brief Starts the timer in continuous mode.
117 *
118 * @param[in] gptp pointer to the @p GPTDriver object
119 * @param[in] interval period in ticks
120 *
121 * @notapi
122 */
123void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval) {
124
125 (void)gptp;
126 (void)interval;
127
128}
129
130/**
131 * @brief Stops the timer.
132 *
133 * @param[in] gptp pointer to the @p GPTDriver object
134 *
135 * @notapi
136 */
137void gpt_lld_stop_timer(GPTDriver *gptp) {
138
139 (void)gptp;
140
141}
142
143/**
144 * @brief Starts the timer in one shot mode and waits for completion.
145 * @details This function specifically polls the timer waiting for completion
146 * in order to not have extra delays caused by interrupt servicing,
147 * this function is only recommended for short delays.
148 *
149 * @param[in] gptp pointer to the @p GPTDriver object
150 * @param[in] interval time interval in ticks
151 *
152 * @notapi
153 */
154void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) {
155
156 (void)gptp;
157 (void)interval;
158
159}
160
161#endif /* HAL_USE_GPT == TRUE */
162
163/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_gpt_lld.h b/lib/chibios/os/hal/templates/hal_gpt_lld.h
new file mode 100644
index 000000000..468dfd0cc
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_gpt_lld.h
@@ -0,0 +1,154 @@
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_gpt_lld.h
19 * @brief PLATFORM GPT subsystem low level driver header.
20 *
21 * @addtogroup GPT
22 * @{
23 */
24
25#ifndef HAL_GPT_LLD_H
26#define HAL_GPT_LLD_H
27
28#if (HAL_USE_GPT == 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 GPTD1 driver enable switch.
44 * @details If set to @p TRUE the support for GPTD1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_GPT_USE_GPT1) || defined(__DOXYGEN__)
48#define PLATFORM_GPT_USE_GPT1 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 GPT frequency type.
62 */
63typedef uint32_t gptfreq_t;
64
65/**
66 * @brief GPT counter type.
67 */
68typedef uint16_t gptcnt_t;
69
70/**
71 * @brief Driver configuration structure.
72 * @note It could be empty on some architectures.
73 */
74typedef struct {
75 /**
76 * @brief Timer clock in Hz.
77 * @note The low level can use assertions in order to catch invalid
78 * frequency specifications.
79 */
80 gptfreq_t frequency;
81 /**
82 * @brief Timer callback pointer.
83 * @note This callback is invoked on GPT counter events.
84 */
85 gptcallback_t callback;
86 /* End of the mandatory fields.*/
87} GPTConfig;
88
89/**
90 * @brief Structure representing a GPT driver.
91 */
92struct GPTDriver {
93 /**
94 * @brief Driver state.
95 */
96 gptstate_t state;
97 /**
98 * @brief Current configuration data.
99 */
100 const GPTConfig *config;
101#if defined(GPT_DRIVER_EXT_FIELDS)
102 GPT_DRIVER_EXT_FIELDS
103#endif
104 /* End of the mandatory fields.*/
105};
106
107/*===========================================================================*/
108/* Driver macros. */
109/*===========================================================================*/
110
111/**
112 * @brief Changes the interval of GPT peripheral.
113 * @details This function changes the interval of a running GPT unit.
114 * @pre The GPT unit must have been activated using @p gptStart().
115 * @pre The GPT unit must have been running in continuous mode using
116 * @p gptStartContinuous().
117 * @post The GPT unit interval is changed to the new value.
118 * @note The function has effect at the next cycle start.
119 *
120 * @param[in] gptp pointer to a @p GPTDriver object
121 * @param[in] interval new cycle time in timer ticks
122 * @notapi
123 */
124#define gpt_lld_change_interval(gptp, interval) { \
125 (void)gptp; \
126 (void)interval; \
127}
128
129/*===========================================================================*/
130/* External declarations. */
131/*===========================================================================*/
132
133#if (PLATFORM_GPT_USE_GPT1 == TRUE) && !defined(__DOXYGEN__)
134extern GPTDriver GPTD1;
135#endif
136
137#ifdef __cplusplus
138extern "C" {
139#endif
140 void gpt_lld_init(void);
141 void gpt_lld_start(GPTDriver *gptp);
142 void gpt_lld_stop(GPTDriver *gptp);
143 void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval);
144 void gpt_lld_stop_timer(GPTDriver *gptp);
145 void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval);
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* HAL_USE_GPT == TRUE */
151
152#endif /* HAL_GPT_LLD_H */
153
154/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_i2c_lld.c b/lib/chibios/os/hal/templates/hal_i2c_lld.c
new file mode 100644
index 000000000..e2552b949
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_i2c_lld.c
@@ -0,0 +1,187 @@
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_i2c_lld.c
19 * @brief PLATFORM I2C subsystem low level driver source.
20 *
21 * @addtogroup I2C
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief I2C1 driver identifier.
39 */
40#if (PLATFORM_I2C_USE_I2C1 == TRUE) || defined(__DOXYGEN__)
41I2CDriver I2CD1;
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 I2C driver initialization.
62 *
63 * @notapi
64 */
65void i2c_lld_init(void) {
66
67#if PLATFORM_I2C_USE_I2C1 == TRUE
68 i2cObjectInit(&I2CD1);
69#endif
70}
71
72/**
73 * @brief Configures and activates the I2C peripheral.
74 *
75 * @param[in] i2cp pointer to the @p I2CDriver object
76 *
77 * @notapi
78 */
79void i2c_lld_start(I2CDriver *i2cp) {
80
81 if (i2cp->state == I2C_STOP) {
82 /* Enables the peripheral.*/
83#if PLATFORM_I2C_USE_I2C1 == TRUE
84 if (&I2CD1 == i2cp) {
85
86 }
87#endif
88 }
89
90}
91
92/**
93 * @brief Deactivates the I2C peripheral.
94 *
95 * @param[in] i2cp pointer to the @p I2CDriver object
96 *
97 * @notapi
98 */
99void i2c_lld_stop(I2CDriver *i2cp) {
100
101 if (i2cp->state != I2C_STOP) {
102
103 /* Disables the peripheral.*/
104#if PLATFORM_I2C_USE_I2C1 == TRUE
105 if (&I2CD1 == i2cp) {
106
107 }
108#endif
109 }
110}
111
112/**
113 * @brief Receives data via the I2C bus as master.
114 *
115 * @param[in] i2cp pointer to the @p I2CDriver object
116 * @param[in] addr slave device address
117 * @param[out] rxbuf pointer to the receive buffer
118 * @param[in] rxbytes number of bytes to be received
119 * @param[in] timeout the number of ticks before the operation timeouts,
120 * the following special values are allowed:
121 * - @a TIME_INFINITE no timeout.
122 * .
123 * @return The operation status.
124 * @retval MSG_OK if the function succeeded.
125 * @retval MSG_RESET if one or more I2C errors occurred, the errors can
126 * be retrieved using @p i2cGetErrors().
127 * @retval MSG_TIMEOUT if a timeout occurred before operation end. <b>After a
128 * timeout the driver must be stopped and restarted
129 * because the bus is in an uncertain state</b>.
130 *
131 * @notapi
132 */
133msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
134 uint8_t *rxbuf, size_t rxbytes,
135 sysinterval_t timeout) {
136
137 (void)i2cp;
138 (void)addr;
139 (void)rxbuf;
140 (void)rxbytes;
141 (void)timeout;
142
143 return MSG_OK;
144}
145
146/**
147 * @brief Transmits data via the I2C bus as master.
148 *
149 * @param[in] i2cp pointer to the @p I2CDriver object
150 * @param[in] addr slave device address
151 * @param[in] txbuf pointer to the transmit buffer
152 * @param[in] txbytes number of bytes to be transmitted
153 * @param[out] rxbuf pointer to the receive buffer
154 * @param[in] rxbytes number of bytes to be received
155 * @param[in] timeout the number of ticks before the operation timeouts,
156 * the following special values are allowed:
157 * - @a TIME_INFINITE no timeout.
158 * .
159 * @return The operation status.
160 * @retval MSG_OK if the function succeeded.
161 * @retval MSG_RESET if one or more I2C errors occurred, the errors can
162 * be retrieved using @p i2cGetErrors().
163 * @retval MSG_TIMEOUT if a timeout occurred before operation end. <b>After a
164 * timeout the driver must be stopped and restarted
165 * because the bus is in an uncertain state</b>.
166 *
167 * @notapi
168 */
169msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
170 const uint8_t *txbuf, size_t txbytes,
171 uint8_t *rxbuf, size_t rxbytes,
172 sysinterval_t timeout) {
173
174 (void)i2cp;
175 (void)addr;
176 (void)txbuf;
177 (void)txbytes;
178 (void)rxbuf;
179 (void)rxbytes;
180 (void)timeout;
181
182 return MSG_OK;
183}
184
185#endif /* HAL_USE_I2C == TRUE */
186
187/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_i2c_lld.h b/lib/chibios/os/hal/templates/hal_i2c_lld.h
new file mode 100644
index 000000000..30eec6a17
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_i2c_lld.h
@@ -0,0 +1,152 @@
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_i2c_lld.h
19 * @brief PLATFORM I2C subsystem low level driver header.
20 *
21 * @addtogroup I2C
22 * @{
23 */
24
25#ifndef HAL_I2C_LLD_H
26#define HAL_I2C_LLD_H
27
28#if (HAL_USE_I2C == 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 I2C1 driver enable switch.
44 * @details If set to @p TRUE the support for I2C1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_I2C_USE_I2C1) || defined(__DOXYGEN__)
48#define PLATFORM_I2C_USE_I2C1 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 Type representing an I2C address.
62 */
63typedef uint16_t i2caddr_t;
64
65/**
66 * @brief Type of I2C Driver condition flags.
67 */
68typedef uint32_t i2cflags_t;
69
70/**
71 * @brief Type of I2C driver configuration structure.
72 * @note Implementations may extend this structure to contain more,
73 * architecture dependent, fields.
74 */
75typedef struct {
76 /* End of the mandatory fields.*/
77 uint32_t dummy;
78} I2CConfig;
79
80/**
81 * @brief Type of a structure representing an I2C driver.
82 */
83typedef struct I2CDriver I2CDriver;
84
85/**
86 * @brief Structure representing an I2C driver.
87 */
88struct I2CDriver {
89 /**
90 * @brief Driver state.
91 */
92 i2cstate_t state;
93 /**
94 * @brief Current configuration data.
95 */
96 const I2CConfig *config;
97 /**
98 * @brief Error flags.
99 */
100 i2cflags_t errors;
101#if (I2C_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
102 mutex_t mutex;
103#endif
104#if defined(I2C_DRIVER_EXT_FIELDS)
105 I2C_DRIVER_EXT_FIELDS
106#endif
107 /* End of the mandatory fields.*/
108};
109
110/*===========================================================================*/
111/* Driver macros. */
112/*===========================================================================*/
113
114/**
115 * @brief Get errors from I2C driver.
116 *
117 * @param[in] i2cp pointer to the @p I2CDriver object
118 *
119 * @notapi
120 */
121#define i2c_lld_get_errors(i2cp) ((i2cp)->errors)
122
123/*===========================================================================*/
124/* External declarations. */
125/*===========================================================================*/
126
127#if (PLATFORM_I2C_USE_I2C1 == TRUE) && !defined(__DOXYGEN__)
128extern I2CDriver I2CD1;
129#endif
130
131#ifdef __cplusplus
132extern "C" {
133#endif
134 void i2c_lld_init(void);
135 void i2c_lld_start(I2CDriver *i2cp);
136 void i2c_lld_stop(I2CDriver *i2cp);
137 msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
138 const uint8_t *txbuf, size_t txbytes,
139 uint8_t *rxbuf, size_t rxbytes,
140 sysinterval_t timeout);
141 msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
142 uint8_t *rxbuf, size_t rxbytes,
143 sysinterval_t timeout);
144#ifdef __cplusplus
145}
146#endif
147
148#endif /* HAL_USE_I2C == TRUE */
149
150#endif /* HAL_I2C_LLD_H */
151
152/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_i2s_lld.c b/lib/chibios/os/hal/templates/hal_i2s_lld.c
new file mode 100644
index 000000000..1ee525c2b
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_i2s_lld.c
@@ -0,0 +1,137 @@
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_i2s_lld.c
19 * @brief PLATFORM I2S subsystem low level driver source.
20 *
21 * @addtogroup I2S
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_I2S == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/** @brief I2S2 driver identifier.*/
38#if (PLATFORM_I2S_USE_I2S1 == TRUE) || defined(__DOXYGEN__)
39I2SDriver I2SD1;
40#endif
41
42/*===========================================================================*/
43/* Driver local variables and types. */
44/*===========================================================================*/
45
46/*===========================================================================*/
47/* Driver local functions. */
48/*===========================================================================*/
49
50/*===========================================================================*/
51/* Driver interrupt handlers. */
52/*===========================================================================*/
53
54/*===========================================================================*/
55/* Driver exported functions. */
56/*===========================================================================*/
57
58/**
59 * @brief Low level I2S driver initialization.
60 *
61 * @notapi
62 */
63void i2s_lld_init(void) {
64
65#if PLATFORM_I2S_USE_I2S1
66 i2sObjectInit(&I2SD1);
67#endif
68}
69
70/**
71 * @brief Configures and activates the I2S peripheral.
72 *
73 * @param[in] i2sp pointer to the @p I2SDriver object
74 *
75 * @notapi
76 */
77void i2s_lld_start(I2SDriver *i2sp) {
78
79 /* If in stopped state then enables the SPI and DMA clocks.*/
80 if (i2sp->state == I2S_STOP) {
81
82#if PLATFORM_I2S_USE_I2S1
83 if (&I2SD1 == i2sp) {
84
85 }
86#endif
87 }
88}
89
90/**
91 * @brief Deactivates the I2S peripheral.
92 *
93 * @param[in] i2sp pointer to the @p I2SDriver object
94 *
95 * @notapi
96 */
97void i2s_lld_stop(I2SDriver *i2sp) {
98
99 /* If in ready state then disables the SPI clock.*/
100 if (i2sp->state == I2S_READY) {
101#if PLATFORM_I2S_USE_I2S1
102 if (&I2SD1 == i2sp) {
103
104 }
105#endif
106 }
107}
108
109/**
110 * @brief Starts a I2S data exchange.
111 *
112 * @param[in] i2sp pointer to the @p I2SDriver object
113 *
114 * @notapi
115 */
116void i2s_lld_start_exchange(I2SDriver *i2sp) {
117
118 (void)i2sp;
119}
120
121/**
122 * @brief Stops the ongoing data exchange.
123 * @details The ongoing data exchange, if any, is stopped, if the driver
124 * was not active the function does nothing.
125 *
126 * @param[in] i2sp pointer to the @p I2SDriver object
127 *
128 * @notapi
129 */
130void i2s_lld_stop_exchange(I2SDriver *i2sp) {
131
132 (void)i2sp;
133}
134
135#endif /* HAL_USE_I2S */
136
137/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_i2s_lld.h b/lib/chibios/os/hal/templates/hal_i2s_lld.h
new file mode 100644
index 000000000..6167ef26d
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_i2s_lld.h
@@ -0,0 +1,102 @@
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_i2s_lld.h
19 * @brief PLATFORM I2S subsystem low level driver header.
20 *
21 * @addtogroup I2S
22 * @{
23 */
24
25#ifndef HAL_I2S_LLD_H
26#define HAL_I2S_LLD_H
27
28#if (HAL_USE_I2S == 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 I2SD1 driver enable switch.
44 * @details If set to @p TRUE the support for I2S1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_I2S_USE_I2S1) || defined(__DOXYGEN__)
48#define PLATFORM_I2S_USE_I2S1 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/* Driver macros. */
62/*===========================================================================*/
63
64/**
65 * @brief Low level fields of the I2S driver structure.
66 */
67#define i2s_lld_driver_fields \
68 /* Dummy field, it is not needed.*/ \
69 uint32_t dummy
70
71/**
72 * @brief Low level fields of the I2S configuration structure.
73 */
74#define i2s_lld_config_fields \
75 /* Dummy configuration, it is not needed.*/ \
76 uint32_t dummy
77
78/*===========================================================================*/
79/* External declarations. */
80/*===========================================================================*/
81
82#if (PLATFORM_I2S_USE_I2S1 == TRUE) && !defined(__DOXYGEN__)
83extern I2SDriver I2SD1;
84#endif
85
86#ifdef __cplusplus
87extern "C" {
88#endif
89 void i2s_lld_init(void);
90 void i2s_lld_start(I2SDriver *i2sp);
91 void i2s_lld_stop(I2SDriver *i2sp);
92 void i2s_lld_start_exchange(I2SDriver *i2sp);
93 void i2s_lld_stop_exchange(I2SDriver *i2sp);
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* HAL_USE_I2S == TRUE */
99
100#endif /* HAL_I2S_LLD_H */
101
102/** @} */
diff --git a/lib/chibios/os/hal/templates/hal_icu_lld.c b/lib/chibios/os/hal/templates/hal_icu_lld.c
new file mode 100644
index 000000000..bdf7349b9
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_icu_lld.c
@@ -0,0 +1,187 @@
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_icu_lld.c
19 * @brief PLATFORM ADC subsystem low level driver source.
20 *
21 * @addtogroup ICU
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_ICU == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief ICUD1 driver identifier.
39 * @note The driver ICUD1 allocates the complex timer TIM1 when enabled.
40 */
41#if (PLATFORM_ICU_USE_ICU1 == TRUE) || defined(__DOXYGEN__)
42ICUDriver ICUD1;
43#endif
44
45/*===========================================================================*/
46/* Driver local variables and types. */
47/*===========================================================================*/
48
49/*===========================================================================*/
50/* Driver local functions. */
51/*===========================================================================*/
52
53/*===========================================================================*/
54/* Driver interrupt handlers. */
55/*===========================================================================*/
56
57/*===========================================================================*/
58/* Driver exported functions. */
59/*===========================================================================*/
60
61/**
62 * @brief Low level ICU driver initialization.
63 *
64 * @notapi
65 */
66void icu_lld_init(void) {
67
68#if PLATFORM_ICU_USE_ICU1 == TRUE
69 /* Driver initialization.*/
70 icuObjectInit(&ICUD1);
71#endif
72}
73
74/**
75 * @brief Configures and activates the ICU peripheral.
76 *
77 * @param[in] icup pointer to the @p ICUDriver object
78 *
79 * @notapi
80 */
81void icu_lld_start(ICUDriver *icup) {
82
83 if (icup->state == ICU_STOP) {
84 /* Clock activation and timer reset.*/
85#if PLATFORM_ICU_USE_ICU1 == TRUE
86 if (&ICUD1 == icup) {
87
88 }
89#endif
90 }
91}
92
93/**
94 * @brief Deactivates the ICU peripheral.
95 *
96 * @param[in] icup pointer to the @p ICUDriver object
97 *
98 * @notapi
99 */
100void icu_lld_stop(ICUDriver *icup) {
101
102 if (icup->state == ICU_READY) {
103 /* Clock deactivation.*/
104#if PLATFORM_ICU_USE_ICU1 == TRUE
105 if (&ICUD1 == icup) {
106
107 }
108#endif
109 }
110}
111
112/**
113 * @brief Starts the input capture.
114 *
115 * @param[in] icup pointer to the @p ICUDriver object
116 *
117 * @notapi
118 */
119void icu_lld_start_capture(ICUDriver *icup) {
120
121 (void)icup;
122}
123
124/**
125 * @brief Waits for a completed capture.
126 * @note The operation is performed in polled mode.
127 * @note In order to use this function notifications must be disabled.
128 *
129 * @param[in] icup pointer to the @p ICUDriver object
130 * @return The capture status.
131 * @retval false if the capture is successful.
132 * @retval true if a timer overflow occurred.
133 *
134 * @notapi
135 */
136bool icu_lld_wait_capture(ICUDriver *icup) {
137
138 (void)icup;
139
140 return false;
141}
142
143/**
144 * @brief Stops the input capture.
145 *
146 * @param[in] icup pointer to the @p ICUDriver object
147 *
148 * @notapi
149 */
150void icu_lld_stop_capture(ICUDriver *icup) {
151
152 (void)icup;
153}
154
155/**
156 * @brief Enables notifications.
157 * @pre The ICU unit must have been activated using @p icuStart() and the
158 * capture started using @p icuStartCapture().
159 * @note If the notification is already enabled then the call has no effect.
160 *
161 * @param[in] icup pointer to the @p ICUDriver object
162 *
163 * @api
164 */
165void icu_lld_enable_notifications(ICUDriver *icup) {
166
167 (void)icup;
168}
169
170/**
171 * @brief Disables notifications.
172 * @pre The ICU unit must have been activated using @p icuStart() and the
173 * capture started using @p icuStartCapture().
174 * @note If the notification is already disabled then the call has no effect.
175 *