added sumd serial receiver support by cesco/Plüschi
This commit is contained in:
parent
92c0947d7f
commit
a695ddd66a
1
Makefile
1
Makefile
|
@ -53,6 +53,7 @@ COMMON_SRC = startup_stm32f10x_md_gcc.S \
|
||||||
sensors.c \
|
sensors.c \
|
||||||
serial.c \
|
serial.c \
|
||||||
sbus.c \
|
sbus.c \
|
||||||
|
sumd.c \
|
||||||
spektrum.c \
|
spektrum.c \
|
||||||
telemetry.c \
|
telemetry.c \
|
||||||
drv_gpio.c \
|
drv_gpio.c \
|
||||||
|
|
6626
obj/baseflight.hex
6626
obj/baseflight.hex
File diff suppressed because it is too large
Load Diff
|
@ -82,6 +82,7 @@ typedef enum {
|
||||||
SERIALRX_SPEKTRUM1024 = 0,
|
SERIALRX_SPEKTRUM1024 = 0,
|
||||||
SERIALRX_SPEKTRUM2048 = 1,
|
SERIALRX_SPEKTRUM2048 = 1,
|
||||||
SERIALRX_SBUS = 2,
|
SERIALRX_SBUS = 2,
|
||||||
|
SERIALRX_SUMD = 3,
|
||||||
} SerialRXType;
|
} SerialRXType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -130,7 +130,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "softserial_inverted", VAR_UINT8, &mcfg.softserial_inverted, 0, 1 },
|
{ "softserial_inverted", VAR_UINT8, &mcfg.softserial_inverted, 0, 1 },
|
||||||
{ "gps_type", VAR_UINT8, &mcfg.gps_type, 0, 3 },
|
{ "gps_type", VAR_UINT8, &mcfg.gps_type, 0, 3 },
|
||||||
{ "gps_baudrate", VAR_INT8, &mcfg.gps_baudrate, -1, 4 },
|
{ "gps_baudrate", VAR_INT8, &mcfg.gps_baudrate, -1, 4 },
|
||||||
{ "serialrx_type", VAR_UINT8, &mcfg.serialrx_type, 0, 2 },
|
{ "serialrx_type", VAR_UINT8, &mcfg.serialrx_type, 0, 3 },
|
||||||
{ "telemetry_softserial", VAR_UINT8, &mcfg.telemetry_softserial, 0, 1 },
|
{ "telemetry_softserial", VAR_UINT8, &mcfg.telemetry_softserial, 0, 1 },
|
||||||
{ "telemetry_switch", VAR_UINT8, &mcfg.telemetry_switch, 0, 1 },
|
{ "telemetry_switch", VAR_UINT8, &mcfg.telemetry_switch, 0, 1 },
|
||||||
{ "vbatscale", VAR_UINT8, &mcfg.vbatscale, 10, 200 },
|
{ "vbatscale", VAR_UINT8, &mcfg.vbatscale, 10, 200 },
|
||||||
|
|
|
@ -96,10 +96,12 @@ int main(void)
|
||||||
case SERIALRX_SPEKTRUM2048:
|
case SERIALRX_SPEKTRUM2048:
|
||||||
spektrumInit(&rcReadRawFunc);
|
spektrumInit(&rcReadRawFunc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SERIALRX_SBUS:
|
case SERIALRX_SBUS:
|
||||||
sbusInit(&rcReadRawFunc);
|
sbusInit(&rcReadRawFunc);
|
||||||
break;
|
break;
|
||||||
|
case SERIALRX_SUMD:
|
||||||
|
sumdInit(&rcReadRawFunc);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else { // spektrum and GPS are mutually exclusive
|
} else { // spektrum and GPS are mutually exclusive
|
||||||
// Optional GPS - available in both PPM and PWM input mode, in PWM input, reduces number of available channels by 2.
|
// Optional GPS - available in both PPM and PWM input mode, in PWM input, reduces number of available channels by 2.
|
||||||
|
|
3
src/mw.c
3
src/mw.c
|
@ -447,6 +447,9 @@ void loop(void)
|
||||||
case SERIALRX_SBUS:
|
case SERIALRX_SBUS:
|
||||||
rcReady = sbusFrameComplete();
|
rcReady = sbusFrameComplete();
|
||||||
break;
|
break;
|
||||||
|
case SERIALRX_SUMD:
|
||||||
|
rcReady = sumdFrameComplete();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
src/mw.h
4
src/mw.h
|
@ -453,6 +453,10 @@ bool spektrumFrameComplete(void);
|
||||||
void sbusInit(rcReadRawDataPtr *callback);
|
void sbusInit(rcReadRawDataPtr *callback);
|
||||||
bool sbusFrameComplete(void);
|
bool sbusFrameComplete(void);
|
||||||
|
|
||||||
|
// sumd
|
||||||
|
void sumdInit(rcReadRawDataPtr *callback);
|
||||||
|
bool sumdFrameComplete(void);
|
||||||
|
|
||||||
// buzzer
|
// buzzer
|
||||||
void buzzer(uint8_t warn_vbat);
|
void buzzer(uint8_t warn_vbat);
|
||||||
void systemBeep(bool onoff);
|
void systemBeep(bool onoff);
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
#include "board.h"
|
||||||
|
#include "mw.h"
|
||||||
|
|
||||||
|
// driver for SUMD receiver using UART2
|
||||||
|
|
||||||
|
#define SUMD_SYNCBYTE 0xA8
|
||||||
|
#define SUMD_MAX_CHANNEL 8
|
||||||
|
#define SUMD_BUFFSIZE (SUMD_MAX_CHANNEL * 2 + 5) // 6 channels + 5 -> 17 bytes for 6 channels
|
||||||
|
|
||||||
|
static bool sumdFrameDone = false;
|
||||||
|
static void sumdDataReceive(uint16_t c);
|
||||||
|
static uint16_t sumdReadRawRC(uint8_t chan);
|
||||||
|
|
||||||
|
static uint32_t sumdChannelData[SUMD_MAX_CHANNEL];
|
||||||
|
|
||||||
|
void sumdInit(rcReadRawDataPtr *callback)
|
||||||
|
{
|
||||||
|
core.rcvrport = uartOpen(USART2, sumdDataReceive, 115200, MODE_RX);
|
||||||
|
if (callback)
|
||||||
|
*callback = sumdReadRawRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t sumd[SUMD_BUFFSIZE] = { 0, };
|
||||||
|
static uint8_t sumdSize;
|
||||||
|
|
||||||
|
// Receive ISR callback
|
||||||
|
static void sumdDataReceive(uint16_t c)
|
||||||
|
{
|
||||||
|
uint32_t sumdTime;
|
||||||
|
static uint32_t sumdTimeLast;
|
||||||
|
static uint8_t sumdIndex;
|
||||||
|
|
||||||
|
sumdTime = micros();
|
||||||
|
if ((sumdTime - sumdTimeLast) > 4000)
|
||||||
|
sumdIndex = 0;
|
||||||
|
sumdTimeLast = sumdTime;
|
||||||
|
|
||||||
|
if (sumdIndex == 0) {
|
||||||
|
if (c != SUMD_SYNCBYTE)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
sumdFrameDone = false; // lazy main loop didnt fetch the stuff
|
||||||
|
}
|
||||||
|
if (sumdIndex == 2)
|
||||||
|
sumdSize = (uint8_t)c;
|
||||||
|
if (sumdIndex < SUMD_BUFFSIZE)
|
||||||
|
sumd[sumdIndex] = (uint8_t)c;
|
||||||
|
sumdIndex++;
|
||||||
|
if (sumdIndex == sumdSize * 2 + 5) {
|
||||||
|
sumdIndex = 0;
|
||||||
|
sumdFrameDone = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sumdFrameComplete(void)
|
||||||
|
{
|
||||||
|
uint8_t b;
|
||||||
|
|
||||||
|
if (sumdFrameDone) {
|
||||||
|
sumdFrameDone = false;
|
||||||
|
if (sumd[1] == 0x01) {
|
||||||
|
failsafeCnt = 0;
|
||||||
|
if (sumdSize > SUMD_MAX_CHANNEL)
|
||||||
|
sumdSize = SUMD_MAX_CHANNEL;
|
||||||
|
for (b = 0; b < sumdSize; b++)
|
||||||
|
sumdChannelData[b] = ((sumd[2 * b + 3] << 8) | sumd[2 * b + 4]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t sumdReadRawRC(uint8_t chan)
|
||||||
|
{
|
||||||
|
return sumdChannelData[mcfg.rcmap[chan]] / 8;
|
||||||
|
}
|
Loading…
Reference in New Issue