SLT: fix going from NRF to CC2500

This commit is contained in:
Pascal Langer 2020-02-17 13:10:57 +01:00
parent 5124c2a96d
commit 5503502bad
3 changed files with 25 additions and 12 deletions

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_PATCH_LEVEL 69 #define VERSION_PATCH_LEVEL 70
//****************** //******************
// Protocols // Protocols

View File

@ -353,7 +353,11 @@ static void __attribute__((unused)) XN297L_SetFreqOffset()
static void __attribute__((unused)) NRF250K_SetTXAddr(uint8_t* addr, uint8_t len) static void __attribute__((unused)) NRF250K_SetTXAddr(uint8_t* addr, uint8_t len)
{ {
if (len > 5) len = 5;
if (len < 3) len = 3;
#ifdef CC2500_INSTALLED #ifdef CC2500_INSTALLED
xn297_addr_len = len;
memcpy(xn297_tx_addr, addr, len);
if(option==0) if(option==0)
#endif #endif
{//NRF {//NRF
@ -361,12 +365,6 @@ static void __attribute__((unused)) NRF250K_SetTXAddr(uint8_t* addr, uint8_t len
return; return;
} }
//CC2500 //CC2500
#ifdef CC2500_INSTALLED
if (len > 5) len = 5;
if (len < 3) len = 3;
xn297_addr_len = len;
memcpy(xn297_tx_addr, addr, len);
#endif
} }
static void __attribute__((unused)) NRF250K_WritePayload(uint8_t* msg, uint8_t len) static void __attribute__((unused)) NRF250K_WritePayload(uint8_t* msg, uint8_t len)
@ -388,16 +386,15 @@ static void __attribute__((unused)) NRF250K_WritePayload(uint8_t* msg, uint8_t l
//nrf preamble //nrf preamble
if(xn297_tx_addr[xn297_addr_len - 1] & 0x80) if(xn297_tx_addr[xn297_addr_len - 1] & 0x80)
buf[0]=0x55;
else
buf[0]=0xAA; buf[0]=0xAA;
else
buf[0]=0x55;
last++; last++;
// address // address
for (i = 0; i < xn297_addr_len; ++i) for (i = 0; i < xn297_addr_len; ++i)
buf[last++] = xn297_tx_addr[xn297_addr_len - i - 1]; buf[last++] = xn297_tx_addr[xn297_addr_len - i - 1];
// payload // payload
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
// bit-reverse bytes in packet
buf[last++] = msg[i]; buf[last++] = msg[i];
// crc // crc
@ -407,6 +404,9 @@ static void __attribute__((unused)) NRF250K_WritePayload(uint8_t* msg, uint8_t l
buf[last++] = crc >> 8; buf[last++] = crc >> 8;
buf[last++] = crc & 0xff; buf[last++] = crc & 0xff;
//for(uint8_t i=0;i<last;i++)
// debug("%02X ",buf[i]);
//debugln("");
// stop TX/RX // stop TX/RX
CC2500_Strobe(CC2500_SIDLE); CC2500_Strobe(CC2500_SIDLE);
// flush tx FIFO // flush tx FIFO

View File

@ -49,7 +49,8 @@ enum {
SLT_DATA2, SLT_DATA2,
SLT_DATA3, SLT_DATA3,
SLT_BIND1, SLT_BIND1,
SLT_BIND2 SLT_BIND2,
SLT_TEST
}; };
static void __attribute__((unused)) SLT_init() static void __attribute__((unused)) SLT_init()
@ -120,6 +121,7 @@ static void __attribute__((unused)) SLT_build_packet()
static uint8_t calib_counter=0; static uint8_t calib_counter=0;
// Set radio channel - once per packet batch // Set radio channel - once per packet batch
NRF250K_SetFreqOffset(); // Set frequency offset
NRF250K_Hopping(hopping_frequency_no); NRF250K_Hopping(hopping_frequency_no);
if (++hopping_frequency_no >= SLT_NFREQCHANNELS) if (++hopping_frequency_no >= SLT_NFREQCHANNELS)
hopping_frequency_no = 0; hopping_frequency_no = 0;
@ -258,7 +260,13 @@ uint16_t SLT_callback()
return 20000-SLT_TIMING_BUILD-SLT_V1_TIMING_BIND2; return 20000-SLT_TIMING_BUILD-SLT_V1_TIMING_BIND2;
else //V2 else //V2
return 13730-SLT_TIMING_BUILD-SLT_V2_TIMING_BIND1-SLT_V2_TIMING_BIND2; return 13730-SLT_TIMING_BUILD-SLT_V2_TIMING_BIND1-SLT_V2_TIMING_BIND2;
} /* case SLT_TEST:
for(uint8_t i=0;i<10;i++)
packet[i]=0x10+i;
NRF250K_WritePayload(packet,10);
NRF250K_SetFreqOffset(); // Set frequency offset
return 5000;
*/ }
return 19000; return 19000;
} }
@ -279,6 +287,11 @@ uint16_t initSLT()
SLT_set_freq(); SLT_set_freq();
SLT_init(); SLT_init();
phase = SLT_BUILD; phase = SLT_BUILD;
/* phase=SLT_TEST;
NRF250K_SetTXAddr((uint8_t*)"\x01\x02\x03\x04\x05",5);
NRF250K_RFChannel(0);
*/
return 50000; return 50000;
} }