mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-12-16 21:03:14 +00:00
RX routines added
This commit is contained in:
@@ -214,6 +214,15 @@ uint16_t DSM_RX_callback()
|
||||
uint8_t rx_status;
|
||||
static uint8_t read_retry=0;
|
||||
|
||||
if(sub_protocol == DSM_ERASE)
|
||||
{
|
||||
if(packet_count)
|
||||
packet_count--;
|
||||
else
|
||||
BIND_DONE;
|
||||
return 10000; // Nothing to do...
|
||||
}
|
||||
|
||||
switch (phase)
|
||||
{
|
||||
case DSM_RX_BIND1:
|
||||
@@ -240,6 +249,10 @@ uint16_t DSM_RX_callback()
|
||||
{
|
||||
// store tx info into eeprom
|
||||
uint16_t temp = DSM_RX_EEPROM_OFFSET;
|
||||
if (sub_protocol==DSM_CLONE)
|
||||
{
|
||||
temp = DSM_CLONE_EEPROM_OFFSET;
|
||||
}
|
||||
debug("ID=");
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
{
|
||||
@@ -261,11 +274,11 @@ uint16_t DSM_RX_callback()
|
||||
&0xF0 => false=1024, true=2048 */
|
||||
DSM_rx_type=packet_in[12];
|
||||
debugln(", num_ch=%d, type=%02X",num_ch, DSM_rx_type);
|
||||
if(sub_protocol==DSM_CLONE)
|
||||
{
|
||||
debugln("Collecting TX MfgId");
|
||||
}
|
||||
eeprom_write_byte((EE_ADDR)temp, DSM_rx_type);
|
||||
if (sub_protocol==DSM_CLONE)
|
||||
{
|
||||
eeprom_write_byte((EE_ADDR)++temp, num_ch);
|
||||
}
|
||||
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x20); // Abort RX operation
|
||||
CYRF_SetTxRxMode(TX_EN); // Force end state TX
|
||||
CYRF_ConfigDataCode((const uint8_t *)"\x98\x88\x1B\xE4\x30\x79\x03\x84", 16);
|
||||
@@ -474,12 +487,31 @@ void DSM_RX_init()
|
||||
|
||||
if (IS_BIND_IN_PROGRESS)
|
||||
{
|
||||
packet_count=0;
|
||||
phase = DSM_RX_BIND1;
|
||||
if(sub_protocol == DSM_ERASE)
|
||||
{
|
||||
// Clear all cloned addresses
|
||||
uint16_t addr = DSM_CLONE_EEPROM_OFFSET;
|
||||
for(uint8_t i=0; i<7; i++)
|
||||
{
|
||||
eeprom_write_byte((EE_ADDR)(addr++), 0xFF);
|
||||
}
|
||||
packet_count = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet_count=0;
|
||||
phase = DSM_RX_BIND1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
uint16_t temp = DSM_RX_EEPROM_OFFSET;
|
||||
if (sub_protocol==DSM_CLONE)
|
||||
{
|
||||
temp = DSM_CLONE_EEPROM_OFFSET;
|
||||
}
|
||||
|
||||
debug("ID=");
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
{
|
||||
@@ -488,6 +520,12 @@ void DSM_RX_init()
|
||||
}
|
||||
DSM_rx_type=eeprom_read_byte((EE_ADDR)temp);
|
||||
debugln(", type=%02X", DSM_rx_type);
|
||||
if (sub_protocol==DSM_CLONE)
|
||||
{
|
||||
num_ch=eeprom_read_byte((EE_ADDR)++temp);
|
||||
debugln(", channels=%02", num_ch);
|
||||
}
|
||||
|
||||
phase = DSM_RX_DATA_PREP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,7 +829,8 @@ enum {
|
||||
#define FRSKYX2_CLONE_EEPROM_OFFSET 873 // (1) format + (3) TX ID, 4 bytes, end is 877
|
||||
#define DSM_RX_EEPROM_OFFSET 877 // (4) TX ID + format, 5 bytes, end is 882
|
||||
#define MOULDKG_EEPROM_OFFSET 882 // RX ID, 3 bytes per model, end is 882+64*3=1074
|
||||
//#define CONFIG_EEPROM_OFFSET 1074 // Current configuration of the multimodule
|
||||
#define DSM_CLONE_EEPROM_OFFSET 1074 // (4) TX ID, (1) RX type, (1) No of channels, end is 1090
|
||||
//#define CONFIG_EEPROM_OFFSET 1090 // Current configuration of the multimodule
|
||||
|
||||
/* STM32 Flash Size */
|
||||
#ifndef DISABLE_FLASH_SIZE_CHECK
|
||||
|
||||
@@ -379,7 +379,7 @@
|
||||
/*************************/
|
||||
//In this section you can configure all details about PPM.
|
||||
//If you do not plan to use the PPM mode comment this line using "//" to save Flash space, you don't need to configure anything below in this case
|
||||
#define ENABLE_PPM
|
||||
//#define ENABLE_PPM
|
||||
|
||||
/** TX END POINTS **/
|
||||
//It is important for the module to know the endpoints of your radio.
|
||||
|
||||
Reference in New Issue
Block a user