mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 20:38:14 +00:00
DSM function name change for uniqness
This commit is contained in:
parent
282b2a0a43
commit
1f0f9a2eae
@ -164,7 +164,7 @@ const uint8_t PROGMEM data_vals[][2] = {
|
|||||||
{CYRF_1E_RX_OVERRIDE, 0x00}, // CRC16 enabled, no ACK
|
{CYRF_1E_RX_OVERRIDE, 0x00}, // CRC16 enabled, no ACK
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __attribute__((unused)) cyrf_config()
|
static void __attribute__((unused)) DSM_cyrf_config()
|
||||||
{
|
{
|
||||||
for(uint8_t i = 0; i < sizeof(init_vals) / 2; i++)
|
for(uint8_t i = 0; i < sizeof(init_vals) / 2; i++)
|
||||||
CYRF_WriteRegister(pgm_read_byte_near(&init_vals[i][0]), pgm_read_byte_near(&init_vals[i][1]));
|
CYRF_WriteRegister(pgm_read_byte_near(&init_vals[i][0]), pgm_read_byte_near(&init_vals[i][1]));
|
||||||
@ -172,7 +172,7 @@ static void __attribute__((unused)) cyrf_config()
|
|||||||
CYRF_ConfigRFChannel(0x61);
|
CYRF_ConfigRFChannel(0x61);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) build_bind_packet()
|
static void __attribute__((unused)) DSM_build_bind_packet()
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint16_t sum = 384 - 0x10;//
|
uint16_t sum = 384 - 0x10;//
|
||||||
@ -211,21 +211,21 @@ static void __attribute__((unused)) build_bind_packet()
|
|||||||
packet[15] = sum & 0xff;
|
packet[15] = sum & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) initialize_bind_phase()
|
static void __attribute__((unused)) DSM_initialize_bind_phase()
|
||||||
{
|
{
|
||||||
CYRF_ConfigRFChannel(DSM_BIND_CHANNEL); //This seems to be random?
|
CYRF_ConfigRFChannel(DSM_BIND_CHANNEL); //This seems to be random?
|
||||||
//64 SDR Mode is configured so only the 8 first values are needed but need to write 16 values...
|
//64 SDR Mode is configured so only the 8 first values are needed but need to write 16 values...
|
||||||
CYRF_ConfigDataCode((const uint8_t*)"\xD7\xA1\x54\xB1\x5E\x89\xAE\x86\xc6\x94\x22\xfe\x48\xe6\x57\x4e", 16);
|
CYRF_ConfigDataCode((const uint8_t*)"\xD7\xA1\x54\xB1\x5E\x89\xAE\x86\xc6\x94\x22\xfe\x48\xe6\x57\x4e", 16);
|
||||||
build_bind_packet();
|
DSM_build_bind_packet();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) cyrf_configdata()
|
static void __attribute__((unused)) DSM_cyrf_configdata()
|
||||||
{
|
{
|
||||||
for(uint8_t i = 0; i < sizeof(data_vals) / 2; i++)
|
for(uint8_t i = 0; i < sizeof(data_vals) / 2; i++)
|
||||||
CYRF_WriteRegister(pgm_read_byte_near(&data_vals[i][0]), pgm_read_byte_near(&data_vals[i][1]));
|
CYRF_WriteRegister(pgm_read_byte_near(&data_vals[i][0]), pgm_read_byte_near(&data_vals[i][1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) update_channels()
|
static void __attribute__((unused)) DSM_update_channels()
|
||||||
{
|
{
|
||||||
prev_option=option;
|
prev_option=option;
|
||||||
if(sub_protocol==DSM_AUTO)
|
if(sub_protocol==DSM_AUTO)
|
||||||
@ -243,13 +243,13 @@ static void __attribute__((unused)) update_channels()
|
|||||||
ch_map[i]=pgm_read_byte_near(&ch_map_progmem[idx][i]);
|
ch_map[i]=pgm_read_byte_near(&ch_map_progmem[idx][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) build_data_packet(uint8_t upper)
|
static void __attribute__((unused)) DSM_build_data_packet(uint8_t upper)
|
||||||
{
|
{
|
||||||
uint16_t max = 2047;
|
uint16_t max = 2047;
|
||||||
uint8_t bits = 11;
|
uint8_t bits = 11;
|
||||||
|
|
||||||
if(prev_option!=option)
|
if(prev_option!=option)
|
||||||
update_channels();
|
DSM_update_channels();
|
||||||
|
|
||||||
if (sub_protocol==DSMX_11 || sub_protocol==DSMX_22 )
|
if (sub_protocol==DSMX_11 || sub_protocol==DSMX_22 )
|
||||||
{
|
{
|
||||||
@ -288,7 +288,7 @@ static void __attribute__((unused)) build_data_packet(uint8_t upper)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) set_sop_data_crc()
|
static void __attribute__((unused)) DSM_set_sop_data_crc()
|
||||||
{
|
{
|
||||||
//The crc for channel '1' is NOT(mfgid[0] << 8 + mfgid[1])
|
//The crc for channel '1' is NOT(mfgid[0] << 8 + mfgid[1])
|
||||||
//The crc for channel '2' is (mfgid[0] << 8 + mfgid[1])
|
//The crc for channel '2' is (mfgid[0] << 8 + mfgid[1])
|
||||||
@ -314,7 +314,7 @@ static void __attribute__((unused)) set_sop_data_crc()
|
|||||||
hopping_frequency_no %=2;
|
hopping_frequency_no %=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) calc_dsmx_channel()
|
static void __attribute__((unused)) DSM_calc_dsmx_channel()
|
||||||
{
|
{
|
||||||
uint8_t idx = 0;
|
uint8_t idx = 0;
|
||||||
uint32_t id = ~(((uint32_t)cyrfmfg_id[0] << 24) | ((uint32_t)cyrfmfg_id[1] << 16) | ((uint32_t)cyrfmfg_id[2] << 8) | (cyrfmfg_id[3] << 0));
|
uint32_t id = ~(((uint32_t)cyrfmfg_id[0] << 24) | ((uint32_t)cyrfmfg_id[1] << 16) | ((uint32_t)cyrfmfg_id[2] << 8) | (cyrfmfg_id[3] << 0));
|
||||||
@ -433,17 +433,17 @@ uint16_t ReadDsm()
|
|||||||
#endif
|
#endif
|
||||||
case DSM_CHANSEL:
|
case DSM_CHANSEL:
|
||||||
BIND_DONE;
|
BIND_DONE;
|
||||||
cyrf_configdata();
|
DSM_cyrf_configdata();
|
||||||
CYRF_SetTxRxMode(TX_EN);
|
CYRF_SetTxRxMode(TX_EN);
|
||||||
hopping_frequency_no = 0;
|
hopping_frequency_no = 0;
|
||||||
phase = DSM_CH1_WRITE_A; // in fact phase++
|
phase = DSM_CH1_WRITE_A; // in fact phase++
|
||||||
set_sop_data_crc();
|
DSM_set_sop_data_crc();
|
||||||
return 10000;
|
return 10000;
|
||||||
case DSM_CH1_WRITE_A:
|
case DSM_CH1_WRITE_A:
|
||||||
case DSM_CH1_WRITE_B:
|
case DSM_CH1_WRITE_B:
|
||||||
case DSM_CH2_WRITE_A:
|
case DSM_CH2_WRITE_A:
|
||||||
case DSM_CH2_WRITE_B:
|
case DSM_CH2_WRITE_B:
|
||||||
build_data_packet(phase == DSM_CH1_WRITE_B||phase == DSM_CH2_WRITE_B); // build lower or upper channels
|
DSM_build_data_packet(phase == DSM_CH1_WRITE_B||phase == DSM_CH2_WRITE_B); // build lower or upper channels
|
||||||
CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS); // clear IRQ flags
|
CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS); // clear IRQ flags
|
||||||
CYRF_WriteDataPacket(packet);
|
CYRF_WriteDataPacket(packet);
|
||||||
phase++; // change from WRITE to CHECK mode
|
phase++; // change from WRITE to CHECK mode
|
||||||
@ -463,12 +463,12 @@ uint16_t ReadDsm()
|
|||||||
if (((CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS) & 0x22) == 0x20) || (CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80))
|
if (((CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS) & 0x22) == 0x20) || (CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80))
|
||||||
{
|
{
|
||||||
CYRF_Reset();
|
CYRF_Reset();
|
||||||
cyrf_config();
|
DSM_cyrf_config();
|
||||||
cyrf_configdata();
|
DSM_cyrf_configdata();
|
||||||
CYRF_SetTxRxMode(TX_EN);
|
CYRF_SetTxRxMode(TX_EN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
set_sop_data_crc();
|
DSM_set_sop_data_crc();
|
||||||
phase++; // change from CH1_CHECK to CH2_WRITE
|
phase++; // change from CH1_CHECK to CH2_WRITE
|
||||||
return DSM_CH1_CH2_DELAY - DSM_WRITE_DELAY;
|
return DSM_CH1_CH2_DELAY - DSM_WRITE_DELAY;
|
||||||
}
|
}
|
||||||
@ -510,11 +510,11 @@ uint16_t ReadDsm()
|
|||||||
phase = DSM_CH1_WRITE_A; //Transmit lower
|
phase = DSM_CH1_WRITE_A; //Transmit lower
|
||||||
CYRF_SetTxRxMode(TX_EN); //TX mode
|
CYRF_SetTxRxMode(TX_EN); //TX mode
|
||||||
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x00); //Clear abort RX operation
|
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x00); //Clear abort RX operation
|
||||||
set_sop_data_crc();
|
DSM_set_sop_data_crc();
|
||||||
return DSM_READ_DELAY;
|
return DSM_READ_DELAY;
|
||||||
#else
|
#else
|
||||||
// No telemetry
|
// No telemetry
|
||||||
set_sop_data_crc();
|
DSM_set_sop_data_crc();
|
||||||
if (phase == DSM_CH2_CHECK_A)
|
if (phase == DSM_CH2_CHECK_A)
|
||||||
{
|
{
|
||||||
if(DSM_num_ch > 7 || sub_protocol==DSM2_11 || sub_protocol==DSMX_11)
|
if(DSM_num_ch > 7 || sub_protocol==DSM2_11 || sub_protocol==DSMX_11)
|
||||||
@ -548,7 +548,7 @@ uint16_t initDsm()
|
|||||||
}
|
}
|
||||||
//Hopping frequencies
|
//Hopping frequencies
|
||||||
if (sub_protocol == DSMX_11 || sub_protocol == DSMX_22)
|
if (sub_protocol == DSMX_11 || sub_protocol == DSMX_22)
|
||||||
calc_dsmx_channel();
|
DSM_calc_dsmx_channel();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint8_t tmpch[10];
|
uint8_t tmpch[10];
|
||||||
@ -565,15 +565,15 @@ uint16_t initDsm()
|
|||||||
hopping_frequency[1] = tmpch[idx];
|
hopping_frequency[1] = tmpch[idx];
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
cyrf_config();
|
DSM_cyrf_config();
|
||||||
CYRF_SetTxRxMode(TX_EN);
|
CYRF_SetTxRxMode(TX_EN);
|
||||||
//
|
//
|
||||||
update_channels();
|
DSM_update_channels();
|
||||||
//
|
//
|
||||||
if(IS_AUTOBIND_FLAG_on )
|
if(IS_AUTOBIND_FLAG_on )
|
||||||
{
|
{
|
||||||
BIND_IN_PROGRESS;
|
BIND_IN_PROGRESS;
|
||||||
initialize_bind_phase();
|
DSM_initialize_bind_phase();
|
||||||
phase = DSM_BIND_WRITE;
|
phase = DSM_BIND_WRITE;
|
||||||
bind_counter=DSM_BIND_COUNT;
|
bind_counter=DSM_BIND_COUNT;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user