Skip to content

Commit

Permalink
Update Losi_cyrf6936.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
pascallanger committed Nov 29, 2023
1 parent 4957063 commit 9cbcafe
Showing 1 changed file with 72 additions and 29 deletions.
101 changes: 72 additions & 29 deletions Multiprotocol/Losi_cyrf6936.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,55 @@
#define LOSI_FORCE_ID

//const uint8_t PROGMEM LOSI_bind_sop_code[] = {0x62, 0xdf, 0xc1, 0x49, 0xdf, 0xb1, 0xc0, 0x49};
const uint8_t LOSI_bind_data_code[16] = { 0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86, 0xC9, 0x2C, 0x06, 0x93, 0x86, 0xB9, 0x9E, 0xD7 } ;

const uint8_t LOSI_data_code[][16] = {
{ 0xF1, 0x94, 0x30, 0x21, 0xA1, 0x1C, 0x88, 0xA9, 0xD0, 0xD2, 0x8E, 0xBC, 0x82, 0x2F, 0xE3, 0xB4 },
{ 0x17, 0xFF, 0x9E, 0x21, 0x36, 0x90, 0xC7, 0x82, 0xBC, 0x5D, 0x9A, 0x5B, 0xEE, 0x7F, 0x42, 0xEB },
{ 0x4C, 0x97, 0x9D, 0xBF, 0xB8, 0x3D, 0xB5, 0xBE, 0x0C, 0x5D, 0x24, 0x30, 0x9F, 0xCA, 0x6D, 0xBD },
{ 0x7D, 0x2D, 0x49, 0x54, 0xD0, 0x80, 0x40, 0xC1, 0xB6, 0xF2, 0xE6, 0x1B, 0x80, 0x5A, 0x36, 0xB4 },
{ 0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA, 0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC }
const uint8_t LOSI_bind_data_code[8] =
{ 0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86 } ;

const uint8_t LOSI_data_code[][8] = {
//(Freq-1)%5=0
{ 0x83, 0xF7, 0xA8, 0x2D, 0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6 },
{ 0x9B, 0x75, 0xF7, 0xE0, 0x14, 0x8D, 0xB5, 0x80 },
{ 0xBF, 0x54, 0x98, 0xB9, 0xB7, 0x30, 0x5A, 0x88 },
{ 0x35, 0xD1, 0xFC, 0x97, 0x23, 0xD4, 0xC9, 0x88 },
//(Freq-1)%5=3
{ 0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40, 0x93 },
{ 0xDC, 0x68, 0x08, 0x99, 0x97, 0xAE, 0xAF, 0x8C },
{ 0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA },
{ 0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC },
{ 0x5C, 0xD5, 0x9C, 0xB8, 0x46, 0x9C, 0x7D, 0x84 },
{ 0xF1, 0xC6, 0xFE, 0x5C, 0x9D, 0xA5, 0x4F, 0xB7 },
{ 0x58, 0xB5, 0xB3, 0xDD, 0x0E, 0x28, 0xF1, 0xB0 },
{ 0x5F, 0x30, 0x3B, 0x56, 0x96, 0x45, 0xF4, 0xA1 },
//(Freq-1)%5=4
{ 0x03, 0xBC, 0x6E, 0x8A, 0xEF, 0xBD, 0xFE, 0xF8 },
{ 0x88, 0x17, 0x13, 0x3B, 0x2D, 0xBF, 0x06, 0xD6 },
{ 0xF1, 0x94, 0x30, 0x21, 0xA1, 0x1C, 0x88, 0xA9 },
{ 0xD0, 0xD2, 0x8E, 0xBC, 0x82, 0x2F, 0xE3, 0xB4 },
{ 0x8C, 0xFA, 0x47, 0x9B, 0x83, 0xA5, 0x66, 0xD0 },
{ 0x07, 0xBD, 0x9F, 0x26, 0xC8, 0x31, 0x0F, 0xB8 },
{ 0xEF, 0x03, 0x95, 0x89, 0xB4, 0x71, 0x61, 0x9D },
{ 0x40, 0xBA, 0x97, 0xD5, 0x86, 0x4F, 0xCC, 0xD1 }
};

static uint16_t __attribute__((unused)) LOSI_check(uint16_t val)
Expand Down Expand Up @@ -64,7 +105,7 @@ static void __attribute__((unused)) LOSI_send_packet()
{
for(uint8_t i=0; i<3; i++)
{
uint16_t val = LOSI_check(LOSI_check(Channel_data[i]<<1);
uint16_t val = LOSI_check(Channel_data[i]<<1);
packet[4+i*2] = val >> 8;
packet[5+i*2] = val;
}
Expand All @@ -89,7 +130,7 @@ static void __attribute__((unused)) LOSI_cyrf_init()
CYRF_WriteRegister(CYRF_1B_TX_OFFSET_LSB, 0x55);
CYRF_WriteRegister(CYRF_1C_TX_OFFSET_MSB, 0x05);
//CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x24);
CYRF_SetPower(0x38); // 64 SDR mode
CYRF_SetPower(0x38); // 64 SDR mode -> 8 bytes data code
CYRF_WriteRegister(CYRF_12_DATA64_THOLD, 0x0A);
CYRF_WriteRegister(CYRF_39_ANALOG_CTRL, 0x01);
CYRF_WritePreamble(0x333304);
Expand All @@ -112,7 +153,8 @@ uint16_t LOSI_callback()
if(bind_counter==0)
{
BIND_DONE;
CYRF_ConfigDataCode(LOSI_data_code[hopping_frequency[0] % 5], 16); // Load normal data code
// Load normal data code
CYRF_ConfigDataCode(LOSI_data_code[(((hopping_frequency[0] - 1) % 5) << 3) + num_ch], 16);
packet_period = 19738;
}
}
Expand All @@ -128,33 +170,34 @@ void LOSI_init()
hopping_frequency[0] |= 1; // Only odd channels are used, integrated in CYRF code...

#ifdef LOSI_FORCE_ID
/* rx_tx_addr[0] = 0x47;
/*
rx_tx_addr[0] = 0x47;
rx_tx_addr[1] = 0x52;
rx_tx_addr[2] = 0xAE;
rx_tx_addr[3] = 0xAA;
crc8 = 0x0B;
hopping_frequency[0] = 0x27;
/* { 0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40, 0x93, 0xDC, 0x68, 0x08, 0x99, 0x97, 0xAE, 0xAF, 0x8C },
{ 0xDC, 0x68, 0x08, 0x99, 0x97, 0xAE, 0xAF, 0x8C, 0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA },
{ 0xC3, 0x0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 0x5A, 0x36, 0xB4 },
//{ 0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA, 0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC }

// Note: crc8=00..0F and num_ch=00..07
#endif

CYRF_ConfigRFChannel(hopping_frequency[0]);
Expand Down

0 comments on commit 9cbcafe

Please sign in to comment.