From 68ff383637ee9e5bd5714b74b8bd70cb1acc6730 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 20 Dec 2015 23:45:37 +0100 Subject: [PATCH] LP-104 Adding HoTT support for Revolution and Revo Nano. --- .../targets/boards/revolution/board_hw_defs.c | 89 +++++++++++++++++++ .../revolution/firmware/inc/pios_config.h | 1 + .../boards/revolution/firmware/pios_board.c | 48 ++++++++++ flight/targets/boards/revolution/pios_board.h | 6 ++ .../targets/boards/revonano/board_hw_defs.c | 89 +++++++++++++++++++ .../revonano/firmware/inc/pios_config.h | 1 + .../boards/revonano/firmware/pios_board.c | 47 ++++++++++ flight/targets/boards/revonano/pios_board.h | 6 ++ shared/uavobjectdefinition/hwsettings.xml | 4 +- 9 files changed, 289 insertions(+), 2 deletions(-) diff --git a/flight/targets/boards/revolution/board_hw_defs.c b/flight/targets/boards/revolution/board_hw_defs.c index d77666147..b0e1904dc 100644 --- a/flight/targets/boards/revolution/board_hw_defs.c +++ b/flight/targets/boards/revolution/board_hw_defs.c @@ -1054,6 +1054,95 @@ static const struct pios_usart_cfg pios_usart_srxl_flexi_cfg = { }; #endif /* PIOS_INCLUDE_SRXL */ +#if defined(PIOS_INCLUDE_HOTT) +/* + * HOTT USART + */ +#include + +static const struct pios_usart_cfg pios_usart_hott_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_hott_main_cfg = { + .regs = USART1, + .remap = GPIO_AF_USART1, + .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 = USART1_IRQn, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .rx = { + .gpio = GPIOA, + .init = { + .GPIO_Pin = GPIO_Pin_10, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + .tx = { + .gpio = GPIOA, + .init = { + .GPIO_Pin = GPIO_Pin_9, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, +}; + +#endif /* PIOS_INCLUDE_HOTT */ /* * HK OSD */ diff --git a/flight/targets/boards/revolution/firmware/inc/pios_config.h b/flight/targets/boards/revolution/firmware/inc/pios_config.h index baa1680ba..bced97f12 100644 --- a/flight/targets/boards/revolution/firmware/inc/pios_config.h +++ b/flight/targets/boards/revolution/firmware/inc/pios_config.h @@ -104,6 +104,7 @@ #define PIOS_INCLUDE_DSM #define PIOS_INCLUDE_SBUS #define PIOS_INCLUDE_SRXL +#define PIOS_INCLUDE_HOTT #define PIOS_INCLUDE_GCSRCVR #define PIOS_INCLUDE_OPLINKRCVR diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 5bfc0a16c..495fe927b 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -520,6 +520,30 @@ void PIOS_Board_Init(void) } #endif break; + case HWSETTINGS_RM_FLEXIPORT_HOTTSUMD: + case HWSETTINGS_RM_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_RM_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_HOTTFLEXIPORT] = pios_hott_rcvr_id; + } +#endif /* PIOS_INCLUDE_HOTT */ + break; + } /* hwsettings_rm_flexiport */ /* Moved this here to allow binding on flexiport */ @@ -704,6 +728,30 @@ void PIOS_Board_Init(void) PIOS_Board_configure_dsm(&pios_usart_dsm_main_cfg, &pios_dsm_main_cfg, &pios_usart_com_driver, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT, &hwsettings_DSMxBind); break; + case HWSETTINGS_RM_MAINPORT_HOTTSUMD: + case HWSETTINGS_RM_MAINPORT_HOTTSUMH: +#if defined(PIOS_INCLUDE_HOTT) + { + uint32_t pios_usart_hott_id; + if (PIOS_USART_Init(&pios_usart_hott_id, &pios_usart_hott_main_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_mainport == HWSETTINGS_RM_MAINPORT_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_HOTTMAINPORT] = pios_hott_rcvr_id; + } +#endif /* PIOS_INCLUDE_HOTT */ + break; + case HWSETTINGS_RM_MAINPORT_DEBUGCONSOLE: #if defined(PIOS_INCLUDE_DEBUG_CONSOLE) { diff --git a/flight/targets/boards/revolution/pios_board.h b/flight/targets/boards/revolution/pios_board.h index ff723d419..feb778a78 100644 --- a/flight/targets/boards/revolution/pios_board.h +++ b/flight/targets/boards/revolution/pios_board.h @@ -257,6 +257,12 @@ extern uint32_t pios_packet_handler; #define PIOS_SBUS_MAX_DEVS 1 #define PIOS_SBUS_NUM_INPUTS (16 + 2) +//------------------------- +// Receiver HSUM input +//------------------------- +#define PIOS_HOTT_MAX_DEVS 2 +#define PIOS_HOTT_NUM_INPUTS 32 + // ------------------------- // Receiver Multiplex SRXL input // ------------------------- diff --git a/flight/targets/boards/revonano/board_hw_defs.c b/flight/targets/boards/revonano/board_hw_defs.c index 2c3deefe0..b0ca380e2 100644 --- a/flight/targets/boards/revonano/board_hw_defs.c +++ b/flight/targets/boards/revonano/board_hw_defs.c @@ -535,6 +535,95 @@ static const struct pios_dsm_cfg pios_dsm_flexi_cfg = { #endif /* PIOS_INCLUDE_DSM */ +#if defined(PIOS_INCLUDE_HOTT) +/* + * HOTT USART + */ +#include +static const struct pios_usart_cfg pios_usart_hott_main_cfg = { + .regs = MAIN_USART_REGS, + .remap = MAIN_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 = MAIN_USART_IRQ, + .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, + .NVIC_IRQChannelSubPriority = 0, + .NVIC_IRQChannelCmd = ENABLE, + }, + }, + .rx = { + .gpio = MAIN_USART_RX_GPIO, + .init = { + .GPIO_Pin = MAIN_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 = MAIN_USART_TX_GPIO, + .init = { + .GPIO_Pin = MAIN_USART_TX_PIN, + .GPIO_Speed = GPIO_Speed_2MHz, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, +}; + +static const struct pios_usart_cfg pios_usart_hott_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_HOTT */ + #if defined(PIOS_INCLUDE_SRXL) /* * SRXL USART diff --git a/flight/targets/boards/revonano/firmware/inc/pios_config.h b/flight/targets/boards/revonano/firmware/inc/pios_config.h index 16803c751..f8315d626 100644 --- a/flight/targets/boards/revonano/firmware/inc/pios_config.h +++ b/flight/targets/boards/revonano/firmware/inc/pios_config.h @@ -108,6 +108,7 @@ #define PIOS_INCLUDE_DSM #define PIOS_INCLUDE_SBUS #define PIOS_INCLUDE_SRXL +#define PIOS_INCLUDE_HOTT #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 dcf373a51..5b1a021e5 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -586,6 +586,30 @@ void PIOS_Board_Init(void) &pios_usart_com_driver, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT, &hwsettings_DSMxBind); } break; + case HWSETTINGS_RM_MAINPORT_HOTTSUMD: + case HWSETTINGS_RM_MAINPORT_HOTTSUMH: +#if defined(PIOS_INCLUDE_HOTT) + { + uint32_t pios_usart_hott_id; + if (PIOS_USART_Init(&pios_usart_hott_id, &pios_usart_hott_main_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_mainport == HWSETTINGS_RM_MAINPORT_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_HOTTMAINPORT] = pios_hott_rcvr_id; + } +#endif /* PIOS_INCLUDE_HOTT */ + break; + case HWSETTINGS_RM_MAINPORT_DEBUGCONSOLE: #if defined(PIOS_INCLUDE_DEBUG_CONSOLE) { @@ -666,6 +690,29 @@ void PIOS_Board_Init(void) } #endif break; + case HWSETTINGS_RM_FLEXIPORT_HOTTSUMD: + case HWSETTINGS_RM_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_RM_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_HOTTFLEXIPORT] = pios_hott_rcvr_id; + } +#endif /* PIOS_INCLUDE_HOTT */ + break; } /* hwsettings_rm_flexiport */ diff --git a/flight/targets/boards/revonano/pios_board.h b/flight/targets/boards/revonano/pios_board.h index 54776fe34..0805c1a5f 100644 --- a/flight/targets/boards/revonano/pios_board.h +++ b/flight/targets/boards/revonano/pios_board.h @@ -257,6 +257,12 @@ extern uint32_t pios_packet_handler; #define PIOS_SBUS_MAX_DEVS 1 #define PIOS_SBUS_NUM_INPUTS (16 + 2) +//------------------------- +// Receiver HSUM input +//------------------------- +#define PIOS_HOTT_MAX_DEVS 2 +#define PIOS_HOTT_NUM_INPUTS 32 + // ------------------------- // Receiver Multiplex SRXL input // ------------------------- diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml index 9b5459678..f5fc9645f 100644 --- a/shared/uavobjectdefinition/hwsettings.xml +++ b/shared/uavobjectdefinition/hwsettings.xml @@ -15,8 +15,8 @@ - - + +