mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-02 19:29:15 +01:00
Merge branch 'sambas/dsmx_stuff' of ssh://git.openpilot.org/OpenPilot into next
Conflicts: shared/uavobjectdefinition/hwsettings.xml
This commit is contained in:
commit
5f7a9b513a
@ -923,6 +923,8 @@ void PIOS_Board_Init(void) {
|
|||||||
TaskMonitorInitialize();
|
TaskMonitorInitialize();
|
||||||
|
|
||||||
/* Configure the main IO port */
|
/* Configure the main IO port */
|
||||||
|
uint8_t hwsettings_DSMxBind;
|
||||||
|
HwSettingsDSMxBindGet(&hwsettings_DSMxBind);
|
||||||
uint8_t hwsettings_cc_mainport;
|
uint8_t hwsettings_cc_mainport;
|
||||||
HwSettingsCC_MainPortGet(&hwsettings_cc_mainport);
|
HwSettingsCC_MainPortGet(&hwsettings_cc_mainport);
|
||||||
|
|
||||||
@ -991,7 +993,7 @@ void PIOS_Board_Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pios_spektrum_id;
|
uint32_t pios_spektrum_id;
|
||||||
if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_main_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, false)) {
|
if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_main_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, 0)) {
|
||||||
PIOS_Assert(0);
|
PIOS_Assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1053,7 +1055,7 @@ void PIOS_Board_Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pios_spektrum_id;
|
uint32_t pios_spektrum_id;
|
||||||
if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_flexi_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, false)) {
|
if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_flexi_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, hwsettings_DSMxBind)) {
|
||||||
PIOS_Assert(0);
|
PIOS_Assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
*
|
*
|
||||||
* @file pios_spektrum.c
|
* @file pios_spektrum.c
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
|
||||||
* @brief USART commands. Inits USARTs, controls USARTs & Interrupt handlers. (STM32 dependent)
|
* @brief USART commands. Inits USARTs, controls USARTs & Interrupt handlers. (STM32 dependent)
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
*
|
*
|
||||||
@ -59,7 +58,7 @@ uint8_t sync_of = 0;
|
|||||||
uint16_t supv_timer=0;
|
uint16_t supv_timer=0;
|
||||||
|
|
||||||
static void PIOS_SPEKTRUM_Supervisor(uint32_t spektrum_id);
|
static void PIOS_SPEKTRUM_Supervisor(uint32_t spektrum_id);
|
||||||
static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg);
|
static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg, uint8_t bind);
|
||||||
static int32_t PIOS_SPEKTRUM_Decode(uint8_t b);
|
static int32_t PIOS_SPEKTRUM_Decode(uint8_t b);
|
||||||
|
|
||||||
static uint16_t PIOS_SPEKTRUM_RxInCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield)
|
static uint16_t PIOS_SPEKTRUM_RxInCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield)
|
||||||
@ -85,11 +84,11 @@ static uint16_t PIOS_SPEKTRUM_RxInCallback(uint32_t context, uint8_t * buf, uint
|
|||||||
/**
|
/**
|
||||||
* Bind and Initialise Spektrum satellite receiver
|
* Bind and Initialise Spektrum satellite receiver
|
||||||
*/
|
*/
|
||||||
int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, bool bind)
|
int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, uint8_t bind)
|
||||||
{
|
{
|
||||||
// TODO: need setting flag for bind on next powerup
|
// TODO: need setting flag for bind on next powerup
|
||||||
if (bind) {
|
if (bind) {
|
||||||
PIOS_SPEKTRUM_Bind(cfg);
|
PIOS_SPEKTRUM_Bind(cfg,bind);
|
||||||
}
|
}
|
||||||
|
|
||||||
(driver->bind_rx_cb)(lower_id, PIOS_SPEKTRUM_RxInCallback, 0);
|
(driver->bind_rx_cb)(lower_id, PIOS_SPEKTRUM_RxInCallback, 0);
|
||||||
@ -121,9 +120,15 @@ static int32_t PIOS_SPEKTRUM_Get(uint32_t rcvr_id, uint8_t channel)
|
|||||||
* \output true Successful bind
|
* \output true Successful bind
|
||||||
* \output false Bind failed
|
* \output false Bind failed
|
||||||
*/
|
*/
|
||||||
static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg)
|
static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg, uint8_t bind)
|
||||||
{
|
{
|
||||||
#define BIND_PULSES 5
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
GPIO_InitStructure.GPIO_Pin = cfg->bind.init.GPIO_Pin;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = cfg->bind.init.GPIO_Speed;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
|
|
||||||
|
/* just to limit bind pulses */
|
||||||
|
bind=(bind<=10)?bind:10;
|
||||||
|
|
||||||
GPIO_Init(cfg->bind.gpio, &cfg->bind.init);
|
GPIO_Init(cfg->bind.gpio, &cfg->bind.init);
|
||||||
/* RX line, set high */
|
/* RX line, set high */
|
||||||
@ -132,7 +137,7 @@ static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg)
|
|||||||
/* on CC works upto 140ms, I guess bind window is around 20-140ms after powerup */
|
/* on CC works upto 140ms, I guess bind window is around 20-140ms after powerup */
|
||||||
PIOS_DELAY_WaitmS(60);
|
PIOS_DELAY_WaitmS(60);
|
||||||
|
|
||||||
for (int i = 0; i < BIND_PULSES ; i++) {
|
for (int i = 0; i < bind ; i++) {
|
||||||
/* RX line, drive low for 120us */
|
/* RX line, drive low for 120us */
|
||||||
GPIO_ResetBits(cfg->bind.gpio, cfg->bind.init.GPIO_Pin);
|
GPIO_ResetBits(cfg->bind.gpio, cfg->bind.init.GPIO_Pin);
|
||||||
PIOS_DELAY_WaituS(120);
|
PIOS_DELAY_WaituS(120);
|
||||||
@ -141,6 +146,7 @@ static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg)
|
|||||||
PIOS_DELAY_WaituS(120);
|
PIOS_DELAY_WaituS(120);
|
||||||
}
|
}
|
||||||
/* RX line, set input and wait for data, PIOS_SPEKTRUM_Init */
|
/* RX line, set input and wait for data, PIOS_SPEKTRUM_Init */
|
||||||
|
GPIO_Init(cfg->bind.gpio, &GPIO_InitStructure);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -172,9 +178,10 @@ static int32_t PIOS_SPEKTRUM_Decode(uint8_t b)
|
|||||||
CaptureValue[7]=b;
|
CaptureValue[7]=b;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Known sync bytes, 0x01, 0x02, 0x12 */
|
/* Known sync bytes, 0x01, 0x02, 0x12, 0xb2 */
|
||||||
|
/* 0xb2 DX8 3bind pulses only */
|
||||||
if (bytecount == 2) {
|
if (bytecount == 2) {
|
||||||
if (b == 0x01) {
|
if ((b == 0x01) || (b == 0xb2)) {
|
||||||
datalength=0; // 10bit
|
datalength=0; // 10bit
|
||||||
//frames=1;
|
//frames=1;
|
||||||
sync = 1;
|
sync = 1;
|
||||||
@ -234,17 +241,17 @@ static int32_t PIOS_SPEKTRUM_Decode(uint8_t b)
|
|||||||
*@brief clears the channel values
|
*@brief clears the channel values
|
||||||
*/
|
*/
|
||||||
static void PIOS_SPEKTRUM_Supervisor(uint32_t spektrum_id) {
|
static void PIOS_SPEKTRUM_Supervisor(uint32_t spektrum_id) {
|
||||||
/* 125hz */
|
/* 625hz */
|
||||||
supv_timer++;
|
supv_timer++;
|
||||||
if(supv_timer > 5) {
|
if(supv_timer > 4) {
|
||||||
/* sync between frames */
|
/* sync between frames */
|
||||||
sync = 0;
|
sync = 0;
|
||||||
bytecount = 0;
|
bytecount = 0;
|
||||||
prev_byte = 0xFF;
|
prev_byte = 0xFF;
|
||||||
frame_error = 0;
|
frame_error = 0;
|
||||||
sync_of++;
|
sync_of++;
|
||||||
/* watchdog activated after 100ms silence */
|
/* watchdog activated after 200ms silence */
|
||||||
if (sync_of > 12) {
|
if (sync_of > 30) {
|
||||||
/* signal lost */
|
/* signal lost */
|
||||||
sync_of = 0;
|
sync_of = 0;
|
||||||
for (int i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS; i++) {
|
for (int i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS; i++) {
|
||||||
|
@ -42,7 +42,7 @@ struct pios_spektrum_cfg {
|
|||||||
|
|
||||||
extern const struct pios_rcvr_driver pios_spektrum_rcvr_driver;
|
extern const struct pios_rcvr_driver pios_spektrum_rcvr_driver;
|
||||||
|
|
||||||
extern int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, bool bind);
|
extern int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, uint8_t bind);
|
||||||
|
|
||||||
#endif /* PIOS_PWM_PRIV_H */
|
#endif /* PIOS_PWM_PRIV_H */
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<field name="CC_FlexiPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,Spektrum,ComAux,I2C" defaultvalue="Disabled"/>
|
<field name="CC_FlexiPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,Spektrum,ComAux,I2C" defaultvalue="Disabled"/>
|
||||||
<field name="CC_MainPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,S.Bus,GPS,Spektrum,ComAux" defaultvalue="Telemetry"/>
|
<field name="CC_MainPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,S.Bus,GPS,Spektrum,ComAux" defaultvalue="Telemetry"/>
|
||||||
<field name="OptionalModules" units="" type="enum" elementnames="CameraStabilization,GPS" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
<field name="OptionalModules" units="" type="enum" elementnames="CameraStabilization,GPS" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||||
|
<field name="DSMxBind" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user