From 5895468f08a613a88e9e1754f8630c8ddd309bbe Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Wed, 3 Aug 2016 17:31:41 +0200 Subject: [PATCH 1/4] LP-298 Port Ibus Input driver from dRonin - Not tested --- flight/make/apps-defs.mk | 1 + flight/modules/Receiver/receiver.c | 3 + flight/pios/common/pios_ibus.c | 256 ++++++++++++++++++ flight/pios/inc/pios_ibus.h | 38 +++ flight/pios/inc/pios_ibus_priv.h | 51 ++++ flight/pios/pios.h | 4 + .../boards/coptercontrol/board_hw_defs.c | 44 +++ .../coptercontrol/firmware/inc/pios_config.h | 1 + .../coptercontrol/firmware/pios_board.c | 23 +- .../targets/boards/coptercontrol/pios_board.h | 6 + .../targets/boards/revolution/board_hw_defs.c | 49 ++++ .../revolution/firmware/inc/pios_config.h | 1 + .../boards/revolution/firmware/pios_board.c | 22 ++ .../targets/boards/revonano/board_hw_defs.c | 51 +++- .../boards/revonano/firmware/pios_board.c | 24 +- flight/targets/boards/sparky2/board_hw_defs.c | 80 ++++++ .../boards/sparky2/firmware/inc/pios_config.h | 1 + .../boards/sparky2/firmware/pios_board.c | 34 ++- .../src/plugins/config/inputchannelform.cpp | 3 + shared/uavobjectdefinition/hwsettings.xml | 8 +- .../manualcontrolsettings.xml | 2 +- .../uavobjectdefinition/receiveractivity.xml | 2 +- 22 files changed, 694 insertions(+), 10 deletions(-) create mode 100644 flight/pios/common/pios_ibus.c create mode 100644 flight/pios/inc/pios_ibus.h create mode 100644 flight/pios/inc/pios_ibus_priv.h diff --git a/flight/make/apps-defs.mk b/flight/make/apps-defs.mk index 929efafdc..d4d89ce31 100644 --- a/flight/make/apps-defs.mk +++ b/flight/make/apps-defs.mk @@ -93,6 +93,7 @@ SRC += $(PIOSCOMMON)/pios_sbus.c SRC += $(PIOSCOMMON)/pios_hott.c SRC += $(PIOSCOMMON)/pios_srxl.c SRC += $(PIOSCOMMON)/pios_exbus.c +SRC += $(PIOSCOMMON)/pios_ibus.c SRC += $(PIOSCOMMON)/pios_sdcard.c SRC += $(PIOSCOMMON)/pios_sensors.c SRC += $(PIOSCOMMON)/pios_openlrs.c diff --git a/flight/modules/Receiver/receiver.c b/flight/modules/Receiver/receiver.c index 2414c8115..900e1194c 100644 --- a/flight/modules/Receiver/receiver.c +++ b/flight/modules/Receiver/receiver.c @@ -670,6 +670,9 @@ static bool updateRcvrActivityCompare(uint32_t rcvr_id, struct rcvr_activity_fsm case MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL: group = RECEIVERACTIVITY_ACTIVEGROUP_SRXL; break; + case MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS: + group = RECEIVERACTIVITY_ACTIVEGROUP_IBUS; + break; case MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS: group = RECEIVERACTIVITY_ACTIVEGROUP_GCS; break; diff --git a/flight/pios/common/pios_ibus.c b/flight/pios/common/pios_ibus.c new file mode 100644 index 000000000..5f3300d53 --- /dev/null +++ b/flight/pios/common/pios_ibus.c @@ -0,0 +1,256 @@ +/** + ****************************************************************************** + * @file pios_ibus.c + * @author dRonin, http://dRonin.org/, Copyright (C) 2016 + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @addtogroup PIOS_IBus PiOS IBus receiver driver + * @{ + * @brief Receives and decodes IBus protocol reciever packets + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Additional note on redistribution: The copyright and license notices above + * must be maintained in each individual source file that is a derivative work + * of this source file; otherwise redistribution is prohibited. + */ + +#include "pios_ibus_priv.h" + +#ifdef PIOS_INCLUDE_IBUS + +// private +#define PIOS_IBUS_CHANNELS 10 +// 1 sync byte, 1 unknown byte, 10x channels (uint16_t), 8 unknown bytes, 2 crc bytes +#define PIOS_IBUS_BUFLEN (1 + 1 + PIOS_IBUS_CHANNELS * 2 + 8 + 2) +#define PIOS_IBUS_SYNCBYTE 0x20 +#define PIOS_IBUS_MAGIC 0x84fd9a39 + +/** + * @brief IBus receiver driver internal state data + */ +struct pios_ibus_dev { + uint32_t magic; + int buf_pos; + int rx_timer; + int failsafe_timer; + uint16_t checksum; + uint16_t channel_data[PIOS_IBUS_CHANNELS]; + uint8_t rx_buf[PIOS_IBUS_BUFLEN]; +}; + +/** + * @brief Allocates a driver instance + * @retval pios_ibus_dev pointer on success, NULL on failure + */ +static struct pios_ibus_dev *PIOS_IBUS_Alloc(void); +/** + * @brief Validate a driver instance + * @param[in] dev device driver instance pointer + * @retval true on success, false on failure + */ +static bool PIOS_IBUS_Validate(const struct pios_ibus_dev *ibus_dev); +/** + * @brief Read a channel from the last received frame + * @param[in] id Driver instance + * @param[in] channel 0-based channel index + * @retval raw channel value, or error value (see pios_rcvr.h) + */ +static int32_t PIOS_IBUS_Read(uint32_t id, uint8_t channel); +/** + * @brief Set all channels in the last frame buffer to a given value + * @param[in] dev Driver instance + * @param[in] value channel value + */ +static void PIOS_IBUS_SetAllChannels(struct pios_ibus_dev *ibus_dev, uint16_t value); +/** + * @brief Serial receive callback + * @param[in] context Driver instance handle + * @param[in] buf Receive buffer + * @param[in] buf_len Number of bytes available + * @param[out] headroom Number of bytes remaining in internal buffer + * @param[out] task_woken Did we awake a task? + * @retval Number of bytes consumed from the buffer + */ +static uint16_t PIOS_IBUS_Receive(uint32_t context, uint8_t *buf, uint16_t buf_len, + uint16_t *headroom, bool *task_woken); +/** + * @brief Reset the internal receive buffer state + * @param[in] ibus_dev device driver instance pointer + */ +static void PIOS_IBUS_ResetBuffer(struct pios_ibus_dev *ibus_dev); +/** + * @brief Unpack a frame from the internal receive buffer to the channel buffer + * @param[in] ibus_dev device driver instance pointer + */ +static void PIOS_IBUS_UnpackFrame(struct pios_ibus_dev *ibus_dev); +/** + * @brief RTC tick callback + * @param[in] context Driver instance handle + */ +static void PIOS_IBUS_Supervisor(uint32_t context); + +// public +const struct pios_rcvr_driver pios_ibus_rcvr_driver = { + .read = PIOS_IBUS_Read, +}; + + +static struct pios_ibus_dev *PIOS_IBUS_Alloc(void) +{ + struct pios_ibus_dev *ibus_dev; + + ibus_dev = (struct pios_ibus_dev *)pios_malloc(sizeof(*ibus_dev)); + + if (!ibus_dev) { + return NULL; + } + + memset(ibus_dev, 0, sizeof(*ibus_dev)); + ibus_dev->magic = PIOS_IBUS_MAGIC; + + return ibus_dev; +} + +static bool PIOS_IBUS_Validate(const struct pios_ibus_dev *ibus_dev) +{ + return ibus_dev && ibus_dev->magic == PIOS_IBUS_MAGIC; +} + +int32_t PIOS_IBUS_Init(uint32_t *ibus_id, const struct pios_com_driver *driver, + uint32_t lower_id) +{ + struct pios_ibus_dev *ibus_dev = PIOS_IBUS_Alloc(); + + if (!ibus_dev) { + return -1; + } + + *ibus_id = (uint32_t)ibus_dev; + + PIOS_IBUS_SetAllChannels(ibus_dev, PIOS_RCVR_INVALID); + + if (!PIOS_RTC_RegisterTickCallback(PIOS_IBUS_Supervisor, *ibus_id)) { + PIOS_Assert(0); + } + + (driver->bind_rx_cb)(lower_id, PIOS_IBUS_Receive, *ibus_id); + + return 0; +} + +static int32_t PIOS_IBUS_Read(uint32_t context, uint8_t channel) +{ + if (channel > PIOS_IBUS_CHANNELS) { + return PIOS_RCVR_INVALID; + } + + struct pios_ibus_dev *ibus_dev = (struct pios_ibus_dev *)context; + if (!PIOS_IBUS_Validate(ibus_dev)) { + return PIOS_RCVR_NODRIVER; + } + + return ibus_dev->channel_data[channel]; +} + +static void PIOS_IBUS_SetAllChannels(struct pios_ibus_dev *ibus_dev, uint16_t value) +{ + for (int i = 0; i < PIOS_IBUS_CHANNELS; i++) { + ibus_dev->channel_data[i] = value; + } +} + +static uint16_t PIOS_IBUS_Receive(uint32_t context, uint8_t *buf, uint16_t buf_len, + uint16_t *headroom, bool *task_woken) +{ + struct pios_ibus_dev *ibus_dev = (struct pios_ibus_dev *)context; + + if (!PIOS_IBUS_Validate(ibus_dev)) { + goto out_fail; + } + + for (int i = 0; i < buf_len; i++) { + if (ibus_dev->buf_pos == 0 && buf[i] != PIOS_IBUS_SYNCBYTE) { + continue; + } + + ibus_dev->rx_buf[ibus_dev->buf_pos++] = buf[i]; + if (ibus_dev->buf_pos <= PIOS_IBUS_BUFLEN - 2) { + ibus_dev->checksum -= buf[i]; + } else if (ibus_dev->buf_pos == PIOS_IBUS_BUFLEN) { + PIOS_IBUS_UnpackFrame(ibus_dev); + } + } + + ibus_dev->rx_timer = 0; + + *headroom = PIOS_IBUS_BUFLEN - ibus_dev->buf_pos; + *task_woken = false; + return buf_len; + +out_fail: + *headroom = 0; + *task_woken = false; + return 0; +} + +static void PIOS_IBUS_ResetBuffer(struct pios_ibus_dev *ibus_dev) +{ + ibus_dev->checksum = 0xffff; + ibus_dev->buf_pos = 0; +} + +static void PIOS_IBUS_UnpackFrame(struct pios_ibus_dev *ibus_dev) +{ + uint16_t rxsum = ibus_dev->rx_buf[PIOS_IBUS_BUFLEN - 1] << 8 | + ibus_dev->rx_buf[PIOS_IBUS_BUFLEN - 2]; + + if (ibus_dev->checksum != rxsum) { + goto out_fail; + } + + uint16_t *chan = (uint16_t *)&ibus_dev->rx_buf[2]; + for (int i = 0; i < PIOS_IBUS_CHANNELS; i++) { + ibus_dev->channel_data[i] = *chan++; + } + + ibus_dev->failsafe_timer = 0; + +out_fail: + PIOS_IBUS_ResetBuffer(ibus_dev); +} + +static void PIOS_IBUS_Supervisor(uint32_t context) +{ + struct pios_ibus_dev *ibus_dev = (struct pios_ibus_dev *)context; + + PIOS_Assert(PIOS_IBUS_Validate(ibus_dev)); + + if (++ibus_dev->rx_timer > 3) { + PIOS_IBUS_ResetBuffer(ibus_dev); + } + + if (++ibus_dev->failsafe_timer > 32) { + PIOS_IBUS_SetAllChannels(ibus_dev, PIOS_RCVR_TIMEOUT); + } +} + +#endif // PIOS_INCLUDE_IBUS + +/** + * @} + * @} + */ diff --git a/flight/pios/inc/pios_ibus.h b/flight/pios/inc/pios_ibus.h new file mode 100644 index 000000000..7c27d26d2 --- /dev/null +++ b/flight/pios/inc/pios_ibus.h @@ -0,0 +1,38 @@ +/** + ****************************************************************************** + * + * @file pios_ibus.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. + * dRonin, http://dRonin.org/, Copyright (C) 2016 + * @brief FlySky IBus functions header. + * @see The GNU Public License (GPL) Version 3 + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PIOS_IBUS_H +#define PIOS_IBUS_H + +/* Global Types */ + +/* Public Functions */ + +#endif /* PIOS_IBUS_H */ + +/** + * @} + * @} + */ diff --git a/flight/pios/inc/pios_ibus_priv.h b/flight/pios/inc/pios_ibus_priv.h new file mode 100644 index 000000000..d0a9146f6 --- /dev/null +++ b/flight/pios/inc/pios_ibus_priv.h @@ -0,0 +1,51 @@ +/** + ****************************************************************************** + * @file pios_ibus_priv.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. + * dRonin, http://dRonin.org/, Copyright (C) 2016 + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @addtogroup PIOS_IBus IBus receiver functions + * @{ + * @brief Receives and decodes IBus protocol receiver packets + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Additional note on redistribution: The copyright and license notices above + * must be maintained in each individual source file that is a derivative work + * of this source file; otherwise redistribution is prohibited. + */ + + +#ifndef PIOS_IBUS_PRIV_H +#define PIOS_IBUS_PRIV_H + +#include +#include + +/* IBUS receiver instance configuration */ +extern const struct pios_rcvr_driver pios_ibus_rcvr_driver; + +extern int32_t PIOS_IBUS_Init(uint32_t *ibus_id, + const struct pios_com_driver *driver, + uint32_t lower_id); + +#endif // PIOS_IBUS_PRIV_H + +/** + * @} + * @} + */ diff --git a/flight/pios/pios.h b/flight/pios/pios.h index fca43089b..3050b9c6f 100644 --- a/flight/pios/pios.h +++ b/flight/pios/pios.h @@ -241,6 +241,10 @@ extern "C" { #include #endif +#ifdef PIOS_INCLUDE_IBUS +#include +#endif + /* PIOS abstract receiver interface */ #ifdef PIOS_INCLUDE_RCVR #include diff --git a/flight/targets/boards/coptercontrol/board_hw_defs.c b/flight/targets/boards/coptercontrol/board_hw_defs.c index b693a7e9b..4222540ef 100644 --- a/flight/targets/boards/coptercontrol/board_hw_defs.c +++ b/flight/targets/boards/coptercontrol/board_hw_defs.c @@ -1151,6 +1151,50 @@ static const struct pios_usart_cfg pios_usart_srxl_flexi_cfg = { #endif /* PIOS_INCLUDE_SRXL */ +#if defined(PIOS_INCLUDE_IBUS) +/* + * IBUS USART + */ +#include + +static const struct pios_usart_cfg pios_usart_ibus_flexi_cfg = { + .regs = USART3, + .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 = USART3_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .rx = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_11, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_IPU, + }, + }, + .tx = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_10, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_IN_FLOATING, + }, + }, +}; + +#endif /* PIOS_INCLUDE_IBUS */ + #if defined(PIOS_INCLUDE_SBUS) /* * S.Bus USART diff --git a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h index 1d4bcebbe..a6f521c81 100644 --- a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h +++ b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h @@ -106,6 +106,7 @@ #define PIOS_INCLUDE_EXBUS #define PIOS_INCLUDE_SRXL #define PIOS_INCLUDE_HOTT +#define PIOS_INCLUDE_IBUS /* #define PIOS_INCLUDE_GCSRCVR */ /* #define PIOS_INCLUDE_OPLINKRCVR */ diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index 25486b94d..820211c1d 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -382,7 +382,6 @@ void PIOS_Board_Init(void) break; case HWSETTINGS_USB_VCPPORT_USBTELEMETRY: #if defined(PIOS_INCLUDE_COM) - { uint32_t pios_usb_cdc_id; if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) { @@ -670,6 +669,28 @@ void PIOS_Board_Init(void) #endif /* PIOS_INCLUDE_SRXL */ break; + case HWSETTINGS_CC_FLEXIPORT_IBUS: +#if defined(PIOS_INCLUDE_IBUS) + { + uint32_t pios_usart_ibus_id; + if (PIOS_USART_Init(&pios_usart_ibus_id, &pios_usart_ibus_flexi_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; + } +#endif /* PIOS_INCLUDE_IBUS */ + break; + case HWSETTINGS_CC_FLEXIPORT_DEBUGCONSOLE: #if defined(PIOS_INCLUDE_COM) #if defined(PIOS_INCLUDE_DEBUG_CONSOLE) diff --git a/flight/targets/boards/coptercontrol/pios_board.h b/flight/targets/boards/coptercontrol/pios_board.h index bfbb91819..1750b4d9a 100644 --- a/flight/targets/boards/coptercontrol/pios_board.h +++ b/flight/targets/boards/coptercontrol/pios_board.h @@ -272,6 +272,12 @@ extern uint32_t pios_com_mavlink_id; #define PIOS_SRXL_MAX_DEVS 1 #define PIOS_SRXL_NUM_INPUTS 16 +// ------------------------- +// Receiver FlySky IBus input +// ------------------------- +#define PIOS_IBUS_MAX_DEVS 1 +#define PIOS_IBUS_NUM_INPUTS 10 + // ------------------------- // Servo outputs // ------------------------- diff --git a/flight/targets/boards/revolution/board_hw_defs.c b/flight/targets/boards/revolution/board_hw_defs.c index 7218aa4a0..ac37cdbe0 100644 --- a/flight/targets/boards/revolution/board_hw_defs.c +++ b/flight/targets/boards/revolution/board_hw_defs.c @@ -1171,6 +1171,55 @@ static const struct pios_usart_cfg pios_usart_hott_flexi_cfg = { #endif /* PIOS_INCLUDE_HOTT */ +#if defined(PIOS_INCLUDE_IBUS) +/* + * IBUS USART + */ +#include + +static const struct pios_usart_cfg pios_usart_ibus_flexi_cfg = { + .regs = USART3, + .remap = GPIO_AF_USART3, + .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 = USART3_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .rx = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_11, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .tx = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_10, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_OUT, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, +}; + +#endif /* PIOS_INCLUDE_IBUS */ + #if defined(PIOS_INCLUDE_EXBUS) /* * EXBUS USART diff --git a/flight/targets/boards/revolution/firmware/inc/pios_config.h b/flight/targets/boards/revolution/firmware/inc/pios_config.h index d040e90d5..efe32a4be 100644 --- a/flight/targets/boards/revolution/firmware/inc/pios_config.h +++ b/flight/targets/boards/revolution/firmware/inc/pios_config.h @@ -107,6 +107,7 @@ #define PIOS_INCLUDE_SRXL #define PIOS_INCLUDE_HOTT #define PIOS_INCLUDE_EXBUS +#define PIOS_INCLUDE_IBUS #define PIOS_INCLUDE_GCSRCVR #define PIOS_INCLUDE_OPLINKRCVR #define PIOS_INCLUDE_OPENLRS_RCVR diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index f491a1e3f..142a7c198 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -586,6 +586,28 @@ void PIOS_Board_Init(void) #endif /* PIOS_INCLUDE_SRXL */ break; + case HWSETTINGS_RM_FLEXIPORT_IBUS: +#if defined(PIOS_INCLUDE_IBUS) + { + uint32_t pios_usart_ibus_id; + if (PIOS_USART_Init(&pios_usart_ibus_id, &pios_usart_ibus_flexi_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; + } +#endif /* PIOS_INCLUDE_IBUS */ + break; + case HWSETTINGS_RM_FLEXIPORT_HOTTSUMD: case HWSETTINGS_RM_FLEXIPORT_HOTTSUMH: #if defined(PIOS_INCLUDE_HOTT) diff --git a/flight/targets/boards/revonano/board_hw_defs.c b/flight/targets/boards/revonano/board_hw_defs.c index 7c651de48..c17c7539c 100644 --- a/flight/targets/boards/revonano/board_hw_defs.c +++ b/flight/targets/boards/revonano/board_hw_defs.c @@ -634,6 +634,55 @@ static const struct pios_usart_cfg pios_usart_srxl_flexi_cfg = { #endif /* PIOS_INCLUDE_SRXL */ +#if defined(PIOS_INCLUDE_IBUS) +/* + * IBUS USART + */ +#include + +static const struct pios_usart_cfg pios_usart_ibus_flexi_cfg = { + .regs = FLEXI_USART_REGS, + .remap = FLEXI_USART_REMAP, + .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 = FLEXI_USART_IRQ, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .rx = { + .gpio = FLEXI_USART_RX_GPIO, + .init = { + .GPIO_Pin = FLEXI_USART_RX_PIN, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .tx = { + .gpio = FLEXI_USART_TX_GPIO, + .init = { + .GPIO_Pin = FLEXI_USART_TX_PIN, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_OUT, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, +}; + +#endif /* PIOS_INCLUDE_IBUS */ + #if defined(PIOS_INCLUDE_EXBUS) /* * EXBUS USART @@ -681,8 +730,8 @@ static const struct pios_usart_cfg pios_usart_exbus_flexi_cfg = { }, }; - #endif /* PIOS_INCLUDE_EXBUS */ + /* * HK OSD */ diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index 9e8e6accf..c09a117b3 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -733,7 +733,29 @@ void PIOS_Board_Init(void) } pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL] = pios_srxl_rcvr_id; } -#endif +#endif /* PIOS_INCLUDE_SRXL */ + break; + + case HWSETTINGS_RM_FLEXIPORT_IBUS: +#if defined(PIOS_INCLUDE_IBUS) + { + uint32_t pios_usart_ibus_id; + if (PIOS_USART_Init(&pios_usart_ibus_id, &pios_usart_ibus_flexi_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; + } +#endif /* PIOS_INCLUDE_IBUS */ break; case HWSETTINGS_RM_FLEXIPORT_HOTTSUMD: diff --git a/flight/targets/boards/sparky2/board_hw_defs.c b/flight/targets/boards/sparky2/board_hw_defs.c index 7e550cdf7..3fb99a725 100644 --- a/flight/targets/boards/sparky2/board_hw_defs.c +++ b/flight/targets/boards/sparky2/board_hw_defs.c @@ -838,6 +838,86 @@ static const struct pios_usart_cfg pios_usart_srxl_rcvr_cfg = { #endif /* PIOS_INCLUDE_SRXL */ +#if defined(PIOS_INCLUDE_IBUS) +/* + * IBUS USART + */ +#include + +static const struct pios_usart_cfg pios_usart_ibus_flexi_cfg = { + .regs = USART3, + .remap = GPIO_AF_USART3, + .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 = USART3_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .rx = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_11, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .tx = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_10, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_OUT, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, +}; + +static const struct pios_usart_cfg pios_usart_ibus_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_IBUS */ + // these were copied from Revo support // they might need to be further modified for Sparky2 support #if defined(PIOS_INCLUDE_HOTT) diff --git a/flight/targets/boards/sparky2/firmware/inc/pios_config.h b/flight/targets/boards/sparky2/firmware/inc/pios_config.h index 5a3b39372..e823a82a1 100644 --- a/flight/targets/boards/sparky2/firmware/inc/pios_config.h +++ b/flight/targets/boards/sparky2/firmware/inc/pios_config.h @@ -111,6 +111,7 @@ #define PIOS_INCLUDE_SRXL #define PIOS_INCLUDE_HOTT #define PIOS_INCLUDE_EXBUS +#define PIOS_INCLUDE_IBUS #define PIOS_INCLUDE_GCSRCVR #define PIOS_INCLUDE_OPLINKRCVR #define PIOS_INCLUDE_OPENLRS_RCVR diff --git a/flight/targets/boards/sparky2/firmware/pios_board.c b/flight/targets/boards/sparky2/firmware/pios_board.c index 27446ee6b..f697c156e 100644 --- a/flight/targets/boards/sparky2/firmware/pios_board.c +++ b/flight/targets/boards/sparky2/firmware/pios_board.c @@ -327,6 +327,27 @@ static void PIOS_Board_configure_srxl(const struct pios_usart_cfg *usart_cfg) pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL] = pios_srxl_rcvr_id; } +static void PIOS_Board_configure_ibus(const struct pios_usart_cfg *usart_cfg) +{ + uint32_t pios_usart_ibus_id; + + if (PIOS_USART_Init(&pios_usart_ibus_id, usart_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; +} + static void PIOS_Board_configure_exbus(const struct pios_usart_cfg *usart_cfg) { @@ -582,6 +603,12 @@ void PIOS_Board_Init(void) #endif /* PIOS_INCLUDE_SRXL */ break; + case HWSETTINGS_SPK2_FLEXIPORT_IBUS: +#if defined(PIOS_INCLUDE_IBUS) + PIOS_Board_configure_ibus(&pios_usart_ibus_flexi_cfg); +#endif /* PIOS_INCLUDE_IBUS */ + break; + case HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMD: case HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMH: #if defined(PIOS_INCLUDE_HOTT) @@ -926,7 +953,7 @@ void PIOS_Board_Init(void) // Configure the receiver port // Sparky2 receiver input on PC7 TIM8 CH2 - // include PPM,S.Bus,DSM,SRXL,EX.Bus,HoTT SUMD,HoTT SUMH + // include PPM,S.Bus,DSM,SRXL,IBus,EX.Bus,HoTT SUMD,HoTT SUMH uint8_t hwsettings_rcvrport; HwSettingsSPK2_RcvrPortGet(&hwsettings_rcvrport); @@ -962,6 +989,11 @@ void PIOS_Board_Init(void) PIOS_Board_configure_srxl(&pios_usart_srxl_rcvr_cfg); #endif /* PIOS_INCLUDE_SRXL */ break; + case HWSETTINGS_SPK2_RCVRPORT_IBUS: +#if defined(PIOS_INCLUDE_IBUS) + PIOS_Board_configure_ibus(&pios_usart_ibus_rcvr_cfg); +#endif /* PIOS_INCLUDE_IBUS */ + break; case HWSETTINGS_SPK2_RCVRPORT_HOTTSUMD: case HWSETTINGS_SPK2_RCVRPORT_HOTTSUMH: #if defined(PIOS_INCLUDE_HOTT) diff --git a/ground/gcs/src/plugins/config/inputchannelform.cpp b/ground/gcs/src/plugins/config/inputchannelform.cpp index 5efbf4a9d..4b8ef15d0 100644 --- a/ground/gcs/src/plugins/config/inputchannelform.cpp +++ b/ground/gcs/src/plugins/config/inputchannelform.cpp @@ -146,6 +146,9 @@ void InputChannelForm::groupUpdated() case ManualControlSettings::CHANNELGROUPS_OPLINK: count = 8; // Need to make this 6 for CC break; + case ManualControlSettings::CHANNELGROUPS_IBUS: + count = 10; + break; case ManualControlSettings::CHANNELGROUPS_DSMMAINPORT: case ManualControlSettings::CHANNELGROUPS_DSMFLEXIPORT: case ManualControlSettings::CHANNELGROUPS_DSMRCVRPORT: diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml index bbbbd5200..1eeaa0c48 100644 --- a/shared/uavobjectdefinition/hwsettings.xml +++ b/shared/uavobjectdefinition/hwsettings.xml @@ -3,7 +3,7 @@ Selection of optional hardware configurations. - + @@ -15,11 +15,11 @@ defaultvalue="PWM" limits="%0905NE:PPM+PWM:PPM+Telemetry:Telemetry:ComBridge:MSP:MAVLink;"/> - + - + - + diff --git a/shared/uavobjectdefinition/manualcontrolsettings.xml b/shared/uavobjectdefinition/manualcontrolsettings.xml index 9d9c6bdde..ef1cb93e4 100644 --- a/shared/uavobjectdefinition/manualcontrolsettings.xml +++ b/shared/uavobjectdefinition/manualcontrolsettings.xml @@ -3,7 +3,7 @@ Settings to indicate how to decode receiver input by @ref ManualControlModule. + options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),DSM (RcvrPort),S.Bus,EX.Bus,HoTT,SRXL,IBus,GCS,OPLink,OpenLRS,None" defaultvalue="None"/> Monitors which receiver channels have been active within the last second. From 848638d6e77b60c62fa3b08cb0d014782a728968 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Wed, 3 Aug 2016 19:02:32 +0200 Subject: [PATCH 2/4] LP-298 Add IBus input to wizard --- .../plugins/setupwizard/connectiondiagram.cpp | 3 + .../setupwizard/pages/airspeedpage.cpp | 1 + .../src/plugins/setupwizard/pages/gpspage.cpp | 1 + .../plugins/setupwizard/pages/inputpage.cpp | 11 + .../plugins/setupwizard/pages/inputpage.ui | 55 +- .../setupwizard/resources/bttn-ibus-down.png | Bin 0 -> 3192 bytes .../setupwizard/resources/bttn-ibus-up.png | Bin 0 -> 3792 bytes .../resources/connection-diagrams.svg | 478 +++++++++++++++++- .../src/plugins/setupwizard/setupwizard.cpp | 3 + .../vehicleconfigurationhelper.cpp | 13 + .../setupwizard/vehicleconfigurationsource.h | 2 +- .../plugins/setupwizard/wizardResources.qrc | 2 + 12 files changed, 558 insertions(+), 11 deletions(-) create mode 100644 ground/gcs/src/plugins/setupwizard/resources/bttn-ibus-down.png create mode 100644 ground/gcs/src/plugins/setupwizard/resources/bttn-ibus-up.png diff --git a/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp b/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp index a47088e35..5ea7fea46 100644 --- a/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp +++ b/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp @@ -213,6 +213,9 @@ void ConnectionDiagram::setupGraphicsScene() case VehicleConfigurationSource::INPUT_EXBUS: elementsToShow << QString("%1exbus").arg(prefix); break; + case VehicleConfigurationSource::INPUT_IBUS: + elementsToShow << QString("%1ibus").arg(prefix); + break; default: break; } diff --git a/ground/gcs/src/plugins/setupwizard/pages/airspeedpage.cpp b/ground/gcs/src/plugins/setupwizard/pages/airspeedpage.cpp index d89e370ba..8182e2bd4 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/airspeedpage.cpp +++ b/ground/gcs/src/plugins/setupwizard/pages/airspeedpage.cpp @@ -46,6 +46,7 @@ void AirSpeedPage::initializePage(VehicleConfigurationSource *settings) settings->getInputType() == VehicleConfigurationSource::INPUT_DSM || settings->getInputType() == VehicleConfigurationSource::INPUT_SRXL || settings->getInputType() == VehicleConfigurationSource::INPUT_HOTT_SUMD || + settings->getInputType() == VehicleConfigurationSource::INPUT_IBUS || settings->getInputType() == VehicleConfigurationSource::INPUT_EXBUS)) || settings->getGpsType() == VehicleConfigurationSource::GPS_UBX_FLEXI_I2CMAG) { // Disable non estimated sensors if ports are taken by receivers or I2C Mag diff --git a/ground/gcs/src/plugins/setupwizard/pages/gpspage.cpp b/ground/gcs/src/plugins/setupwizard/pages/gpspage.cpp index 3f6c4295b..2cba4670b 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/gpspage.cpp +++ b/ground/gcs/src/plugins/setupwizard/pages/gpspage.cpp @@ -46,6 +46,7 @@ void GpsPage::initializePage(VehicleConfigurationSource *settings) settings->getInputType() == VehicleConfigurationSource::INPUT_DSM || settings->getInputType() == VehicleConfigurationSource::INPUT_SRXL || settings->getInputType() == VehicleConfigurationSource::INPUT_HOTT_SUMD || + settings->getInputType() == VehicleConfigurationSource::INPUT_IBUS || settings->getInputType() == VehicleConfigurationSource::INPUT_EXBUS)) { // Disable GPS+I2C Mag setItemDisabled(VehicleConfigurationSource::GPS_UBX_FLEXI_I2CMAG, true); diff --git a/ground/gcs/src/plugins/setupwizard/pages/inputpage.cpp b/ground/gcs/src/plugins/setupwizard/pages/inputpage.cpp index 298236190..87354fc14 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/inputpage.cpp +++ b/ground/gcs/src/plugins/setupwizard/pages/inputpage.cpp @@ -69,6 +69,8 @@ bool InputPage::validatePage() getWizard()->setInputType(SetupWizard::INPUT_HOTT_SUMD); } else if (ui->jetiButton->isChecked()) { getWizard()->setInputType(SetupWizard::INPUT_EXBUS); + } else if (ui->flyskyButton->isChecked()) { + getWizard()->setInputType(SetupWizard::INPUT_IBUS); } else if (ui->spectrumButton->isChecked()) { getWizard()->setInputType(SetupWizard::INPUT_DSM); } else if (ui->multiplexButton->isChecked()) { @@ -112,6 +114,9 @@ bool InputPage::restartNeeded(VehicleConfigurationSource::INPUT_TYPE selectedTyp case VehicleConfigurationSource::INPUT_EXBUS: return data.CC_FlexiPort != HwSettings::CC_FLEXIPORT_EXBUS; + case VehicleConfigurationSource::INPUT_IBUS: + return data.CC_FlexiPort != HwSettings::CC_FLEXIPORT_IBUS; + case VehicleConfigurationSource::INPUT_DSM: // TODO: Handle all of the DSM types ?? Which is most common? return data.CC_MainPort != HwSettings::CC_MAINPORT_DSM; @@ -140,6 +145,9 @@ bool InputPage::restartNeeded(VehicleConfigurationSource::INPUT_TYPE selectedTyp case VehicleConfigurationSource::INPUT_EXBUS: return data.RM_FlexiPort != HwSettings::RM_FLEXIPORT_EXBUS; + case VehicleConfigurationSource::INPUT_IBUS: + return data.RM_FlexiPort != HwSettings::RM_FLEXIPORT_IBUS; + case VehicleConfigurationSource::INPUT_SRXL: return data.RM_FlexiPort != HwSettings::RM_FLEXIPORT_SRXL; @@ -173,6 +181,9 @@ bool InputPage::restartNeeded(VehicleConfigurationSource::INPUT_TYPE selectedTyp case VehicleConfigurationSource::INPUT_EXBUS: return data.SPK2_RcvrPort != HwSettings::SPK2_RCVRPORT_EXBUS; + case VehicleConfigurationSource::INPUT_IBUS: + return data.SPK2_RcvrPort != HwSettings::SPK2_RCVRPORT_IBUS; + default: return true; } break; diff --git a/ground/gcs/src/plugins/setupwizard/pages/inputpage.ui b/ground/gcs/src/plugins/setupwizard/pages/inputpage.ui index 9d17c4f55..eb6147641 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/inputpage.ui +++ b/ground/gcs/src/plugins/setupwizard/pages/inputpage.ui @@ -139,13 +139,6 @@ p, li { white-space: pre-wrap; } - - - - - - 2 - @@ -187,6 +180,13 @@ p, li { white-space: pre-wrap; } + + + + + + 2 + @@ -351,6 +351,47 @@ p, li { white-space: pre-wrap; } + + + + + 10 + + + + FlySky IBus + + + QToolButton { border: none } + + + IBus + + + + :/setupwizard/resources/bttn-ibus-up.png + :/setupwizard/resources/bttn-ibus-down.png:/setupwizard/resources/bttn-ibus-up.png + + + + 100 + 100 + + + + true + + + true + + + Qt::ToolButtonTextUnderIcon + + + true + + + diff --git a/ground/gcs/src/plugins/setupwizard/resources/bttn-ibus-down.png b/ground/gcs/src/plugins/setupwizard/resources/bttn-ibus-down.png new file mode 100644 index 0000000000000000000000000000000000000000..762b30bd7ec8fc2350259abcbc2183a0cb0634cd GIT binary patch literal 3192 zcmV-;42ScHP)ay@;P;glXl-f`P zl}AOTFNlxDXPR!G1g?%-6OfGZENPfwu0#PT`^qVMyXiKUruq}K@67{U%QUDyuJu+Ng#!EB2QQd z%R=Y@Y)hluZ}q5c%~}QegVHeFQ5Y@{y36fEqT#C67HSQeI$ubAoL`Sj2|w?5OK&DU z`8;K`#}jka70qv@r;c!SjLnJ_^EsS*jMtaHOU|hxT3_9@!BeS3B85N~Ho|ry?`(GS z2P%wuw}IUTkCUc58pC~V6zaNxrWp<1?&-S5lwS_w{-5;???7QuF;kwI!`FvPY1RI^ z$VXkEg5unL{N~$N*f_;C;F@awpEE8@M8taIk@F5 ztzH6e96CXoo@fkL6o$)-Q7w(0*NJIBhV|>l@5T=$+Ur!FW!ub6dxLk@enD)fo6vM4 zLQ$7XYwa}iXFWl`TY6R{I4OB=!)}&*^aX*S9RYixPE06$+ExHNScx61!19-KVAC?K zUMW=5Lv5bnaw5+(Ln*Yn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xo4jec@RaF&PSy?z7j*!R1n+;7(O;lD^ zlAoWiC$CKs7O?r07@#u)A%do9b$V{}Z;64(12nhWeNojso7vl9a&vR<>D8;(gBFV= zOB6+mVdkL5yoQE`hJ2^fxnaeM6@LR70k^k#ysbrzJ_1D@fxc$;BU1JwTk=z^fol+) zPEC6E=p#u_oZGvvNk^b6`zJ5D&YEBF{&lL1g=hqYbDeb0PiUQk{*M+>nBl9isGk4ZT`wL+~sBwE)>7&UehVi7xR1<5OuCq2;f2uTs?_e8+nN8 z=Qfo@^$O|rsfymSXh|NGW + + + + @@ -20041,6 +20081,115 @@ + + + Satellite + + + + + + + + + + + + + + + + + + + + + + + + + style="display:inline" + sodipodi:insensitive="true"> getControllerType() == VehicleConfigurationSource::CONTROLLER_SPARKY2) { + data.SPK2_RcvrPort = HwSettings::SPK2_RCVRPORT_IBUS; + } else { + data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_IBUS; + } + break; default: break; } @@ -999,6 +1009,9 @@ void VehicleConfigurationHelper::applyManualControlDefaults() case VehicleConfigurationSource::INPUT_EXBUS: channelType = ManualControlSettings::CHANNELGROUPS_EXBUS; break; + case VehicleConfigurationSource::INPUT_IBUS: + channelType = ManualControlSettings::CHANNELGROUPS_IBUS; + break; default: break; } diff --git a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h index 62fbc926f..00e2a88fb 100644 --- a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h +++ b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h @@ -66,7 +66,7 @@ public: GROUNDVEHICLE_MOTORCYCLE, GROUNDVEHICLE_CAR, GROUNDVEHICLE_DIFFERENTIAL }; enum ESC_TYPE { ESC_ONESHOT, ESC_SYNCHED, ESC_RAPID, ESC_STANDARD, ESC_UNKNOWN }; enum SERVO_TYPE { SERVO_ANALOG, SERVO_DIGITAL, SERVO_UNKNOWN }; - enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSM, INPUT_SRXL, INPUT_HOTT_SUMD, INPUT_EXBUS, INPUT_UNKNOWN }; + enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSM, INPUT_SRXL, INPUT_HOTT_SUMD, INPUT_EXBUS, INPUT_IBUS, INPUT_UNKNOWN }; enum AIRSPEED_TYPE { AIRSPEED_ESTIMATE, AIRSPEED_EAGLETREE, AIRSPEED_MS4525, AIRSPEED_DISABLED }; enum GPS_TYPE { GPS_PLATINUM, GPS_NAZA, GPS_UBX_FLEXI_I2CMAG, GPS_UBX, GPS_NMEA, GPS_DISABLED }; enum RADIO_SETTING { RADIO_TELEMETRY, RADIO_DISABLED }; diff --git a/ground/gcs/src/plugins/setupwizard/wizardResources.qrc b/ground/gcs/src/plugins/setupwizard/wizardResources.qrc index 646558f0c..dffe4bac9 100644 --- a/ground/gcs/src/plugins/setupwizard/wizardResources.qrc +++ b/ground/gcs/src/plugins/setupwizard/wizardResources.qrc @@ -60,5 +60,7 @@ resources/bttn-hott-up.png resources/bttn-exbus-down.png resources/bttn-exbus-up.png + resources/bttn-ibus-down.png + resources/bttn-ibus-up.png From e52d2636f0eed043ab4415bd0398794d35f9615b Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Wed, 3 Aug 2016 19:52:34 +0200 Subject: [PATCH 3/4] LP-298 Use PIOS_IBUS_NUM_INPUTS like other inputs --- flight/pios/common/pios_ibus.c | 15 +++++++-------- flight/targets/boards/revolution/pios_board.h | 6 ++++++ flight/targets/boards/revonano/pios_board.h | 6 ++++++ flight/targets/boards/sparky2/pios_board.h | 6 ++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/flight/pios/common/pios_ibus.c b/flight/pios/common/pios_ibus.c index 5f3300d53..4ba74fcf2 100644 --- a/flight/pios/common/pios_ibus.c +++ b/flight/pios/common/pios_ibus.c @@ -1,7 +1,8 @@ /** ****************************************************************************** * @file pios_ibus.c - * @author dRonin, http://dRonin.org/, Copyright (C) 2016 + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. + * dRonin, http://dRonin.org/, Copyright (C) 2016 * @addtogroup PIOS PIOS Core hardware abstraction layer * @{ * @addtogroup PIOS_IBus PiOS IBus receiver driver @@ -32,10 +33,8 @@ #ifdef PIOS_INCLUDE_IBUS -// private -#define PIOS_IBUS_CHANNELS 10 // 1 sync byte, 1 unknown byte, 10x channels (uint16_t), 8 unknown bytes, 2 crc bytes -#define PIOS_IBUS_BUFLEN (1 + 1 + PIOS_IBUS_CHANNELS * 2 + 8 + 2) +#define PIOS_IBUS_BUFLEN (1 + 1 + PIOS_IBUS_NUM_INPUTS * 2 + 8 + 2) #define PIOS_IBUS_SYNCBYTE 0x20 #define PIOS_IBUS_MAGIC 0x84fd9a39 @@ -48,7 +47,7 @@ struct pios_ibus_dev { int rx_timer; int failsafe_timer; uint16_t checksum; - uint16_t channel_data[PIOS_IBUS_CHANNELS]; + uint16_t channel_data[PIOS_IBUS_NUM_INPUTS]; uint8_t rx_buf[PIOS_IBUS_BUFLEN]; }; @@ -154,7 +153,7 @@ int32_t PIOS_IBUS_Init(uint32_t *ibus_id, const struct pios_com_driver *driver, static int32_t PIOS_IBUS_Read(uint32_t context, uint8_t channel) { - if (channel > PIOS_IBUS_CHANNELS) { + if (channel > PIOS_IBUS_NUM_INPUTS) { return PIOS_RCVR_INVALID; } @@ -168,7 +167,7 @@ static int32_t PIOS_IBUS_Read(uint32_t context, uint8_t channel) static void PIOS_IBUS_SetAllChannels(struct pios_ibus_dev *ibus_dev, uint16_t value) { - for (int i = 0; i < PIOS_IBUS_CHANNELS; i++) { + for (int i = 0; i < PIOS_IBUS_NUM_INPUTS; i++) { ibus_dev->channel_data[i] = value; } } @@ -223,7 +222,7 @@ static void PIOS_IBUS_UnpackFrame(struct pios_ibus_dev *ibus_dev) } uint16_t *chan = (uint16_t *)&ibus_dev->rx_buf[2]; - for (int i = 0; i < PIOS_IBUS_CHANNELS; i++) { + for (int i = 0; i < PIOS_IBUS_NUM_INPUTS; i++) { ibus_dev->channel_data[i] = *chan++; } diff --git a/flight/targets/boards/revolution/pios_board.h b/flight/targets/boards/revolution/pios_board.h index 9d002f5c9..a97fdbd67 100644 --- a/flight/targets/boards/revolution/pios_board.h +++ b/flight/targets/boards/revolution/pios_board.h @@ -287,6 +287,12 @@ extern uint32_t pios_packet_handler; #define PIOS_DSM_MAX_DEVS 2 #define PIOS_DSM_NUM_INPUTS 12 +// ------------------------- +// Receiver FlySky IBus input +// ------------------------- +#define PIOS_IBUS_MAX_DEVS 1 +#define PIOS_IBUS_NUM_INPUTS 10 + // ------------------------- // Servo outputs // ------------------------- diff --git a/flight/targets/boards/revonano/pios_board.h b/flight/targets/boards/revonano/pios_board.h index 32a7ee50c..43c55959c 100644 --- a/flight/targets/boards/revonano/pios_board.h +++ b/flight/targets/boards/revonano/pios_board.h @@ -287,6 +287,12 @@ extern uint32_t pios_packet_handler; #define PIOS_DSM_MAX_DEVS 2 #define PIOS_DSM_NUM_INPUTS 12 +// ------------------------- +// Receiver FlySky IBus input +// ------------------------- +#define PIOS_IBUS_MAX_DEVS 1 +#define PIOS_IBUS_NUM_INPUTS 10 + // ------------------------- // Servo outputs // ------------------------- diff --git a/flight/targets/boards/sparky2/pios_board.h b/flight/targets/boards/sparky2/pios_board.h index 15a86a175..26bbb7e53 100644 --- a/flight/targets/boards/sparky2/pios_board.h +++ b/flight/targets/boards/sparky2/pios_board.h @@ -289,6 +289,12 @@ extern uint32_t pios_packet_handler; #define PIOS_DSM_MAX_DEVS 2 #define PIOS_DSM_NUM_INPUTS 12 +// ------------------------- +// Receiver FlySky IBus input +// ------------------------- +#define PIOS_IBUS_MAX_DEVS 1 +#define PIOS_IBUS_NUM_INPUTS 10 + // ------------------------- // Servo outputs // ------------------------- From 34f55ffbe2fe5f74c86d5f2d7667868e8f4e333f Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Fri, 5 Aug 2016 20:49:34 +0200 Subject: [PATCH 4/4] LP-298 Use PIOS_Board_configure_ibus() for all boards - Missing define for RevoNano --- .../coptercontrol/firmware/pios_board.c | 38 ++++++++++-------- .../boards/revolution/firmware/pios_board.c | 39 +++++++++++-------- .../revonano/firmware/inc/pios_config.h | 1 + .../boards/revonano/firmware/pios_board.c | 39 +++++++++++-------- 4 files changed, 66 insertions(+), 51 deletions(-) diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index 820211c1d..fb1abb210 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -156,6 +156,26 @@ static void PIOS_Board_configure_dsm(const struct pios_usart_cfg *pios_usart_dsm pios_rcvr_group_map[channelgroup] = pios_dsm_rcvr_id; } +static void PIOS_Board_configure_ibus(const struct pios_usart_cfg *usart_cfg) +{ + uint32_t pios_usart_ibus_id; + + if (PIOS_USART_Init(&pios_usart_ibus_id, usart_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; +} /** * Configuration for MPU6000 chip @@ -671,23 +691,7 @@ void PIOS_Board_Init(void) case HWSETTINGS_CC_FLEXIPORT_IBUS: #if defined(PIOS_INCLUDE_IBUS) - { - uint32_t pios_usart_ibus_id; - if (PIOS_USART_Init(&pios_usart_ibus_id, &pios_usart_ibus_flexi_cfg)) { - PIOS_Assert(0); - } - - uint32_t pios_ibus_id; - if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { - PIOS_Assert(0); - } - - uint32_t pios_ibus_rcvr_id; - if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { - PIOS_Assert(0); - } - pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; - } + PIOS_Board_configure_ibus(&pios_usart_ibus_flexi_cfg); #endif /* PIOS_INCLUDE_IBUS */ break; diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 142a7c198..19cdec019 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -341,6 +341,27 @@ static void PIOS_Board_configure_dsm(const struct pios_usart_cfg *pios_usart_dsm pios_rcvr_group_map[channelgroup] = pios_dsm_rcvr_id; } +static void PIOS_Board_configure_ibus(const struct pios_usart_cfg *usart_cfg) +{ + uint32_t pios_usart_ibus_id; + + if (PIOS_USART_Init(&pios_usart_ibus_id, usart_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; +} + static void PIOS_Board_configure_pwm(const struct pios_pwm_cfg *pwm_cfg) { /* Set up the receiver port. Later this should be optional */ @@ -588,23 +609,7 @@ void PIOS_Board_Init(void) case HWSETTINGS_RM_FLEXIPORT_IBUS: #if defined(PIOS_INCLUDE_IBUS) - { - uint32_t pios_usart_ibus_id; - if (PIOS_USART_Init(&pios_usart_ibus_id, &pios_usart_ibus_flexi_cfg)) { - PIOS_Assert(0); - } - - uint32_t pios_ibus_id; - if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { - PIOS_Assert(0); - } - - uint32_t pios_ibus_rcvr_id; - if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { - PIOS_Assert(0); - } - pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; - } + PIOS_Board_configure_ibus(&pios_usart_ibus_flexi_cfg); #endif /* PIOS_INCLUDE_IBUS */ break; diff --git a/flight/targets/boards/revonano/firmware/inc/pios_config.h b/flight/targets/boards/revonano/firmware/inc/pios_config.h index 984b77959..49a64f09a 100644 --- a/flight/targets/boards/revonano/firmware/inc/pios_config.h +++ b/flight/targets/boards/revonano/firmware/inc/pios_config.h @@ -111,6 +111,7 @@ #define PIOS_INCLUDE_SRXL #define PIOS_INCLUDE_HOTT #define PIOS_INCLUDE_EXBUS +#define PIOS_INCLUDE_IBUS #define PIOS_INCLUDE_GCSRCVR // #define PIOS_INCLUDE_OPLINKRCVR diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index c09a117b3..9afeab413 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -288,6 +288,27 @@ static void PIOS_Board_configure_dsm(const struct pios_usart_cfg *pios_usart_dsm pios_rcvr_group_map[channelgroup] = pios_dsm_rcvr_id; } +static void PIOS_Board_configure_ibus(const struct pios_usart_cfg *usart_cfg) +{ + uint32_t pios_usart_ibus_id; + + if (PIOS_USART_Init(&pios_usart_ibus_id, usart_cfg)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_id; + if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { + PIOS_Assert(0); + } + + uint32_t pios_ibus_rcvr_id; + if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { + PIOS_Assert(0); + } + + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; +} + static void PIOS_Board_configure_pwm(const struct pios_pwm_cfg *pwm_cfg) { /* Set up the receiver port. Later this should be optional */ @@ -738,23 +759,7 @@ void PIOS_Board_Init(void) case HWSETTINGS_RM_FLEXIPORT_IBUS: #if defined(PIOS_INCLUDE_IBUS) - { - uint32_t pios_usart_ibus_id; - if (PIOS_USART_Init(&pios_usart_ibus_id, &pios_usart_ibus_flexi_cfg)) { - PIOS_Assert(0); - } - - uint32_t pios_ibus_id; - if (PIOS_IBUS_Init(&pios_ibus_id, &pios_usart_com_driver, pios_usart_ibus_id)) { - PIOS_Assert(0); - } - - uint32_t pios_ibus_rcvr_id; - if (PIOS_RCVR_Init(&pios_ibus_rcvr_id, &pios_ibus_rcvr_driver, pios_ibus_id)) { - PIOS_Assert(0); - } - pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_IBUS] = pios_ibus_rcvr_id; - } + PIOS_Board_configure_ibus(&pios_usart_ibus_flexi_cfg); #endif /* PIOS_INCLUDE_IBUS */ break;