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

LP-480 Removed PIOS_BOARD_USART_Ioctl() and moved inverter handling to pios_usart directly. Handling is now conditionally built in based on PIOS_USART_INVERTER_PORT define.

This commit is contained in:
Vladimir Zidar 2017-04-25 13:11:37 +02:00
parent 3d876d7035
commit 01f5baaed2
23 changed files with 156 additions and 303 deletions

View File

@ -318,7 +318,7 @@ int32_t PIOS_DSM_Init(uint32_t *dsm_id,
PIOS_DEBUG_Assert(driver->ioctl);
if ((driver->ioctl)(lower_id, PIOS_IOCTL_USART_GET_RXGPIO, &rxpin) < 0) {
if ((driver->ioctl)(lower_id, PIOS_IOCTL_USART_GET_DSMBIND, &rxpin) < 0) {
return -1;
}

View File

@ -146,6 +146,8 @@ enum pios_com_ioctl_type {
COM_IOCTL_TYPE_SOFT_UART,
};
#define COM_IOCTL_ENOSYS (-1) /* Function not implemented */
#endif /* PIOS_COM_H */
/**

View File

@ -53,6 +53,9 @@ enum PIOS_USART_Inverted {
/* PIOS_IRQ_PRIO_ values */
#define PIOS_IOCTL_USART_SET_IRQ_PRIO COM_IOCTL(COM_IOCTL_TYPE_USART, 6, uint8_t)
#define PIOS_IOCTL_USART_GET_DSMBIND COM_IOCTL(COM_IOCTL_TYPE_USART, 7, struct stm32_gpio)
#endif /* PIOS_USART_H */
/**

View File

@ -190,7 +190,21 @@ int32_t PIOS_USART_Init(uint32_t *usart_id, const struct pios_usart_cfg *cfg)
/* DTR handling? */
*usart_id = (uint32_t)usart_dev;
#ifdef PIOS_USART_INVERTER_PORT
/* Initialize inverter gpio and set it to off */
if (usart_dev->cfg->regs == PIOS_USART_INVERTER_PORT) {
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = PIOS_USART_INVERTER_PIN,
.GPIO_Mode = GPIO_Mode_Out_PP,
.GPIO_Speed = GPIO_Speed_2MHz,
};
GPIO_Init(PIOS_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(PIOS_USART_INVERTER_GPIO,
PIOS_USART_INVERTER_PIN,
PIOS_USART_INVERTER_DISABLE);
}
#endif
/* Configure USART Interrupts */
switch ((uint32_t)usart_dev->cfg->regs) {
@ -210,6 +224,8 @@ int32_t PIOS_USART_Init(uint32_t *usart_id, const struct pios_usart_cfg *cfg)
PIOS_USART_SetIrqPrio(usart_dev, PIOS_IRQ_PRIO_MID);
*usart_id = (uint32_t)usart_dev;
return 0;
out_fail:
@ -462,10 +478,35 @@ static int32_t PIOS_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
PIOS_Assert(valid);
/* First try board specific IOCTL to allow overriding default functions */
if (usart_dev->cfg->ioctl) {
int32_t ret = usart_dev->cfg->ioctl(usart_id, ctl, param);
if (ret != COM_IOCTL_ENOSYS) {
return ret;
}
}
switch (ctl) {
case PIOS_IOCTL_USART_SET_IRQ_PRIO:
return PIOS_USART_SetIrqPrio(usart_dev, *(uint8_t *)param);
#ifdef PIOS_USART_INVERTER_PORT
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_dev->cfg->regs != PIOS_USART_INVERTER_PORT) {
return COM_IOCTL_ENOSYS; /* don't know how */
}
GPIO_WriteBit(PIOS_USART_INVERTER_GPIO,
PIOS_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? PIOS_USART_INVERTER_ENABLE : PIOS_USART_INVERTER_DISABLE);
break;
#endif /* PIOS_USART_INVERTER_PORT */
case PIOS_IOCTL_USART_GET_DSMBIND:
#ifdef PIOS_USART_INVERTER_PORT
if (usart_dev->cfg->regs == PIOS_USART_INVERTER_PORT) {
return -2; /* do not allow dsm bind on port with inverter */
}
#endif /* otherwise, return RXGPIO */
case PIOS_IOCTL_USART_GET_RXGPIO:
*(struct stm32_gpio *)param = usart_dev->cfg->rx;
break;
@ -476,10 +517,7 @@ static int32_t PIOS_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
USART_HalfDuplexCmd(usart_dev->cfg->regs, *(bool *)param ? ENABLE : DISABLE);
break;
default:
if (usart_dev->cfg->ioctl) {
return usart_dev->cfg->ioctl(usart_id, ctl, param);
}
return -1;
return COM_IOCTL_ENOSYS; /* unknown ioctl */
}
return 0;

View File

@ -218,8 +218,23 @@ int32_t PIOS_USART_Init(uint32_t *usart_id, const struct pios_usart_cfg *cfg)
GPIO_Init(usart_dev->cfg->dtr.gpio, (GPIO_InitTypeDef *)&usart_dev->cfg->dtr.init);
PIOS_USART_SetCtrlLine((uint32_t)usart_dev, COM_CTRL_LINE_DTR_MASK, 0);
}
#ifdef PIOS_USART_INVERTER_PORT
/* Initialize inverter gpio and set it to off */
if (usart_dev->cfg->regs == PIOS_USART_INVERTER_PORT) {
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = PIOS_USART_INVERTER_PIN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
};
GPIO_Init(PIOS_USART_INVERTER_GPIO, &inverterGPIOInit);
*usart_id = (uint32_t)usart_dev;
GPIO_WriteBit(PIOS_USART_INVERTER_GPIO,
PIOS_USART_INVERTER_PIN,
PIOS_USART_INVERTER_DISABLE);
}
#endif
/* Configure USART Interrupts */
switch ((uint32_t)usart_dev->cfg->regs) {
@ -252,6 +267,8 @@ int32_t PIOS_USART_Init(uint32_t *usart_id, const struct pios_usart_cfg *cfg)
}
PIOS_USART_SetIrqPrio(usart_dev, PIOS_IRQ_PRIO_MID);
*usart_id = (uint32_t)usart_dev;
return 0;
out_fail:
@ -520,10 +537,35 @@ static int32_t PIOS_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
PIOS_Assert(valid);
/* First try board specific IOCTL to allow overriding default functions */
if (usart_dev->cfg->ioctl) {
int32_t ret = usart_dev->cfg->ioctl(usart_id, ctl, param);
if (ret != COM_IOCTL_ENOSYS) {
return ret;
}
}
switch (ctl) {
case PIOS_IOCTL_USART_SET_IRQ_PRIO:
return PIOS_USART_SetIrqPrio(usart_dev, *(uint8_t *)param);
#ifdef PIOS_USART_INVERTER_PORT
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_dev->cfg->regs != PIOS_USART_INVERTER_PORT) {
return COM_IOCTL_ENOSYS; /* don't know how */
}
GPIO_WriteBit(PIOS_USART_INVERTER_GPIO,
PIOS_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? PIOS_USART_INVERTER_ENABLE : PIOS_USART_INVERTER_DISABLE);
break;
#endif /* PIOS_USART_INVERTER_PORT */
case PIOS_IOCTL_USART_GET_DSMBIND:
#ifdef PIOS_USART_INVERTER_PORT
if (usart_dev->cfg->regs == PIOS_USART_INVERTER_PORT) {
return -2; /* do not allow dsm bind on port with inverter */
}
#endif /* otherwise, return RXGPIO */
case PIOS_IOCTL_USART_GET_RXGPIO:
*(struct stm32_gpio *)param = usart_dev->cfg->rx;
break;
@ -534,10 +576,7 @@ static int32_t PIOS_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
USART_HalfDuplexCmd(usart_dev->cfg->regs, *(bool *)param ? ENABLE : DISABLE);
break;
default:
if (usart_dev->cfg->ioctl) {
return usart_dev->cfg->ioctl(usart_id, ctl, param);
}
return -1;
return COM_IOCTL_ENOSYS; /* unknown ioctl */
}
return 0;

View File

@ -597,14 +597,6 @@ static const struct pios_tim_channel pios_tim_ppm_flexi_port = TIM_SERVO_CHANNEL
#include "pios_usart_priv.h"
// Inverter for SBUS handling
#define MAIN_USART_INVERTER_GPIO GPIOB
#define MAIN_USART_INVERTER_PIN GPIO_Pin_2
#define MAIN_USART_INVERTER_ENABLE Bit_SET
#define MAIN_USART_INVERTER_DISABLE Bit_RESET
static int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param);
static const struct pios_usart_cfg pios_usart_main_cfg = {
.regs = USART1,
.rx = {
@ -623,7 +615,6 @@ static const struct pios_usart_cfg pios_usart_main_cfg = {
.GPIO_Mode = GPIO_Mode_AF_PP,
},
},
.ioctl = PIOS_BOARD_USART_Ioctl,
};
static const struct pios_usart_cfg pios_usart_flexi_cfg = {

View File

@ -86,26 +86,6 @@ static const PIOS_BOARD_IO_UART_Function flexi_function_map[] = {
[HWSETTINGS_CC_FLEXIPORT_MAVLINK] = PIOS_BOARD_IO_UART_MAVLINK,
};
int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
{
const struct pios_usart_cfg *usart_cfg = PIOS_USART_GetConfig(usart_id);
switch (ctl) {
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_cfg->regs == pios_usart_main_cfg.regs) { /* main port */
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? MAIN_USART_INVERTER_ENABLE : MAIN_USART_INVERTER_DISABLE);
return 0;
}
break;
}
return -1;
}
/**
* PIOS_Board_Init()
* initializes all the core subsystems on this specific hardware
@ -252,21 +232,6 @@ void PIOS_Board_Init(void)
}
/* Configure main USART port */
/* Initialize inverter gpio and set it to off */
{
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = MAIN_USART_INVERTER_PIN,
.GPIO_Mode = GPIO_Mode_Out_PP,
.GPIO_Speed = GPIO_Speed_2MHz,
};
GPIO_Init(MAIN_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
MAIN_USART_INVERTER_DISABLE);
}
uint8_t hwsettings_mainport;
HwSettingsCC_MainPortGet(&hwsettings_mainport);

View File

@ -116,16 +116,23 @@ extern uint32_t pios_i2c_flexi_adapter_id;
//
// See also pios_board.c
// -------------------------
#define PIOS_SPI_MAX_DEVS 2
#define PIOS_SPI_MAX_DEVS 2
extern uint32_t pios_spi_gyro_adapter_id;
#define PIOS_SPI_MPU6000_ADAPTER (pios_spi_gyro_adapter_id)
#define PIOS_SPI_MPU6000_ADAPTER (pios_spi_gyro_adapter_id)
extern uint32_t pios_spi_flash_accel_adapter_id;
#define PIOS_SPI_ADXL345_ADAPTER (pios_spi_flash_accel_adapter_id)
#define PIOS_SPI_ADXL345_ADAPTER (pios_spi_flash_accel_adapter_id)
// -------------------------
// PIOS_USART
// -------------------------
#define PIOS_USART_MAX_DEVS 2
#define PIOS_USART_MAX_DEVS 2
// Inverter for SBUS handling
#define PIOS_USART_INVERTER_PORT USART1
#define PIOS_USART_INVERTER_GPIO GPIOB
#define PIOS_USART_INVERTER_PIN GPIO_Pin_2
#define PIOS_USART_INVERTER_ENABLE Bit_SET
#define PIOS_USART_INVERTER_DISABLE Bit_RESET
// -------------------------
// PIOS_COM

View File

@ -606,13 +606,6 @@ static const struct flashfs_logfs_cfg flashfs_internal_user_cfg = {
/*
* MAIN USART
*/
// Inverter for SBUS handling
#define MAIN_USART_INVERTER_GPIO GPIOC
#define MAIN_USART_INVERTER_PIN GPIO_Pin_0
#define MAIN_USART_INVERTER_ENABLE Bit_SET
#define MAIN_USART_INVERTER_DISABLE Bit_RESET
static int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param);
static const struct pios_usart_cfg pios_usart_main_cfg = {
.regs = USART1,
@ -637,7 +630,6 @@ static const struct pios_usart_cfg pios_usart_main_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.ioctl = PIOS_BOARD_USART_Ioctl,
};
/*

View File

@ -99,25 +99,6 @@ static const PIOS_BOARD_IO_UART_Function flexi_function_map[] = {
[HWSETTINGS_RM_FLEXIPORT_MAVLINK] = PIOS_BOARD_IO_UART_MAVLINK,
};
int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
{
const struct pios_usart_cfg *usart_cfg = PIOS_USART_GetConfig(usart_id);
switch (ctl) {
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_cfg->regs == pios_usart_main_cfg.regs) { /* main port */
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? MAIN_USART_INVERTER_ENABLE : MAIN_USART_INVERTER_DISABLE);
return 0;
}
break;
}
return -1;
}
/**
* PIOS_Board_Init()
* initializes all the core subsystems on this specific hardware
@ -256,23 +237,6 @@ void PIOS_Board_Init(void)
#endif
/* Configure main USART port */
/* Initialize inverter gpio and set it to off */
{
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = MAIN_USART_INVERTER_PIN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
};
GPIO_Init(MAIN_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
MAIN_USART_INVERTER_DISABLE);
}
uint8_t hwsettings_mainport;
HwSettingsRM_MainPortGet(&hwsettings_mainport);

View File

@ -119,7 +119,13 @@ extern uint32_t pios_i2c_flexiport_adapter_id;
//
// See also pios_board.c
// -------------------------
#define PIOS_USART_MAX_DEVS 5
#define PIOS_USART_MAX_DEVS 5
// Inverter for SBUS handling
#define PIOS_USART_INVERTER_PORT USART1
#define PIOS_USART_INVERTER_GPIO GPIOC
#define PIOS_USART_INVERTER_PIN GPIO_Pin_0
#define PIOS_USART_INVERTER_ENABLE Bit_SET
#define PIOS_USART_INVERTER_DISABLE Bit_RESET
// -------------------------
// PIOS_COM

View File

@ -794,14 +794,6 @@ static const struct flashfs_logfs_cfg flashfs_internal_cfg = {
* MAIN USART
*/
// Inverter for SBUS handling
#define MAIN_USART_INVERTER_GPIO GPIOC
#define MAIN_USART_INVERTER_PIN GPIO_Pin_0
#define MAIN_USART_INVERTER_ENABLE Bit_SET
#define MAIN_USART_INVERTER_DISABLE Bit_RESET
static int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param);
static const struct pios_usart_cfg pios_usart_main_cfg = {
.regs = USART1,
.remap = GPIO_AF_USART1,
@ -825,7 +817,6 @@ static const struct pios_usart_cfg pios_usart_main_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.ioctl = PIOS_BOARD_USART_Ioctl,
};
/*

View File

@ -98,25 +98,6 @@ static const PIOS_BOARD_IO_UART_Function flexi_function_map[] = {
[HWSETTINGS_RM_FLEXIPORT_MAVLINK] = PIOS_BOARD_IO_UART_MAVLINK,
};
int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
{
const struct pios_usart_cfg *usart_cfg = PIOS_USART_GetConfig(usart_id);
switch (ctl) {
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_cfg->regs == pios_usart_main_cfg.regs) { /* main port */
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? MAIN_USART_INVERTER_ENABLE : MAIN_USART_INVERTER_DISABLE);
return 0;
}
break;
}
return -1;
}
/**
* PIOS_Board_Init()
* initializes all the core subsystems on this specific hardware
@ -255,23 +236,6 @@ void PIOS_Board_Init(void)
#endif
/* Configure main USART port */
/* Initialize inverter gpio and set it to off */
{
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = MAIN_USART_INVERTER_PIN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
};
GPIO_Init(MAIN_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
MAIN_USART_INVERTER_DISABLE);
}
uint8_t hwsettings_mainport;
HwSettingsRM_MainPortGet(&hwsettings_mainport);

View File

@ -139,7 +139,13 @@ extern uint32_t pios_i2c_flexiport_adapter_id;
//
// See also pios_board.c
// -------------------------
#define PIOS_USART_MAX_DEVS 5
#define PIOS_USART_MAX_DEVS 5
#define PIOS_USART_INVERTER_PORT USART1
#define PIOS_USART_INVERTER_GPIO GPIOC
#define PIOS_USART_INVERTER_PIN GPIO_Pin_0
#define PIOS_USART_INVERTER_ENABLE Bit_SET
#define PIOS_USART_INVERTER_DISABLE Bit_RESET
// -------------------------
// PIOS_COM

View File

@ -42,29 +42,24 @@
* o5 | PA0 | TIM5_CH1 | ADC1_0
* o6 | PA1 | TIM5_CH2 | ADC1_1
*/
#define MAIN_USART_REGS USART2
#define MAIN_USART_REMAP GPIO_AF_USART2
#define MAIN_USART_IRQ USART2_IRQn
#define MAIN_USART_RX_GPIO GPIOA
#define MAIN_USART_RX_PIN GPIO_Pin_3
#define MAIN_USART_TX_GPIO GPIOA
#define MAIN_USART_TX_PIN GPIO_Pin_2
// Inverter for SBUS handling
#define MAIN_USART_INVERTER_GPIO GPIOC
#define MAIN_USART_INVERTER_PIN GPIO_Pin_15
#define MAIN_USART_INVERTER_ENABLE Bit_SET
#define MAIN_USART_INVERTER_DISABLE Bit_RESET
#define MAIN_USART_REGS USART2
#define MAIN_USART_REMAP GPIO_AF_USART2
#define MAIN_USART_IRQ USART2_IRQn
#define MAIN_USART_RX_GPIO GPIOA
#define MAIN_USART_RX_PIN GPIO_Pin_3
#define MAIN_USART_TX_GPIO GPIOA
#define MAIN_USART_TX_PIN GPIO_Pin_2
#define FLEXI_USART_REGS USART1
#define FLEXI_USART_REMAP GPIO_AF_USART1
#define FLEXI_USART_IRQ USART1_IRQn
#define FLEXI_USART_RX_GPIO GPIOB
#define FLEXI_USART_RX_PIN GPIO_Pin_7
#define FLEXI_USART_TX_GPIO GPIOB
#define FLEXI_USART_TX_PIN GPIO_Pin_6
#define FLEXI_USART_REGS USART1
#define FLEXI_USART_REMAP GPIO_AF_USART1
#define FLEXI_USART_IRQ USART1_IRQn
#define FLEXI_USART_RX_GPIO GPIOB
#define FLEXI_USART_RX_PIN GPIO_Pin_7
#define FLEXI_USART_TX_GPIO GPIOB
#define FLEXI_USART_TX_PIN GPIO_Pin_6
// ReceiverPort pin 3
#define FLEXI_USART_DTR_GPIO GPIOB
#define FLEXI_USART_DTR_PIN GPIO_Pin_10
#define FLEXI_USART_DTR_GPIO GPIOB
#define FLEXI_USART_DTR_PIN GPIO_Pin_10
#if defined(PIOS_INCLUDE_LED)
@ -245,8 +240,6 @@ void PIOS_SPI_gyro_irq_handler(void)
* MAIN USART
*/
static int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param);
static const struct pios_usart_cfg pios_usart_main_cfg = {
.regs = MAIN_USART_REGS,
.remap = MAIN_USART_REMAP,
@ -270,7 +263,6 @@ static const struct pios_usart_cfg pios_usart_main_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.ioctl = PIOS_BOARD_USART_Ioctl,
};
/*

View File

@ -95,25 +95,6 @@ static const PIOS_BOARD_IO_UART_Function main_function_map[] = {
[HWSETTINGS_RM_MAINPORT_MAVLINK] = PIOS_BOARD_IO_UART_MAVLINK,
};
int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
{
const struct pios_usart_cfg *usart_cfg = PIOS_USART_GetConfig(usart_id);
switch (ctl) {
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_cfg->regs == pios_usart_main_cfg.regs) { /* main port */
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? MAIN_USART_INVERTER_ENABLE : MAIN_USART_INVERTER_DISABLE);
return 0;
}
break;
}
return -1;
}
void PIOS_Board_Init(void)
{
const struct pios_board_info *bdinfo = &pios_board_info_blob;
@ -222,23 +203,6 @@ void PIOS_Board_Init(void)
}
/* Configure main USART port */
/* Initialize inverter gpio and set it to off */
{
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = MAIN_USART_INVERTER_PIN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
};
GPIO_Init(MAIN_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
MAIN_USART_INVERTER_DISABLE);
}
uint8_t hwsettings_mainport;
HwSettingsRM_MainPortGet(&hwsettings_mainport);

View File

@ -135,7 +135,13 @@ extern uint32_t pios_i2c_flexiport_adapter_id;
//
// See also pios_board.c
// -------------------------
#define PIOS_USART_MAX_DEVS 5
#define PIOS_USART_MAX_DEVS 5
// Inverter for SBUS handling
#define PIOS_USART_INVERTER_PORT USART2
#define PIOS_USART_INVERTER_GPIO GPIOC
#define PIOS_USART_INVERTER_PIN GPIO_Pin_15
#define PIOS_USART_INVERTER_ENABLE Bit_SET
#define PIOS_USART_INVERTER_DISABLE Bit_RESET
// -------------------------
// PIOS_COM

View File

@ -712,14 +712,6 @@ static const struct pios_usart_cfg pios_usart_aux_cfg = {
* AUX USART SBUS ( UART/ S Bus label on rev2)
*/
// Inverter for SBUS handling
#define MAIN_USART_INVERTER_GPIO GPIOC
#define MAIN_USART_INVERTER_PIN GPIO_Pin_3
#define MAIN_USART_INVERTER_ENABLE Bit_SET
#define MAIN_USART_INVERTER_DISABLE Bit_RESET
static int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param);
static const struct pios_usart_cfg pios_usart_auxsbus_cfg = {
.regs = UART4,
.remap = GPIO_AF_UART4,
@ -743,7 +735,6 @@ static const struct pios_usart_cfg pios_usart_auxsbus_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.ioctl = PIOS_BOARD_USART_Ioctl,
};
#endif /* PIOS_INCLUDE_COM_AUXSBUS */

View File

@ -56,25 +56,6 @@ uintptr_t pios_user_fs_id;
#include <pios_board_info.h>
int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
{
const struct pios_usart_cfg *usart_cfg = PIOS_USART_GetConfig(usart_id);
switch (ctl) {
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_cfg->regs == pios_usart_auxsbus_cfg.regs) { /* main port */
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? MAIN_USART_INVERTER_ENABLE : MAIN_USART_INVERTER_DISABLE);
return 0;
}
break;
}
return -1;
}
void PIOS_Board_Init(void)
{
/* Delay system */
@ -183,23 +164,6 @@ void PIOS_Board_Init(void)
#if defined(PIOS_INCLUDE_USB)
PIOS_BOARD_IO_Configure_USB();
#endif
/* Initialize inverter gpio and set it to off */
{
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = MAIN_USART_INVERTER_PIN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
};
GPIO_Init(MAIN_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(MAIN_USART_INVERTER_GPIO,
MAIN_USART_INVERTER_PIN,
MAIN_USART_INVERTER_DISABLE);
}
/* Configure IO ports */
/* Configure Telemetry port */

View File

@ -122,7 +122,13 @@ extern uint32_t pios_i2c_flexiport_adapter_id;
//
// See also pios_board.c
// -------------------------
#define PIOS_USART_MAX_DEVS 5
#define PIOS_USART_MAX_DEVS 5
// Inverter for SBUS handling
#define PIOS_USART_INVERTER_PORT UART4
#define PIOS_USART_INVERTER_GPIO GPIOC
#define PIOS_USART_INVERTER_PIN GPIO_Pin_3
#define PIOS_USART_INVERTER_ENABLE Bit_SET
#define PIOS_USART_INVERTER_DISABLE Bit_RESET
// -------------------------
// PIOS_COM

View File

@ -605,15 +605,6 @@ static const struct pios_usart_cfg pios_usart_flexi_cfg = {
* RCVR PORT
*/
// Inverter for SBUS handling
#define RCVR_USART_INVERTER_GPIO GPIOC
#define RCVR_USART_INVERTER_PIN GPIO_Pin_4
#define RCVR_USART_INVERTER_ENABLE Bit_SET
#define RCVR_USART_INVERTER_DISABLE Bit_RESET
static int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param);
static const struct pios_usart_cfg pios_usart_rcvr_cfg = {
.regs = USART6,
.remap = GPIO_AF_USART6,
@ -627,7 +618,6 @@ static const struct pios_usart_cfg pios_usart_rcvr_cfg = {
.GPIO_PuPd = GPIO_PuPd_UP
},
},
.ioctl = PIOS_BOARD_USART_Ioctl,
};
#endif /* PIOS_INCLUDE_USART */

View File

@ -93,25 +93,6 @@ static const PIOS_BOARD_IO_UART_Function flexi_function_map[] = {
[HWSETTINGS_SPK2_FLEXIPORT_MAVLINK] = PIOS_BOARD_IO_UART_MAVLINK,
};
int32_t PIOS_BOARD_USART_Ioctl(uint32_t usart_id, uint32_t ctl, void *param)
{
const struct pios_usart_cfg *usart_cfg = PIOS_USART_GetConfig(usart_id);
switch (ctl) {
case PIOS_IOCTL_USART_SET_INVERTED:
if (usart_cfg->regs == pios_usart_rcvr_cfg.regs) { /* rcvr port */
GPIO_WriteBit(RCVR_USART_INVERTER_GPIO,
RCVR_USART_INVERTER_PIN,
(*(enum PIOS_USART_Inverted *)param & PIOS_USART_Inverted_Rx) ? RCVR_USART_INVERTER_ENABLE : RCVR_USART_INVERTER_DISABLE);
return 0;
}
break;
}
return -1;
}
/**
* PIOS_Board_Init()
* initializes all the core subsystems on this specific hardware
@ -265,22 +246,6 @@ void PIOS_Board_Init(void)
PIOS_BOARD_IO_Configure_RadioAuxStream(hwsettings_radioaux);
#endif /* PIOS_INCLUDE_RFM22B */
/* Initialize inverter gpio and set it to off */
{
GPIO_InitTypeDef inverterGPIOInit = {
.GPIO_Pin = RCVR_USART_INVERTER_PIN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_UP
};
GPIO_Init(RCVR_USART_INVERTER_GPIO, &inverterGPIOInit);
GPIO_WriteBit(RCVR_USART_INVERTER_GPIO,
RCVR_USART_INVERTER_PIN,
RCVR_USART_INVERTER_DISABLE);
}
// Configure the receiver port
// Sparky2 receiver input on PC7 TIM8 CH2
// include PPM,S.Bus,DSM,SRXL,IBus,EX.Bus,HoTT SUMD,HoTT SUMH

View File

@ -140,7 +140,14 @@ extern uint32_t pios_i2c_flexiport_adapter_id;
//
// See also pios_board.c
// -------------------------
#define PIOS_USART_MAX_DEVS 5
#define PIOS_USART_MAX_DEVS 5
// Inverter for SBUS handling
#define PIOS_USART_INVERTER_PORT USART6
#define PIOS_USART_INVERTER_GPIO GPIOC
#define PIOS_USART_INVERTER_PIN GPIO_Pin_4
#define PIOS_USART_INVERTER_ENABLE Bit_SET
#define PIOS_USART_INVERTER_DISABLE Bit_RESET
// -------------------------
// PIOS_COM