diff --git a/flight/targets/boards/sparky2/board_hw_defs.c b/flight/targets/boards/sparky2/board_hw_defs.c
index 4d883cb70..830e5360c 100644
--- a/flight/targets/boards/sparky2/board_hw_defs.c
+++ b/flight/targets/boards/sparky2/board_hw_defs.c
@@ -839,6 +839,37 @@ static const struct pios_usart_cfg pios_usart_hott_flexi_cfg = {
},
};
+static const struct pios_usart_cfg pios_usart_hott_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_HOTT */
#if defined(PIOS_INCLUDE_EXBUS)
@@ -888,6 +919,37 @@ static const struct pios_usart_cfg pios_usart_exbus_flexi_cfg = {
},
};
+static const struct pios_usart_cfg pios_usart_exbus_rcvr_cfg = {
+ .regs = USART6,
+ .remap = GPIO_AF_USART6,
+ .init = {
+ .USART_BaudRate = 125000,
+ .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_EXBUS */
/*
diff --git a/flight/targets/boards/sparky2/firmware/pios_board.c b/flight/targets/boards/sparky2/firmware/pios_board.c
index eae72288d..6baa2499f 100644
--- a/flight/targets/boards/sparky2/firmware/pios_board.c
+++ b/flight/targets/boards/sparky2/firmware/pios_board.c
@@ -323,6 +323,47 @@ 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_exbus(const struct pios_usart_cfg *usart_cfg)
+{
+ uint32_t pios_usart_exbus_id;
+
+ if (PIOS_USART_Init(&pios_usart_exbus_id, usart_cfg)) {
+ PIOS_Assert(0);
+ }
+
+ uint32_t pios_exbus_id;
+ if (PIOS_EXBUS_Init(&pios_exbus_id, &pios_usart_com_driver, pios_usart_exbus_id)) {
+ PIOS_Assert(0);
+ }
+
+ uint32_t pios_exbus_rcvr_id;
+ if (PIOS_RCVR_Init(&pios_exbus_rcvr_id, &pios_exbus_rcvr_driver, pios_exbus_id)) {
+ PIOS_Assert(0);
+ }
+ pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_EXBUS] = pios_exbus_rcvr_id;
+}
+
+static void PIOS_Board_configure_hott(const struct pios_usart_cfg *usart_cfg, enum pios_hott_proto proto)
+{
+ uint32_t pios_usart_hott_id;
+
+ if (PIOS_USART_Init(&pios_usart_hott_id, usart_cfg)) {
+ PIOS_Assert(0);
+ }
+
+ uint32_t pios_hott_id;
+ if (PIOS_HOTT_Init(&pios_hott_id, &pios_usart_com_driver, pios_usart_hott_id, proto)) {
+ PIOS_Assert(0);
+ }
+
+ uint32_t pios_hott_rcvr_id;
+ if (PIOS_RCVR_Init(&pios_hott_rcvr_id, &pios_hott_rcvr_driver, pios_hott_id)) {
+ PIOS_Assert(0);
+ }
+ pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_HOTT] = pios_hott_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;
@@ -538,46 +579,14 @@ void PIOS_Board_Init(void)
case HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMD:
case HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMH:
#if defined(PIOS_INCLUDE_HOTT)
- {
- uint32_t pios_usart_hott_id;
- if (PIOS_USART_Init(&pios_usart_hott_id, &pios_usart_hott_flexi_cfg)) {
- PIOS_Assert(0);
- }
-
- uint32_t pios_hott_id;
- if (PIOS_HOTT_Init(&pios_hott_id, &pios_usart_com_driver, pios_usart_hott_id,
- hwsettings_flexiport == HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMD ? PIOS_HOTT_PROTO_SUMD : PIOS_HOTT_PROTO_SUMH)) {
- PIOS_Assert(0);
- }
-
- uint32_t pios_hott_rcvr_id;
- if (PIOS_RCVR_Init(&pios_hott_rcvr_id, &pios_hott_rcvr_driver, pios_hott_id)) {
- PIOS_Assert(0);
- }
- pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_HOTT] = pios_hott_rcvr_id;
- }
+ PIOS_Board_configure_hott(&pios_usart_hott_flexi_cfg,
+ hwsettings_flexiport == HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMD ? PIOS_HOTT_PROTO_SUMD : PIOS_HOTT_PROTO_SUMH);
#endif /* PIOS_INCLUDE_HOTT */
break;
case HWSETTINGS_SPK2_FLEXIPORT_EXBUS:
#if defined(PIOS_INCLUDE_EXBUS)
- {
- uint32_t pios_usart_exbus_id;
- if (PIOS_USART_Init(&pios_usart_exbus_id, &pios_usart_exbus_flexi_cfg)) {
- PIOS_Assert(0);
- }
-
- uint32_t pios_exbus_id;
- if (PIOS_EXBUS_Init(&pios_exbus_id, &pios_usart_com_driver, pios_usart_exbus_id)) {
- PIOS_Assert(0);
- }
-
- uint32_t pios_exbus_rcvr_id;
- if (PIOS_RCVR_Init(&pios_exbus_rcvr_id, &pios_exbus_rcvr_driver, pios_exbus_id)) {
- PIOS_Assert(0);
- }
- pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_EXBUS] = pios_exbus_rcvr_id;
- }
+ PIOS_Board_configure_exbus(&pios_usart_exbus_flexi_cfg);
#endif /* PIOS_INCLUDE_EXBUS */
break;
} /* hwsettings_rm_flexiport */
@@ -920,6 +929,19 @@ void PIOS_Board_Init(void)
PIOS_Board_configure_srxl(&pios_usart_srxl_rcvr_cfg);
#endif /* PIOS_INCLUDE_SRXL */
break;
+ case HWSETTINGS_SPK2_RCVRPORT_HOTTSUMD:
+ case HWSETTINGS_SPK2_RCVRPORT_HOTTSUMH:
+#if defined(PIOS_INCLUDE_HOTT)
+ PIOS_Board_configure_hott(&pios_usart_hott_rcvr_cfg,
+ hwsettings_flexiport == HWSETTINGS_SPK2_FLEXIPORT_HOTTSUMD ? PIOS_HOTT_PROTO_SUMD : PIOS_HOTT_PROTO_SUMH);
+#endif /* PIOS_INCLUDE_HOTT */
+ break;
+
+ case HWSETTINGS_SPK2_RCVRPORT_EXBUS:
+#if defined(PIOS_INCLUDE_EXBUS)
+ PIOS_Board_configure_exbus(&pios_usart_exbus_rcvr_cfg);
+#endif /* PIOS_INCLUDE_EXBUS */
+ 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,
diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml
index f2cc5eb22..552611c1a 100644
--- a/shared/uavobjectdefinition/hwsettings.xml
+++ b/shared/uavobjectdefinition/hwsettings.xml
@@ -17,7 +17,7 @@
-
+