mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Patch up ASC config
This commit is contained in:
parent
b36d705688
commit
7ef8d197c6
@ -38,7 +38,6 @@ px4_add_module(
|
||||
SRCS
|
||||
../common/board_name.c
|
||||
asc_init.c
|
||||
asc_pwr.c
|
||||
asc_timer_config.c
|
||||
asc_spi.c
|
||||
asc_usb.c
|
||||
|
||||
@ -129,26 +129,12 @@ __END_DECLS
|
||||
|
||||
__EXPORT void stm32_boardinitialize(void)
|
||||
{
|
||||
/* Hold power state */
|
||||
|
||||
board_pwr_init(0);
|
||||
|
||||
/* TEMP ctrl Off (active high, init is clear) */
|
||||
|
||||
stm32_configgpio(GPIO_TEMP_CONT);
|
||||
|
||||
|
||||
/* Select 0 */
|
||||
|
||||
stm32_configgpio(GPIO_S0);
|
||||
stm32_configgpio(GPIO_S1);
|
||||
stm32_configgpio(GPIO_S2);
|
||||
|
||||
/* Radio Off (active low, init is set) */
|
||||
|
||||
stm32_configgpio(GPIO_PCON_RADIO);
|
||||
|
||||
|
||||
/* configure always-on ADC pins */
|
||||
|
||||
stm32_configgpio(GPIO_ADC1_IN10);
|
||||
@ -200,8 +186,6 @@ __EXPORT int nsh_archinitialize(void)
|
||||
(hrt_callout)stm32_serial_dma_poll,
|
||||
NULL);
|
||||
|
||||
board_pwr_init(1);
|
||||
|
||||
/* initial LED state */
|
||||
drv_led_start();
|
||||
led_off(LED_AMBER);
|
||||
|
||||
@ -70,19 +70,131 @@
|
||||
|
||||
__EXPORT void stm32_spiinitialize(void)
|
||||
{
|
||||
stm32_configgpio(GPIO_SPI_CS_SDCARD);
|
||||
stm32_configgpio(GPIO_SPI_SD_SW);
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
// px4_arch_configgpio(GPIO_SPI_CS_MPU9250);
|
||||
// px4_arch_configgpio(GPIO_SPI_CS_HMC5983);
|
||||
// px4_arch_configgpio(GPIO_SPI_CS_MS5611);
|
||||
// px4_arch_configgpio(GPIO_SPI_CS_ICM_20608_G);
|
||||
|
||||
// /* De-activate all peripherals,
|
||||
// * required for some peripheral
|
||||
// * state machines
|
||||
// */
|
||||
// px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
// px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
// px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
// px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
|
||||
// px4_arch_configgpio(GPIO_DRDY_MPU9250);
|
||||
// px4_arch_configgpio(GPIO_DRDY_HMC5983);
|
||||
// px4_arch_configgpio(GPIO_DRDY_ICM_20608_G);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI4
|
||||
// px4_arch_configgpio(GPIO_SPI_CS_FRAM);
|
||||
// px4_arch_gpiowrite(GPIO_SPI_CS_FRAM, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
__EXPORT void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
/* there can only be one device on this bus, so always select it */
|
||||
stm32_gpiowrite(GPIO_SPI_CS_SDCARD, !selected);
|
||||
/* SPI select is active low, so write !selected to select the device */
|
||||
|
||||
switch (devid) {
|
||||
case PX4_SPIDEV_ICM:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, !selected);
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_ACCEL_MAG:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_BARO:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, !selected);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_HMC:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, !selected);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_MPU:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, !selected);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
__EXPORT uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
__EXPORT uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return !stm32_gpioread(GPIO_SPI_SD_SW);
|
||||
return SPI_STATUS_PRESENT;
|
||||
}
|
||||
|
||||
__EXPORT void stm32_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
/* SPI select is active low, so write !selected to select the device */
|
||||
|
||||
switch (devid) {
|
||||
case PX4_SPIDEV_ICM:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, !selected);
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_ACCEL_MAG:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_BARO:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, !selected);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_HMC:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, !selected);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
break;
|
||||
|
||||
case PX4_SPIDEV_MPU:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MPU9250, !selected);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
px4_arch_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
__EXPORT uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return SPI_STATUS_PRESENT;
|
||||
}
|
||||
@ -168,15 +168,6 @@ __BEGIN_DECLS
|
||||
#define GPIO_GPIO4_OUTPUT (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN10)
|
||||
#define GPIO_GPIO5_OUTPUT (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN11)
|
||||
|
||||
/*
|
||||
* Tone alarm output
|
||||
*/
|
||||
/* todo:Revisit - cannnot tell from schematic - one could be tone alarm*/
|
||||
#define TONE_ALARM_TIMER 8 /* timer 8 */
|
||||
#define TONE_ALARM_CHANNEL 3 /* channel 3 */
|
||||
#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN8)
|
||||
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF2|GPIO_SPEED_2MHz|GPIO_FLOAT|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN8)
|
||||
|
||||
/*
|
||||
* PWM
|
||||
*
|
||||
@ -194,7 +185,7 @@ __BEGIN_DECLS
|
||||
#define GPIO_TIM3_CH2OUT GPIO_TIM3_CH2OUT_1
|
||||
#define GPIO_TIM3_CH3OUT GPIO_TIM3_CH3OUT_1
|
||||
#define GPIO_TIM3_CH4OUT GPIO_TIM3_CH4OUT_1
|
||||
#define DIRECT_PWM_OUTPUT_CHANNELS 4
|
||||
#define DIRECT_PWM_OUTPUT_CHANNELS 0
|
||||
|
||||
#define BOARD_HAS_LED_PWM
|
||||
#define LED_TIM3_CH1OUT GPIO_TIM3_CH1OUT
|
||||
@ -210,8 +201,8 @@ __BEGIN_DECLS
|
||||
|
||||
/* High-resolution timer
|
||||
*/
|
||||
#define HRT_TIMER 1 /* use timer1 for the HRT */
|
||||
#define HRT_TIMER_CHANNEL 1 /* use capture/compare channel */
|
||||
#define HRT_TIMER 3 /* use timer8 for the HRT */
|
||||
#define HRT_TIMER_CHANNEL 4 /* use capture/compare channel */
|
||||
|
||||
#define BOARD_NAME "TAP_V1"
|
||||
|
||||
@ -236,10 +227,26 @@ __BEGIN_DECLS
|
||||
{GPIO_GPIO5_INPUT, GPIO_GPIO5_OUTPUT, 0}, }
|
||||
|
||||
|
||||
#define MS_PWR_BUTTON_DOWN 750
|
||||
#define KEY_AD_GPIO (GPIO_INPUT|GPIO_PULLDOWN|GPIO_EXTI|GPIO_PORTC|GPIO_PIN1)
|
||||
#define POWER_ON_GPIO (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
|
||||
#define POWER_OFF_GPIO (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN4)
|
||||
#define GPIO_SPI_CS_MPU9250 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_SPI_CS_HMC5983 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15)
|
||||
#define GPIO_SPI_CS_LIS3MDL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15)
|
||||
#define GPIO_SPI_CS_MS5611 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
|
||||
#define GPIO_SPI_CS_ICM_20608_G (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN15)
|
||||
|
||||
#define PX4_SPI_BUS_SENSORS 1
|
||||
#define PX4_SPI_BUS_RAMTRON 2
|
||||
#define PX4_SPI_BUS_BARO PX4_SPI_BUS_RAMTRON
|
||||
|
||||
/* Use these in place of the spi_dev_e enumeration to select a specific SPI device on SPI1 */
|
||||
#define PX4_SPIDEV_GYRO 1
|
||||
#define PX4_SPIDEV_ACCEL_MAG 2
|
||||
#define PX4_SPIDEV_BARO 3
|
||||
#define PX4_SPIDEV_MPU 4
|
||||
#define PX4_SPIDEV_HMC 5
|
||||
#define PX4_SPIDEV_ICM 6
|
||||
#define PX4_SPIDEV_LIS 7
|
||||
#define PX4_SPIDEV_BMI 8
|
||||
#define PX4_SPIDEV_BMA 9
|
||||
|
||||
#define GPIO_S0 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN15)
|
||||
#define GPIO_S1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN14)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user