diff options
Diffstat (limited to 'lib/chibios/os/hal/boards/OLIMEX_STM32_LCD')
-rw-r--r-- | lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.c | 87 | ||||
-rw-r--r-- | lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.h | 196 | ||||
-rw-r--r-- | lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.mk | 9 |
3 files changed, 292 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.c b/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.c new file mode 100644 index 000000000..bbc28c6f6 --- /dev/null +++ b/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.c | |||
@@ -0,0 +1,87 @@ | |||
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 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__) | ||
25 | const 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 | {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH}, | ||
32 | {VAL_GPIOFODR, VAL_GPIOFCRL, VAL_GPIOFCRH}, | ||
33 | {VAL_GPIOGODR, VAL_GPIOGCRL, VAL_GPIOGCRH}, | ||
34 | }; | ||
35 | #endif | ||
36 | |||
37 | /* | ||
38 | * Early initialization code. | ||
39 | * This initialization must be performed just after stack setup and before | ||
40 | * any other initialization. | ||
41 | */ | ||
42 | void __early_init(void) { | ||
43 | stm32_clock_init(); | ||
44 | } | ||
45 | |||
46 | #if HAL_USE_SDC || defined(__DOXYGEN__) | ||
47 | /** | ||
48 | * @brief SDC card detection. | ||
49 | */ | ||
50 | bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { | ||
51 | (void)sdcp; | ||
52 | |||
53 | return TRUE; | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @brief SDC card write protection detection. | ||
58 | */ | ||
59 | bool sdc_lld_is_write_protected(SDCDriver *sdcp) { | ||
60 | (void)sdcp; | ||
61 | |||
62 | return FALSE; | ||
63 | } | ||
64 | #endif /* HAL_USE_SDC */ | ||
65 | |||
66 | #if HAL_USE_MMC_SPI | ||
67 | /* Board-related functions related to the MMC_SPI driver.*/ | ||
68 | bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { | ||
69 | (void)mmcp; | ||
70 | |||
71 | return TRUE; | ||
72 | } | ||
73 | |||
74 | bool mmc_lld_is_write_protected(MMCDriver *mmcp) { | ||
75 | (void)mmcp; | ||
76 | |||
77 | return FALSE; | ||
78 | } | ||
79 | #endif | ||
80 | |||
81 | /* | ||
82 | * Board-specific initialization code. | ||
83 | */ | ||
84 | void boardInit(void) { | ||
85 | |||
86 | } | ||
87 | |||
diff --git a/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.h b/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.h new file mode 100644 index 000000000..b943bd885 --- /dev/null +++ b/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.h | |||
@@ -0,0 +1,196 @@ | |||
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 the Olimex STM32-LCD proto board. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | * Board identifier. | ||
26 | */ | ||
27 | #define BOARD_OLIMEX_STM32_LCD | ||
28 | #define BOARD_NAME "Olimex STM32-LCD" | ||
29 | |||
30 | /* | ||
31 | * Board frequencies. | ||
32 | */ | ||
33 | #define STM32_LSECLK 32768 | ||
34 | #define STM32_HSECLK 8000000 | ||
35 | |||
36 | /* | ||
37 | * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h. | ||
38 | */ | ||
39 | #define STM32F10X_HD | ||
40 | |||
41 | /* | ||
42 | * IO pins assignments. | ||
43 | */ | ||
44 | #define GPIOA_SPI1NSS 4 | ||
45 | |||
46 | #define GPIOB_SPI2NSS 12 | ||
47 | |||
48 | #define GPIOA_USB_P 0 | ||
49 | #define GPIOD_USB_DISC 2 | ||
50 | |||
51 | #define GPIOE_TFT_RST 2 | ||
52 | #define GPIOD_TFT_LIGHT 13 | ||
53 | #define GPIOC_TFT_YD 0 | ||
54 | #define GPIOC_TFT_YU 1 | ||
55 | #define GPIOC_TFT_XL 2 | ||
56 | #define GPIOC_TFT_XR 3 | ||
57 | |||
58 | /* | ||
59 | * I/O ports initial setup, this configuration is established soon after reset | ||
60 | * in the initialization code. | ||
61 | * | ||
62 | * The digits have the following meaning: | ||
63 | * 0 - Analog input. | ||
64 | * 1 - Push Pull output 10MHz. | ||
65 | * 2 - Push Pull output 2MHz. | ||
66 | * 3 - Push Pull output 50MHz. | ||
67 | * 4 - Digital input. | ||
68 | * 5 - Open Drain output 10MHz. | ||
69 | * 6 - Open Drain output 2MHz. | ||
70 | * 7 - Open Drain output 50MHz. | ||
71 | * 8 - Digital input with PullUp or PullDown resistor depending on ODR. | ||
72 | * 9 - Alternate Push Pull output 10MHz. | ||
73 | * A - Alternate Push Pull output 2MHz. | ||
74 | * B - Alternate Push Pull output 50MHz. | ||
75 | * C - Reserved. | ||
76 | * D - Alternate Open Drain output 10MHz. | ||
77 | * E - Alternate Open Drain output 2MHz. | ||
78 | * F - Alternate Open Drain output 50MHz. | ||
79 | * Please refer to the STM32 Reference Manual for details. | ||
80 | */ | ||
81 | |||
82 | /* | ||
83 | * Port A setup. | ||
84 | * Everything input with pull-up except: | ||
85 | * PA0 - Normal input (USB P). | ||
86 | * PA2 - Alternate output (USART2 TX). | ||
87 | * PA3 - Normal input (USART2 RX). | ||
88 | * PA11 - Normal input (USB DM). | ||
89 | * PA12 - Normal input (USB DP). | ||
90 | */ | ||
91 | #define VAL_GPIOACRL 0x88884B84 /* PA7...PA0 */ | ||
92 | #define VAL_GPIOACRH 0x88844888 /* PA15...PA8 */ | ||
93 | #define VAL_GPIOAODR 0xFFFFFFFF | ||
94 | |||
95 | /* | ||
96 | * Port B setup. | ||
97 | * Everything input with pull-up except: | ||
98 | */ | ||
99 | #define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */ | ||
100 | #define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */ | ||
101 | #define VAL_GPIOBODR 0xFFFFFFFF | ||
102 | |||
103 | /* | ||
104 | * Port C setup. | ||
105 | * Everything input with pull-up except: | ||
106 | * PC0 - Analog Input (TP_YD). | ||
107 | * PC1 - Analog Input (TP_YU). | ||
108 | * PC2 - Analog Input (TP_XL). | ||
109 | * PC3 - Analog Input (TP_XR). | ||
110 | * PC8 - Alternate PP 50M (SD_D0). | ||
111 | * PC9 - Alternate PP 50M (SD_D1). | ||
112 | * PC10 - Alternate PP 50M (SD_D2). | ||
113 | * PC11 - Alternate PP 50M (SD_D3). | ||
114 | * PC12 - Alternate PP 50M (SD_CLK). | ||
115 | * PC14 - Normal input (XTAL). | ||
116 | * PC15 - Normal input (XTAL). | ||
117 | */ | ||
118 | #define VAL_GPIOCCRL 0x88880000 /* PC7...PC0 */ | ||
119 | #define VAL_GPIOCCRH 0x448BBBBB /* PC15...PC8 */ | ||
120 | #define VAL_GPIOCODR 0xFFFFFFFF | ||
121 | |||
122 | /* | ||
123 | * Port D setup. | ||
124 | * Everything input with pull-up except: | ||
125 | * PD2 - Alternate PP 50M (SD_CMD) | ||
126 | * PD0 - Alternate PP 50M (FSMC_D2) | ||
127 | * PD1 - Alternate PP 50M (FSMC_D3) | ||
128 | * PD4 - Alternate PP 50M (TFT_RD) | ||
129 | * PD5 - Alternate PP 50M (TFT_WR) | ||
130 | * PD7 - Alternate PP 50M (TFT_CS) | ||
131 | * PD8 - Alternate PP 50M (FSMC_D13) | ||
132 | * PD9 - Alternate PP 50M (FSMC_D14) | ||
133 | * PD10 - Alternate PP 50M (FSMC_D15) | ||
134 | * PD14 - Alternate PP 50M (FSMC_D0) | ||
135 | * PD15 - Alternate PP 50M (FSMC_D1) | ||
136 | */ | ||
137 | #define VAL_GPIODCRL 0xBBBB8BBB /* PD7...PD0 */ | ||
138 | #define VAL_GPIODCRH 0xBB388BBB /* PD15...PD8 */ | ||
139 | #define VAL_GPIODODR 0xFFFFFFFF | ||
140 | |||
141 | /* | ||
142 | * Port E setup. | ||
143 | * Everything input with pull-up except: | ||
144 | * PE2 - Digital Output (TFT_RST) | ||
145 | * PE3 - Alternate PP 50M (TFT_RS) | ||
146 | * PE7 - Alternate PP 50M (FSMC_D4) | ||
147 | * PE8 - Alternate PP 50M (FSMC_D5) | ||
148 | * PE9 - Alternate PP 50M (FSMC_D6) | ||
149 | * PE10 - Alternate PP 50M (FSMC_D7) | ||
150 | * PE11 - Alternate PP 50M (FSMC_D8) | ||
151 | * PE12 - Alternate PP 50M (FSMC_D9) | ||
152 | * PE13 - Alternate PP 50M (FSMC_D10) | ||
153 | * PE14 - Alternate PP 50M (FSMC_D11) | ||
154 | * PE15 - Alternate PP 50M (FSMC_D12) | ||
155 | */ | ||
156 | #define VAL_GPIOECRL 0xB888B388 /* PE7...PE0 */ | ||
157 | #define VAL_GPIOECRH 0xBBBBBBBB /* PE15...PE8 */ | ||
158 | #define VAL_GPIOEODR 0xFFFFFFFF | ||
159 | |||
160 | /* | ||
161 | * Port F setup. | ||
162 | * Everything input with pull-up expect: | ||
163 | */ | ||
164 | #define VAL_GPIOFCRL 0x88888888 /* PF7...PF0 */ | ||
165 | #define VAL_GPIOFCRH 0x88888888 /* PF15...PF8 */ | ||
166 | #define VAL_GPIOFODR 0xFFFFFFFF | ||
167 | |||
168 | /* | ||
169 | * Port G setup. | ||
170 | * Everything input with pull-up expect: | ||
171 | */ | ||
172 | #define VAL_GPIOGCRL 0x88888888 /* PG7...PG0 */ | ||
173 | #define VAL_GPIOGCRH 0x88888888 /* PG15...PG8 */ | ||
174 | #define VAL_GPIOGODR 0xFFFFFFFF | ||
175 | |||
176 | /* | ||
177 | * USB bus activation macro, required by the USB driver. | ||
178 | */ | ||
179 | #define usb_lld_connect_bus(usbp) palClearPad(GPIOD, GPIOD_USB_DISC) | ||
180 | |||
181 | /* | ||
182 | * USB bus de-activation macro, required by the USB driver. | ||
183 | */ | ||
184 | #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOD, GPIOD_USB_DISC) | ||
185 | |||
186 | #if !defined(_FROM_ASM_) | ||
187 | #ifdef __cplusplus | ||
188 | extern "C" { | ||
189 | #endif | ||
190 | void boardInit(void); | ||
191 | #ifdef __cplusplus | ||
192 | } | ||
193 | #endif | ||
194 | #endif /* _FROM_ASM_ */ | ||
195 | |||
196 | #endif /* _BOARD_H_ */ | ||
diff --git a/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.mk b/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.mk new file mode 100644 index 000000000..ccfec85bf --- /dev/null +++ b/lib/chibios/os/hal/boards/OLIMEX_STM32_LCD/board.mk | |||
@@ -0,0 +1,9 @@ | |||
1 | # List of all the board related files. | ||
2 | BOARDSRC = ${CHIBIOS}/os/hal/boards/OLIMEX_STM32_LCD/board.c | ||
3 | |||
4 | # Required include directories | ||
5 | BOARDINC = ${CHIBIOS}/os/hal/boards/OLIMEX_STM32_LCD | ||
6 | |||
7 | # Shared variables | ||
8 | ALLCSRC += $(BOARDSRC) | ||
9 | ALLINC += $(BOARDINC) | ||