1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-26 15:54:15 +01:00

LP-72 Cleaned up SPK2_RcvrPort: removed MSP from hwsettings, added SRXL rcvr port uart definition and initialization.

This commit is contained in:
Vladimir Zidar 2016-05-21 22:45:36 +02:00 committed by Laurent Lalanne
parent b98452a374
commit a1a6b130b8
2 changed files with 58 additions and 17 deletions

View File

@ -757,6 +757,37 @@ static const struct pios_usart_cfg pios_usart_srxl_flexi_cfg = {
},
};
static const struct pios_usart_cfg pios_usart_srxl_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
},
},
};
#endif /* PIOS_INCLUDE_SRXL */
// these were copied from Revo support

View File

@ -302,6 +302,27 @@ static void PIOS_Board_configure_ppm(const struct pios_ppm_cfg *ppm_cfg)
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_PPM] = pios_ppm_rcvr_id;
}
static void PIOS_Board_configure_srxl(const struct pios_usart_cfg *usart_cfg)
{
uint32_t pios_usart_srxl_id;
if (PIOS_USART_Init(&pios_usart_srxl_id, usart_cfg)) {
PIOS_Assert(0);
}
uint32_t pios_srxl_id;
if (PIOS_SRXL_Init(&pios_srxl_id, &pios_usart_com_driver, pios_usart_srxl_id)) {
PIOS_Assert(0);
}
uint32_t pios_srxl_rcvr_id;
if (PIOS_RCVR_Init(&pios_srxl_rcvr_id, &pios_srxl_rcvr_driver, pios_srxl_id)) {
PIOS_Assert(0);
}
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL] = pios_srxl_rcvr_id;
}
static void PIOS_Board_PPM_callback(const int16_t *channels)
{
uint8_t max_chan = (RFM22B_PPM_NUM_CHANNELS < OPLINKRECEIVER_CHANNEL_NUMELEM) ? RFM22B_PPM_NUM_CHANNELS : OPLINKRECEIVER_CHANNEL_NUMELEM;
@ -510,23 +531,7 @@ void PIOS_Board_Init(void)
break;
case HWSETTINGS_SPK2_FLEXIPORT_SRXL:
#if defined(PIOS_INCLUDE_SRXL)
{
uint32_t pios_usart_srxl_id;
if (PIOS_USART_Init(&pios_usart_srxl_id, &pios_usart_srxl_flexi_cfg)) {
PIOS_Assert(0);
}
uint32_t pios_srxl_id;
if (PIOS_SRXL_Init(&pios_srxl_id, &pios_usart_com_driver, pios_usart_srxl_id)) {
PIOS_Assert(0);
}
uint32_t pios_srxl_rcvr_id;
if (PIOS_RCVR_Init(&pios_srxl_rcvr_id, &pios_srxl_rcvr_driver, pios_srxl_id)) {
PIOS_Assert(0);
}
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL] = pios_srxl_rcvr_id;
}
PIOS_Board_configure_srxl(&pios_usart_srxl_flexi_cfg);
#endif /* PIOS_INCLUDE_SRXL */
break;
@ -910,6 +915,11 @@ void PIOS_Board_Init(void)
}
#endif
break;
case HWSETTINGS_SPK2_RCVRPORT_SRXL:
#if defined(PIOS_INCLUDE_SRXL)
PIOS_Board_configure_srxl(&pios_usart_srxl_rcvr_cfg);
#endif /* PIOS_INCLUDE_SRXL */
break;
case HWSETTINGS_SPK2_RCVRPORT_DSM:
// TODO: Define the various Channelgroup for Sparky2 dsm inputs and handle here
PIOS_Board_configure_dsm(&pios_usart_dsm_rcvr_cfg, &pios_dsm_rcvr_cfg,