1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
/*
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
This is an example board.h for Board Component, New Board should follow the macro defines.
*/
#ifndef __BOARD_H__
#define __BOARD_H__
#include <soc.h>
#ifdef __cplusplus
extern "C" {
#endif
// Common Board Features Define
/*
The Common BOARD_XXX Macro Defines Boards supported features which may reference by Solutions.
Common board macro include:
. BOARD_NAME
· UART
· GPIO
· PWM
· ADC
· BUTTON
· LED
· WIFI
· BT
· AUDIO
BOARD_XXX Macro described below should be defined if the board support.
*/
/****************************************************************************/
/*
This riscv dummy board include:
· UART x1
· GPIO x2
· PWM x2
· ADC x1
· BUTTON x2
· LED x2
· WIFI x0
· BT x0
· AUDIO x1
*/
#ifndef CONFIG_BOARD_UART
#define CONFIG_BOARD_UART 1
#endif
#ifndef CONFIG_BOARD_GPIO
#define CONFIG_BOARD_GPIO 0
#endif
#ifndef CONFIG_BOARD_PWM
#define CONFIG_BOARD_PWM 0
#endif
#ifndef CONFIG_BOARD_ADC
#define CONFIG_BOARD_ADC 0
#endif
#ifndef CONFIG_BOARD_BUTTON
#define CONFIG_BOARD_BUTTON 0
#endif
#ifndef CONFIG_BOARD_LED
#define CONFIG_BOARD_LED 0
#endif
#ifndef CONFIG_BOARD_WIFI
#define CONFIG_BOARD_WIFI 0
#endif
#ifndef CONFIG_BOARD_BT
#define CONFIG_BOARD_BT 0
#endif
#ifndef CONFIG_BOARD_AUDIO
#define CONFIG_BOARD_AUDIO 0
#endif
#define BOARD_NAME "RISCV_DUMMY"
/* the board pins, can be used as uart, gpio, pwd... */
#define BOARD_PIN0 (0)
#define BOARD_PIN1 (1)
#define BOARD_PIN2 (2)
#define BOARD_PIN3 (3)
#define BOARD_PIN4 (4)
#define BOARD_PIN5 (5)
#define BOARD_PIN6 (6)
#define BOARD_PIN7 (7)
#define BOARD_PIN8 (8)
#define BOARD_PIN9 (9)
#define BOARD_PIN10 (10)
#define BOARD_PIN11 (11)
#define BOARD_PIN12 (12)
//...
#if defined(CONFIG_BOARD_UART) && CONFIG_BOARD_UART
// UART
/*
The total supported uart numbers on this board, 0 means No uart support.
the BOARD_UART<x>_XXX, x in range of (0, BOARD_UART_NUM - 1)
*/
#ifndef BOARD_UART_NUM
#define BOARD_UART_NUM (1)
#endif
#if defined(BOARD_UART_NUM) && BOARD_UART_NUM > 0
/* the board uart0 tx pin */
#define BOARD_UART0_TX_PIN (BOARD_PIN0)
/* the borad uart0 rx pin */
#define BOARD_UART0_RX_PIN (BOARD_PIN1)
/* The real UART port reference to board logic port 0 */
#define BOARD_UART0_IDX (0)
/* The default baudrate for uart0 */
#define BOARD_UART0_BAUD (115200)
//#define BOARD_UART1_IDX (1)
//#define BOARD_UART1_BAUD (115200)
// ...
#endif // defined(BOARD_UART_NUM) && BOARD_UART_NUM > 0
#endif // defined(CONFIG_BOARD_UART) && CONFIG_BOARD_UART
#if defined(CONFIG_BOARD_GPIO) && CONFIG_BOARD_GPIO
// GPIO
/*
The total supported GPIO Pin numbers on this board, 0 meas No uart support.
the BOARD_GPIO_PIN<x>, x in rang of (0, BOARD_GPIO_PIN_NUM - 1)
*/
#ifndef BOARD_GPIO_PIN_NUM
#define BOARD_GPIO_PIN_NUM (2)
#endif
#if defined(BOARD_GPIO_PIN_NUM) && BOARD_GPIO_PIN_NUM > 0
/* The real gpio reference to board logic gpio pin */
#define BOARD_GPIO_PIN0 (BOARD_PIN2)
#define BOARD_GPIO_PIN1 (BOARD_PIN3)
//#define BOARD_GPIO_PIN2 (x)
//#define BOARD_GPIO_PIN3 (x)
#endif // defined(BOARD_GPIO_PIN_NUM) && BOARD_GPIO_PIN_NUM > 0
#endif // defined(CONFIG_BOARD_GPIO) && CONFIG_BOARD_GPIO
#if defined(CONFIG_BOARD_PWM) && CONFIG_BOARD_PWM
// PWM
/* the board supported pwm channels */
#ifndef BOARD_PWM_NUM
#define BOARD_PWM_NUM (2)
#endif
#if defined(BOARD_PWM_NUM) && BOARD_PWM_NUM > 0
/* the board pwm pin */
#define BOARD_PWM0_PIN (BOARD_PIN4)
/* The real pwm channel reference to board logic pwm channel */
#define BOARD_PWM0_CH (0)
#define BOARD_PWM1_PIN (BOARD_PIN5)
#define BOARD_PWM1_CH (1)
#endif // defined(BOARD_PWM_NUM) && BOARD_PWM_NUM > 0
#endif // defined(CONFIG_BOARD_PWM) && CONFIG_BOARD_PWM
#if defined(CONFIG_BOARD_ADC) && CONFIG_BOARD_ADC > 0
// ADC
/* the board supported adc channels */
#ifndef BOARD_ADC_NUM
#define BOARD_ADC_NUM (1)
#endif
#if defined(BOARD_ADC_NUM) && BOARD_ADC_NUM > 0
/* the board adc pin */
#define BOARD_ADC0_PIN (BOARD_PIN6)
/* The real adc channel reference to board logic adc channel */
#define BOARD_ADC0_CH (0)
#endif // defined(BOARD_ADC_NUM) && BOARD_ADC_NUM > 0
#endif // defined(CONFIG_BOARD_ADC) && CONFIG_BOARD_ADC > 0
#if defined(CONFIG_BOARD_BUTTON) && CONFIG_BOARD_BUTTON > 0
// BUTTON
#ifndef BOARD_BUTTON_NUM
/*
the board supported buttons, include gpio button and adc button,
BOARD_BUTTON_NUM = BOARD_BUTTON_GPIO_NUM + BOARD_BUTTON_ADC_NUM.
*/
#define BOARD_BUTTON_NUM (4)
#endif
#if defined(BOARD_BUTTON_NUM) && BOARD_BUTTON_NUM > 0
#define BOARD_BUTTON0_PIN (BOARD_PIN7)
#define BOARD_BUTTON1_PIN (BOARD_PIN8)
#define BOARD_BUTTON2_PIN (BOARD_PIN9)
#define BOARD_BUTTON3_PIN (BOARD_PIN10)
// GPIO BUTTON
/* the board supported GPIO Buttons */
#ifndef BOARD_BUTTON_GPIO_NUM
#define BOARD_BUTTON_GPIO_NUM (2)
#endif
#if defined(BOARD_BUTTON_GPIO_NUM) && BOARD_BUTTON_GPIO_NUM > 0
/* the board logic button id, in range of (0, BOARD_BUTTON_GPIO_NUM - 1) */
#define BOARD_BUTTON0 (0)
/* for gpio button, define the pin numner. if the gpio pin used as gpio button, it shoudn't reference as BOARD_GPIO_PINx
*/
#define BOARD_BUTTON0_GPIO_PIN (BOARD_BUTTON0_PIN)
#define BOARD_BUTTON1 (1)
#define BOARD_BUTTON1_GPIO_PIN (BOARD_BUTTON1_PIN)
#endif // defined(BOARD_BUTTON_GPIO_NUM) && BOARD_BUTTON_GPIO_NUM > 0
// ADC BUTTON
/* the board supported adc Buttons */
#ifndef BOARD_BUTTON_ADC_NUM
#define BOARD_BUTTON_ADC_NUM (2)
#endif
#if defined(BOARD_BUTTON_ADC_NUM) && BOARD_BUTTON_ADC_NUM > 0
/* the board logic adc button id, in range of (BOARD_BUTTON_GPIO_NUM, BOARD_BUTTON_NUM - 1), if not suuport GPIO Button,
* BOARD_BUTTON_GPIO_NUM should be 0 */
#define BOARD_BUTTON2 (BOARD_BUTTON_GPIO_NUM + 0)
#define BOARD_BUTTON2_ADC_PIN (BOARD_BUTTON2_PIN)
/* the adc channel used for button2, if the adc channel used as adc button, it shoudn't reference as BOARD_ADCx_CH*/
#define BOARD_BUTTON2_ADC_CH (1)
/* the adc device name */
#define BOARD_BUTTON2_ADC_NAME "adc1"
/* adc voltage reference */
#define BOARD_BUTTON2_ADC_REF (100)
/* adc voltage range */
#define BOARD_BUTTON2_ADC_RANG (500)
#define BOARD_BUTTON3 (BOARD_BUTTON_GPIO_NUM + 1)
#define BOARD_BUTTON3_ADC_PIN (BOARD_BUTTON3_PIN)
#define BOARD_BUTTON3_ADC_CH (1)
#define BOARD_BUTTON3_ADC_NAME "adc1"
#define BOARD_BUTTON3_ADC_REF (600)
#define BOARD_BUTTON3_ADC_RANG (500)
//#define BOARD_ADC_BUTTON2 (2)
//#define BOARD_ADC_BUTTON2_CH (1)
//#define BOARD_ADC_BUTTON2_NAME "adc1"
//#define BOARD_ADC_BUTTON2_REF xxx
//#define BOARD_ADC_BUTTON2_RANG xxx
#endif // defined(BOARD_BUTTON_ADC_NUM) && BOARD_BUTTON_ADC_NUM > 0
#endif // defined(BOARD_BUTTON_NUM) && BOARD_BUTTON_NUM > 0
#endif // defined(BOARD_BUTTON_NUM) && BOARD_BUTTON_NUM > 0
#if defined(CONFIG_BOARD_LED) && CONFIG_BOARD_LED > 0
// LED
/* the board supported leds */
#ifndef BOARD_LED_NUM
#define BOARD_LED_NUM (2)
#endif
#define BOARD_LED0_PIN BOARD_PIN11
#define BOARD_LED1_PIN BOARD_PIN12
// PWM LED
/* the board supported pwm leds */
#ifndef BOARD_LED_PWM_NUM
#define BOARD_LED_PWM_NUM (1)
#endif
#if defined(BOARD_LED_PWM_NUM) && BOARD_LED_PWM_NUM > 0
#define BOARD_LED0_PWM_PIN (BOARD_LED0_PIN)
/* the pwm channel used for led0, if the pwm channel used as led0, it shoudn't reference as BOARD_PWMx_CH */
#define BOARD_LED0_PWM_CH (0)
#endif // defined(BOARD_LED_PWM_NUM) && BOARD_LED_PWM_NUM > 0
// GPIO LED
#ifndef BOARD_LED_GPIO_NUM
#define BOARD_LED_GPIO_NUM (1)
#endif
#if defined(BOARD_LED_GPIO_NUM) && BOARD_LED_GPIO_NUM > 0
/* the gpio pin used for led0, if the gpio pin used as led, it shoudn't reference as BOARD_GPIO_PINx */
#define BOARD_LED1_GPIO_PIN (BOARD_LED1_PIN)
#endif // defined(BOARD_LED_GPIO_NUM) && BOARD_LED_GPIO_NUM > 0
#endif // defined(CONFIG_BOARD_LED) && CONFIG_BOARD_LED > 0
#if defined(CONFIG_BOARD_BT) && CONFIG_BOARD_BT > 0
// BT
/* the board support bluetooth */
#ifndef BOARD_BT_SUPPORT
#define BOARD_BT_SUPPORT 1
#endif
#endif // defined(CONFIG_BOARD_BT) && CONFIG_BOARD_BT > 0
#if defined(CONFIG_BOARD_WIFI) && CONFIG_BOARD_WIFI > 0
// WIFI
/* the board support wifi */
#ifndef BOARD_WIFI_SUPPORT
#define BOARD_WIFI_SUPPORT 1
#endif
#endif // defined(CONFIG_BOARD_WIFI) && CONFIG_BOARD_WIFI > 0
#if defined(CONFIG_BOARD_AUDIO) && CONFIG_BOARD_AUDIO > 0
// Audio
/* the board support audio */
#ifndef BOARD_AUDIO_SUPPORT
#define BOARD_AUDIO_SUPPORT 1
#endif
#endif // defined(CONFIG_BOARD_AUDIO) && CONFIG_BOARD_AUDIO > 0
/****************************************************************************/
// Common solutions defines
// Console config, Almost all solutions and demos use these.
#ifndef CONSOLE_UART_IDX
#define CONSOLE_UART_IDX (BOARD_UART0_IDX)
#endif
#ifndef CONFIG_CLI_USART_BAUD
#define CONFIG_CLI_USART_BAUD (BOARD_UART0_BAUD)
#endif
#ifndef CONFIG_CONSOLE_UART_BUFSIZE
#define CONFIG_CONSOLE_UART_BUFSIZE (128)
#endif
/****************************************************************************/
// Commom test demos defines
// i2c
#define EXAMPLE_IIC_IDX 0 // 1
#define EXAMPLE_PIN_IIC_SDA 0 // PC1
#define EXAMPLE_PIN_IIC_SCL 0 // PC0
#define EXAMPLE_PIN_IIC_SDA_FUNC 0 // PC1_I2C1_SDA
#define EXAMPLE_PIN_IIC_SCL_FUNC 0 // PC0_I2C1_SCL
// adc
#define EXAMPLE_ADC_CH0 0 // PA8
#define EXAMPLE_ADC_CH0_FUNC 0 // PA8_ADC_A0
#define EXAMPLE_ADC_CH12 0 // PA26
#define EXAMPLE_ADC_CH12_FUNC 0 // PA26_ADC_A12
/****************************************************************************/
// Vendor board defines
/* other board specific defines */
//#define CUSTOM_BOARD_xxx
/****************************************************************************/
/**
* @brief init the board for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_init(void);
/**
* @brief init the board gpio pin for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_gpio_pin_init(void);
/**
* @brief init the board uart for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_uart_init(void);
/**
* @brief init the board pwm for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_pwm_init(void);
/**
* @brief init the board adc for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_adc_init(void);
/**
* @brief init the board button for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_button_init(void);
/**
* @brief init the board led for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_led_init(void);
/**
* @brief init the board wifi for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_wifi_init(void);
/**
* @brief init the board bt for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_bt_init(void);
/**
* @brief init the board audio for default: pin mux, etc.
* re-implement if need.
* @return
*/
void board_audio_init(void);
#ifdef __cplusplus
}
#endif
#endif /* __BOARD_H__ */
|