1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

LP-72 - HW definition cleanup

This commit is contained in:
Alessio Morale 2016-03-21 04:44:44 +01:00 committed by Laurent Lalanne
parent cbe52f3f51
commit b88cba80ee
2 changed files with 45 additions and 360 deletions

View File

@ -140,136 +140,6 @@ const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused))
#if defined(PIOS_INCLUDE_SPI) #if defined(PIOS_INCLUDE_SPI)
#include <pios_spi_priv.h> #include <pios_spi_priv.h>
#if (0 && defined(PIOS_OVERO_SPI))
// Revo hardware config
/* SPI2 Interface
* - Used for Flexi/IO/Overo communications
3: PB12 = SPI2 NSS, CAN2 RX
4: PB13 = SPI2 SCK, CAN2 TX, USART3 CTS
5: PB14 = SPI2 MISO, TIM12 CH1, USART3 RTS
6: PB15 = SPI2 MOSI, TIM12 CH2
*/
#include <pios_overo_priv.h>
void PIOS_OVERO_irq_handler(void);
void DMA1_Stream7_IRQHandler(void) __attribute__((alias("PIOS_OVERO_irq_handler")));
static const struct pios_overo_cfg pios_overo_cfg = {
.regs = SPI2,
.remap = GPIO_AF_SPI2,
.init = {
.SPI_Mode = SPI_Mode_Slave,
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
.SPI_DataSize = SPI_DataSize_8b,
.SPI_NSS = SPI_NSS_Hard,
.SPI_FirstBit = SPI_FirstBit_MSB,
.SPI_CRCPolynomial = 7,
.SPI_CPOL = SPI_CPOL_High,
.SPI_CPHA = SPI_CPHA_2Edge,
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2,
},
.use_crc = false,
.dma = {
.irq = {
// Note this is the stream ID that triggers interrupts (in this case TX)
.flags = (DMA_IT_TCIF7),
.init = {
.NVIC_IRQChannel = DMA1_Stream7_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.rx = {
.channel = DMA1_Stream0,
.init = {
.DMA_Channel = DMA_Channel_0,
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR),
.DMA_DIR = DMA_DIR_PeripheralToMemory,
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
.DMA_MemoryInc = DMA_MemoryInc_Enable,
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
.DMA_Mode = DMA_Mode_Circular,
.DMA_Priority = DMA_Priority_Medium,
// TODO: Enable FIFO
.DMA_FIFOMode = DMA_FIFOMode_Disable,
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
},
},
.tx = {
.channel = DMA1_Stream7,
.init = {
.DMA_Channel = DMA_Channel_0,
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR),
.DMA_DIR = DMA_DIR_MemoryToPeripheral,
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
.DMA_MemoryInc = DMA_MemoryInc_Enable,
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
.DMA_Mode = DMA_Mode_Circular,
.DMA_Priority = DMA_Priority_Medium,
.DMA_FIFOMode = DMA_FIFOMode_Disable,
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
},
},
},
.sclk = {
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_13,
.GPIO_Speed = GPIO_Speed_100MHz,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL
},
},
.miso = {
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_14,
.GPIO_Speed = GPIO_Speed_50MHz,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL
},
},
.mosi = {
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_15,
.GPIO_Speed = GPIO_Speed_50MHz,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL
},
},
.slave_count = 1,
.ssel = {
{
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_12,
.GPIO_Speed = GPIO_Speed_50MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
}
},
};
uint32_t pios_overo_id = 0;
void PIOS_OVERO_irq_handler(void)
{
/* Call into the generic code to handle the IRQ for this specific device */
PIOS_OVERO_DMA_irq_handler(pios_overo_id);
}
#endif /* (0 && defined(PIOS_OVERO_SPI)) */
/* /*
* SPI1 Interface * SPI1 Interface
* Used for MPU9250 gyro, accelerometer and mag * Used for MPU9250 gyro, accelerometer and mag
@ -733,58 +603,6 @@ static const struct pios_dsm_cfg pios_dsm_main_cfg = {
#endif /* PIOS_INCLUDE_DSM */ #endif /* PIOS_INCLUDE_DSM */
#include <pios_sbus_priv.h>
#if defined(PIOS_INCLUDE_SBUS)
/*
* S.Bus USART
*/
#include <pios_sbus_priv.h>
#if 0
static const struct pios_usart_cfg pios_usart_sbus_main_cfg = {
.regs = USART1,
.remap = GPIO_AF_USART1,
.init = {
.USART_BaudRate = 100000,
.USART_WordLength = USART_WordLength_8b,
.USART_Parity = USART_Parity_Even,
.USART_StopBits = USART_StopBits_2,
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
.USART_Mode = USART_Mode_Rx,
},
.irq = {
.init = {
.NVIC_IRQChannel = USART1_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.rx = {
.gpio = GPIOA,
.init = {
.GPIO_Pin = GPIO_Pin_10,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.tx = {
.gpio = GPIOA,
.init = {
.GPIO_Pin = GPIO_Pin_9,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL
},
},
};
#endif
#endif /* PIOS_INCLUDE_SBUS */
#ifdef PIOS_INCLUDE_COM_FLEXI #ifdef PIOS_INCLUDE_COM_FLEXI
/* /*
* FLEXI PORT * FLEXI PORT
@ -1130,68 +948,12 @@ static const struct pios_usart_cfg pios_usart_hkosd_flexi_cfg = {
/* /*
* RCVR PORT * RCVR PORT
*/ */
#if 0
static const struct pios_usart_cfg pios_usart_rcvr_cfg = {
.regs = USART6,
.remap = GPIO_AF_USART6,
.init = {
.USART_BaudRate = 57600,
.USART_WordLength = USART_WordLength_8b,
.USART_Parity = USART_Parity_No,
.USART_StopBits = USART_StopBits_1,
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
},
.irq = {
.init = {
.NVIC_IRQChannel = USART6_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.dtr = {
// FlexIO pin 9
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_8,
.GPIO_Speed = GPIO_Speed_25MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
},
},
.tx = {
// * 7: PC6 = TIM8 CH1, USART6 TX
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_6,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
.pin_source = GPIO_PinSource6,
},
.rx = {
// * 8: PC7 = TIM8 CH2, USART6 RX
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_7,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
.pin_source = GPIO_PinSource7,
}
};
#endif
#if defined(PIOS_INCLUDE_SBUS) #if defined(PIOS_INCLUDE_SBUS)
/*
* S.Bus USART
*/
#include <pios_sbus_priv.h>
static const struct pios_usart_cfg pios_usart_sbus_rcvr_cfg = { static const struct pios_usart_cfg pios_usart_sbus_rcvr_cfg = {
.regs = USART6, .regs = USART6,
@ -1222,11 +984,6 @@ static const struct pios_usart_cfg pios_usart_sbus_rcvr_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
#if 0
.tx = {
.gpio = NULL,
},
#endif
}; };
#endif /* PIOS_INCLUDE_SBUS */ #endif /* PIOS_INCLUDE_SBUS */
@ -1237,9 +994,7 @@ static const struct pios_sbus_cfg pios_sbus_cfg = {
.inv = { .inv = {
.gpio = GPIOC, .gpio = GPIOC,
.init = { .init = {
// according to TL code, Sparky uses PC6 and Revo uses PC0 .GPIO_Pin = GPIO_Pin_6,
// according to the schematics, they both use PC0
.GPIO_Pin = GPIO_Pin_6, // GPIO_Pin_6 Sparky2 has external inverter connected to PC6, Revo=PC0
.GPIO_Speed = GPIO_Speed_2MHz, .GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT, .GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP, .GPIO_OType = GPIO_OType_PP,
@ -1248,8 +1003,6 @@ static const struct pios_sbus_cfg pios_sbus_cfg = {
}, },
.gpio_inv_enable = Bit_SET, .gpio_inv_enable = Bit_SET,
.gpio_inv_disable = Bit_RESET, .gpio_inv_disable = Bit_RESET,
// in TauLabs Revo code these exist
// in TauLabs Sparky2 code these do not exist
.gpio_clk_func = RCC_AHB1PeriphClockCmd, .gpio_clk_func = RCC_AHB1PeriphClockCmd,
.gpio_clk_periph = RCC_AHB1Periph_GPIOC, .gpio_clk_periph = RCC_AHB1Periph_GPIOC,
}; };
@ -1304,11 +1057,6 @@ static const struct pios_usart_cfg pios_usart_dsm_rcvr_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
#if 0
.tx = {
.gpio = NULL,
},
#endif
}; };
#endif /* PIOS_INCLUDE_DSM */ #endif /* PIOS_INCLUDE_DSM */
@ -1886,27 +1634,6 @@ const struct pios_ws2811_pin_cfg pios_ws2811_pin_cfg[] = {
.GPIO_OType = GPIO_OType_PP, .GPIO_OType = GPIO_OType_PP,
}, },
}, },
#if 0
// Revo FlexiIo (receiver port) is not available on Sparky2
[HWSETTINGS_WS2811LED_OUT_FLEXIIOPIN3] = {
.gpio = GPIOB,
.gpioInit = {
.GPIO_Pin = GPIO_Pin_12,
.GPIO_Speed = GPIO_Speed_25MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
},
},
[HWSETTINGS_WS2811LED_OUT_FLEXIIOPIN4] = {
.gpio = GPIOB,
.gpioInit = {
.GPIO_Pin = GPIO_Pin_13,
.GPIO_Speed = GPIO_Speed_25MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
},
},
#endif
}; };
const struct pios_ws2811_cfg pios_ws2811_cfg = { const struct pios_ws2811_cfg pios_ws2811_cfg = {

View File

@ -100,52 +100,10 @@ void PIOS_ADC_DMC_irq_handler(void)
pios_hmc5x83_dev_t i2c_port_mag = 0; pios_hmc5x83_dev_t i2c_port_mag = 0;
pios_hmc5x83_dev_t flexi_port_mag = 0; pios_hmc5x83_dev_t flexi_port_mag = 0;
#if 0
bool pios_board_internal_mag_handler()
{
return PIOS_HMC5x83_IRQHandler(i2c_port_mag);
}
static const struct pios_exti_cfg pios_exti_hmc5x83_cfg __exti_config = {
.vector = pios_board_internal_mag_handler,
.line = EXTI_Line7,
.pin = {
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_7,
.GPIO_Speed = GPIO_Speed_100MHz,
.GPIO_Mode = GPIO_Mode_IN,
.GPIO_OType = GPIO_OType_OD,
.GPIO_PuPd = GPIO_PuPd_NOPULL,
},
},
.irq = {
.init = {
.NVIC_IRQChannel = EXTI9_5_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.exti = {
.init = {
.EXTI_Line = EXTI_Line7, // matches above GPIO pin
.EXTI_Mode = EXTI_Mode_Interrupt,
.EXTI_Trigger = EXTI_Trigger_Rising,
.EXTI_LineCmd = ENABLE,
},
},
};
#endif
static const struct pios_hmc5x83_cfg pios_hmc5x83_cfg = { static const struct pios_hmc5x83_cfg pios_hmc5x83_cfg = {
#if 0
.exti_cfg = &pios_exti_hmc5x83_cfg,
#else
#ifdef PIOS_HMC5X83_HAS_GPIOS #ifdef PIOS_HMC5X83_HAS_GPIOS
.exti_cfg = NULL, .exti_cfg = NULL,
#endif /* PIOS_HMC5X83_HAS_GPIOS */ #endif /* PIOS_HMC5X83_HAS_GPIOS */
#endif /* 0 */
.M_ODR = PIOS_HMC5x83_ODR_75, .M_ODR = PIOS_HMC5x83_ODR_75,
.Meas_Conf = PIOS_HMC5x83_MEASCONF_NORMAL, .Meas_Conf = PIOS_HMC5x83_MEASCONF_NORMAL,
.Gain = PIOS_HMC5x83_GAIN_1_9, .Gain = PIOS_HMC5x83_GAIN_1_9,
@ -1043,7 +1001,7 @@ void PIOS_Board_Init(void)
PIOS_HMC5x83_Register(i2c_port_mag, PIOS_SENSORS_TYPE_3AXIS_AUXMAG); PIOS_HMC5x83_Register(i2c_port_mag, PIOS_SENSORS_TYPE_3AXIS_AUXMAG);
#endif /* PIOS_INCLUDE_HMC5X83 */ #endif /* PIOS_INCLUDE_HMC5X83 */
#else #else /* if 0 */
#if defined(PIOS_INCLUDE_I2C) #if defined(PIOS_INCLUDE_I2C)
#ifdef PIOS_INCLUDE_WDG #ifdef PIOS_INCLUDE_WDG