aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO')
-rw-r--r--lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.c49
-rw-r--r--lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.h140
-rw-r--r--lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.mk9
3 files changed, 198 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.c b/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.c
new file mode 100644
index 000000000..36a27cb58
--- /dev/null
+++ b/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.c
@@ -0,0 +1,49 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 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 PAL setup.
21 * @details Digital I/O ports static configuration as defined in @p board.h.
22 * This variable is used by the HAL when initializing the PAL driver.
23 */
24#if HAL_USE_PAL || defined(__DOXYGEN__)
25const PALConfig pal_default_config =
26{
27 {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH},
28 {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
29 {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
30 {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
31};
32#endif
33
34/*
35 * Early initialization code.
36 * This initialization must be performed just after stack setup and before
37 * any other initialization.
38 */
39void __early_init(void) {
40 gd32_clock_init();
41}
42
43/*
44 * Board-specific initialization code.
45 */
46void boardInit(void) {
47 /* Free B4 pin by disabling JTAG NJTRST. */
48 AFIO->PCF0 |= AFIO_PCF0_SWJ_CFG_NOJNTRST;
49}
diff --git a/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.h b/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.h
new file mode 100644
index 000000000..5ce1b8716
--- /dev/null
+++ b/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.h
@@ -0,0 +1,140 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 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 GD32VF103 board.
22 */
23
24/*
25 * Board identifier.
26 */
27#define BOARD_GD32VF103
28#define BOARD_NAME "Sipeed Longan Nano GD32VF103CBT6"
29#define BOARD_USBFS_NOVBUSSENS
30
31/*
32 * Board frequencies.
33 */
34#define GD32_LXTALCLK 32768
35#define GD32_HXTALCLK 8000000
36
37/*
38 * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
39 */
40#define GD32VF103CB
41
42/*
43 * IO pins assignments
44 */
45#define PIN_GREEN_LED 1
46#define PIN_BLUE_LED 2
47#define PIN_RED_LED 13
48
49#define PIN_DISPLAY_MISO 6
50#define PIN_DISPLAY_MOSI 7
51#define PIN_DISPLAY_SCK 5
52#define PIN_DISPLAY_CS 2
53#define PIN_DISPLAY_DC 0
54#define PIN_DISPLAY_RST 1
55
56#define LINE_GREEN_LED PAL_LINE(GPIOA, PIN_GREEN_LED)
57#define LINE_BLUE_LED PAL_LINE(GPIOA, PIN_BLUE_LED)
58#define LINE_RED_LED PAL_LINE(GPIOC, PIN_RED_LED)
59
60#define LINE_DISPLAY_MISO PAL_LINE(GPIOA, PIN_DISPLAY_MISO)
61#define LINE_DISPLAY_MOSI PAL_LINE(GPIOA, PIN_DISPLAY_MOSI)
62#define LINE_DISPLAY_SCK PAL_LINE(GPIOA, PIN_DISPLAY_SCK)
63#define LINE_DISPLAY_CS PAL_LINE(GPIOB, PIN_DISPLAY_CS)
64#define LINE_DISPLAY_DC PAL_LINE(GPIOB, PIN_DISPLAY_DC)
65#define LINE_DISPLAY_RST PAL_LINE(GPIOB, PIN_DISPLAY_RST)
66/*
67 * I/O ports initial setup, this configuration is established soon after reset
68 * in the initialization code.
69 *
70 * The digits have the following meaning:
71 * 0 - Analog input.
72 * 1 - Push Pull output 10MHz.
73 * 2 - Push Pull output 2MHz.
74 * 3 - Push Pull output 50MHz.
75 * 4 - Digital input.
76 * 5 - Open Drain output 10MHz.
77 * 6 - Open Drain output 2MHz.
78 * 7 - Open Drain output 50MHz.
79 * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
80 * 9 - Alternate Push Pull output 10MHz.
81 * A - Alternate Push Pull output 2MHz.
82 * B - Alternate Push Pull output 50MHz.
83 * C - Reserved.
84 * D - Alternate Open Drain output 10MHz.
85 * E - Alternate Open Drain output 2MHz.
86 * F - Alternate Open Drain output 50MHz.
87 * Please refer to the STM32 Reference Manual for details.
88 */
89
90/*
91 * Port A setup.
92 * Everything input with pull-up except:
93 * A1 - Green LED - Push Pull output 50MHz
94 * A2 - Blue LED - Push Pull output 50MHz
95 * A5 - Display SCK - Alternate Push Pull output 50MHz.
96 * A7 - Display MOSI - Alternate Push Pull output 50MHz.
97 */
98#define VAL_GPIOACRL 0xB8B88338 /* PA7...PA0 */
99#define VAL_GPIOACRH 0x88888888 /* PA15...PA8 */
100#define VAL_GPIOAODR 0xFFFFFFFF
101
102/*
103 * Port B setup.
104 * Everything input with pull-up except:
105 * B0 - Display DC - Push Pull output 50Mhz.
106 * B1 - Display RST - Push Pull output 50Mhz.
107 * B2 - Display CS - Push Pull output 50Mhz.
108 */
109#define VAL_GPIOBCRL 0x88888333 /* PB7...PB0 */
110#define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
111#define VAL_GPIOBODR 0xFFFFFFFF
112
113/*
114 * Port C setup.
115 * Everything input with pull-up except:
116 * C13 - RED LED - Push Pull output 50MHz
117 */
118#define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
119#define VAL_GPIOCCRH 0x88388888 /* PC15...PC8 */
120#define VAL_GPIOCODR 0xFFFFFFFF
121
122/*
123 * Port D setup.
124 * Everything input with pull-up except:
125 */
126#define VAL_GPIODCRL 0x88888888 /* PD7...PD0 */
127#define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
128#define VAL_GPIODODR 0xFFFFFFFF
129
130#if !defined(_FROM_ASM_)
131#ifdef __cplusplus
132extern "C" {
133#endif
134 void boardInit(void);
135#ifdef __cplusplus
136}
137#endif
138#endif /* _FROM_ASM_ */
139
140#endif /* _BOARD_H_ */
diff --git a/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.mk b/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.mk
new file mode 100644
index 000000000..960fc2678
--- /dev/null
+++ b/lib/chibios-contrib/os/hal/boards/SIPEED_LONGAN_NANO/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = ${CHIBIOS_CONTRIB}/os/hal/boards/SIPEED_LONGAN_NANO/board.c
3
4# Required include directories
5BOARDINC = ${CHIBIOS_CONTRIB}/os/hal/boards/SIPEED_LONGAN_NANO
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)