kosmos/source/firmware/arch/stm32f4xx/board/stm32f4-discovery/include/stm32f4-discovery.h

420 lines
8.0 KiB
C
Raw Normal View History

2016-07-28 19:02:54 +00:00
/*! \file 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_
#include <stddef.h>
#include <stdint.h>
2016-08-15 20:25:35 +00:00
#if 0
#include "../../../../../kernel/include/sys_tick.h"
#include "../../../driver/include/stm32_sys_tick.h"
#include "../../../driver/include/stm32f4_pwm.h"
#include "../../../driver/include/stm32f4_uart.h"
2016-08-09 10:35:56 +00:00
#include "pwm.h"
2016-07-28 19:02:54 +00:00
#include "timer.h"
#include "uart.h"
#include "ringbuffer.h"
2016-08-15 20:25:35 +00:00
#endif
2016-07-28 19:02:54 +00:00
#include "stm32f4xx.h"
2016-08-15 20:25:35 +00:00
#include "gpio.h"
2016-07-28 19:02:54 +00:00
#include "stm32f4_gpio.h"
2016-08-15 20:25:35 +00:00
#include "driver.h"
2016-07-28 19:02:54 +00:00
2016-08-15 20:25:35 +00:00
// GPIO_D12
static const GPIO_InitTypeDef port_cfg_d12 = {
.Pin = GPIO_PIN_12,
.Mode = GPIO_MODE_OUTPUT_PP,
.Speed = GPIO_SPEED_FREQ_HIGH,
.Pull = GPIO_PULLUP,
};
2016-08-09 10:35:56 +00:00
2016-08-15 20:25:35 +00:00
static const struct stm32f4_gpio stm32_f4_gpio_d12 = {
.port = GPIOD,
.pin = &port_cfg_d12,
};
static const struct gpio __gpio_d12 = {
(void*)&stm32_f4_gpio_d12,
&gpio_fp
};
const struct driver gpio_d12 = {
DRIVER_TYPE_GPIO,
&__gpio_d12,
};
#if 0
2016-07-28 19:02: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-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-09 10:35:56 +00:00
// PWM CHANNEL 4
/* apb1 clock = 84MHz */
/* period_reg = src_clk / presc / cnt_clk */
/* 4199 = 84MHZ / (0 + 1) / 20kHz - 1 */
static const TIM_TimeBaseInitTypeDef timer_4_cfg = {
.TIM_RepetitionCounter = 0x0000,
.TIM_Prescaler = 0,
.TIM_ClockDivision = TIM_CKD_DIV1,
.TIM_CounterMode = TIM_CounterMode_Up,
.TIM_Period = 4199
};
static const TIM_OCInitTypeDef t4_output_compare_cfg = {
.TIM_OutputNState = TIM_OutputNState_Disable,
.TIM_OCNPolarity = TIM_OCPolarity_High,
.TIM_OCIdleState = TIM_OCIdleState_Reset,
.TIM_OCNIdleState = TIM_OCNIdleState_Set,
.TIM_OCMode = TIM_OCMode_PWM1,
.TIM_OCPolarity = TIM_OCPolarity_High,
.TIM_OutputState = TIM_OutputState_Enable,
2016-08-09 10:52:38 +00:00
.TIM_Pulse = 0,
2016-08-09 10:35:56 +00:00
};
2016-08-10 09:31:49 +00:00
static const GPIO_InitTypeDef port_cfg_D15 = {
2016-08-09 10:35:56 +00:00
.GPIO_Pin = GPIO_Pin_15,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP,
.GPIO_Speed = GPIO_Speed_100MHz,
};
2016-08-10 09:31:49 +00:00
static struct stm32f4_pwm str32f4_pwm_4 = {
2016-08-09 10:35:56 +00:00
.timer = TIM4,
.timer_cfg = &timer_4_cfg,
.output_compare_cfg = &t4_output_compare_cfg,
.port = GPIOD,
.pin_src = GPIO_PinSource15,
2016-08-10 09:31:49 +00:00
.port_cfg = &port_cfg_D15,
2016-08-09 10:35:56 +00:00
.channel = channel_4,
};
static const struct pwm pwm_ch4 = {
2016-08-10 09:31:49 +00:00
.arch_dep_device = &str32f4_pwm_4,
2016-08-09 10:35:56 +00:00
.fp = &stm32f4_pwm_fp,
};
2016-08-09 10:52:38 +00:00
#ifdef TEST_APP
static const struct driver pwm_4 = {
#else
const struct driver pwm_4 = {
#endif
DRIVER_TYPE_PWM,
&pwm_ch4,
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-10 09:31:49 +00:00
// PWM Channel 3
static const GPIO_InitTypeDef port_cfg_D14 = {
.GPIO_Pin = GPIO_Pin_14,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP,
.GPIO_Speed = GPIO_Speed_100MHz,
};
static struct stm32f4_pwm str32f4_pwm_3 = {
.timer = TIM4,
.timer_cfg = &timer_4_cfg,
.output_compare_cfg = &t4_output_compare_cfg,
.port = GPIOD,
.pin_src = GPIO_PinSource14,
.port_cfg = &port_cfg_D14,
.channel = channel_3,
};
static const struct pwm pwm_ch3 = {
.arch_dep_device = &str32f4_pwm_3,
.fp = &stm32f4_pwm_fp,
};
#ifdef TEST_APP
static const struct driver pwm_3 = {
#else
const struct driver pwm_3 = {
#endif
DRIVER_TYPE_PWM,
&pwm_ch3,
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-10 09:31:49 +00:00
// PWM Channel 2
static const GPIO_InitTypeDef port_cfg_D13 = {
.GPIO_Pin = GPIO_Pin_13,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP,
.GPIO_Speed = GPIO_Speed_100MHz,
};
static struct stm32f4_pwm str32f4_pwm_2 = {
.timer = TIM4,
.timer_cfg = &timer_4_cfg,
.output_compare_cfg = &t4_output_compare_cfg,
.port = GPIOD,
.pin_src = GPIO_PinSource13,
.port_cfg = &port_cfg_D13,
.channel = channel_2,
};
static const struct pwm pwm_ch2 = {
.arch_dep_device = &str32f4_pwm_2,
.fp = &stm32f4_pwm_fp,
};
#ifdef TEST_APP
static const struct driver pwm_2 = {
#else
const struct driver pwm_2 = {
#endif
DRIVER_TYPE_PWM,
&pwm_ch2,
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
// PWM Channel 1
2016-08-10 09:31:49 +00:00
static const GPIO_InitTypeDef port_cfg_D12 = {
.GPIO_Pin = GPIO_Pin_12,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP,
.GPIO_Speed = GPIO_Speed_100MHz,
};
static struct stm32f4_pwm str32f4_pwm_1 = {
.timer = TIM4,
.timer_cfg = &timer_4_cfg,
.output_compare_cfg = &t4_output_compare_cfg,
.port = GPIOD,
.pin_src = GPIO_PinSource12,
.port_cfg = &port_cfg_D12,
.channel = channel_1,
};
static const struct pwm pwm_ch1 = {
.arch_dep_device = &str32f4_pwm_1,
.fp = &stm32f4_pwm_fp,
};
#ifdef TEST_APP
static const struct driver pwm_1 = {
#else
const struct driver pwm_1 = {
#endif
DRIVER_TYPE_PWM,
&pwm_ch1,
2016-08-10 09:31:49 +00:00
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-09 10:35:56 +00:00
// UART 1
2016-07-28 19:02: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
};
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-08-02 12:10:11 +00:00
#ifdef TEST_APP
static const struct driver uart_1 = {
#else
2016-07-28 19:02:54 +00:00
const struct driver uart_1 = {
2016-08-02 12:10:11 +00:00
#endif
2016-07-28 19:02:54 +00:00
DRIVER_TYPE_UART,
&__uart_1,
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-10 09:31:49 +00:00
// GPIOC0
static const GPIO_InitTypeDef port_cfg_C0 = {
GPIO_Pin_0,
2016-07-28 19:02:54 +00:00
GPIO_Mode_OUT,
GPIO_Speed_100MHz,
GPIO_OType_PP,
GPIO_PuPd_NOPULL
};
2016-08-10 09:31:49 +00:00
static const struct stm32f4_gpio stm32_f4_gpio_C0 = {
GPIOC,
&port_cfg_C0,
2016-07-28 19:02:54 +00:00
NULL,
NULL,
NULL,
NULL
};
2016-08-10 09:31:49 +00:00
static const struct gpio __gpio_c0 = {
(void*)&stm32_f4_gpio_C0,
2016-07-28 19:02:54 +00:00
&gpio_fp
};
#ifdef TEST_APP
2016-08-10 09:31:49 +00:00
static const struct driver gpio_c0 = {
#else
2016-08-10 09:31:49 +00:00
const struct driver gpio_c0 = {
#endif
2016-07-28 19:02:54 +00:00
DRIVER_TYPE_GPIO,
2016-08-10 09:31:49 +00:00
&__gpio_c0,
2016-07-28 19:02:54 +00:00
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-10 09:31:49 +00:00
// GPIO_C1
static const GPIO_InitTypeDef port_cfg_C1 = {
GPIO_Pin_1,
2016-07-28 19:02:54 +00:00
GPIO_Mode_OUT,
GPIO_Speed_100MHz,
GPIO_OType_PP,
GPIO_PuPd_NOPULL
};
2016-08-10 09:31:49 +00:00
static const struct stm32f4_gpio stm32_f4_gpio_C1 = {
GPIOC,
&port_cfg_C1,
2016-07-28 19:02:54 +00:00
NULL,
NULL,
NULL,
NULL
};
2016-08-10 09:31:49 +00:00
static const struct gpio __gpio_c1 = {
(void*)&stm32_f4_gpio_C1,
2016-07-28 19:02:54 +00:00
&gpio_fp
};
2016-08-02 12:10:11 +00:00
#ifdef TEST_APP
2016-08-10 09:31:49 +00:00
static const struct driver gpio_c1 = {
2016-08-02 12:10:11 +00:00
#else
2016-08-10 09:31:49 +00:00
const struct driver gpio_c1 = {
2016-08-02 12:10:11 +00:00
#endif
2016-07-28 19:02:54 +00:00
DRIVER_TYPE_GPIO,
2016-08-10 09:31:49 +00:00
&__gpio_c1,
2016-07-28 19:02:54 +00:00
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-10 09:31:49 +00:00
// GPIO_C2
static const GPIO_InitTypeDef port_cfg_C2 = {
GPIO_Pin_2,
2016-07-28 19:02:54 +00:00
GPIO_Mode_OUT,
GPIO_Speed_100MHz,
GPIO_OType_PP,
GPIO_PuPd_NOPULL
};
2016-08-10 09:31:49 +00:00
static const struct stm32f4_gpio stm32_f4_gpio_C2 = {
GPIOC,
&port_cfg_C2,
2016-07-28 19:02:54 +00:00
NULL,
NULL,
NULL,
NULL
};
2016-08-10 09:31:49 +00:00
static const struct gpio __gpio_c2 = {
(void*)&stm32_f4_gpio_C2,
2016-07-28 19:02:54 +00:00
&gpio_fp
};
2016-08-02 12:10:11 +00:00
#ifdef TEST_APP
2016-08-10 09:31:49 +00:00
static const struct driver gpio_c2 = {
2016-08-02 12:10:11 +00:00
#else
2016-08-10 09:31:49 +00:00
const struct driver gpio_c2 = {
2016-08-02 12:10:11 +00:00
#endif
2016-07-28 19:02:54 +00:00
DRIVER_TYPE_GPIO,
2016-08-10 09:31:49 +00:00
&__gpio_c2,
2016-07-28 19:02:54 +00:00
};
2016-08-15 20:25:35 +00:00
#endif
#if 0
2016-08-10 09:31:49 +00:00
// GPIO_C3
static const GPIO_InitTypeDef port_cfg_C3 = {
GPIO_Pin_3,
2016-07-28 19:02:54 +00:00
GPIO_Mode_OUT,
GPIO_Speed_100MHz,
GPIO_OType_PP,
GPIO_PuPd_NOPULL
};
2016-08-10 09:31:49 +00:00
static const struct stm32f4_gpio stm32_f4_gpio_C3 = {
GPIOC,
&port_cfg_C3,
2016-07-28 19:02:54 +00:00
NULL,
NULL,
NULL,
NULL
};
2016-08-10 09:31:49 +00:00
static const struct gpio __gpio_c3 = {
(void*)&stm32_f4_gpio_C3,
2016-07-28 19:02:54 +00:00
&gpio_fp
};
2016-08-02 12:10:11 +00:00
#ifdef TEST_APP
2016-08-10 09:31:49 +00:00
static const struct driver gpio_c3 = {
2016-08-02 12:10:11 +00:00
#else
2016-08-10 09:31:49 +00:00
const struct driver gpio_c3 = {
2016-08-02 12:10:11 +00:00
#endif
2016-07-28 19:02:54 +00:00
DRIVER_TYPE_GPIO,
2016-08-10 09:31:49 +00:00
&__gpio_c3,
2016-07-28 19:02:54 +00:00
};
2016-08-15 20:25:35 +00:00
#endif
2016-07-28 19:02:54 +00:00
//! \brief Setup the hardware of the stm32f4-discovery board.
void board_init(void);
#endif /* BSP_STM32F4_DISCOVERY_H_ */