aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/boards/st_stm32f4discovery
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2015-03-01 15:02:52 -0800
committerbnewbold <bnewbold@robocracy.org>2015-03-03 00:19:07 -0800
commit92728fbd1f92123c92a42fcc36f0fc127011e112 (patch)
treecaa24599aa0a27011e1a3967a523088e64fd5ddf /wirish/boards/st_stm32f4discovery
parent2c2e9ff751d46eac3d9564dfe91ec7734e75e07a (diff)
downloadlibrambutan-stm32f4discovery.tar.gz
librambutan-stm32f4discovery.zip
WIP: board support for STM32F4DISCOVERY (huge F407 chip)stm32f4discovery
Diffstat (limited to 'wirish/boards/st_stm32f4discovery')
-rw-r--r--wirish/boards/st_stm32f4discovery/board.cpp151
-rw-r--r--wirish/boards/st_stm32f4discovery/include/board/board.h95
2 files changed, 246 insertions, 0 deletions
diff --git a/wirish/boards/st_stm32f4discovery/board.cpp b/wirish/boards/st_stm32f4discovery/board.cpp
new file mode 100644
index 0000000..7f46a57
--- /dev/null
+++ b/wirish/boards/st_stm32f4discovery/board.cpp
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2015 Bryan Newbold
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *****************************************************************************/
+
+/**
+ * @file wirish/boards/st_stm32f4discovery/board.cpp
+ * @author Bryan Newbold <bnewbold@robocracy.org>
+ * @brief st_stm32f4discovery board file (based on Maple Native)
+ */
+
+#include <board/board.h>
+
+#include <libmaple/fsmc.h>
+#include <libmaple/gpio.h>
+#include <libmaple/rcc.h>
+#include <libmaple/timer.h>
+
+#include <wirish/wirish_types.h>
+
+static void initSRAMChip(void);
+
+void boardInit(void) {
+ initSRAMChip();
+}
+
+extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {
+
+ /* {gpio_dev, timer_dev, adc_dev, gpio_bit, timer_channel, adc_channel} */
+ /* XXX: haven't filled in timer or ADC info here */
+ {GPIOA, ADC123, TIM5, 0, 1, 0},
+ {GPIOA, NULL, NULL, 1, 0, ADCx},
+ {GPIOA, NULL, NULL, 2, 0, ADCx},
+ {GPIOA, NULL, NULL, 3, 0, ADCx},
+ {GPIOA, NULL, NULL, 4, 0, ADCx},
+ {GPIOA, NULL, NULL, 5, 0, ADCx},
+ {GPIOA, NULL, NULL, 6, 0, ADCx},
+ {GPIOA, NULL, NULL, 7, 0, ADCx},
+ {GPIOA, NULL, NULL, 8, 0, ADCx},
+ {GPIOA, NULL, NULL, 9, 0, ADCx},
+ {GPIOA, NULL, NULL, 10, 0, ADCx},
+ {GPIOA, NULL, NULL, 11, 0, ADCx},
+ {GPIOA, NULL, NULL, 12, 0, ADCx},
+ {GPIOA, NULL, NULL, 13, 0, ADCx},
+ {GPIOA, NULL, NULL, 14, 0, ADCx},
+ {GPIOA, NULL, NULL, 15, 0, ADCx},
+
+ {GPIOB, NULL, NULL, 0, 0, ADCx},
+ {GPIOB, NULL, NULL, 1, 0, ADCx},
+ {GPIOB, NULL, NULL, 2, 0, ADCx},
+ {GPIOB, NULL, NULL, 3, 0, ADCx},
+ {GPIOB, NULL, NULL, 4, 0, ADCx},
+ {GPIOB, NULL, NULL, 5, 0, ADCx},
+ {GPIOB, NULL, NULL, 6, 0, ADCx},
+ {GPIOB, NULL, NULL, 7, 0, ADCx},
+ {GPIOB, NULL, NULL, 8, 0, ADCx},
+ {GPIOB, NULL, NULL, 9, 0, ADCx},
+ {GPIOB, NULL, NULL, 10, 0, ADCx},
+ {GPIOB, NULL, NULL, 11, 0, ADCx},
+ {GPIOB, NULL, NULL, 12, 0, ADCx},
+ {GPIOB, NULL, NULL, 13, 0, ADCx},
+ {GPIOB, NULL, NULL, 14, 0, ADCx},
+ {GPIOB, NULL, NULL, 15, 0, ADCx},
+
+ {GPIOC, NULL, NULL, 0, 0, ADCx},
+ {GPIOC, NULL, NULL, 1, 0, ADCx},
+ {GPIOC, NULL, NULL, 2, 0, ADCx},
+ {GPIOC, NULL, NULL, 3, 0, ADCx},
+ {GPIOC, NULL, NULL, 4, 0, ADCx},
+ {GPIOC, NULL, NULL, 5, 0, ADCx},
+ {GPIOC, NULL, NULL, 6, 0, ADCx},
+ {GPIOC, NULL, NULL, 7, 0, ADCx},
+ {GPIOC, NULL, NULL, 8, 0, ADCx},
+ {GPIOC, NULL, NULL, 9, 0, ADCx},
+ {GPIOC, NULL, NULL, 10, 0, ADCx},
+ {GPIOC, NULL, NULL, 11, 0, ADCx},
+ {GPIOC, NULL, NULL, 12, 0, ADCx},
+ {GPIOC, NULL, NULL, 13, 0, ADCx},
+ {GPIOC, NULL, NULL, 14, 0, ADCx},
+ {GPIOC, NULL, NULL, 15, 0, ADCx},
+
+ {GPIOD, NULL, NULL, 0, 0, ADCx},
+ {GPIOD, NULL, NULL, 1, 0, ADCx},
+ {GPIOD, NULL, NULL, 2, 0, ADCx},
+ {GPIOD, NULL, NULL, 3, 0, ADCx},
+ {GPIOD, NULL, NULL, 4, 0, ADCx},
+ {GPIOD, NULL, NULL, 5, 0, ADCx},
+ {GPIOD, NULL, NULL, 6, 0, ADCx},
+ {GPIOD, NULL, NULL, 7, 0, ADCx},
+ {GPIOD, NULL, NULL, 8, 0, ADCx},
+ {GPIOD, NULL, NULL, 9, 0, ADCx},
+ {GPIOD, NULL, NULL, 10, 0, ADCx},
+ {GPIOD, NULL, NULL, 11, 0, ADCx},
+ {GPIOD, NULL, NULL, 12, 0, ADCx},
+ {GPIOD, NULL, NULL, 13, 0, ADCx},
+ {GPIOD, NULL, NULL, 14, 0, ADCx},
+ {GPIOD, NULL, NULL, 15, 0, ADCx},
+
+ {GPIOE, NULL, NULL, 0, 0, ADCx},
+ {GPIOE, NULL, NULL, 1, 0, ADCx},
+ {GPIOE, NULL, NULL, 2, 0, ADCx},
+ {GPIOE, NULL, NULL, 3, 0, ADCx},
+ {GPIOE, NULL, NULL, 4, 0, ADCx},
+ {GPIOE, NULL, NULL, 5, 0, ADCx},
+ {GPIOE, NULL, NULL, 6, 0, ADCx},
+ {GPIOE, NULL, NULL, 7, 0, ADCx},
+ {GPIOE, NULL, NULL, 8, 0, ADCx},
+ {GPIOE, NULL, NULL, 9, 0, ADCx},
+ {GPIOE, NULL, NULL, 10, 0, ADCx},
+ {GPIOE, NULL, NULL, 11, 0, ADCx},
+ {GPIOE, NULL, NULL, 12, 0, ADCx},
+ {GPIOE, NULL, NULL, 13, 0, ADCx},
+ {GPIOE, NULL, NULL, 14, 0, ADCx},
+ {GPIOE, NULL, NULL, 15, 0, ADCx},
+};
+
+extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {
+ /* XXX: haven't filled in timer or ADC info here */
+};
+
+extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
+ /* XXX: haven't filled in timer or ADC info here */
+};
+
+extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
+ BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN,
+ BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN,
+ /* XXX: haven't filled in timer or ADC info here */
+};
+
diff --git a/wirish/boards/st_stm32f4discovery/include/board/board.h b/wirish/boards/st_stm32f4discovery/include/board/board.h
new file mode 100644
index 0000000..f2dcb27
--- /dev/null
+++ b/wirish/boards/st_stm32f4discovery/include/board/board.h
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2015 Bryan Newbold
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *****************************************************************************/
+
+/**
+ * @file wirish/boards/st_stm32f4discovery/include/board/board.h
+ * @author Bryan Newbold <bnewbold@robocracy.org>
+ * @brief st_stm32f4discovery board file (based on Maple Native)
+ *
+ * See wirish/boards/maple/include/board/board.h for more information
+ * on these definitions.
+ */
+
+#ifndef _BOARD_ST_STM32F4DISCOVERY_H_
+#define _BOARD_ST_STM32F4DISCOVERY_H_
+
+// OSC as MCO from ST-LINK microcontroller at 8 MHz
+#define CYCLES_PER_MICROSECOND 168
+#define SYSTICK_RELOAD_VAL 167999
+
+#define BOARD_LED_PIN PA9
+#define BOARD_BUTTON_PIN PA0
+
+// TODO: Check this
+#define BOARD_NR_USARTS 5
+#define BOARD_USART1_TX_PIN PA9
+#define BOARD_USART1_RX_PIN PA10
+#define BOARD_USART2_TX_PIN PD5
+#define BOARD_USART2_RX_PIN PD6
+#define BOARD_USART3_TX_PIN PD8
+#define BOARD_USART3_RX_PIN PD9
+#define BOARD_UART4_TX_PIN PC10
+#define BOARD_UART4_RX_PIN PC11
+#define BOARD_UART5_TX_PIN PC12
+#define BOARD_UART5_RX_PIN PD2
+
+#define BOARD_NR_SPI 5
+#define BOARD_SPI1_NSS_PIN PA4
+#define BOARD_SPI1_SCK_PIN PA5
+#define BOARD_SPI1_MISO_PIN PA6
+#define BOARD_SPI1_MOSI_PIN PA7
+#define BOARD_SPI2_NSS_PIN PB12
+#define BOARD_SPI2_SCK_PIN PB13
+#define BOARD_SPI2_MISO_PIN PB14
+#define BOARD_SPI2_MOSI_PIN PB15
+#define BOARD_SPI3_NSS_PIN PA15
+#define BOARD_SPI3_MOSI_PIN PB3
+#define BOARD_SPI3_MISO_PIN PB4
+#define BOARD_SPI3_SCK_PIN PB5
+
+#define BOARD_NR_GPIO_PINS (5*16)
+#define BOARD_NR_PWM_PINS 0
+#define BOARD_NR_ADC_PINS 0
+#define BOARD_NR_USED_PINS (5*16)
+#define BOARD_JTMS_SWDIO_PIN PA13
+#define BOARD_JTCK_SWCLK_PIN PA14
+#define BOARD_JTDI_PIN PA15
+#define BOARD_JTDO_PIN PB3
+#define BOARD_NJTRST_PIN PB4
+
+// XXX: is BOARD_USB_DISC PowerOn?
+#define BOARD_USB_DISC_DEV GPIOC
+#define BOARD_USB_DISC_BIT 0
+
+enum {
+ PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15,
+ PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15,
+ PC0,PC1,PC2,PC3,PC4,PC5,PC6,PC7,PC8,PC9,PC10,PC11,PC12,PC13,PC14,PC15,
+ PD0,PD1,PD2,PD3,PD4,PD5,PD6,PD7,PD8,PD9,PD10,PD11,PD12,PD13,PD14,PD15,
+ PE0,PE1,PE2,PE3,PE4,PE5,PE6,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15,
+};
+
+#endif