diff --git a/Multiprotocol/CYRF6936_SPI.ino b/Multiprotocol/CYRF6936_SPI.ino index dcf06e1..d37e484 100644 --- a/Multiprotocol/CYRF6936_SPI.ino +++ b/Multiprotocol/CYRF6936_SPI.ino @@ -258,3 +258,37 @@ void CYRF_FindBestChannels(uint8_t *channels, uint8_t len, uint8_t minspace, uin } CYRF_SetTxRxMode(TX_EN); } + +#if defined(DEVO_CYRF6936_INO) || defined(J6PRO_CYRF6936_INO) +const uint8_t PROGMEM DEVO_j6pro_sopcodes[][8] = { + /* Note these are in order transmitted (LSB 1st) */ + {0x3C, 0x37, 0xCC, 0x91, 0xE2, 0xF8, 0xCC, 0x91}, + {0x9B, 0xC5, 0xA1, 0x0F, 0xAD, 0x39, 0xA2, 0x0F}, + {0xEF, 0x64, 0xB0, 0x2A, 0xD2, 0x8F, 0xB1, 0x2A}, + {0x66, 0xCD, 0x7C, 0x50, 0xDD, 0x26, 0x7C, 0x50}, + {0x5C, 0xE1, 0xF6, 0x44, 0xAD, 0x16, 0xF6, 0x44}, + {0x5A, 0xCC, 0xAE, 0x46, 0xB6, 0x31, 0xAE, 0x46}, + {0xA1, 0x78, 0xDC, 0x3C, 0x9E, 0x82, 0xDC, 0x3C}, + {0xB9, 0x8E, 0x19, 0x74, 0x6F, 0x65, 0x18, 0x74}, + {0xDF, 0xB1, 0xC0, 0x49, 0x62, 0xDF, 0xC1, 0x49}, + {0x97, 0xE5, 0x14, 0x72, 0x7F, 0x1A, 0x14, 0x72}, +#if defined(J6PRO_CYRF6936_INO) + {0x82, 0xC7, 0x90, 0x36, 0x21, 0x03, 0xFF, 0x17}, + {0xE2, 0xF8, 0xCC, 0x91, 0x3C, 0x37, 0xCC, 0x91}, //Note: the '03' was '9E' in the Cypress recommended table + {0xAD, 0x39, 0xA2, 0x0F, 0x9B, 0xC5, 0xA1, 0x0F}, //The following are the same as the 1st 8 above, + {0xD2, 0x8F, 0xB1, 0x2A, 0xEF, 0x64, 0xB0, 0x2A}, //but with the upper and lower word swapped + {0xDD, 0x26, 0x7C, 0x50, 0x66, 0xCD, 0x7C, 0x50}, + {0xAD, 0x16, 0xF6, 0x44, 0x5C, 0xE1, 0xF6, 0x44}, + {0xB6, 0x31, 0xAE, 0x46, 0x5A, 0xCC, 0xAE, 0x46}, + {0x9E, 0x82, 0xDC, 0x3C, 0xA1, 0x78, 0xDC, 0x3C}, + {0x6F, 0x65, 0x18, 0x74, 0xB9, 0x8E, 0x19, 0x74}, +#endif +}; +#endif +static void __attribute__((unused)) CYRF_PROGMEM_ConfigSOPCode(const uint8_t *data) +{ + uint8_t code[8]; + for(uint8_t i=0;i<8;i++) + code[i]=pgm_read_byte_near(&data[i]); + CYRF_ConfigSOPCode(code); +} \ No newline at end of file diff --git a/Multiprotocol/Devo_cyrf6936.ino b/Multiprotocol/Devo_cyrf6936.ino index cf56eed..a677de9 100644 --- a/Multiprotocol/Devo_cyrf6936.ino +++ b/Multiprotocol/Devo_cyrf6936.ino @@ -43,28 +43,6 @@ enum { DEVO_BOUND_10, }; -const uint8_t PROGMEM DEVO_sopcodes[][8] = { - /* Note these are in order transmitted (LSB 1st) */ - /* 0 */ {0x3C,0x37,0xCC,0x91,0xE2,0xF8,0xCC,0x91}, //0x91CCF8E291CC373C - /* 1 */ {0x9B,0xC5,0xA1,0x0F,0xAD,0x39,0xA2,0x0F}, //0x0FA239AD0FA1C59B - /* 2 */ {0xEF,0x64,0xB0,0x2A,0xD2,0x8F,0xB1,0x2A}, //0x2AB18FD22AB064EF - /* 3 */ {0x66,0xCD,0x7C,0x50,0xDD,0x26,0x7C,0x50}, //0x507C26DD507CCD66 - /* 4 */ {0x5C,0xE1,0xF6,0x44,0xAD,0x16,0xF6,0x44}, //0x44F616AD44F6E15C - /* 5 */ {0x5A,0xCC,0xAE,0x46,0xB6,0x31,0xAE,0x46}, //0x46AE31B646AECC5A - /* 6 */ {0xA1,0x78,0xDC,0x3C,0x9E,0x82,0xDC,0x3C}, //0x3CDC829E3CDC78A1 - /* 7 */ {0xB9,0x8E,0x19,0x74,0x6F,0x65,0x18,0x74}, //0x7418656F74198EB9 - /* 8 */ {0xDF,0xB1,0xC0,0x49,0x62,0xDF,0xC1,0x49}, //0x49C1DF6249C0B1DF - /* 9 */ {0x97,0xE5,0x14,0x72,0x7F,0x1A,0x14,0x72}, //0x72141A7F7214E597 -}; - -static void __attribute__((unused)) DEVO_ConfigSOPCode(uint8_t val) -{ - uint8_t code[8]; - for(uint8_t i=0;i<8;i++) - code[i]=pgm_read_byte_near(&DEVO_sopcodes[val][i]); - CYRF_ConfigSOPCode(code); -} - static void __attribute__((unused)) DEVO_scramble_pkt() { #ifdef NO_SCRAMBLE @@ -181,7 +159,7 @@ static void __attribute__((unused)) DEVO_cyrf_set_bound_sop_code() uint8_t sopidx = (0xff &((cyrfmfg_id[0] << 2) + cyrfmfg_id[1] + cyrfmfg_id[2])) % 10; CYRF_SetTxRxMode(TX_EN); CYRF_ConfigCRCSeed((crc << 8) + crc); - DEVO_ConfigSOPCode(sopidx); + CYRF_PROGMEM_ConfigSOPCode(DEVO_j6pro_sopcodes[sopidx]); CYRF_SetPower(0x08); } @@ -313,7 +291,7 @@ uint16_t DevoInit() CYRF_GetMfgData(cyrfmfg_id); CYRF_SetTxRxMode(TX_EN); CYRF_ConfigCRCSeed(0x0000); - DEVO_ConfigSOPCode(0); + CYRF_PROGMEM_ConfigSOPCode(DEVO_j6pro_sopcodes[0]); DEVO_set_radio_channels(); hopping_frequency_ptr = hopping_frequency; diff --git a/Multiprotocol/J6Pro_cyrf6936.ino b/Multiprotocol/J6Pro_cyrf6936.ino index f82bb70..02f1743 100644 --- a/Multiprotocol/J6Pro_cyrf6936.ino +++ b/Multiprotocol/J6Pro_cyrf6936.ino @@ -35,30 +35,8 @@ enum PktState { J6PRO_CHAN_4, }; -const uint8_t j6pro_sopcodes[][8] = { - /* Note these are in order transmitted (LSB 1st) */ - {0x3C, 0x37, 0xCC, 0x91, 0xE2, 0xF8, 0xCC, 0x91}, - {0x9B, 0xC5, 0xA1, 0x0F, 0xAD, 0x39, 0xA2, 0x0F}, - {0xEF, 0x64, 0xB0, 0x2A, 0xD2, 0x8F, 0xB1, 0x2A}, - {0x66, 0xCD, 0x7C, 0x50, 0xDD, 0x26, 0x7C, 0x50}, - {0x5C, 0xE1, 0xF6, 0x44, 0xAD, 0x16, 0xF6, 0x44}, - {0x5A, 0xCC, 0xAE, 0x46, 0xB6, 0x31, 0xAE, 0x46}, - {0xA1, 0x78, 0xDC, 0x3C, 0x9E, 0x82, 0xDC, 0x3C}, - {0xB9, 0x8E, 0x19, 0x74, 0x6F, 0x65, 0x18, 0x74}, - {0xDF, 0xB1, 0xC0, 0x49, 0x62, 0xDF, 0xC1, 0x49}, - {0x97, 0xE5, 0x14, 0x72, 0x7F, 0x1A, 0x14, 0x72}, - {0x82, 0xC7, 0x90, 0x36, 0x21, 0x03, 0xFF, 0x17}, - {0xE2, 0xF8, 0xCC, 0x91, 0x3C, 0x37, 0xCC, 0x91}, //Note: the '03' was '9E' in the Cypress recommended table - {0xAD, 0x39, 0xA2, 0x0F, 0x9B, 0xC5, 0xA1, 0x0F}, //The following are the same as the 1st 8 above, - {0xD2, 0x8F, 0xB1, 0x2A, 0xEF, 0x64, 0xB0, 0x2A}, //but with the upper and lower word swapped - {0xDD, 0x26, 0x7C, 0x50, 0x66, 0xCD, 0x7C, 0x50}, - {0xAD, 0x16, 0xF6, 0x44, 0x5C, 0xE1, 0xF6, 0x44}, - {0xB6, 0x31, 0xAE, 0x46, 0x5A, 0xCC, 0xAE, 0x46}, - {0x9E, 0x82, 0xDC, 0x3C, 0xA1, 0x78, 0xDC, 0x3C}, - {0x6F, 0x65, 0x18, 0x74, 0xB9, 0x8E, 0x19, 0x74}, -}; -const uint8_t bind_sop_code[] = {0x62, 0xdf, 0xc1, 0x49, 0xdf, 0xb1, 0xc0, 0x49}; -const uint8_t data_code[] = {0x02, 0xf9, 0x93, 0x97, 0x02, 0xfa, 0x5c, 0xe3, 0x01, 0x2b, 0xf1, 0xdb, 0x01, 0x32, 0xbe, 0x6f}; +const uint8_t PROGMEM j6pro_bind_sop_code[] = {0x62, 0xdf, 0xc1, 0x49, 0xdf, 0xb1, 0xc0, 0x49}; +const uint8_t j6pro_data_code[] = {0x02, 0xf9, 0x93, 0x97, 0x02, 0xfa, 0x5c, 0xe3, 0x01, 0x2b, 0xf1, 0xdb, 0x01, 0x32, 0xbe, 0x6f}; static void __attribute__((unused)) j6pro_build_bind_packet() { @@ -106,7 +84,7 @@ static void __attribute__((unused)) j6pro_cyrf_init() CYRF_WriteRegister(CYRF_10_FRAMING_CFG, 0xee); CYRF_WriteRegister(CYRF_1F_TX_OVERRIDE, 0x00); CYRF_WriteRegister(CYRF_1E_RX_OVERRIDE, 0x00); - CYRF_ConfigDataCode(data_code, 16); + CYRF_ConfigDataCode(j6pro_data_code, 16); CYRF_WritePreamble(0x023333); CYRF_GetMfgData(cyrfmfg_id); @@ -121,7 +99,7 @@ static void __attribute__((unused)) cyrf_bindinit() CYRF_SetPower(0x28); //Deviation using max power, replaced by bind power... CYRF_ConfigRFChannel(0x52); - CYRF_ConfigSOPCode(bind_sop_code); + CYRF_PROGMEM_ConfigSOPCode(j6pro_bind_sop_code); CYRF_ConfigCRCSeed(0x0000); CYRF_WriteRegister(CYRF_06_RX_CFG, 0x4a); CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x83); @@ -144,7 +122,7 @@ static void __attribute__((unused)) cyrf_datainit() uint16_t crc = (0xff & (cyrfmfg_id[1] - cyrfmfg_id[4] + cyrfmfg_id[5])) | ((0xff & (cyrfmfg_id[2] + cyrfmfg_id[3] - cyrfmfg_id[4] + cyrfmfg_id[5])) << 8); CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x25); - CYRF_ConfigSOPCode(j6pro_sopcodes[sop_idx]); + CYRF_PROGMEM_ConfigSOPCode(DEVO_j6pro_sopcodes[sop_idx]); CYRF_ConfigCRCSeed(crc); }