2011-06-11 10:49:51 +00:00
|
|
|
/*
|
|
|
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
2012-01-21 14:29:42 +00:00
|
|
|
2011,2012 Giovanni Di Sirio.
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
This file is part of ChibiOS/RT.
|
|
|
|
|
|
|
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BOARD_H_
|
|
|
|
#define _BOARD_H_
|
|
|
|
|
|
|
|
/*
|
2011-11-02 17:36:00 +00:00
|
|
|
* Setup for STMicroelectronics STM32L-Discovery board.
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Board identifier.
|
|
|
|
*/
|
2011-11-02 17:36:00 +00:00
|
|
|
#define BOARD_ST_STM32L_DISCOVERY
|
2011-06-14 08:10:38 +00:00
|
|
|
#define BOARD_NAME "ST STM32L-Discovery"
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Board frequencies.
|
2011-06-14 08:10:38 +00:00
|
|
|
* NOTE: The HSE crystal is not fitted by default on the board.
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
|
|
|
#define STM32_LSECLK 32768
|
2011-09-18 10:18:17 +00:00
|
|
|
#define STM32_HSECLK 8000000
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
2011-06-14 08:10:38 +00:00
|
|
|
* MCU type as defined in the ST header file stm32l1xx.h.
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
2011-06-14 08:10:38 +00:00
|
|
|
#define STM32L1XX_MD
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IO pins assignments.
|
|
|
|
*/
|
|
|
|
#define GPIOA_BUTTON 0
|
|
|
|
|
2011-06-14 08:10:38 +00:00
|
|
|
#define GPIOB_LED4 6
|
|
|
|
#define GPIOB_LED3 7
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* I/O ports initial setup, this configuration is established soon after reset
|
|
|
|
* in the initialization code.
|
|
|
|
* Please refer to the STM32 Reference Manual for details.
|
|
|
|
*/
|
2011-10-15 13:24:40 +00:00
|
|
|
#define PIN_MODE_INPUT(n) (0U << ((n) * 2))
|
|
|
|
#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2))
|
|
|
|
#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2))
|
|
|
|
#define PIN_MODE_ANALOG(n) (3U << ((n) * 2))
|
|
|
|
#define PIN_OTYPE_PUSHPULL(n) (0U << (n))
|
|
|
|
#define PIN_OTYPE_OPENDRAIN(n) (1U << (n))
|
|
|
|
#define PIN_OSPEED_400K(n) (0U << ((n) * 2))
|
|
|
|
#define PIN_OSPEED_2M(n) (1U << ((n) * 2))
|
|
|
|
#define PIN_OSPEED_10M(n) (2U << ((n) * 2))
|
|
|
|
#define PIN_OSPEED_40M(n) (3U << ((n) * 2))
|
|
|
|
#define PIN_PUDR_FLOATING(n) (0U << ((n) * 2))
|
|
|
|
#define PIN_PUDR_PULLUP(n) (1U << ((n) * 2))
|
|
|
|
#define PIN_PUDR_PULLDOWN(n) (2U << ((n) * 2))
|
2011-12-03 07:46:27 +00:00
|
|
|
#define PIN_AFIO_AF(n, v) ((v##U) << ((n % 8) * 4))
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Port A setup.
|
2011-06-19 10:45:38 +00:00
|
|
|
* All input with pull-up except:
|
|
|
|
* PA0 - GPIOA_BUTTON (input floating).
|
|
|
|
* PA13 - JTMS/SWDAT (alternate 0).
|
|
|
|
* PA14 - JTCK/SWCLK (alternate 0).
|
|
|
|
* PA15 - JTDI (alternate 0).
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
2011-06-19 10:45:38 +00:00
|
|
|
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON) | \
|
2011-09-17 08:45:43 +00:00
|
|
|
PIN_MODE_INPUT(1) | \
|
|
|
|
PIN_MODE_INPUT(2) | \
|
|
|
|
PIN_MODE_INPUT(3) | \
|
|
|
|
PIN_MODE_INPUT(4) | \
|
|
|
|
PIN_MODE_INPUT(5) | \
|
|
|
|
PIN_MODE_INPUT(6) | \
|
|
|
|
PIN_MODE_INPUT(7) | \
|
|
|
|
PIN_MODE_INPUT(8) | \
|
|
|
|
PIN_MODE_INPUT(9) | \
|
|
|
|
PIN_MODE_INPUT(10) | \
|
|
|
|
PIN_MODE_INPUT(11) | \
|
|
|
|
PIN_MODE_INPUT(12) | \
|
2011-06-19 10:45:38 +00:00
|
|
|
PIN_MODE_ALTERNATE(13) | \
|
|
|
|
PIN_MODE_ALTERNATE(14) | \
|
|
|
|
PIN_MODE_ALTERNATE(15))
|
|
|
|
#define VAL_GPIOA_OTYPER 0x00000000
|
|
|
|
#define VAL_GPIOA_OSPEEDR 0xFFFFFFFF
|
2011-09-17 08:45:43 +00:00
|
|
|
#define VAL_GPIOA_PUPDR (PIN_PUDR_PULLUP(GPIOA_BUTTON) | \
|
|
|
|
PIN_PUDR_PULLUP(1) | \
|
|
|
|
PIN_PUDR_PULLUP(2) | \
|
|
|
|
PIN_PUDR_PULLUP(3) | \
|
|
|
|
PIN_PUDR_PULLUP(4) | \
|
|
|
|
PIN_PUDR_PULLUP(5) | \
|
|
|
|
PIN_PUDR_PULLUP(6) | \
|
|
|
|
PIN_PUDR_PULLUP(7) | \
|
|
|
|
PIN_PUDR_PULLUP(8) | \
|
|
|
|
PIN_PUDR_PULLUP(9) | \
|
|
|
|
PIN_PUDR_PULLUP(10) | \
|
|
|
|
PIN_PUDR_PULLUP(11) | \
|
|
|
|
PIN_PUDR_PULLUP(12) | \
|
|
|
|
PIN_PUDR_FLOATING(13) | \
|
|
|
|
PIN_PUDR_FLOATING(14) | \
|
|
|
|
PIN_PUDR_FLOATING(15))
|
2011-06-19 10:45:38 +00:00
|
|
|
#define VAL_GPIOA_ODR 0xFFFFFFFF
|
2011-09-17 06:48:56 +00:00
|
|
|
#define VAL_GPIOA_AFRL 0x00000000
|
|
|
|
#define VAL_GPIOA_AFRH 0x00000000
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Port B setup.
|
2011-06-19 10:45:38 +00:00
|
|
|
* All input with pull-up except:
|
|
|
|
* PB3 - JTDO (alternate 0).
|
|
|
|
* PB4 - JNTRST (alternate 0).
|
|
|
|
* PB6 - GPIOB_LED4 (output push-pull).
|
|
|
|
* PB7 - GPIOB_LED3 (output push-pull).
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
2011-09-17 08:45:43 +00:00
|
|
|
#define VAL_GPIOB_MODER (PIN_MODE_INPUT(0) | \
|
|
|
|
PIN_MODE_INPUT(1) | \
|
|
|
|
PIN_MODE_INPUT(2) | \
|
|
|
|
PIN_MODE_ALTERNATE(3) | \
|
2011-06-19 10:45:38 +00:00
|
|
|
PIN_MODE_ALTERNATE(4) | \
|
2011-09-17 08:45:43 +00:00
|
|
|
PIN_MODE_INPUT(5) | \
|
2011-06-19 10:45:38 +00:00
|
|
|
PIN_MODE_OUTPUT(GPIOB_LED4) | \
|
2011-09-17 08:45:43 +00:00
|
|
|
PIN_MODE_OUTPUT(GPIOB_LED3) | \
|
|
|
|
PIN_MODE_INPUT(8) | \
|
|
|
|
PIN_MODE_INPUT(9) | \
|
|
|
|
PIN_MODE_INPUT(10) | \
|
|
|
|
PIN_MODE_INPUT(11) | \
|
|
|
|
PIN_MODE_INPUT(12) | \
|
|
|
|
PIN_MODE_INPUT(13) | \
|
|
|
|
PIN_MODE_INPUT(14) | \
|
|
|
|
PIN_MODE_INPUT(15))
|
2011-06-19 10:45:38 +00:00
|
|
|
#define VAL_GPIOB_OTYPER 0x00000000
|
|
|
|
#define VAL_GPIOB_OSPEEDR 0xFFFFFFFF
|
2011-09-17 08:45:43 +00:00
|
|
|
#define VAL_GPIOB_PUPDR (PIN_PUDR_PULLUP(0) | \
|
|
|
|
PIN_PUDR_PULLUP(1) | \
|
|
|
|
PIN_PUDR_PULLUP(2) | \
|
|
|
|
PIN_PUDR_FLOATING(3) | \
|
|
|
|
PIN_PUDR_FLOATING(4) | \
|
|
|
|
PIN_PUDR_PULLUP(5) | \
|
|
|
|
PIN_PUDR_FLOATING(GPIOB_LED4) | \
|
|
|
|
PIN_PUDR_FLOATING(GPIOB_LED3) | \
|
|
|
|
PIN_PUDR_PULLUP(8) | \
|
|
|
|
PIN_PUDR_PULLUP(9) | \
|
|
|
|
PIN_PUDR_PULLUP(10) | \
|
|
|
|
PIN_PUDR_PULLUP(11) | \
|
|
|
|
PIN_PUDR_PULLUP(12) | \
|
|
|
|
PIN_PUDR_PULLUP(13) | \
|
|
|
|
PIN_PUDR_PULLUP(14) | \
|
|
|
|
PIN_PUDR_PULLUP(15))
|
2011-06-19 14:41:33 +00:00
|
|
|
#define VAL_GPIOB_ODR 0xFFFFFF3F
|
2011-09-17 06:48:56 +00:00
|
|
|
#define VAL_GPIOB_AFRL 0x00000000
|
|
|
|
#define VAL_GPIOB_AFRH 0x00000000
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Port C setup.
|
2011-06-19 10:45:38 +00:00
|
|
|
* All input with pull-up except:
|
|
|
|
* PC13 - OSC32_OUT (input floating).
|
|
|
|
* PC14 - OSC32_IN (input floating).
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
2011-06-19 10:45:38 +00:00
|
|
|
#define VAL_GPIOC_MODER 0x00000000
|
|
|
|
#define VAL_GPIOC_OTYPER 0x00000000
|
|
|
|
#define VAL_GPIOC_OSPEEDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOC_PUPDR (~(PIN_PUDR_FLOATING(15) | \
|
|
|
|
PIN_PUDR_FLOATING(14)))
|
|
|
|
#define VAL_GPIOC_ODR 0xFFFFFFFF
|
2011-09-17 06:48:56 +00:00
|
|
|
#define VAL_GPIOC_AFRL 0x00000000
|
|
|
|
#define VAL_GPIOC_AFRH 0x00000000
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Port D setup.
|
2011-06-19 10:45:38 +00:00
|
|
|
* All input with pull-up.
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
2011-06-19 10:45:38 +00:00
|
|
|
#define VAL_GPIOD_MODER 0x00000000
|
|
|
|
#define VAL_GPIOD_OTYPER 0x00000000
|
|
|
|
#define VAL_GPIOD_OSPEEDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOD_PUPDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOD_ODR 0xFFFFFFFF
|
2011-09-17 06:48:56 +00:00
|
|
|
#define VAL_GPIOD_AFRL 0x00000000
|
|
|
|
#define VAL_GPIOD_AFRH 0x00000000
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Port E setup.
|
2011-06-19 10:45:38 +00:00
|
|
|
* All input with pull-up.
|
2011-06-11 10:49:51 +00:00
|
|
|
*/
|
2011-06-19 10:45:38 +00:00
|
|
|
#define VAL_GPIOE_MODER 0x00000000
|
|
|
|
#define VAL_GPIOE_OTYPER 0x00000000
|
|
|
|
#define VAL_GPIOE_OSPEEDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOE_PUPDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOE_ODR 0xFFFFFFFF
|
2011-09-17 06:48:56 +00:00
|
|
|
#define VAL_GPIOE_AFRL 0x00000000
|
|
|
|
#define VAL_GPIOE_AFRH 0x00000000
|
2011-06-19 10:45:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Port H setup.
|
|
|
|
* All input with pull-up.
|
|
|
|
*/
|
|
|
|
#define VAL_GPIOH_MODER 0x00000000
|
|
|
|
#define VAL_GPIOH_OTYPER 0x00000000
|
|
|
|
#define VAL_GPIOH_OSPEEDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOH_PUPDR 0xFFFFFFFF
|
|
|
|
#define VAL_GPIOH_ODR 0xFFFFFFFF
|
2011-09-17 06:48:56 +00:00
|
|
|
#define VAL_GPIOH_AFRL 0x00000000
|
|
|
|
#define VAL_GPIOH_AFRH 0x00000000
|
2011-06-11 10:49:51 +00:00
|
|
|
|
|
|
|
#if !defined(_FROM_ASM_)
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
void boardInit(void);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* _FROM_ASM_ */
|
|
|
|
|
|
|
|
#endif /* _BOARD_H_ */
|