qmk

QMK Firmware
git clone git://git.z3bra.org/qmk.git
Log | Files | Refs | Submodules | LICENSE

board.h (4738B)


      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 STM32F103 board.
     22  */
     23 
     24 /*
     25  * Board identifier.
     26  */
     27 #define BOARD_GENERIC_STM32_F103
     28 #define BOARD_NAME              "Generic STM32F103x board"
     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 STM32F103xB
     40 
     41 /*
     42  * IO pins assignments
     43  */
     44 
     45 /* on-board */
     46 
     47 #define GPIOA_LED               8
     48 #define GPIOD_OSC_IN            0
     49 #define GPIOD_OSC_OUT           1
     50 
     51 /* In case your board has a "USB enable" hardware
     52    controlled by a pin, define it here. (It could be just
     53    a 1.5k resistor connected to D+ line.)
     54 */
     55 /*
     56 #define GPIOB_USB_DISC          10
     57 */
     58 
     59 /*
     60  * I/O ports initial setup, this configuration is established soon after reset
     61  * in the initialization code.
     62  *
     63  * The digits have the following meaning:
     64  *   0 - Analog input.
     65  *   1 - Push Pull output 10MHz.
     66  *   2 - Push Pull output 2MHz.
     67  *   3 - Push Pull output 50MHz.
     68  *   4 - Digital input.
     69  *   5 - Open Drain output 10MHz.
     70  *   6 - Open Drain output 2MHz.
     71  *   7 - Open Drain output 50MHz.
     72  *   8 - Digital input with PullUp or PullDown resistor depending on ODR.
     73  *   9 - Alternate Push Pull output 10MHz.
     74  *   A - Alternate Push Pull output 2MHz.
     75  *   B - Alternate Push Pull output 50MHz.
     76  *   C - Reserved.
     77  *   D - Alternate Open Drain output 10MHz.
     78  *   E - Alternate Open Drain output 2MHz.
     79  *   F - Alternate Open Drain output 50MHz.
     80  * Please refer to the STM32 Reference Manual for details.
     81  */
     82 
     83 /*
     84  * Port A setup.
     85  * Everything input with pull-up except:
     86  * PA2  - Alternate output  (USART2 TX).
     87  * PA3  - Normal input      (USART2 RX).
     88  * PA9  - Alternate output  (USART1 TX).
     89  * PA10 - Normal input      (USART1 RX).
     90  */
     91 #define VAL_GPIOACRL            0x88884B88      /*  PA7...PA0 */
     92 #define VAL_GPIOACRH            0x888884B8      /* PA15...PA8 */
     93 #define VAL_GPIOAODR            0xFFFFFFFF
     94 
     95 /*
     96  * Port B setup.
     97  * Everything input with pull-up except:
     98  * PB10    - Push Pull output  (USB switch).
     99  */
    100 #define VAL_GPIOBCRL            0x88888888      /*  PB7...PB0 */
    101 #define VAL_GPIOBCRH            0x88888388      /* PB15...PB8 */
    102 #define VAL_GPIOBODR            0xFFFFFFFF
    103 
    104 /*
    105  * Port C setup.
    106  * Everything input with pull-up except:
    107  * PC13    - Push Pull output  (LED).
    108  */
    109 #define VAL_GPIOCCRL            0x88888888      /*  PC7...PC0 */
    110 #define VAL_GPIOCCRH            0x88388888      /* PC15...PC8 */
    111 #define VAL_GPIOCODR            0xFFFFFFFF
    112 
    113 /*
    114  * Port D setup.
    115  * Everything input with pull-up except:
    116  * PD0  - Normal input (XTAL).
    117  * PD1  - Normal input (XTAL).
    118  */
    119 #define VAL_GPIODCRL            0x88888844      /*  PD7...PD0 */
    120 #define VAL_GPIODCRH            0x88888888      /* PD15...PD8 */
    121 #define VAL_GPIODODR            0xFFFFFFFF
    122 
    123 /*
    124  * Port E setup.
    125  * Everything input with pull-up except:
    126  */
    127 #define VAL_GPIOECRL            0x88888888      /*  PE7...PE0 */
    128 #define VAL_GPIOECRH            0x88888888      /* PE15...PE8 */
    129 #define VAL_GPIOEODR            0xFFFFFFFF
    130 
    131 /*
    132  * USB bus activation macro, required by the USB driver.
    133  */
    134 /* The point is that most of the generic STM32F103* boards
    135    have a 1.5k resistor connected on one end to the D+ line
    136    and on the other end to some pin. Or even a slightly more
    137    complicated "USB enable" circuit, controlled by a pin.
    138    That should go here.
    139 
    140    However on some boards (e.g. one that I have), there's no
    141    such hardware. In which case it's better to not do anything.
    142 */
    143 /*
    144 #define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)
    145 */
    146 #define usb_lld_connect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_INPUT);
    147 
    148 /*
    149  * USB bus de-activation macro, required by the USB driver.
    150  */
    151 /*
    152 #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)
    153 */
    154 #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12);
    155 
    156 #if !defined(_FROM_ASM_)
    157 #ifdef __cplusplus
    158 extern "C" {
    159 #endif
    160   void boardInit(void);
    161 #ifdef __cplusplus
    162 }
    163 #endif
    164 #endif /* _FROM_ASM_ */
    165 
    166 #endif /* _BOARD_H_ */