]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.h
Add ChibiOS support for QMK (#465)
[qmk_firmware.git] / keyboards / stm32_f103_onekey / boards / GENERIC_STM32_F103 / board.h
1 /*\r
2     ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio\r
3 \r
4     Licensed under the Apache License, Version 2.0 (the "License");\r
5     you may not use this file except in compliance with the License.\r
6     You may obtain a copy of the License at\r
7 \r
8         http://www.apache.org/licenses/LICENSE-2.0\r
9 \r
10     Unless required by applicable law or agreed to in writing, software\r
11     distributed under the License is distributed on an "AS IS" BASIS,\r
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13     See the License for the specific language governing permissions and\r
14     limitations under the License.\r
15 */\r
16 \r
17 #ifndef _BOARD_H_\r
18 #define _BOARD_H_\r
19 \r
20 /*\r
21  * Setup for a Generic STM32F103 board.\r
22  */\r
23 \r
24 /*\r
25  * Board identifier.\r
26  */\r
27 #define BOARD_GENERIC_STM32_F103\r
28 #define BOARD_NAME              "Generic STM32F103x board"\r
29 \r
30 /*\r
31  * Board frequencies.\r
32  */\r
33 #define STM32_LSECLK            32768\r
34 #define STM32_HSECLK            8000000\r
35 \r
36 /*\r
37  * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.\r
38  */\r
39 #define STM32F103xB\r
40 \r
41 /*\r
42  * IO pins assignments\r
43  */\r
44 \r
45 /* on-board */\r
46 \r
47 #define GPIOC_LED               13\r
48 #define GPIOD_OSC_IN            0\r
49 #define GPIOD_OSC_OUT           1\r
50 \r
51 /* In case your board has a "USB enable" hardware\r
52    controlled by a pin, define it here. (It could be just\r
53    a 1.5k resistor connected to D+ line.)\r
54 */\r
55 /*\r
56 #define GPIOB_USB_DISC          10\r
57 */\r
58 \r
59 /*\r
60  * I/O ports initial setup, this configuration is established soon after reset\r
61  * in the initialization code.\r
62  *\r
63  * The digits have the following meaning:\r
64  *   0 - Analog input.\r
65  *   1 - Push Pull output 10MHz.\r
66  *   2 - Push Pull output 2MHz.\r
67  *   3 - Push Pull output 50MHz.\r
68  *   4 - Digital input.\r
69  *   5 - Open Drain output 10MHz.\r
70  *   6 - Open Drain output 2MHz.\r
71  *   7 - Open Drain output 50MHz.\r
72  *   8 - Digital input with PullUp or PullDown resistor depending on ODR.\r
73  *   9 - Alternate Push Pull output 10MHz.\r
74  *   A - Alternate Push Pull output 2MHz.\r
75  *   B - Alternate Push Pull output 50MHz.\r
76  *   C - Reserved.\r
77  *   D - Alternate Open Drain output 10MHz.\r
78  *   E - Alternate Open Drain output 2MHz.\r
79  *   F - Alternate Open Drain output 50MHz.\r
80  * Please refer to the STM32 Reference Manual for details.\r
81  */\r
82 \r
83 /*\r
84  * Port A setup.\r
85  * Everything input with pull-up except:\r
86  * PA2  - Alternate output  (USART2 TX).\r
87  * PA3  - Normal input      (USART2 RX).\r
88  * PA9  - Alternate output  (USART1 TX).\r
89  * PA10 - Normal input      (USART1 RX).\r
90  */\r
91 #define VAL_GPIOACRL            0x88884B88      /*  PA7...PA0 */\r
92 #define VAL_GPIOACRH            0x888884B8      /* PA15...PA8 */\r
93 #define VAL_GPIOAODR            0xFFFFFFFF\r
94 \r
95 /*\r
96  * Port B setup.\r
97  * Everything input with pull-up except:\r
98  * PB10    - Push Pull output  (USB switch).\r
99  */\r
100 #define VAL_GPIOBCRL            0x88888888      /*  PB7...PB0 */\r
101 #define VAL_GPIOBCRH            0x88888388      /* PB15...PB8 */\r
102 #define VAL_GPIOBODR            0xFFFFFFFF\r
103 \r
104 /*\r
105  * Port C setup.\r
106  * Everything input with pull-up except:\r
107  * PC13    - Push Pull output  (LED).\r
108  */\r
109 #define VAL_GPIOCCRL            0x88888888      /*  PC7...PC0 */\r
110 #define VAL_GPIOCCRH            0x88388888      /* PC15...PC8 */\r
111 #define VAL_GPIOCODR            0xFFFFFFFF\r
112 \r
113 /*\r
114  * Port D setup.\r
115  * Everything input with pull-up except:\r
116  * PD0  - Normal input (XTAL).\r
117  * PD1  - Normal input (XTAL).\r
118  */\r
119 #define VAL_GPIODCRL            0x88888844      /*  PD7...PD0 */\r
120 #define VAL_GPIODCRH            0x88888888      /* PD15...PD8 */\r
121 #define VAL_GPIODODR            0xFFFFFFFF\r
122 \r
123 /*\r
124  * Port E setup.\r
125  * Everything input with pull-up except:\r
126  */\r
127 #define VAL_GPIOECRL            0x88888888      /*  PE7...PE0 */\r
128 #define VAL_GPIOECRH            0x88888888      /* PE15...PE8 */\r
129 #define VAL_GPIOEODR            0xFFFFFFFF\r
130 \r
131 /*\r
132  * USB bus activation macro, required by the USB driver.\r
133  */\r
134 /* The point is that most of the generic STM32F103* boards\r
135    have a 1.5k resistor connected on one end to the D+ line\r
136    and on the other end to some pin. Or even a slightly more\r
137    complicated "USB enable" circuit, controlled by a pin.\r
138    That should go here.\r
139 \r
140    However on some boards (e.g. one that I have), there's no\r
141    such hardware. In which case it's better to not do anything.\r
142 */\r
143 /*\r
144 #define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)\r
145 */\r
146 #define usb_lld_connect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_INPUT);\r
147 \r
148 /*\r
149  * USB bus de-activation macro, required by the USB driver.\r
150  */\r
151 /*\r
152 #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)\r
153 */\r
154 #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12);\r
155 \r
156 #if !defined(_FROM_ASM_)\r
157 #ifdef __cplusplus\r
158 extern "C" {\r
159 #endif\r
160   void boardInit(void);\r
161 #ifdef __cplusplus\r
162 }\r
163 #endif\r
164 #endif /* _FROM_ASM_ */\r
165 \r
166 #endif /* _BOARD_H_ */\r