Test commit May 2021
Dependencies: SX127x sx12xx_hal
Revision 8:54050cc82d0f, committed 2021-05-09
- Comitter:
- lightshow
- Date:
- Sun May 09 19:09:30 2021 +0000
- Parent:
- 7:ccb3088ce5be
- Commit message:
- Test commit May 2021
Changed in this revision
diff -r ccb3088ce5be -r 54050cc82d0f SX127x.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SX127x.lib Sun May 09 19:09:30 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/dudmuck/code/SX127x/#cd54c52c6003
diff -r ccb3088ce5be -r 54050cc82d0f main.cpp --- a/main.cpp Wed Jul 18 18:52:35 2018 -0700 +++ b/main.cpp Sun May 09 19:09:30 2021 +0000 @@ -4,7 +4,7 @@ #if defined(SX127x_H) || defined(SX126x_H) #define BW_KHZ 500 #define SPREADING_FACTOR 11 - #define CF_HZ 910800000 + #define CF_HZ 908000000 #if defined(SX126x_H) #define TX_DBM (Radio::chipType == CHIP_TYPE_SX1262 ? 20 : 14) #else @@ -43,63 +43,37 @@ #define CMD_PINC 0x06 #define CMD_PIND 0x08 -volatile bool tx_done; - -static uint16_t crc_ccitt( uint8_t *buffer, uint16_t length ) -{ - // The CRC calculation follows CCITT - const uint16_t polynom = 0x1021; - // CRC initial value - uint16_t crc = 0x0000; +uint8_t ID_byte = 42; - if( buffer == NULL ) - { - return 0; - } - - for( uint16_t i = 0; i < length; ++i ) - { - crc ^= ( uint16_t ) buffer[i] << 8; - for( uint16_t j = 0; j < 8; ++j ) - { - crc = ( crc & 0x8000 ) ? ( crc << 1 ) ^ polynom : ( crc << 1 ); - } - } - - return crc; -} +volatile bool tx_done; void transmit(unsigned target, uint8_t cmd) { unsigned t_diff; - uint16_t crc; - - Radio::radio.tx_buf[0] = cmd; + + Radio::radio.tx_buf[0] = ID_byte; + Radio::radio.tx_buf[1] = cmd; t_diff = target - t.read_us(); - Radio::radio.tx_buf[1] = t_diff >> 24; - Radio::radio.tx_buf[2] = t_diff >> 16; - Radio::radio.tx_buf[3] = t_diff >> 8; - Radio::radio.tx_buf[4] = t_diff & 0xff; - crc = crc_ccitt(Radio::radio.tx_buf, 5); - Radio::radio.tx_buf[5] = crc >> 8; - Radio::radio.tx_buf[6] = crc & 0xff; - - Radio::Send(7, 0, 0, 0); + Radio::radio.tx_buf[2] = t_diff >> 24; + Radio::radio.tx_buf[3] = t_diff >> 16; + Radio::radio.tx_buf[4] = t_diff >> 8; + Radio::radio.tx_buf[5] = t_diff & 0xff; + + Radio::Send(6, 0, 0, 0); for (tx_done = false; !tx_done; ) Radio::service(); - printf("t_diff:%u crc:%04x\r\n", t_diff, crc); } -#define TARGET_LATENCY 2000000 +#define TARGET_LATENCY 1820500 void send_alarm(uint8_t cmd) { int i; unsigned target = t.read_us() + TARGET_LATENCY; printf("send_alarm() %u\n", target); - for (i = 0; i < 5; i++) { + for (i = 0; i < 6; i++) { transmit(target, cmd); wait(0.1); }
diff -r ccb3088ce5be -r 54050cc82d0f sx12xx_hal.lib --- a/sx12xx_hal.lib Wed Jul 18 18:52:35 2018 -0700 +++ b/sx12xx_hal.lib Sun May 09 19:09:30 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/dudmuck/code/sx12xx_hal/#c321b5919516 +https://os.mbed.com/users/dudmuck/code/sx12xx_hal/#a354f82d12d9