Protocol NCC1701

CH5: Warp
Telemetry:
A1 voltage is used for crash detection. In case of a crash A1=0V. You can be assign a sound to the crash.
This commit is contained in:
Pascal Langer 2018-11-03 17:24:47 +01:00
parent f42da14413
commit ea96c328fc
6 changed files with 53 additions and 15 deletions

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_REVISION 1 #define VERSION_REVISION 1
#define VERSION_PATCH_LEVEL 4 #define VERSION_PATCH_LEVEL 5
//****************** //******************
// Protocols // Protocols

View File

@ -614,7 +614,7 @@ uint8_t Update_All()
update_led_status(); update_led_status();
#if defined(TELEMETRY) #if defined(TELEMETRY)
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) ) #if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC)) if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_NCC1701) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC))
#endif #endif
TelemetryUpdate(); TelemetryUpdate();
#endif #endif
@ -1594,7 +1594,7 @@ void pollBoot()
#if defined(TELEMETRY) #if defined(TELEMETRY)
void PPM_Telemetry_serial_init() void PPM_Telemetry_serial_init()
{ {
if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_BAYANG) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI)) if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_BAYANG)|| (protocol==PROTO_NCC1701) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI))
initTXSerial( SPEED_9600 ) ; initTXSerial( SPEED_9600 ) ;
if(protocol==PROTO_FRSKYX) if(protocol==PROTO_FRSKYX)
initTXSerial( SPEED_57600 ) ; initTXSerial( SPEED_57600 ) ;

View File

@ -27,7 +27,8 @@ enum {
NCC_BIND_RX1, NCC_BIND_RX1,
NCC_BIND_TX2, NCC_BIND_TX2,
NCC_BIND_RX2, NCC_BIND_RX2,
NCC_DATA, NCC_BIND_TX3,
NCC_BIND_RX3,
}; };
static void __attribute__((unused)) NCC_init() static void __attribute__((unused)) NCC_init()
@ -54,13 +55,13 @@ static void __attribute__((unused)) NCC_init()
| (0 << NRF24L01_00_PRIM_RX)); | (0 << NRF24L01_00_PRIM_RX));
} }
uint8_t NCC_xorout[]={0x80, 0x44, 0x64, 0x75, 0x6C, 0x71, 0x2A, 0x36, 0x7C, 0xF1, 0x6E, 0x52, 0x09, 0x9D}; uint8_t NCC_xor[]={0x80, 0x44, 0x64, 0x75, 0x6C, 0x71, 0x2A, 0x36, 0x7C, 0xF1, 0x6E, 0x52, 0x09, 0x9D};
static void __attribute__((unused)) NCC_Crypt_Packet() static void __attribute__((unused)) NCC_Crypt_Packet()
{ {
uint16_t crc=0; uint16_t crc=0;
for(uint8_t i=0; i< NCC_TX_PACKET_LEN-2; i++) for(uint8_t i=0; i< NCC_TX_PACKET_LEN-2; i++)
{ {
packet[i]^=NCC_xorout[i]; packet[i]^=NCC_xor[i];
crc=crc16_update(crc, packet[i], 8); crc=crc16_update(crc, packet[i], 8);
} }
crc^=0x60DE; crc^=0x60DE;
@ -74,7 +75,7 @@ static boolean __attribute__((unused)) NCC_Decrypt_Packet()
for(uint8_t i=0; i< NCC_RX_PACKET_LEN-2; i++) for(uint8_t i=0; i< NCC_RX_PACKET_LEN-2; i++)
{ {
crc=crc16_update(crc, packet[i], 8); crc=crc16_update(crc, packet[i], 8);
packet[i]^=NCC_xorout[i]; packet[i]^=NCC_xor[i];
debug("%02X ",packet[i]); debug("%02X ",packet[i]);
} }
crc^=0xA950; crc^=0xA950;
@ -101,7 +102,7 @@ static void __attribute__((unused)) NCC_Write_Packet()
packet[9]=rx_id[2]; packet[9]=rx_id[2];
packet[10]=rx_id[3]; packet[10]=rx_id[3];
packet[11]=rx_id[4]; packet[11]=rx_id[4];
packet[12]=0x02; // default:0x00 -> Warp:0x02 ?? packet[12]=GET_FLAG(CH5_SW, 0x02); // Warp:0x00 -> 0x02
packet[13]=packet[5]+packet[6]+packet[7]+packet[8]+packet[12]; packet[13]=packet[5]+packet[6]+packet[7]+packet[8]+packet[12];
if(phase==NCC_BIND_TX1) if(phase==NCC_BIND_TX1)
{ {
@ -176,7 +177,7 @@ uint16_t NCC_callback()
rx_id[4]=packet[10]; rx_id[4]=packet[10];
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit
BIND_DONE; BIND_DONE;
phase=NCC_DATA; phase=NCC_BIND_TX3;
return NCC_PACKET_INTERVAL; return NCC_PACKET_INTERVAL;
} }
} }
@ -194,9 +195,38 @@ uint16_t NCC_callback()
NRF24L01_FlushRx(); NRF24L01_FlushRx();
phase = NCC_BIND_TX2; phase = NCC_BIND_TX2;
return NCC_PACKET_INTERVAL - NCC_WRITE_WAIT; return NCC_PACKET_INTERVAL - NCC_WRITE_WAIT;
case NCC_DATA: case NCC_BIND_TX3:
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_RX_DR))
{ // RX fifo data ready
NRF24L01_ReadPayload(packet, NCC_RX_PACKET_LEN);
if(NCC_Decrypt_Packet())
{
//Telemetry
//packet[5] and packet[7] roll angle
//packet[6] crash detect: 0x00 no crash, 0x02 crash
#ifdef NCC1701_HUB_TELEMETRY
v_lipo1 = packet[6]?0x00:0xFF; // Crash indication
v_lipo2 = 0x00;
RX_RSSI = 0x7F; // Dummy RSSI
TX_RSSI = 0x7F; // Dummy RSSI
telemetry_link=1;
#endif
}
}
NCC_Write_Packet(); NCC_Write_Packet();
return NCC_PACKET_INTERVAL; phase = NCC_BIND_RX3;
return NCC_WRITE_WAIT;
case NCC_BIND_RX3:
// switch to RX mode and disable CRC
NRF24L01_SetTxRxMode(TXRX_OFF);
NRF24L01_SetTxRxMode(RX_EN);
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (0 << NRF24L01_00_EN_CRC)
| (1 << NRF24L01_00_CRCO)
| (1 << NRF24L01_00_PWR_UP)
| (1 << NRF24L01_00_PRIM_RX));
NRF24L01_FlushRx();
phase = NCC_BIND_TX3;
return NCC_PACKET_INTERVAL - NCC_WRITE_WAIT;
} }
return 0; return 0;
} }
@ -237,6 +267,9 @@ uint16_t initNCC(void)
hopping_frequency_no=4; // start with bind hopping_frequency_no=4; // start with bind
NCC_init(); NCC_init();
phase=NCC_BIND_TX1; phase=NCC_BIND_TX1;
#ifdef NCC1701_HUB_TELEMETRY
init_frskyd_link_telemetry();
#endif
return 10000; return 10000;
} }

View File

@ -367,7 +367,7 @@ void frsky_link_frame()
telemetry_link |= 2 ; // Send hub if available telemetry_link |= 2 ; // Send hub if available
} }
else else
if (protocol==PROTO_HUBSAN||protocol==PROTO_AFHDS2A||protocol==PROTO_BAYANG||protocol==PROTO_CABELL||protocol==PROTO_HITEC||protocol==PROTO_BUGS||protocol==PROTO_BUGSMINI) if (protocol==PROTO_HUBSAN||protocol==PROTO_AFHDS2A||protocol==PROTO_BAYANG||protocol==PROTO_NCC1701||protocol==PROTO_CABELL||protocol==PROTO_HITEC||protocol==PROTO_BUGS||protocol==PROTO_BUGSMINI)
{ {
frame[1] = v_lipo1; frame[1] = v_lipo1;
frame[2] = v_lipo2; frame[2] = v_lipo2;
@ -997,7 +997,7 @@ void TelemetryUpdate()
#endif #endif
if((telemetry_link & 1 )&& protocol != PROTO_FRSKYX) if((telemetry_link & 1 )&& protocol != PROTO_FRSKYX)
{ // FrSkyD + Hubsan + AFHDS2A + Bayang + Cabell + Hitec + Bugs + BugsMini { // FrSkyD + Hubsan + AFHDS2A + Bayang + Cabell + Hitec + Bugs + BugsMini + NCC1701
frsky_link_frame(); frsky_link_frame();
return; return;
} }

View File

@ -196,6 +196,7 @@
#undef CABELL_HUB_TELEMETRY #undef CABELL_HUB_TELEMETRY
#undef HUBSAN_HUB_TELEMETRY #undef HUBSAN_HUB_TELEMETRY
#undef BUGS_HUB_TELEMETRY #undef BUGS_HUB_TELEMETRY
#undef NCC1701_HUB_TELEMETRY
#undef HUB_TELEMETRY #undef HUB_TELEMETRY
#undef SPORT_TELEMETRY #undef SPORT_TELEMETRY
#undef SPORT_POLLING #undef SPORT_POLLING
@ -209,6 +210,9 @@
#if not defined(BAYANG_NRF24L01_INO) #if not defined(BAYANG_NRF24L01_INO)
#undef BAYANG_HUB_TELEMETRY #undef BAYANG_HUB_TELEMETRY
#endif #endif
#if not defined(NCC1701_NRF24L01_INO)
#undef NCC1701_HUB_TELEMETRY
#endif
#if not ( defined(BUGS_A7105_INO) || defined(BUGSMINI_NRF24L01_INO) ) #if not ( defined(BUGS_A7105_INO) || defined(BUGSMINI_NRF24L01_INO) )
#undef BUGS_HUB_TELEMETRY #undef BUGS_HUB_TELEMETRY
#endif #endif
@ -242,7 +246,7 @@
#if not defined(DSM_CYRF6936_INO) #if not defined(DSM_CYRF6936_INO)
#undef DSM_TELEMETRY #undef DSM_TELEMETRY
#endif #endif
#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) #if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY)
#undef TELEMETRY #undef TELEMETRY
#undef INVERT_TELEMETRY #undef INVERT_TELEMETRY
#undef SPORT_POLLING #undef SPORT_POLLING

View File

@ -253,6 +253,7 @@
#define BAYANG_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define BAYANG_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define BUGS_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define BUGS_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define NCC1701_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, ersky9x and OpenTX #define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, ersky9x and OpenTX
#define HITEC_FW_TELEMETRY // Under development: Forward received telemetry packets to be decoded by ersky9x and OpenTX #define HITEC_FW_TELEMETRY // Under development: Forward received telemetry packets to be decoded by ersky9x and OpenTX