mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 13:55:40 +08:00
[boards] stm32f4_discovery board file for some testing
This commit is contained in:
Executable
+236
@@ -0,0 +1,236 @@
|
||||
#ifndef CONFIG_STM32F4_DISCOVERY_H
|
||||
#define CONFIG_STM32F4_DISCOVERY_H
|
||||
|
||||
#define BOARD_STM32F4_DISCOVERY
|
||||
|
||||
/* STM32F4_DISCOVERY has a 8MHz external clock and 168MHz internal. */
|
||||
#define EXT_CLK 8000000
|
||||
#define AHB_CLK 168000000
|
||||
|
||||
/*
|
||||
* Onboard LEDs
|
||||
*/
|
||||
|
||||
/* orange, on PD13 */
|
||||
#ifndef USE_LED_3
|
||||
#define USE_LED_3 1
|
||||
#endif
|
||||
#define LED_3_GPIO GPIOD
|
||||
#define LED_3_GPIO_CLK RCC_AHB1ENR_IOPDEN
|
||||
#define LED_3_GPIO_PIN GPIO13
|
||||
#define LED_3_AFIO_REMAP ((void)0)
|
||||
#define LED_3_GPIO_ON gpio_set
|
||||
#define LED_3_GPIO_OFF gpio_clear
|
||||
|
||||
/* green, on PD12 */
|
||||
#ifndef USE_LED_4
|
||||
#define USE_LED_4 1
|
||||
#endif
|
||||
#define LED_4_GPIO GPIOD
|
||||
#define LED_4_GPIO_CLK RCC_AHB1ENR_IOPDEN
|
||||
#define LED_4_GPIO_PIN GPIO12
|
||||
#define LED_4_AFIO_REMAP ((void)0)
|
||||
#define LED_4_GPIO_ON gpio_set
|
||||
#define LED_4_GPIO_OFF gpio_clear
|
||||
|
||||
/* red, PD14 */
|
||||
#ifndef USE_LED_5
|
||||
#define USE_LED_5 1
|
||||
#endif
|
||||
#define LED_5_GPIO GPIOD
|
||||
#define LED_5_GPIO_CLK RCC_AHB1ENR_IOPDEN
|
||||
#define LED_5_GPIO_PIN GPIO14
|
||||
#define LED_5_AFIO_REMAP ((void)0)
|
||||
#define LED_5_GPIO_ON gpio_set
|
||||
#define LED_5_GPIO_OFF gpio_clear
|
||||
|
||||
/* blue, PD15 */
|
||||
#ifndef USE_LED_6
|
||||
#define USE_LED_6 1
|
||||
#endif
|
||||
#define LED_6_GPIO GPIOD
|
||||
#define LED_6_GPIO_CLK RCC_AHB1ENR_IOPDEN
|
||||
#define LED_6_GPIO_PIN GPIO15
|
||||
#define LED_6_AFIO_REMAP ((void)0)
|
||||
#define LED_6_GPIO_ON gpio_set
|
||||
#define LED_6_GPIO_OFF gpio_clear
|
||||
|
||||
|
||||
/* UART */
|
||||
#define UART1_GPIO_AF GPIO_AF7
|
||||
#define UART1_GPIO_PORT_RX GPIOA
|
||||
#define UART1_GPIO_RX GPIO10
|
||||
#define UART1_GPIO_PORT_TX GPIOB
|
||||
#define UART1_GPIO_TX GPIO6
|
||||
|
||||
#define UART2_GPIO_AF GPIO_AF7
|
||||
#define UART2_GPIO_PORT_RX GPIOA
|
||||
#define UART2_GPIO_RX GPIO3
|
||||
#define UART2_GPIO_PORT_TX GPIOA
|
||||
#define UART2_GPIO_TX GPIO2
|
||||
|
||||
#define UART4_GPIO_AF GPIO_AF8
|
||||
#define UART4_GPIO_PORT_RX GPIOA
|
||||
#define UART4_GPIO_RX GPIO1
|
||||
#define UART4_GPIO_PORT_TX GPIOA
|
||||
#define UART4_GPIO_TX GPIO0
|
||||
|
||||
#define UART6_GPIO_AF GPIO_AF8
|
||||
#define UART6_GPIO_PORT_RX GPIOC
|
||||
#define UART6_GPIO_RX GPIO7
|
||||
#define UART6_GPIO_PORT_TX GPIOC
|
||||
#define UART6_GPIO_TX GPIO6
|
||||
|
||||
|
||||
/* SPI */
|
||||
#define SPI1_GPIO_AF GPIO_AF5
|
||||
#define SPI1_GPIO_PORT_MISO GPIOA
|
||||
#define SPI1_GPIO_MISO GPIO6
|
||||
#define SPI1_GPIO_PORT_MOSI GPIOA
|
||||
#define SPI1_GPIO_MOSI GPIO7
|
||||
#define SPI1_GPIO_PORT_SCK GPIOA
|
||||
#define SPI1_GPIO_SCK GPIO5
|
||||
|
||||
#define SPI_SELECT_SLAVE0_PORT GPIOB
|
||||
#define SPI_SELECT_SLAVE0_PIN GPIO9
|
||||
|
||||
|
||||
/* I2C mapping */
|
||||
#define I2C1_GPIO_PORT GPIOB
|
||||
#define I2C1_GPIO_SCL GPIO8
|
||||
#define I2C1_GPIO_SDA GPIO9
|
||||
|
||||
#define I2C2_GPIO_PORT GPIOB
|
||||
#define I2C2_GPIO_SCL GPIO10
|
||||
#define I2C2_GPIO_SDA GPIO11
|
||||
|
||||
#define I2C3_GPIO_PORT_SCL GPIOA
|
||||
#define I2C3_GPIO_PORT_SDA GPIOC
|
||||
#define I2C3_GPIO_SCL GPIO8
|
||||
#define I2C3_GPIO_SDA GPIO9
|
||||
|
||||
|
||||
/*
|
||||
* PPM
|
||||
*/
|
||||
#define USE_PPM_TIM1 1
|
||||
|
||||
#define PPM_CHANNEL TIM_IC1
|
||||
#define PPM_TIMER_INPUT TIM_IC_IN_TI1
|
||||
#define PPM_IRQ NVIC_TIM1_CC_IRQ
|
||||
#define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
|
||||
// Capture/Compare InteruptEnable and InterruptFlag
|
||||
#define PPM_CC_IE TIM_DIER_CC1IE
|
||||
#define PPM_CC_IF TIM_SR_CC1IF
|
||||
#define PPM_GPIO_PORT GPIOA
|
||||
#define PPM_GPIO_PIN GPIO8
|
||||
#define PPM_GPIO_AF GPIO_AF1
|
||||
|
||||
|
||||
/*
|
||||
* Spektrum
|
||||
*/
|
||||
/* The line that is pulled low at power up to initiate the bind process */
|
||||
#define SPEKTRUM_BIND_PIN GPIO8
|
||||
#define SPEKTRUM_BIND_PIN_PORT GPIOA
|
||||
|
||||
#define SPEKTRUM_UART2_RCC_REG &RCC_APB2ENR
|
||||
#define SPEKTRUM_UART2_RCC_DEV RCC_APB2ENR_USART1EN
|
||||
#define SPEKTRUM_UART2_BANK GPIOA
|
||||
#define SPEKTRUM_UART2_PIN GPIO10
|
||||
#define SPEKTRUM_UART2_AF GPIO_AF7
|
||||
#define SPEKTRUM_UART2_IRQ NVIC_USART1_IRQ
|
||||
#define SPEKTRUM_UART2_ISR usart1_isr
|
||||
#define SPEKTRUM_UART2_DEV USART1
|
||||
|
||||
|
||||
/* Onboard ADCs */
|
||||
#define USE_AD_TIM4 1
|
||||
|
||||
#define BOARD_ADC_CHANNEL_1 9
|
||||
#define BOARD_ADC_CHANNEL_2 15
|
||||
#define BOARD_ADC_CHANNEL_3 14
|
||||
#define BOARD_ADC_CHANNEL_4 4
|
||||
|
||||
#ifndef USE_AD1
|
||||
#define USE_AD1 1
|
||||
#endif
|
||||
/* provide defines that can be used to access the ADC_x in the code or airframe file
|
||||
* these directly map to the index number of the 4 adc channels defined above
|
||||
* 4th (index 3) is used for bat monitoring by default
|
||||
*/
|
||||
// AUX 1
|
||||
#define ADC_1 ADC1_C1
|
||||
#ifdef USE_ADC_1
|
||||
#ifndef ADC_1_GPIO_CLOCK_PORT
|
||||
#define ADC_1_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPBEN
|
||||
#define ADC_1_INIT() gpio_mode_setup(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1)
|
||||
#endif
|
||||
#define USE_AD1_1 1
|
||||
#else
|
||||
#define ADC_1_GPIO_CLOCK_PORT 0
|
||||
#define ADC_1_INIT() {}
|
||||
#endif
|
||||
|
||||
// AUX 2
|
||||
#define ADC_2 ADC1_C2
|
||||
#ifdef USE_ADC_2
|
||||
#ifndef ADC_2_GPIO_CLOCK_PORT
|
||||
#define ADC_2_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
|
||||
#define ADC_2_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5)
|
||||
#endif
|
||||
#define USE_AD1_2 1
|
||||
#else
|
||||
#define ADC_2_GPIO_CLOCK_PORT 0
|
||||
#define ADC_2_INIT() {}
|
||||
#endif
|
||||
|
||||
// AUX 3
|
||||
#define ADC_3 ADC1_C3
|
||||
#ifdef USE_ADC_3
|
||||
#ifndef ADC_3_GPIO_CLOCK_PORT
|
||||
#define ADC_3_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPCEN
|
||||
#define ADC_3_INIT() gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4)
|
||||
#endif
|
||||
#define USE_AD1_3 1
|
||||
#else
|
||||
#define ADC_3_GPIO_CLOCK_PORT 0
|
||||
#define ADC_3_INIT() {}
|
||||
#endif
|
||||
|
||||
// BAT
|
||||
#define ADC_4 ADC1_C4
|
||||
#ifndef ADC_4_GPIO_CLOCK_PORT
|
||||
#define ADC_4_GPIO_CLOCK_PORT RCC_AHB1ENR_IOPAEN
|
||||
#define ADC_4_INIT() gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4)
|
||||
#endif
|
||||
#define USE_AD1_4 1
|
||||
|
||||
/* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
|
||||
#ifndef ADC_CHANNEL_VSUPPLY
|
||||
#define ADC_CHANNEL_VSUPPLY ADC_4
|
||||
#endif
|
||||
|
||||
#define ADC_GPIO_CLOCK_PORT (ADC_1_GPIO_CLOCK_PORT | ADC_2_GPIO_CLOCK_PORT | ADC_3_GPIO_CLOCK_PORT | ADC_4_GPIO_CLOCK_PORT)
|
||||
|
||||
/* GPIO mapping for ADC1 pins, overwrites the default in arch/stm32/mcu_periph/adc_arch.c */
|
||||
#ifdef USE_AD1
|
||||
#define ADC1_GPIO_INIT(gpio) { \
|
||||
ADC_1_INIT(); \
|
||||
ADC_2_INIT(); \
|
||||
ADC_3_INIT(); \
|
||||
ADC_4_INIT(); \
|
||||
}
|
||||
#endif // USE_AD1
|
||||
|
||||
#define DefaultVoltageOfAdc(adc) (0.00485*adc)
|
||||
|
||||
|
||||
/* Default actuators driver */
|
||||
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
|
||||
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
|
||||
#define ActuatorsDefaultInit() ActuatorsPwmInit()
|
||||
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
|
||||
|
||||
|
||||
#endif /* CONFIG_STM32F4_DISCOVERY_H */
|
||||
Reference in New Issue
Block a user