2016-07-23 05:59:54 +00:00
|
|
|
/*! \file bsp_stm32f4-discovery.h
|
|
|
|
* \author tkl
|
|
|
|
* \date Mai 7, 2012
|
|
|
|
* \brief Header file of the board definition for the STM32F4-Discovery board.
|
|
|
|
*/
|
|
|
|
#ifndef BSP_STM32F4_DISCOVERY_H_
|
|
|
|
#define BSP_STM32F4_DISCOVERY_H_
|
|
|
|
|
2016-07-25 13:23:31 +00:00
|
|
|
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
|
|
|
|
|
2016-07-23 05:59:54 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "gpio.h"
|
|
|
|
#include "uart.h"
|
|
|
|
#include "ringbuffer.h"
|
|
|
|
#include "stm32f4xx.h"
|
|
|
|
#include "stm32f4_gpio.h"
|
2016-07-25 13:23:31 +00:00
|
|
|
#include "stm32f4_uart.h"
|
2016-07-23 05:59:54 +00:00
|
|
|
#include "stm32_sys_tick.h"
|
|
|
|
|
2016-07-25 13:23:31 +00:00
|
|
|
#if 0
|
2016-07-23 05:59:54 +00:00
|
|
|
#include "usb_vport.h"
|
2016-07-25 13:23:31 +00:00
|
|
|
#endif
|
2016-07-23 05:59:54 +00:00
|
|
|
|
|
|
|
// SYSTEM TICK
|
|
|
|
static const enum stm32_sys_tick_time_base stm23_sys_tick_time_base =
|
|
|
|
STM32_SYS_TICK_TIME_BASE_MS;
|
|
|
|
static const struct stm32_sys_tick stm32_sys_tick = {
|
|
|
|
&stm23_sys_tick_time_base,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct loki_timer timer_1 = {
|
|
|
|
(void*)&stm32_sys_tick,
|
|
|
|
&timer_fp
|
|
|
|
};
|
|
|
|
|
2016-07-25 13:23:31 +00:00
|
|
|
#if 0
|
2016-07-23 05:59:54 +00:00
|
|
|
// USB
|
2016-07-25 13:23:31 +00:00
|
|
|
static const stm32_usb_vport_t stm32_usb_vport;
|
|
|
|
static const struct uart uart_0 = {
|
|
|
|
&stm32_usb_vport,
|
|
|
|
&usb_vport_fp,
|
|
|
|
&console_buffer
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2016-07-23 05:59:54 +00:00
|
|
|
static char console_linear_buffer[80];
|
|
|
|
static struct ringbuffer console_buffer = {
|
|
|
|
console_linear_buffer,
|
|
|
|
console_linear_buffer,
|
|
|
|
console_linear_buffer,
|
|
|
|
sizeof(console_linear_buffer),
|
|
|
|
0
|
|
|
|
};
|
2016-07-25 13:23:31 +00:00
|
|
|
static const GPIO_InitTypeDef stm32f4_discovery_uart1_gpio = {
|
|
|
|
GPIO_Pin_6 | GPIO_Pin_7,
|
|
|
|
GPIO_Mode_AF,
|
|
|
|
GPIO_Speed_50MHz,
|
|
|
|
GPIO_OType_PP,
|
|
|
|
GPIO_PuPd_UP
|
|
|
|
};
|
|
|
|
|
|
|
|
static const USART_InitTypeDef stm32f4_discovery_uart1_usart_init = {
|
|
|
|
115200,
|
|
|
|
USART_WordLength_8b,
|
|
|
|
USART_StopBits_1,
|
|
|
|
USART_Parity_No,
|
|
|
|
USART_Mode_Tx | USART_Mode_Rx,
|
|
|
|
USART_HardwareFlowControl_None,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const NVIC_InitTypeDef stm32f4_discovery_uart1_nvic_init = {
|
|
|
|
USART1_IRQn,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
ENABLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct stm32f4_uart stm32f4_uart1 = {
|
|
|
|
&stm32f4_discovery_uart1_gpio,
|
|
|
|
GPIOB,
|
|
|
|
GPIO_PinSource7,
|
|
|
|
GPIO_PinSource6,
|
|
|
|
&stm32f4_discovery_uart1_usart_init,
|
|
|
|
USART1,
|
|
|
|
USART_IT_RXNE /* | USART_IT_TXE*/,
|
|
|
|
&stm32f4_discovery_uart1_nvic_init,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct uart uart_1 = {
|
|
|
|
&stm32f4_uart1,
|
|
|
|
&stm32f4_uart_fp,
|
|
|
|
&console_buffer,
|
2016-07-23 05:59:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// STATUS LED
|
|
|
|
//! \brief Status Led is forwarded to led 4.
|
|
|
|
#define led_1 led_4
|
|
|
|
|
|
|
|
// LED 3
|
|
|
|
static const GPIO_InitTypeDef stm32_f4_discovery_led_3_gpio = {
|
|
|
|
GPIO_Pin_12,
|
|
|
|
GPIO_Mode_OUT,
|
|
|
|
GPIO_Speed_100MHz,
|
|
|
|
GPIO_OType_PP,
|
|
|
|
GPIO_PuPd_NOPULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct stm32f4_gpio stm32_f4_discovery_led_3 = {
|
|
|
|
GPIOD,
|
|
|
|
&stm32_f4_discovery_led_3_gpio,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct gpio led_3 = {
|
|
|
|
(void*)&stm32_f4_discovery_led_3,
|
|
|
|
&gpio_fp
|
|
|
|
};
|
|
|
|
|
|
|
|
// LED 4
|
|
|
|
static const GPIO_InitTypeDef stm32_f4_discovery_led_4_gpio = {
|
|
|
|
GPIO_Pin_13,
|
|
|
|
GPIO_Mode_OUT,
|
|
|
|
GPIO_Speed_100MHz,
|
|
|
|
GPIO_OType_PP,
|
|
|
|
GPIO_PuPd_NOPULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct stm32f4_gpio stm32_f4_discovery_led_4 = {
|
|
|
|
GPIOD,
|
|
|
|
&stm32_f4_discovery_led_4_gpio,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct gpio led_4 = {
|
|
|
|
(void*)&stm32_f4_discovery_led_4,
|
|
|
|
&gpio_fp
|
|
|
|
};
|
|
|
|
|
|
|
|
// LED 5
|
|
|
|
static const GPIO_InitTypeDef stm32_f4_discovery_led_5_gpio = {
|
|
|
|
GPIO_Pin_14,
|
|
|
|
GPIO_Mode_OUT,
|
|
|
|
GPIO_Speed_100MHz,
|
|
|
|
GPIO_OType_PP,
|
|
|
|
GPIO_PuPd_NOPULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct stm32f4_gpio stm32_f4_discovery_led_5 = {
|
|
|
|
GPIOD,
|
|
|
|
&stm32_f4_discovery_led_5_gpio,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct gpio led_5 = {
|
|
|
|
(void*)&stm32_f4_discovery_led_5,
|
|
|
|
&gpio_fp
|
|
|
|
};
|
|
|
|
|
|
|
|
// LED 6
|
|
|
|
static const GPIO_InitTypeDef stm32_f4_discovery_led_6_gpio = {
|
|
|
|
GPIO_Pin_15,
|
|
|
|
GPIO_Mode_OUT,
|
|
|
|
GPIO_Speed_100MHz,
|
|
|
|
GPIO_OType_PP,
|
|
|
|
GPIO_PuPd_NOPULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct stm32f4_gpio stm32_f4_discovery_led_6 = {
|
|
|
|
GPIOD,
|
|
|
|
&stm32_f4_discovery_led_6_gpio,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct gpio led_6 = {
|
|
|
|
(void*)&stm32_f4_discovery_led_6,
|
|
|
|
&gpio_fp
|
|
|
|
};
|
|
|
|
|
|
|
|
// BUTTON
|
|
|
|
static const GPIO_InitTypeDef stm32_f4_discovery_user_button_gpio = {
|
|
|
|
GPIO_Pin_0,
|
|
|
|
GPIO_Mode_IN,
|
|
|
|
GPIO_Speed_100MHz,
|
|
|
|
GPIO_OType_PP,
|
|
|
|
GPIO_PuPd_NOPULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const EXTI_InitTypeDef stm32_f4_discovery_user_button_exti = {
|
|
|
|
EXTI_Line0,
|
|
|
|
EXTI_Mode_Interrupt,
|
|
|
|
EXTI_Trigger_Rising_Falling,
|
|
|
|
ENABLE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const NVIC_InitTypeDef stm32_f4_discovery_user_button_nvic = {
|
|
|
|
EXTI0_IRQn,
|
|
|
|
0x0F,
|
|
|
|
0x0F,
|
|
|
|
ENABLE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct stm32f4_gpio stm32_f4_discovery_user_button = {
|
|
|
|
GPIOA,
|
|
|
|
&stm32_f4_discovery_user_button_gpio,
|
|
|
|
&stm32_f4_discovery_user_button_exti,
|
|
|
|
&stm32_f4_discovery_user_button_nvic,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct gpio user_button = {
|
|
|
|
(void*)&stm32_f4_discovery_user_button,
|
|
|
|
&gpio_fp
|
|
|
|
};
|
|
|
|
|
|
|
|
//! \brief Setup the hardware of the stm32f4-discovery board.
|
|
|
|
void board_init(void);
|
|
|
|
|
|
|
|
#endif /* BSP_STM32F4_DISCOVERY_H_ */
|