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

LP-72 DSM PPM Voltage and Current sensors coded but not tested

This commit is contained in:
Cliff Geerdes 2015-11-08 04:12:44 -05:00 committed by Laurent Lalanne
parent 534b33d491
commit 3115711049
4 changed files with 199 additions and 115 deletions

View File

@ -56,6 +56,21 @@ static const struct pios_gpio pios_leds_v2[] = {
},
.active_low = true
},
#if 0
// the other LED in the TL code is accessed this way
[PIOS_LED_LINK] = {
.pin = {
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_6,
.GPIO_Speed = GPIO_Speed_50MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
},
},
#endif
#ifdef PIOS_RFM22B_DEBUG_ON_TELEM
[PIOS_LED_D1] = {
.pin = {
@ -254,7 +269,7 @@ void PIOS_OVERO_irq_handler(void)
/*
* SPI1 Interface
* Used for MPU6000 gyro and accelerometer
* Used for MPU9250 gyro, accelerometer and mag
*/
void PIOS_SPI_gyro_irq_handler(void);
void DMA2_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
@ -609,7 +624,7 @@ static const struct flashfs_logfs_cfg flashfs_internal_cfg = {
#ifdef PIOS_INCLUDE_COM_TELEM
/*
* MAIN USART
* MAIN PORT
*/
static const struct pios_usart_cfg pios_usart_main_cfg = {
.regs = USART1,
@ -722,6 +737,7 @@ static const struct pios_dsm_cfg pios_dsm_main_cfg = {
*/
#include <pios_sbus_priv.h>
#if 0
static const struct pios_usart_cfg pios_usart_sbus_main_cfg = {
.regs = USART1,
.remap = GPIO_AF_USART1,
@ -762,71 +778,10 @@ static const struct pios_usart_cfg pios_usart_sbus_main_cfg = {
},
},
};
static const struct pios_usart_cfg pios_usart_sbus_rcvrport_cfg = {
.regs = USART6,
.remap = GPIO_AF_USART6,
.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 = USART6_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.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
},
},
#if 0
.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 */
// Need this defined regardless to be able to turn it off
static const struct pios_sbus_cfg pios_sbus_cfg = {
/* Inverter configuration */
.inv = {
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_6, // GPIO_Pin_6 Sparky2 has external inverter on PC6, Revo=PC0
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.gpio_inv_enable = Bit_SET,
.gpio_inv_disable = Bit_RESET,
.gpio_clk_func = RCC_AHB1PeriphClockCmd,
.gpio_clk_periph = RCC_AHB1Periph_GPIOC,
};
#ifdef PIOS_INCLUDE_COM_FLEXI
/*
* FLEXI PORT
@ -1067,7 +1022,11 @@ static const struct pios_usart_cfg pios_usart_hkosd_flexi_cfg = {
},
};
static const struct pios_usart_cfg pios_usart_rcvrport_cfg = {
/*
* RCVR PORT
*/
static const struct pios_usart_cfg pios_usart_rcvr_cfg = {
.regs = USART6,
.remap = GPIO_AF_USART6,
.init = {
@ -1125,6 +1084,131 @@ static const struct pios_usart_cfg pios_usart_rcvrport_cfg = {
}
};
static const struct pios_usart_cfg pios_usart_sbus_rcvr_cfg = {
.regs = USART6,
.remap = GPIO_AF_USART6,
.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 = USART6_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.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
},
},
#if 0
.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
},
},
#else
.tx = {
.gpio = NULL,
},
#endif
};
static const struct pios_sbus_cfg pios_sbus_cfg = {
/* Inverter configuration */
.inv = {
.gpio = GPIOC,
.init = {
// according to TL code, Sparky uses PC6 and Revo uses PC0
// 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_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.gpio_inv_enable = Bit_SET,
.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_periph = RCC_AHB1Periph_GPIOC,
};
// It looks like TL notes originally came from OP's pios_dsm_main_cfg
// (TL note) Because of the inverter on the main port this will not
// (TL note) work. Notice the mode is set to IN to maintain API
// (TL note) compatibility but protect the pins
static const struct pios_dsm_cfg pios_dsm_rcvr_cfg = {
.bind = {
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_7,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL
},
},
};
static const struct pios_usart_cfg pios_usart_dsm_rcvr_cfg = {
.regs = USART6,
.remap = GPIO_AF_USART6,
.init = {
.USART_BaudRate = 115200,
.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,
},
.irq = {
.init = {
.NVIC_IRQChannel = USART6_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.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
},
},
.tx = {
.gpio = NULL,
},
};
#if defined(PIOS_INCLUDE_COM)
#include <pios_com_priv.h>
@ -1746,7 +1830,7 @@ const struct pios_servo_cfg pios_servo_cfg_out_in = {
*/
#if defined(PIOS_INCLUDE_PWM) || defined(PIOS_INCLUDE_PPM)
#include <pios_pwm_priv.h>
static const struct pios_tim_channel pios_tim_rcvrport_all_channels[] = {
static const struct pios_tim_channel pios_tim_rcvr_all_channels[] = {
#if 0
{
.timer = TIM12,
@ -1874,8 +1958,8 @@ const struct pios_pwm_cfg pios_pwm_cfg = {
.TIM_ICPrescaler = TIM_ICPSC_DIV1,
.TIM_ICFilter = 0x0,
},
.channels = pios_tim_rcvrport_all_channels,
.num_channels = NELEMENTS(pios_tim_rcvrport_all_channels),
.channels = pios_tim_rcvr_all_channels,
.num_channels = NELEMENTS(pios_tim_rcvr_all_channels),
};
// this configures outputs 2-6 as pwm inputs
const struct pios_pwm_cfg pios_pwm_ppm_cfg = {
@ -1885,8 +1969,8 @@ const struct pios_pwm_cfg pios_pwm_ppm_cfg = {
.TIM_ICPrescaler = TIM_ICPSC_DIV1,
.TIM_ICFilter = 0x0,
},
.channels = &pios_tim_rcvrport_all_channels[1],
.num_channels = NELEMENTS(pios_tim_rcvrport_all_channels) - 1,
.channels = &pios_tim_rcvr_all_channels[1],
.num_channels = NELEMENTS(pios_tim_rcvr_all_channels) - 1,
};
#endif
@ -1906,7 +1990,7 @@ static const struct pios_ppm_cfg pios_ppm_cfg = {
.TIM_Channel = TIM_Channel_2,
},
/* Use only the first channel for ppm */
.channels = &pios_tim_rcvrport_all_channels[0],
.channels = &pios_tim_rcvr_all_channels[0],
.num_channels = 1,
};

View File

@ -438,6 +438,9 @@ void PIOS_Board_Init(void)
OPLinkSettingsInitialize();
OPLinkStatusInitialize();
#endif /* PIOS_INCLUDE_RFM22B */
#if defined(PIOS_INCLUDE_HMC5X83)
AuxMagSettingsInitialize();
#endif /* PIOS_INCLUDE_HMC5X83 */
/* Initialize the alarms library */
AlarmsInitialize();
@ -477,16 +480,14 @@ void PIOS_Board_Init(void)
PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id);
break;
case HWSETTINGS_RM_FLEXIPORT_I2C:
#if 0
#if defined(PIOS_INCLUDE_I2C)
#if defined(PIOS_INCLUDE_HMC5X83)
{
if (PIOS_I2C_Init(&pios_i2c_flexiport_adapter_id, &pios_i2c_flexiport_adapter_cfg)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_I2C */
#else
#if defined(PIOS_INCLUDE_I2C)
// get auxmag type
AuxMagSettingsTypeOptions option;
AuxMagSettingsTypeGet(&option);
// the FlexiPort type is I2C, so if the AuxMag type is Flexi(Port) then set it up
if (option == AUXMAGSETTINGS_TYPE_FLEXI) {
if (PIOS_I2C_Init(&pios_i2c_flexiport_adapter_id, &pios_i2c_flexiport_adapter_cfg)) {
PIOS_Assert(0);
}
@ -498,13 +499,6 @@ void PIOS_Board_Init(void)
// to avoid making something else fail when HMC5X83 is removed
PIOS_WDG_Clear();
#endif /* PIOS_INCLUDE_WDG */
#if defined(PIOS_INCLUDE_HMC5X83)
// get auxmag type
AuxMagSettingsTypeOptions option;
AuxMagSettingsInitialize();
AuxMagSettingsTypeGet(&option);
// if the aux mag type is FlexiPort then set it up
if (option == AUXMAGSETTINGS_TYPE_FLEXI) {
// attach the 5x83 mag to the previously inited I2C2
flexi_port_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_cfg, pios_i2c_flexiport_adapter_id, 0);
#ifdef PIOS_INCLUDE_WDG
@ -520,9 +514,9 @@ void PIOS_Board_Init(void)
// mag alarm is cleared later, so use I2C
AlarmsSet(SYSTEMALARMS_ALARM_I2C, (flexi_port_mag) ? SYSTEMALARMS_ALARM_OK : SYSTEMALARMS_ALARM_WARNING);
}
}
#endif /* PIOS_INCLUDE_HMC5X83 */
#endif /* PIOS_INCLUDE_I2C */
#endif /* 0 */
break;
case HWSETTINGS_RM_FLEXIPORT_GPS:
PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_GPS_RX_BUF_LEN, PIOS_COM_GPS_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_gps_id);
@ -893,7 +887,7 @@ void PIOS_Board_Init(void)
#if defined(PIOS_INCLUDE_SBUS)
{
uint32_t pios_usart_sbus_id;
if (PIOS_USART_Init(&pios_usart_sbus_id, &pios_usart_sbus_rcvrport_cfg)) {
if (PIOS_USART_Init(&pios_usart_sbus_id, &pios_usart_sbus_rcvr_cfg)) {
PIOS_Assert(0);
}
@ -910,6 +904,11 @@ void PIOS_Board_Init(void)
}
#endif
break;
case HWSETTINGS_SPK2_RCVRPORT_DSM:
// TODO: Define the various Channelgroup for Revo dsm inputs and handle here
PIOS_Board_configure_dsm(&pios_usart_dsm_rcvr_cfg, &pios_dsm_rcvr_cfg,
&pios_usart_com_driver, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMRCVRPORT, &hwsettings_DSMxBind);
break;
default:
break;
}
@ -1006,11 +1005,12 @@ void PIOS_Board_Init(void)
#endif /* PIOS_INCLUDE_WDG */
#if defined(PIOS_INCLUDE_HMC5X83)
// get auxmag type
HwSettingsSPK2_I2CPortOptions i2cOption;
AuxMagSettingsTypeOptions option;
AuxMagSettingsInitialize();
HwSettingsSPK2_I2CPortGet(&i2cOption);
AuxMagSettingsTypeGet(&option);
// if the aux mag type is FlexiPort then set it up
if (option == AUXMAGSETTINGS_TYPE_I2C) {
// if the I2CPort type is I2C(Port) and the AuxMag type is I2C(Port) then set it up
if (i2cOption == HWSETTINGS_SPK2_I2CPORT_I2C && option == AUXMAGSETTINGS_TYPE_I2C) {
// attach the 5x83 mag to the previously inited I2C2
i2c_port_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_cfg, pios_i2c_mag_pressure_adapter_id, 0);
#ifdef PIOS_INCLUDE_WDG

View File

@ -289,7 +289,7 @@ extern uint32_t pios_packet_handler;
// -------------------------
#define PIOS_DMA_PIN_CONFIG \
{ \
{ GPIOC, GPIO_Pin_1, ADC_Channel_11, false }, /* batt/sonar pin 3 */ \
{ GPIOC, GPIO_Pin_3, ADC_Channel_13, false }, /* batt/sonar pin 3 */ \
{ GPIOC, GPIO_Pin_2, ADC_Channel_12, false }, /* batt/sonar pin 4 */ \
{ GPIOA, GPIO_Pin_3, ADC_Channel_3, false }, /* Servo pin 3 */ \
{ GPIOA, GPIO_Pin_2, ADC_Channel_2, false }, /* Servo pin 4 */ \

View File

@ -3,7 +3,7 @@
<description>Settings to indicate how to decode receiver input by @ref ManualControlModule.</description>
<field name="ChannelGroups" units="Channel Group" type="enum"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),S.Bus,EX.Bus,HoTT,SRXL,GCS,OPLink,None" defaultvalue="None"/>
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),DSM (RcvrPort),S.Bus,EX.Bus,HoTT,SRXL,GCS,OPLink,None" defaultvalue="None"/>
<field name="ChannelNumber" units="channel" type="uint8" defaultvalue="0"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"/>
<field name="ChannelMin" units="us" type="int16" defaultvalue="1000"