diff --git a/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.c b/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.c new file mode 100644 index 00000000..164422bb --- /dev/null +++ b/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.c @@ -0,0 +1,380 @@ +/** +\brief This program lets SCuM transmit BLE packets over a range of + frequency settings. +*/ + +#include + +#include "scm3c_hw_interface.h" +#include "memory_map.h" +#include "rftimer.h" +#include "radio.h" +#include "ble.h" +#include "optical.h" + +//=========================== defines ========================================= + +#define CRC_VALUE (*((unsigned int *) 0x0000FFFC)) +#define CODE_LENGTH (*((unsigned int *) 0x0000FFF8)) + +#define CHANNEL 0 // ble channel + +#define TXPOWER 0xC5 // used for ibeacon pkt + +#define NUMPKT_PER_CFG 1 +#define STEPS_PER_CONFIG 32 +#define TIMER_PERIOD 2000 // 500 = 1ms@500kHz + +// only this coarse settings are swept, +// channel 37 and 0 are known within the setting scope of coarse=24 +#define CFG_COARSE 24 + +#define HS_3 + +#ifdef TEST + #define MID_START 0 + #define MID_END 32 +#endif + +#ifdef HS_2 + #define MID_START 15 + #define MID_END 20 +#endif + +#ifdef HS_1 + #define MID_START 0 + #define MID_END 32 +#endif + +#ifdef HS_3 + #define MID_START 17 + #define MID_END 22 +#endif + + +const static uint8_t ble_device_addr[6] = { + 0xaa, 0xbb, 0xcc, 0xcc, 0xbb, 0xaa +}; + +const static uint8_t ble_uuid[16] = { + + 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, + 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf +}; + +//=========================== variables ======================================= + +typedef struct { + uint8_t tx_coarse; + uint8_t tx_mid; + uint8_t tx_fine; + + bool sendDone; + + uint8_t pdu[PDU_LENGTH+CRC_LENGTH]; // protocol data unit + uint8_t pdu_len; +} app_vars_t; + +app_vars_t app_vars; + +//=========================== prototypes ====================================== + +void cb_endFrame_tx(uint32_t timestamp); +void cb_timer(void); + +uint8_t prepare_pdu_nordic_aoa_beacon(void); +uint8_t prepare_pdu_ibeacon(void); +uint8_t prepare_pdu_cte_inline(void); +uint8_t prepare_freq_setting_pdu(uint8_t coarse, uint8_t mid, uint8_t fine); +void delay_tx(void); +void delay_lc_setup(void); + +//=========================== main ============================================ + +int main(void) { + + uint32_t calc_crc; + + uint8_t cfg_mid; + uint8_t cfg_fine; + + uint8_t i; + uint8_t j; + uint8_t offset; + + uint32_t t; + + memset(&app_vars, 0, sizeof(app_vars_t)); + + printf("Initializing..."); + + // Set up mote configuration + // This function handles all the analog scan chain setup + initialize_mote(); + ble_init_tx(); + + radio_setEndFrameTxCb(cb_endFrame_tx); + rftimer_set_callback(cb_timer); + + // Disable interrupts for the radio and rftimer + radio_disable_interrupts(); + rftimer_disable_interrupts(); + + // Check CRC to ensure there were no errors during optical programming + printf("\r\n-------------------\r\n"); + printf("Validating program integrity..."); + + calc_crc = crc32c(0x0000,CODE_LENGTH); + + if (calc_crc == CRC_VALUE) { + printf("CRC OK\r\n"); + } else { + printf("\r\nProgramming Error - CRC DOES NOT MATCH - Halting Execution\r\n"); + while(1); + } + + // After bootloading the next thing that happens is frequency calibration using optical + printf("Calibrating frequencies...\r\n"); + + // Initial frequency calibration will tune the frequencies for HCLK, the RX/TX chip clocks, and the LO + + optical_enableLCCalibration(); + + // Turn on LO, DIV, PA, and IF + ANALOG_CFG_REG__10 = 0x78; + + // Turn off polyphase and disable mixer + ANALOG_CFG_REG__16 = 0x6; + +#if CHANNEL==37 + // For TX, LC target freq = 2.402G - 0.25M = 2.40175 GHz. + optical_setLCTarget(250182); +#elif CHANNEL==0 + + // For TX, LC target freq = 2.404G - 0.25M = 2.40375 GHz. + optical_setLCTarget(250390); +#endif + + // For the LO, calibration for RX channel 11, so turn on AUX, IF, and LO LDOs + // by calling radio rxEnable + radio_rxEnable(); + + // Enable optical SFD interrupt for optical calibration + optical_enable(); + + // Wait for optical cal to finish + while(!optical_getCalibrationFinished()); + + printf("Cal complete\r\n"); + + // Enable interrupts for the radio FSM (Not working for ble) + radio_enable_interrupts(); + + radio_rfOff(); + + ble_set_channel(CHANNEL); + + while (1) { + + // loop through all configuration + + // customize coarse, mid, fine values to change the sweeping range + for (cfg_mid=MID_START;cfg_mid0; j--) { + app_vars.pdu[i++] = flipChar(ble_device_addr[j-1]); + } + + field_len += 6; + + app_vars.pdu[i++] = flipChar(0x1a); + app_vars.pdu[i++] = flipChar(0xff); + app_vars.pdu[i++] = flipChar(0x4c); + app_vars.pdu[i++] = flipChar(0x00); + + field_len += 4; + + app_vars.pdu[i++] = flipChar(0x02); + app_vars.pdu[i++] = flipChar(0x15); + for (j=16; j>0; j--) { + app_vars.pdu[i++] = flipChar(ble_uuid[j-1]); + } + + // major + app_vars.pdu[i++] = flipChar(0x00); + app_vars.pdu[i++] = flipChar(0xff); + // minor + app_vars.pdu[i++] = flipChar(0x00); + app_vars.pdu[i++] = flipChar(0x0f); + // power level + app_vars.pdu[i++] = flipChar(TXPOWER); + + field_len += 23; + + app_vars.pdu[1] = flipChar(field_len); + + // the pdu length = field_len plus 2 bytes header + return (field_len+2); +} + +uint8_t prepare_pdu_nordic_aoa_beacon(void){ + + uint8_t i; + uint8_t field_len; + + memset(app_vars.pdu, 0, sizeof(app_vars.pdu)); + + i = 0; + + app_vars.pdu[i++] = flipChar(0x46); + app_vars.pdu[i++] = flipChar(0x06); + field_len = 6; + app_vars.pdu[i++] = flipChar(0x01); + app_vars.pdu[i++] = flipChar(0x02); + app_vars.pdu[i++] = flipChar(0x03); + app_vars.pdu[i++] = flipChar(0x04); + app_vars.pdu[i++] = flipChar(0x05); + app_vars.pdu[i++] = flipChar(0xc6); + + // the pdu length = field_len plus 2 bytes header + return (field_len+2); +} diff --git a/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.uvoptx b/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.uvoptx new file mode 100644 index 00000000..84027589 --- /dev/null +++ b/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.uvoptx @@ -0,0 +1,440 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + ble_freq_sweep + 0x4 + ARM-ADS + + 10000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 7 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + + + + + + + + + + + BIN\UL2CM3.DLL + + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + app + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + .\ble_freq_sweep.c + ble_freq_sweep.c + 0 + 0 + + + + + drv + 1 + 0 + 0 + 0 + + 2 + 2 + 2 + 0 + 0 + 0 + ..\..\cm0dsasm.s + cm0dsasm.s + 0 + 0 + + + 2 + 3 + 5 + 0 + 0 + 0 + ..\..\Memory_Map.h + Memory_Map.h + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\retarget.c + retarget.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\optical.c + optical.c + 0 + 0 + + + 2 + 6 + 5 + 0 + 0 + 0 + ..\..\optical.h + optical.h + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\radio.c + radio.c + 0 + 0 + + + 2 + 8 + 5 + 0 + 0 + 0 + ..\..\radio.h + radio.h + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\adc.c + adc.c + 0 + 0 + + + 2 + 10 + 5 + 0 + 0 + 0 + ..\..\adc.h + adc.h + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\gpio.c + gpio.c + 0 + 0 + + + 2 + 12 + 5 + 0 + 0 + 0 + ..\..\gpio.h + gpio.h + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\uart.c + uart.c + 0 + 0 + + + 2 + 14 + 5 + 0 + 0 + 0 + ..\..\uart.h + uart.h + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\rftimer.c + rftimer.c + 0 + 0 + + + 2 + 16 + 5 + 0 + 0 + 0 + ..\..\rftimer.h + rftimer.h + 0 + 0 + + + 2 + 17 + 5 + 0 + 0 + 0 + ..\..\scum_defs.h + scum_defs.h + 0 + 0 + + + 2 + 18 + 5 + 0 + 0 + 0 + ..\..\scm3c_hw_interface.h + scm3c_hw_interface.h + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\scm3c_hw_interface.c + scm3c_hw_interface.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + + + +
diff --git a/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.uvprojx b/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.uvprojx new file mode 100644 index 00000000..5d234fc6 --- /dev/null +++ b/scm_v3c/applications/ble_freq_sweep/ble_freq_sweep.uvprojx @@ -0,0 +1,549 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + ble_freq_sweep + 0x4 + ARM-ADS + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 + + + ARMCM0 + ARM + ARM.CMSIS.5.3.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x80000) IRAM(0x20000000,0x20000) CPUTYPE("Cortex-M0") CLOCK(10000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0$Flash\NEW_DEVICE.flm)) + 0 + $$Device:ARMCM0$Device\Include\ARMCM0.h + + + + + + + + + + $$Device:ARMCM0$SVD\ARMCM0.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + ble_freq_sweep + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf --bin .\Objects\ble_freq_sweep.axf -o .\Objects\ble_freq_sweep.bin + fromelf -cvf .\Objects\ble_freq_sweep.axf -o .\Objects\disasm.txt + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0 + SARMCM3.DLL + + TARMCM1.DLL + -pCM0 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + + + ../../ + + + + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + continuously_cal.sct + + + + + + + + + + + app + + + ble_freq_sweep.c + 1 + .\ble_freq_sweep.c + + + + + drv + + + cm0dsasm.s + 2 + ..\..\cm0dsasm.s + + + Memory_Map.h + 5 + ..\..\Memory_Map.h + + + retarget.c + 1 + ..\..\retarget.c + + + optical.c + 1 + ..\..\optical.c + + + optical.h + 5 + ..\..\optical.h + + + radio.c + 1 + ..\..\radio.c + + + radio.h + 5 + ..\..\radio.h + + + adc.c + 1 + ..\..\adc.c + + + adc.h + 5 + ..\..\adc.h + + + gpio.c + 1 + ..\..\gpio.c + + + gpio.h + 5 + ..\..\gpio.h + + + uart.c + 1 + ..\..\uart.c + + + uart.h + 5 + ..\..\uart.h + + + rftimer.c + 1 + ..\..\rftimer.c + + + rftimer.h + 5 + ..\..\rftimer.h + + + scum_defs.h + 5 + ..\..\scum_defs.h + + + scm3c_hw_interface.h + 5 + ..\..\scm3c_hw_interface.h + + + scm3c_hw_interface.c + 1 + ..\..\scm3c_hw_interface.c + + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + + + + + + + + + + + + + RTE\CMSIS\RTX_Conf_CM.c + + + + + + RTE\Device\ARMCM0\startup_ARMCM0.s + + + + + + RTE\Device\ARMCM0\system_ARMCM0.c + + + + + + RTE\Drivers\NAND_MemBus_Config.h + + + + + + RTE\Drivers\OneNAND_Config.h + + + + + + RTE\File_System\FS_Config.c + + + + + + RTE\File_System\FS_Config_RAM.h + + + + + + + +
diff --git a/scm_v3c/applications/ble_tx/ble_tx.c b/scm_v3c/applications/ble_tx/ble_tx.c new file mode 100644 index 00000000..d22d4f98 --- /dev/null +++ b/scm_v3c/applications/ble_tx/ble_tx.c @@ -0,0 +1,162 @@ +/** +\brief This program lets SCuM transmit BLE packets. +*/ + +#include + +#include "scm3c_hw_interface.h" +#include "memory_map.h" +#include "ble.h" +#include "rftimer.h" +#include "radio.h" +#include "optical.h" + +//=========================== defines ========================================= + +#define CRC_VALUE (*((unsigned int *) 0x0000FFFC)) +#define CODE_LENGTH (*((unsigned int *) 0x0000FFF8)) + +#define TIMER_PERIOD 50000 ///< 500 = 1ms@500kHz + +#define BLE_CALIBRATE_LC false +#define BLE_SWEEP_FINE true + +//=========================== variables ======================================= + +typedef struct { + uint8_t tx_coarse; + uint8_t tx_mid; + uint8_t tx_fine; + + bool txNext; +} app_vars_t; + +app_vars_t app_vars; + +//=========================== prototypes ====================================== + +void cb_timer(void); +void transmit_ble_packet(void); + +//=========================== main ============================================ + +int main(void) { + + uint32_t calc_crc; + + memset(&app_vars, 0, sizeof(app_vars_t)); + + printf("Initializing..."); + + // Set up mote configuration + // This function handles all the analog scan chain setup + initialize_mote(); + ble_init_tx(); + + rftimer_set_callback(cb_timer); + + // Disable interrupts for the radio and rftimer + radio_disable_interrupts(); + rftimer_disable_interrupts(); + + // Check CRC to ensure there were no errors during optical programming + printf("\r\n-------------------\r\n"); + printf("Validating program integrity..."); + + calc_crc = crc32c(0x0000,CODE_LENGTH); + + if (calc_crc == CRC_VALUE){ + printf("CRC OK\r\n"); + } else { + printf("\r\nProgramming Error - CRC DOES NOT MATCH - Halting Execution\r\n"); + while(1); + } + + // Debug output + // printf("\r\nCode length is %u bytes",code_length); + // printf("\r\nCRC calculated by SCM is: 0x%X",calc_crc); + + //printf("done\r\n"); + + // After bootloading the next thing that happens is frequency calibration using optical + printf("Calibrating frequencies...\r\n"); + + // Initial frequency calibration will tune the frequencies for HCLK, the RX/TX chip clocks, and the LO + +#if BLE_CALIBRATE_LC + optical_enableLCCalibration(); + + // Turn on LO, DIV, PA, and IF + ANALOG_CFG_REG__10 = 0x78; + + // Turn off polyphase and disable mixer + ANALOG_CFG_REG__16 = 0x6; + + // For TX, LC target freq = 2.402G - 0.25M = 2.40175 GHz. + optical_setLCTarget(250182); +#endif + + // Enable optical SFD interrupt for optical calibration + optical_enable(); + + // Wait for optical cal to finish + while(!optical_getCalibrationFinished()); + + printf("Cal complete\r\n"); + + // Disable static divider to save power + divProgram(480, 0, 0); + + // Configure coarse, mid, and fine codes for TX. +#if BLE_CALIBRATE_LC + app_vars.tx_coarse = optical_getLCCoarse(); + app_vars.tx_mid = optical_getLCMid(); + app_vars.tx_fine = optical_getLCFine(); +#else + // CHANGE THESE VALUES AFTER LC CALIBRATION. + app_vars.tx_coarse = 23; + app_vars.tx_mid = 11; + app_vars.tx_fine = 23; +#endif + + ble_gen_packet(); + + while (1) { + transmit_ble_packet(); + rftimer_setCompareIn(rftimer_readCounter() + TIMER_PERIOD); + app_vars.txNext = false; + while (!app_vars.txNext); + } +} + +//=========================== public ========================================== + +//=========================== private ========================================= + +void cb_timer(void) { + app_vars.txNext = true; +} + +void transmit_ble_packet(void) { + int t, tx_fine; + +#if BLE_SWEEP_FINE + for (tx_fine = 0; tx_fine < 32; ++tx_fine) { + LC_FREQCHANGE(app_vars.tx_coarse, app_vars.tx_mid, tx_fine); + printf("Transmitting on %u %u %u\n", app_vars.tx_coarse, app_vars.tx_mid, tx_fine); + + // Wait for frequency to settle. + for (t = 0; t < 5000; ++t); + + ble_transmit(); + } +#else + LC_FREQCHANGE(app_vars.tx_coarse, app_vars.tx_mid, app_vars.tx_fine); + printf("Transmitting on %u %u %u\n", app_vars.tx_coarse, app_vars.tx_mid, app_vars.tx_fine); + + // Wait for frequency to settle. + for (t = 0; t < 5000; ++t); + + ble_transmit(); +#endif +} diff --git a/scm_v3c/applications/ble_tx/ble_tx.uvoptx b/scm_v3c/applications/ble_tx/ble_tx.uvoptx new file mode 100644 index 00000000..2600d9aa --- /dev/null +++ b/scm_v3c/applications/ble_tx/ble_tx.uvoptx @@ -0,0 +1,440 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + ble_tx + 0x4 + ARM-ADS + + 10000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 7 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + + + + + + + + + + + BIN\UL2CM3.DLL + + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + app + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + .\ble_tx.c + ble_tx.c + 0 + 0 + + + + + drv + 1 + 0 + 0 + 0 + + 2 + 2 + 2 + 0 + 0 + 0 + ..\..\cm0dsasm.s + cm0dsasm.s + 0 + 0 + + + 2 + 3 + 5 + 0 + 0 + 0 + ..\..\Memory_Map.h + Memory_Map.h + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\retarget.c + retarget.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\optical.c + optical.c + 0 + 0 + + + 2 + 6 + 5 + 0 + 0 + 0 + ..\..\optical.h + optical.h + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\radio.c + radio.c + 0 + 0 + + + 2 + 8 + 5 + 0 + 0 + 0 + ..\..\radio.h + radio.h + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\adc.c + adc.c + 0 + 0 + + + 2 + 10 + 5 + 0 + 0 + 0 + ..\..\adc.h + adc.h + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\gpio.c + gpio.c + 0 + 0 + + + 2 + 12 + 5 + 0 + 0 + 0 + ..\..\gpio.h + gpio.h + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\uart.c + uart.c + 0 + 0 + + + 2 + 14 + 5 + 0 + 0 + 0 + ..\..\uart.h + uart.h + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\rftimer.c + rftimer.c + 0 + 0 + + + 2 + 16 + 5 + 0 + 0 + 0 + ..\..\rftimer.h + rftimer.h + 0 + 0 + + + 2 + 17 + 5 + 0 + 0 + 0 + ..\..\scum_defs.h + scum_defs.h + 0 + 0 + + + 2 + 18 + 5 + 0 + 0 + 0 + ..\..\scm3c_hw_interface.h + scm3c_hw_interface.h + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\scm3c_hw_interface.c + scm3c_hw_interface.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + + + +
diff --git a/scm_v3c/applications/ble_tx/ble_tx.uvprojx b/scm_v3c/applications/ble_tx/ble_tx.uvprojx new file mode 100644 index 00000000..38764fd1 --- /dev/null +++ b/scm_v3c/applications/ble_tx/ble_tx.uvprojx @@ -0,0 +1,549 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + ble_tx + 0x4 + ARM-ADS + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 + + + ARMCM0 + ARM + ARM.CMSIS.5.3.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x80000) IRAM(0x20000000,0x20000) CPUTYPE("Cortex-M0") CLOCK(10000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0$Flash\NEW_DEVICE.flm)) + 0 + $$Device:ARMCM0$Device\Include\ARMCM0.h + + + + + + + + + + $$Device:ARMCM0$SVD\ARMCM0.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + ble_tx + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf --bin .\Objects\ble_tx.axf -o .\Objects\ble_tx.bin + fromelf -cvf .\Objects\ble_tx.axf -o .\Objects\disasm.txt + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0 + SARMCM3.DLL + + TARMCM1.DLL + -pCM0 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + + + ../../ + + + + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + freq_sweep_rx.sct + + + + + + + + + + + app + + + ble_tx.c + 1 + .\ble_tx.c + + + + + drv + + + cm0dsasm.s + 2 + ..\..\cm0dsasm.s + + + Memory_Map.h + 5 + ..\..\Memory_Map.h + + + retarget.c + 1 + ..\..\retarget.c + + + optical.c + 1 + ..\..\optical.c + + + optical.h + 5 + ..\..\optical.h + + + radio.c + 1 + ..\..\radio.c + + + radio.h + 5 + ..\..\radio.h + + + adc.c + 1 + ..\..\adc.c + + + adc.h + 5 + ..\..\adc.h + + + gpio.c + 1 + ..\..\gpio.c + + + gpio.h + 5 + ..\..\gpio.h + + + uart.c + 1 + ..\..\uart.c + + + uart.h + 5 + ..\..\uart.h + + + rftimer.c + 1 + ..\..\rftimer.c + + + rftimer.h + 5 + ..\..\rftimer.h + + + scum_defs.h + 5 + ..\..\scum_defs.h + + + scm3c_hw_interface.h + 5 + ..\..\scm3c_hw_interface.h + + + scm3c_hw_interface.c + 1 + ..\..\scm3c_hw_interface.c + + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + + + + + + + + + + + + + RTE\CMSIS\RTX_Conf_CM.c + + + + + + RTE\Device\ARMCM0\startup_ARMCM0.s + + + + + + RTE\Device\ARMCM0\system_ARMCM0.c + + + + + + RTE\Drivers\NAND_MemBus_Config.h + + + + + + RTE\Drivers\OneNAND_Config.h + + + + + + RTE\File_System\FS_Config.c + + + + + + RTE\File_System\FS_Config_RAM.h + + + + + + + +
diff --git a/scm_v3c/applications/ble_tx/ble_tx_logger.py b/scm_v3c/applications/ble_tx/ble_tx_logger.py new file mode 100644 index 00000000..20b8a5be --- /dev/null +++ b/scm_v3c/applications/ble_tx/ble_tx_logger.py @@ -0,0 +1,71 @@ +import pytest +import os +import time +import serial +import threading +import sys + +# =========================== variables ======================================= + +BAUDRATE_SCUM = 19200 + +LOG_FILE = 'ble_tx_output.txt' + +TIMER_PERIOD = 0.1 +RUNNING_DURATION = 200*TIMER_PERIOD + +# =========================== class =========================================== + +class serialReader(threading.Thread): + + def __init__(self,serialport=None, baudrate=None, log_file=None): + + self.goOn = True + + self.serialport = serialport + self.baudrate = baudrate + + self.output = '' + self.log_file = log_file + + threading.Thread.__init__(self) + + def run(self): + + self.serial = serial.Serial(self.serialport,self.baudrate,timeout=1) + + while self.goOn: + output = self.serial.readline() + if not (self.log_file is None): + with open(self.log_file,'a') as lf: + lf.write(output) + + self.serial.close() + + def close(self): + self.goOn = False + + def get_output(self): + return self.output + +# =========================== test ============================================ + +# ==== tests + +if __name__ == '__main__': + + # port_openmote = os.environ.get('PORT_OPENMOTE') + port_scum = os.environ.get('PORT_SCUM') + # serial_openmote = serialReader(port_openmote, BAUDRATE_OPENMOTE, LOG_FILE) + serial_scum = serialReader(port_scum, BAUDRATE_SCUM, LOG_FILE) + + # starting logging the serial output + # serial_openmote.start() + serial_scum.start() + + print "running for ", RUNNING_DURATION, 's...' + + time.sleep(RUNNING_DURATION) + + # serial_openmote.close() + serial_scum.close() diff --git a/scm_v3c/applications/ble_tx/ble_tx_parser.py b/scm_v3c/applications/ble_tx/ble_tx_parser.py new file mode 100644 index 00000000..6e1933b5 --- /dev/null +++ b/scm_v3c/applications/ble_tx/ble_tx_parser.py @@ -0,0 +1,21 @@ +import os +import re + +# =========================== variables ======================================= + +LOG_FILE = 'ble_tx_output.txt' + +# =========================== helper =========================================== + +# ==== tests + +if __name__ == '__main__': + + num_tx = 0 + + with open(LOG_FILE, 'r') as lf: + for line in lf: + if re.match("Transmitting on \d+ \d+ \d+", line) is not None: + num_tx += 1 + + assert num_tx > 100, "Only received {0} TX lines".format(num_tx) diff --git a/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.c b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.c new file mode 100644 index 00000000..3701f1cb --- /dev/null +++ b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.c @@ -0,0 +1,274 @@ +/** +\brief This program lets SCuM receive 15.4 packets and broadcast them as a BLE packet. +*/ + +#include + +#include "scm3c_hw_interface.h" +#include "memory_map.h" +#include "ble.h" +#include "rftimer.h" +#include "radio.h" +#include "optical.h" + +//=========================== defines ========================================= + +#define CRC_VALUE (*((unsigned int *) 0x0000FFFC)) +#define CODE_LENGTH (*((unsigned int *) 0x0000FFF8)) + +#define LENGTH_PACKET 125 + LENGTH_CRC ///< maximum length is 127 bytes +#define LEN_RX_PKT 20 + LENGTH_CRC ///< length of rx packet + +#define TIMER_PERIOD 200000 ///< 500 = 1ms@500kHz +#define BLE_TX_PERIOD 1 + +#define BLE_CALIBRATE_LC false +#define BLE_SWEEP_FINE false +#define BLE_NUM_REPEAT 1 // Number of times to repeat packet when not sweeping + +//=========================== variables ======================================= + +typedef struct { + uint8_t packet[LENGTH_PACKET]; + uint8_t packet_len; + int8_t rxpk_rssi; + uint8_t rxpk_lqi; + + volatile bool rxpk_crc; + // a flag to mark when to change configure + volatile bool changeConfig; + // a flag to avoid change configure during receiving frame + volatile bool rxFrameStarted; + + volatile uint32_t IF_estimate; + volatile uint32_t LQI_chip_errors; + volatile uint32_t cdr_tau_value; + + uint8_t rx_coarse; + uint8_t rx_mid; + uint8_t rx_fine; + + uint8_t tx_coarse; + uint8_t tx_mid; + uint8_t tx_fine; + + uint16_t rx_iteration; +} app_vars_t; + +app_vars_t app_vars; + +//=========================== prototypes ====================================== + +void cb_startFrame_rx(uint32_t timestamp); +void cb_endFrame_rx(uint32_t timestamp); +void cb_timer(void); +void receive_154_packet(void); +void transmit_ble_packet(void); + +//=========================== main ============================================ + +int main(void) { + + uint32_t calc_crc; + + uint8_t i; + uint8_t j; + uint8_t offset; + int t; + + memset(&app_vars, 0, sizeof(app_vars_t)); + + printf("Initializing..."); + + // Set up mote configuration + // This function handles all the analog scan chain setup + initialize_mote(); + ble_init_tx(); + + radio_setStartFrameRxCb(cb_startFrame_rx); + radio_setEndFrameRxCb(cb_endFrame_rx); + rftimer_set_callback(cb_timer); + + // Disable interrupts for the radio and rftimer + radio_disable_interrupts(); + rftimer_disable_interrupts(); + + // Check CRC to ensure there were no errors during optical programming + printf("\r\n-------------------\r\n"); + printf("Validating program integrity..."); + + calc_crc = crc32c(0x0000,CODE_LENGTH); + + if (calc_crc == CRC_VALUE){ + printf("CRC OK\r\n"); + } else { + printf("\r\nProgramming Error - CRC DOES NOT MATCH - Halting Execution\r\n"); + while(1); + } + + // Debug output + // printf("\r\nCode length is %u bytes",code_length); + // printf("\r\nCRC calculated by SCM is: 0x%X",calc_crc); + + //printf("done\r\n"); + + // After bootloading the next thing that happens is frequency calibration using optical + printf("Calibrating frequencies...\r\n"); + + // Initial frequency calibration will tune the frequencies for HCLK, the RX/TX chip clocks, and the LO + + // For the LO, calibration for RX channel 11, so turn on AUX, IF, and LO LDOs + // by calling radio rxEnable + radio_rxEnable(); + +#if BLE_CALIBRATE_LC + optical_enableLCCalibration(); + + // Turn on LDOs for calibration + radio_txEnable(); + + // Turn on LO, DIV, PA, and IF + ANALOG_CFG_REG__10 = 0x78; + + // For TX, LC target freq = 2.402G - 0.25M = 2.40175 GHz. + optical_setLCTarget(250182); +#endif + + // Enable optical SFD interrupt for optical calibration + optical_enable(); + + // Wait for optical cal to finish + while(!optical_getCalibrationFinished()); + + printf("Cal complete\r\n"); + + // Disable static divider to save power + divProgram(480, 0, 0); + + // Enable interrupts for the radio FSM + radio_enable_interrupts(); + + // Configure coarse, mid, and fine codes for RX. + app_vars.rx_coarse = 23; + app_vars.rx_mid = 15; + app_vars.rx_fine = 15; + + // Configure coarse, mid, and fine codes for TX. +#if BLE_CALIBRATE_LC + app_vars.tx_coarse = optical_getLCCoarse(); + app_vars.tx_mid = optical_getLCMid(); + app_vars.tx_fine = optical_getLCFine(); +#else + // CHANGE THESE VALUES AFTER LC CALIBRATION. + app_vars.tx_coarse = 23; + app_vars.tx_mid = 11; + app_vars.tx_fine = 23; +#endif + + while (1) { + receive_154_packet(); + rftimer_setCompareIn(rftimer_readCounter() + TIMER_PERIOD); + app_vars.changeConfig = false; + while (!app_vars.changeConfig); + + ++app_vars.rx_iteration; + if (app_vars.rx_iteration % BLE_TX_PERIOD == 0) { + transmit_ble_packet(); + } + } +} + +//=========================== public ========================================== + +//=========================== private ========================================= + +void cb_startFrame_rx(uint32_t timestamp){ + app_vars.rxFrameStarted = true; +} + +void cb_endFrame_rx(uint32_t timestamp){ + + uint8_t i; + + radio_getReceivedFrame( + &(app_vars.packet[0]), + &app_vars.packet_len, + sizeof(app_vars.packet), + &app_vars.rxpk_rssi, + &app_vars.rxpk_lqi + ); + + radio_rfOff(); + + if ( + app_vars.packet_len == LEN_RX_PKT && (radio_getCrcOk()) + ) { + // Only record IF estimate, LQI, and CDR tau for valid packets + app_vars.IF_estimate = radio_getIFestimate(); + app_vars.LQI_chip_errors = radio_getLQIchipErrors(); + + printf( + "pkt received on ch%d %d%d%d%d.%d.%d.%d\r\n", + app_vars.packet[4], + app_vars.packet[0], + app_vars.packet[1], + app_vars.packet[2], + app_vars.packet[3], + app_vars.rx_coarse, + app_vars.rx_mid, + app_vars.rx_fine + ); + + ble_set_data(app_vars.packet); + ble_set_data_tx_en(true); + + app_vars.packet_len = 0; + memset(&app_vars.packet[0], 0, LENGTH_PACKET); + } + + radio_rxEnable(); + radio_rxNow(); + + app_vars.rxFrameStarted = false; +} + +void cb_timer(void) { + app_vars.changeConfig = true; +} + +void receive_154_packet(void) { + printf("Receiving on %u %u %u\n", app_vars.rx_coarse, app_vars.rx_mid, app_vars.rx_fine); + while (app_vars.rxFrameStarted); + radio_rfOff(); + LC_FREQCHANGE(app_vars.rx_coarse, app_vars.rx_mid, app_vars.rx_fine); + radio_rxEnable(); + radio_rxNow(); +} + +void transmit_ble_packet(void) { + int i, t, tx_fine; + + ble_gen_packet(); + +#if BLE_SWEEP_FINE + for (tx_fine = 0; tx_fine < 32; ++tx_fine) { + LC_FREQCHANGE(app_vars.tx_coarse, app_vars.tx_mid, tx_fine); + printf("Transmitting on %u %u %u\n", app_vars.tx_coarse, app_vars.tx_mid, tx_fine); + + // Wait for frequency to settle. + for (t = 0; t < 5000; ++t); + + ble_transmit(); + } +#else + for (i = 0; i < BLE_NUM_REPEAT; ++i) { + LC_FREQCHANGE(app_vars.tx_coarse, app_vars.tx_mid, app_vars.tx_fine); + printf("Transmitting on %u %u %u\n", app_vars.tx_coarse, app_vars.tx_mid, app_vars.tx_fine); + + // Wait for frequency to settle. + for (t = 0; t < 5000; ++t); + + ble_transmit(); + } +#endif +} diff --git a/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.uvoptx b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.uvoptx new file mode 100644 index 00000000..1a8a2987 --- /dev/null +++ b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.uvoptx @@ -0,0 +1,440 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + ble_tx_154_rx + 0x4 + ARM-ADS + + 10000000 + + 0 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 7 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + + + + + + + + + + + BIN\UL2CM3.DLL + + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + app + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + .\ble_tx_154_rx.c + ble_tx_154_rx.c + 0 + 0 + + + + + drv + 1 + 0 + 0 + 0 + + 2 + 2 + 2 + 0 + 0 + 0 + ..\..\cm0dsasm.s + cm0dsasm.s + 0 + 0 + + + 2 + 3 + 5 + 0 + 0 + 0 + ..\..\Memory_Map.h + Memory_Map.h + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\retarget.c + retarget.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\optical.c + optical.c + 0 + 0 + + + 2 + 6 + 5 + 0 + 0 + 0 + ..\..\optical.h + optical.h + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\radio.c + radio.c + 0 + 0 + + + 2 + 8 + 5 + 0 + 0 + 0 + ..\..\radio.h + radio.h + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\adc.c + adc.c + 0 + 0 + + + 2 + 10 + 5 + 0 + 0 + 0 + ..\..\adc.h + adc.h + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\gpio.c + gpio.c + 0 + 0 + + + 2 + 12 + 5 + 0 + 0 + 0 + ..\..\gpio.h + gpio.h + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\uart.c + uart.c + 0 + 0 + + + 2 + 14 + 5 + 0 + 0 + 0 + ..\..\uart.h + uart.h + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\rftimer.c + rftimer.c + 0 + 0 + + + 2 + 16 + 5 + 0 + 0 + 0 + ..\..\rftimer.h + rftimer.h + 0 + 0 + + + 2 + 17 + 5 + 0 + 0 + 0 + ..\..\scum_defs.h + scum_defs.h + 0 + 0 + + + 2 + 18 + 5 + 0 + 0 + 0 + ..\..\scm3c_hw_interface.h + scm3c_hw_interface.h + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\scm3c_hw_interface.c + scm3c_hw_interface.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + + + +
diff --git a/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.uvprojx b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.uvprojx new file mode 100644 index 00000000..1ac6357f --- /dev/null +++ b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx.uvprojx @@ -0,0 +1,549 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + ble_tx_154_rx + 0x4 + ARM-ADS + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 + + + ARMCM0 + ARM + ARM.CMSIS.5.3.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x80000) IRAM(0x20000000,0x20000) CPUTYPE("Cortex-M0") CLOCK(10000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0$Flash\NEW_DEVICE.flm)) + 0 + $$Device:ARMCM0$Device\Include\ARMCM0.h + + + + + + + + + + $$Device:ARMCM0$SVD\ARMCM0.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + ble_tx_154_rx + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf --bin .\Objects\ble_tx_154_rx.axf -o .\Objects\ble_tx_154_rx.bin + fromelf -cvf .\Objects\ble_tx_154_rx.axf -o .\Objects\disasm.txt + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0 + SARMCM3.DLL + + TARMCM1.DLL + -pCM0 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + + + ../../ + + + + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + freq_sweep_rx.sct + + + + + + + + + + + app + + + ble_tx_154_rx.c + 1 + .\ble_tx_154_rx.c + + + + + drv + + + cm0dsasm.s + 2 + ..\..\cm0dsasm.s + + + Memory_Map.h + 5 + ..\..\Memory_Map.h + + + retarget.c + 1 + ..\..\retarget.c + + + optical.c + 1 + ..\..\optical.c + + + optical.h + 5 + ..\..\optical.h + + + radio.c + 1 + ..\..\radio.c + + + radio.h + 5 + ..\..\radio.h + + + adc.c + 1 + ..\..\adc.c + + + adc.h + 5 + ..\..\adc.h + + + gpio.c + 1 + ..\..\gpio.c + + + gpio.h + 5 + ..\..\gpio.h + + + uart.c + 1 + ..\..\uart.c + + + uart.h + 5 + ..\..\uart.h + + + rftimer.c + 1 + ..\..\rftimer.c + + + rftimer.h + 5 + ..\..\rftimer.h + + + scum_defs.h + 5 + ..\..\scum_defs.h + + + scm3c_hw_interface.h + 5 + ..\..\scm3c_hw_interface.h + + + scm3c_hw_interface.c + 1 + ..\..\scm3c_hw_interface.c + + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + + + + + + + + + + + + + RTE\CMSIS\RTX_Conf_CM.c + + + + + + RTE\Device\ARMCM0\startup_ARMCM0.s + + + + + + RTE\Device\ARMCM0\system_ARMCM0.c + + + + + + RTE\Drivers\NAND_MemBus_Config.h + + + + + + RTE\Drivers\OneNAND_Config.h + + + + + + RTE\File_System\FS_Config.c + + + + + + RTE\File_System\FS_Config_RAM.h + + + + + + + +
diff --git a/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx_logger.py b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx_logger.py new file mode 100644 index 00000000..807e4c76 --- /dev/null +++ b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx_logger.py @@ -0,0 +1,71 @@ +import pytest +import os +import time +import serial +import threading +import sys + +# =========================== variables ======================================= + +BAUDRATE_SCUM = 19200 + +LOG_FILE = 'ble_tx_154_rx_output.txt' + +TIMER_PERIOD = 0.4 +RUNNING_DURATION = 200*TIMER_PERIOD + +# =========================== class =========================================== + +class serialReader(threading.Thread): + + def __init__(self,serialport=None, baudrate=None, log_file=None): + + self.goOn = True + + self.serialport = serialport + self.baudrate = baudrate + + self.output = '' + self.log_file = log_file + + threading.Thread.__init__(self) + + def run(self): + + self.serial = serial.Serial(self.serialport,self.baudrate,timeout=1) + + while self.goOn: + output = self.serial.readline() + if not (self.log_file is None): + with open(self.log_file,'a') as lf: + lf.write(output) + + self.serial.close() + + def close(self): + self.goOn = False + + def get_output(self): + return self.output + +# =========================== test ============================================ + +# ==== tests + +if __name__ == '__main__': + + # port_openmote = os.environ.get('PORT_OPENMOTE') + port_scum = os.environ.get('PORT_SCUM') + # serial_openmote = serialReader(port_openmote, BAUDRATE_OPENMOTE, LOG_FILE) + serial_scum = serialReader(port_scum, BAUDRATE_SCUM, LOG_FILE) + + # starting logging the serial output + # serial_openmote.start() + serial_scum.start() + + print "running for ", RUNNING_DURATION, 's...' + + time.sleep(RUNNING_DURATION) + + # serial_openmote.close() + serial_scum.close() diff --git a/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx_parser.py b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx_parser.py new file mode 100644 index 00000000..bfcd2450 --- /dev/null +++ b/scm_v3c/applications/ble_tx_154_rx/ble_tx_154_rx_parser.py @@ -0,0 +1,24 @@ +import os +import re + +# =========================== variables ======================================= + +LOG_FILE = 'ble_tx_154_rx_output.txt' + +# =========================== helper =========================================== + +# ==== tests + +if __name__ == '__main__': + + num_tx, num_rx = 0, 0 + + with open(LOG_FILE, 'r') as lf: + for line in lf: + if re.match("Transmitting on \d+ \d+ \d+", line) is not None: + num_tx += 1 + elif re.match("Receiving on \d+ \d+ \d+", line) is not None: + num_rx += 1 + + assert num_tx > 100, "Only received {0} TX lines".format(num_tx) + assert num_rx > 100, "Only received {0} RX lines".format(num_rx) diff --git a/scm_v3c/applications/continuously_cal/continuously_cal.c b/scm_v3c/applications/continuously_cal/continuously_cal.c index 6c812b3d..98c2ffa3 100644 --- a/scm_v3c/applications/continuously_cal/continuously_cal.c +++ b/scm_v3c/applications/continuously_cal/continuously_cal.c @@ -200,7 +200,7 @@ int main(void) { optical_enable(); // Wait for optical cal to finish - while(optical_getCalibrationFinshed() == 0); + while(optical_getCalibrationFinished() == 0); printf("Cal complete\r\n"); diff --git a/scm_v3c/applications/continuously_cal/continuously_cal.uvoptx b/scm_v3c/applications/continuously_cal/continuously_cal.uvoptx index b748b1ca..2cb2d889 100644 --- a/scm_v3c/applications/continuously_cal/continuously_cal.uvoptx +++ b/scm_v3c/applications/continuously_cal/continuously_cal.uvoptx @@ -413,6 +413,30 @@ 0 0 + + 2 + 21 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 22 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + diff --git a/scm_v3c/applications/continuously_cal/continuously_cal.uvprojx b/scm_v3c/applications/continuously_cal/continuously_cal.uvprojx index 8d6809a8..fa01acf9 100644 --- a/scm_v3c/applications/continuously_cal/continuously_cal.uvprojx +++ b/scm_v3c/applications/continuously_cal/continuously_cal.uvprojx @@ -482,6 +482,16 @@ 1 ..\..\scm3c_hw_interface.c + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + diff --git a/scm_v3c/applications/continuously_cal/logs/log_final_failed.txt b/scm_v3c/applications/continuously_cal/logs/log_final_failed.txt new file mode 100644 index 00000000..82bacd9e --- /dev/null +++ b/scm_v3c/applications/continuously_cal/logs/log_final_failed.txt @@ -0,0 +1,324 @@ +á.²EInitializing... +------------------- +Validating program integrity... +Programming Error - CRC DOES NOT MATCH - Halting Execution +Initializing... +------------------- +Validating program integrity...CRC OK +Calibrating frequencies... +HF=0-17 2M=0-21,15,15 LC=0-698 IF=0-18 +HF=2025220-17 2M=201215-21,15,15 LC=249273-698 IF=1624774-18 +HF=2025296-18 2M=201206-22,15,15 LC=249265-699 IF=1624712-19 +HF=2019880-19 2M=200258-22,16,15 LC=249274-700 IF=1622162-20 +HF=2013716-20 2M=199961-22,16,14 LC=249302-701 IF=1619468-21 +HF=2006728-21 2M=199993-22,16,14 LC=249308-702 IF=1616289-22 +HF=2001004-21 2M=200002-22,16,14 LC=249313-703 IF=1613352-23 +HF=2000372-21 2M=200003-22,16,14 LC=249321-704 IF=1610725-24 +HF=2000640-21 2M=200007-22,16,14 LC=249333-705 IF=1608043-25 +HF=2000728-21 2M=200004-22,16,14 LC=249337-706 IF=1605459-26 +HF=2000388-21 2M=200002-22,16,14 LC=249349-707 IF=1602806-27 +HF=2000068-21 2M=200000-22,16,14 LC=249358-708 IF=1600243-27 +HF=1999932-21 2M=199994-22,16,14 LC=249366-709 IF=1600059-27 +HF=1999772-21 2M=199999-22,16,14 LC=249377-710 IF=1600098-27 +HF=2000052-21 2M=199995-22,16,14 LC=249384-711 IF=1600088-27 +HF=2000228-21 2M=199999-22,16,14 LC=249395-712 IF=1600060-27 +HF=2000060-21 2M=200000-22,16,14 LC=249407-713 IF=1600076-27 +HF=1999964-21 2M=200002-22,16,14 LC=249417-714 IF=1600087-27 +HF=1999968-21 2M=199995-22,16,14 LC=249422-715 IF=1599967-27 +HF=2000088-21 2M=200003-22,16,14 LC=249438-716 IF=1599903-27 +HF=1999964-21 2M=199991-22,16,14 LC=249453-717 IF=1600052-27 +HF=1999976-21 2M=199992-22,16,14 LC=249462-718 IF=1600069-27 +HF=1999972-21 2M=199995-22,16,14 LC=249475-719 IF=1600027-27 +HF=1999992-21 2M=200000-22,16,14 LC=249487-720 IF=1599888-27 +HF=2000084-21 2M=200002-22,16,14 LC=249499-721 IF=1599896-27 +done +Cal complete +schedule sweep Tx in 7 seconds +setting_list[0] = 24 8 24 +setting_list[1] = 24 8 26 +setting_list[2] = 24 8 27 +setting_list[3] = 24 8 28 +setting_list[4] = 24 8 29 +setting_list[5] = 24 9 13 +setting_list[6] = 24 9 13 +setting_list[7] = 24 9 19 +setting_list[8] = 24 9 20 +setting_list[9] = 24 9 21 +setting_list[10] = 24 9 22 +setting_list[11] = 24 9 23 +setting_list[12] = 24 9 24 +setting_list[13] = 24 9 13 +setting_list[14] = 24 9 10 +setting_list[15] = 24 9 11 +setting_list[16] = 24 9 12 +setting_list[17] = 24 9 13 +setting_list[18] = 24 9 13 +setting_list[19] = 24 9 16 +setting_list[20] = 24 9 1 +setting_list[21] = 24 9 2 +setting_list[22] = 24 9 3 +setting_list[23] = 24 9 4 +setting_list[24] = 24 9 13 +setting_list[25] = 24 9 13 +setting_list[26] = 24 9 13 +setting_list[27] = 24 12 1 +setting_list[28] = 24 12 2 +setting_list[29] = 24 14 11 +setting_list[30] = 24 14 19 +setting_list[31] = 24 14 20 +setting_list[32] = 24 16 6 +setting_list[33] = 24 16 29 +setting_list[34] = 24 16 31 +setting_list[35] = 24 17 21 +setting_list[36] = 24 17 24 +setting_list[37] = 24 17 26 +setting_list[38] = 24 18 13 +setting_list[39] = 24 18 15 +setting_list[40] = 24 18 16 +setting_list[41] = 24 18 19 +setting_list[42] = 24 19 6 +setting_list[43] = 24 19 7 +setting_list[44] = 24 19 8 +setting_list[45] = 24 19 10 +setting_list[46] = 24 20 0 +RX target setting = 24 9 21 +RX alternative setting = 24 9 15 +SWEEP_TX started +setting_list[0] = 24 0 18 fo=32 +setting_list[1] = 24 1 12 fo=32 +setting_list[2] = 24 8 30 fo=4 +setting_list[3] = 24 8 31 fo=-6 +setting_list[4] = 24 9 22 fo=-17 +setting_list[5] = 24 9 23 fo=-1 +setting_list[6] = 24 9 24 fo=5 +setting_list[7] = 24 9 25 fo=17 +setting_list[8] = 24 9 26 fo=32 +setting_list[9] = 24 9 27 fo=32 +setting_list[10] = 24 9 28 fo=32 +setting_list[11] = 24 9 29 fo=32 +setting_list[12] = 24 9 30 fo=32 +setting_list[13] = 24 9 31 fo=32 +setting_list[14] = 24 9 12 fo=-14 +setting_list[15] = 24 9 13 fo=-1 +setting_list[16] = 24 9 13 fo=-13 +setting_list[17] = 24 9 15 fo=5 +setting_list[18] = 24 9 16 fo=3 +setting_list[19] = 24 9 13 fo=21 +setting_list[20] = 24 9 13 fo=32 +setting_list[21] = 24 9 19 fo=32 +setting_list[22] = 24 9 20 fo=32 +setting_list[23] = 24 9 21 fo=32 +setting_list[24] = 24 9 22 fo=32 +setting_list[25] = 24 9 23 fo=32 +setting_list[26] = 24 9 24 fo=32 +setting_list[27] = 24 9 25 fo=32 +setting_list[28] = 24 9 26 fo=32 +setting_list[29] = 24 9 3 fo=-14 +setting_list[30] = 24 9 4 fo=-20 +setting_list[31] = 24 9 13 fo=-10 +setting_list[32] = 24 9 13 fo=0 +setting_list[33] = 24 9 13 fo=31 +setting_list[34] = 24 9 13 fo=32 +setting_list[35] = 24 9 13 fo=32 +setting_list[36] = 24 9 10 fo=32 +setting_list[37] = 24 9 11 fo=32 +setting_list[38] = 24 9 12 fo=32 +setting_list[39] = 24 9 13 fo=32 +setting_list[40] = 24 9 13 fo=32 +setting_list[41] = 24 9 15 fo=32 +setting_list[42] = 24 9 16 fo=32 +setting_list[43] = 24 12 0 fo=29 +setting_list[44] = 24 12 1 fo=32 +setting_list[45] = 24 12 2 fo=32 +setting_list[46] = 24 12 3 fo=32 +setting_list[47] = 24 12 4 fo=32 +setting_list[48] = 24 12 5 fo=32 +setting_list[49] = 24 12 6 fo=32 +setting_list[50] = 24 12 8 fo=32 +setting_list[51] = 24 16 28 fo=32 +setting_list[52] = 24 21 9 fo=32 +setting_list[53] = 24 21 10 fo=32 +setting_list[54] = 24 24 16 fo=27 +setting_list[55] = 24 24 17 fo=32 +setting_list[56] = 24 26 4 fo=32 +TX target setting = 24 9 16 +TX alternative setting = 24 9 10 +CONTINUOUSLY_CAL started +TX setting 24 9 13 (avg_fo=14) | RX setting 24 9 21 (avg_if=495) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=32) | RX setting 24 9 13 (avg_if=467) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=12) | RX setting 24 9 21 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=20) | RX setting 24 9 13 (avg_if=474) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 20 (avg_if=482) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 13 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 20 (avg_if=504) | 2M setting 22 16 14 (avg_count_2M=60022) | temp=41 +TX setting 24 9 13 (avg_fo=10) | RX setting 24 9 13 (avg_if=490) | 2M setting 22 16 14 (avg_count_2M=60018) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 20 (avg_if=506) | 2M setting 22 16 14 (avg_count_2M=60021) | temp=41 +TX setting 24 9 13 (avg_fo=8) | RX setting 24 9 13 (avg_if=508) | 2M setting 22 16 14 (avg_count_2M=60022) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 21 (avg_if=522) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 13 (avg_if=489) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 20 (avg_if=478) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=5) | RX setting 24 9 13 (avg_if=490) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 20 (avg_if=500) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=14) | RX setting 24 9 13 (avg_if=495) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=522) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=-7) | RX setting 24 9 13 (avg_if=496) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 21 (avg_if=492) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 13 (avg_if=502) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=-6) | RX setting 24 9 21 (avg_if=494) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-5) | RX setting 24 9 13 (avg_if=508) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 21 (avg_if=495) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 21 (avg_if=494) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 13 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=501) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 13 (avg_if=494) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 20 (avg_if=482) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 13 (avg_if=496) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 20 (avg_if=507) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 12 (avg_if=476) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 20 (avg_if=514) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 13 (avg_if=519) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 21 (avg_if=520) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=495) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=481) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 13 (avg_if=491) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=515) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=-8) | RX setting 24 9 13 (avg_if=497) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=8) | RX setting 24 9 20 (avg_if=505) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=12) | RX setting 24 9 13 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=41 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 20 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 13 (avg_fo=-7) | RX setting 24 9 13 (avg_if=486) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 20 (avg_if=510) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 13 (avg_if=491) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=515) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 13 (avg_if=497) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=-5) | RX setting 24 9 13 (avg_if=484) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 13 (avg_if=488) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 20 (avg_if=501) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 13 (avg_if=489) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=-4) | RX setting 24 9 20 (avg_if=513) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=-5) | RX setting 24 9 13 (avg_if=490) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=508) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 13 (avg_if=485) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 12 (avg_fo=2) | RX setting 24 9 20 (avg_if=512) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 12 (avg_fo=0) | RX setting 24 9 13 (avg_if=499) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 21 (avg_if=520) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 12 (avg_if=475) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 21 (avg_if=496) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 12 (avg_if=515) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 21 (avg_if=492) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=515) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 21 (avg_if=490) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 12 (avg_if=512) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 21 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=508) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=483) | 2M setting 22 16 14 (avg_count_2M=60020) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 12 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=41 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 21 (avg_if=521) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 12 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60022) | temp=41 +TX setting 24 9 13 (avg_fo=5) | RX setting 24 9 21 (avg_if=490) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 12 (avg_if=512) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=491) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=-4) | RX setting 24 9 12 (avg_if=508) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=-9) | RX setting 24 9 12 (avg_if=516) | 2M setting 22 16 14 (avg_count_2M=60020) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 20 (avg_if=483) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 13 (avg_if=521) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 20 (avg_if=513) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=13) | RX setting 24 9 13 (avg_if=497) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 20 (avg_if=510) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=5) | RX setting 24 9 13 (avg_if=496) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=5) | RX setting 24 9 20 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 12 (avg_if=479) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 20 (avg_if=512) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 12 (avg_if=515) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=41 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 21 (avg_if=528) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=41 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 12 (avg_if=503) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 12 (avg_fo=8) | RX setting 24 9 21 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=518) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 21 (avg_if=499) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 13 (avg_if=495) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=499) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 13 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=504) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=484) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=41 +TX setting 24 9 13 (avg_fo=10) | RX setting 24 9 21 (avg_if=486) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 13 (avg_if=488) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=41 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 20 (avg_if=476) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 13 (avg_if=492) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 21 (avg_if=517) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=41 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 13 (avg_if=489) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 21 (avg_if=484) | 2M setting 22 16 14 (avg_count_2M=60031) | temp=40 +TX setting 24 9 13 (avg_fo=-7) | RX setting 24 9 12 (avg_if=476) | 2M setting 22 16 14 (avg_count_2M=60032) | temp=40 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 21 (avg_if=494) | 2M setting 22 16 14 (avg_count_2M=60032) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 12 (avg_if=516) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 21 (avg_if=489) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=40 +TX setting 24 9 13 (avg_fo=5) | RX setting 24 9 12 (avg_if=502) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 21 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=-4) | RX setting 24 9 12 (avg_if=510) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=11) | RX setting 24 9 21 (avg_if=491) | 2M setting 22 16 14 (avg_count_2M=60032) | temp=40 +TX setting 24 9 13 (avg_fo=-7) | RX setting 24 9 12 (avg_if=516) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=40 +TX setting 24 9 13 (avg_fo=5) | RX setting 24 9 21 (avg_if=485) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=510) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 20 (avg_if=473) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 12 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 20 (avg_if=503) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=519) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=9) | RX setting 24 9 20 (avg_if=512) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 12 (avg_if=479) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 20 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 12 (avg_if=504) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 20 (avg_if=512) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 12 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=1) | RX setting 24 9 20 (avg_if=510) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=518) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=6) | RX setting 24 9 20 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 13 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=40 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 20 (avg_if=506) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=485) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 20 (avg_if=507) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=40 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 13 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 20 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 13 (avg_if=489) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=9) | RX setting 24 9 20 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 13 (avg_if=492) | 2M setting 22 16 14 (avg_count_2M=60022) | temp=40 +TX setting 24 9 13 (avg_fo=4) | RX setting 24 9 20 (avg_if=507) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 13 (avg_if=489) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 20 (avg_if=505) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=-4) | RX setting 24 9 13 (avg_if=500) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=8) | RX setting 24 9 20 (avg_if=513) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 13 (avg_if=486) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 20 (avg_if=507) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 13 (avg_if=487) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=-4) | RX setting 24 9 20 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=-10) | RX setting 24 9 13 (avg_if=500) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=-10) | RX setting 24 9 21 (avg_if=522) | 2M setting 22 16 14 (avg_count_2M=60022) | temp=40 +TX setting 24 9 13 (avg_fo=9) | RX setting 24 9 13 (avg_if=488) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=8) | RX setting 24 9 21 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=40 +TX setting 24 9 13 (avg_fo=14) | RX setting 24 9 13 (avg_if=485) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=40 +TX setting 24 9 13 (avg_fo=9) | RX setting 24 9 21 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 13 (avg_if=492) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=19) | RX setting 24 9 21 (avg_if=486) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=10) | RX setting 24 9 13 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=8) | RX setting 24 9 21 (avg_if=494) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=40 +TX setting 24 9 13 (avg_fo=-7) | RX setting 24 9 13 (avg_if=495) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 21 (avg_if=484) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=40 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=482) | 2M setting 22 16 14 (avg_count_2M=60030) | temp=40 +TX setting 24 9 13 (avg_fo=7) | RX setting 24 9 21 (avg_if=503) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 12 (avg_if=516) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=14) | RX setting 24 9 21 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=40 +TX setting 24 9 13 (avg_fo=-2) | RX setting 24 9 12 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=-4) | RX setting 24 9 21 (avg_if=491) | 2M setting 22 16 14 (avg_count_2M=60025) | temp=40 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=510) | 2M setting 22 16 14 (avg_count_2M=60028) | temp=40 +TX setting 24 9 13 (avg_fo=-9) | RX setting 24 9 21 (avg_if=493) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=40 +TX setting 24 9 13 (avg_fo=-6) | RX setting 24 9 12 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60024) | temp=40 +TX setting 24 9 13 (avg_fo=0) | RX setting 24 9 21 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=40 +TX setting 24 9 13 (avg_fo=2) | RX setting 24 9 12 (avg_if=502) | 2M setting 22 16 14 (avg_count_2M=60020) | temp=40 +TX setting 24 9 13 (avg_fo=9) | RX setting 24 9 21 (avg_if=498) | 2M setting 22 16 14 (avg_count_2M=60022) | temp=41 +TX setting 24 9 13 (avg_fo=-3) | RX setting 24 9 12 (avg_if=509) | 2M setting 22 16 14 (avg_count_2M=60023) | temp=41 +TX setting 24 9 13 (avg_fo=3) | RX setting 24 9 20 (avg_if=480) | 2M setting 22 16 14 (avg_count_2M=60027) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=506) | 2M setting 22 16 14 (avg_count_2M=60026) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 20 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 +TX setting 24 9 13 (avg_fo=-1) | RX setting 24 9 12 (avg_if=511) | 2M setting 22 16 14 (avg_count_2M=60029) | temp=41 diff --git a/scm_v3c/applications/continuously_cal/logs/parser.py b/scm_v3c/applications/continuously_cal/logs/parser.py index 9393e548..03ef9e56 100644 --- a/scm_v3c/applications/continuously_cal/logs/parser.py +++ b/scm_v3c/applications/continuously_cal/logs/parser.py @@ -61,7 +61,7 @@ def parser_line(line): temp = int(info[21].split('=')[-1][:-1]) - TEMP_OFFSET except: - print line.split(' ') + print(line.split(' ')) return tx_setting, avg_if, rx_setting, avg_fo, rc_2m_setting, avg_2m_counts, temp # find maxlength_setting_list @@ -146,7 +146,7 @@ def get_max_length_setting_list(setting_list): twom_1000_ppm += 1 all = float(len(result['avg_2m_counts'])) -print "if_40_ppm = {0} fo_40_ppm = {1} 2m_count_1000_ppm = {2}".format(if_40_ppm/all, fo_40_ppm/all, twom_1000_ppm/all) +print("if_40_ppm = {0} fo_40_ppm = {1} 2m_count_1000_ppm = {2}".format(if_40_ppm/all, fo_40_ppm/all, twom_1000_ppm/all)) # plot @@ -160,25 +160,25 @@ def get_max_length_setting_list(setting_list): fig, ax = plt.subplots(dpi=300) - DOTSIZE = 2 + DOTSIZE = 7 if key == 'tx_setting': - ax.plot(x_axis, raw_data, '.', color='#0000FF', label='LC OSC frequency setting (TX)') + setting_line = ax.plot(x_axis, raw_data, '.', color='#0000FF', label='LC OSC frequency setting (TX)', markersize=DOTSIZE) # ax.plot(x_axis, [maxlength_list_tx[0] for i in x_axis], 'k--', markersize=DOTSIZE) # ax.plot(x_axis, [maxlength_list_tx[-1] for i in x_axis], 'k--', markersize=DOTSIZE) yticks = [16*i + (maxlength_list_tx[0] & 0xFFE0) for i in range(9)] if key == 'rx_setting': - ax.plot(x_axis, raw_data, '.', color='#0000FF', label='LC OSC frequency setting (RX)', markersize=DOTSIZE) + setting_line = ax.plot(x_axis, raw_data, '.', color='#0000FF', label='LC OSC frequency setting (RX)', markersize=DOTSIZE) # ax.plot(x_axis, [maxlength_list_rx[0] for i in x_axis], 'k--', markersize=DOTSIZE) # ax.plot(x_axis, [maxlength_list_rx[-1] for i in x_axis], 'k--', markersize=DOTSIZE) yticks = [16*i + (maxlength_list_rx[0] & 0xFFE0) for i in range(9)] if key == 'rc_2m_setting': - ax.plot(x_axis, raw_data, '.', color='#0000FF', label='2M RC OSC frequency settings', markersize=DOTSIZE) + setting_line = ax.plot(x_axis, raw_data, '.', color='#0000FF', label='2M RC OSC frequency settings', markersize=DOTSIZE) yticks = [16*i + (raw_data[0] & 0xFFE0) for i in range(12)] ylabel = [converter_config_linear_2_text(i) for i in yticks] @@ -186,18 +186,26 @@ def get_max_length_setting_list(setting_list): ax.set_yticks(yticks) ax.set_yticklabels(ylabel) ax.set_ylabel('frequency settings (coarse.mid.fine)') - ax.legend() + # ax.legend() ax2 = ax.twinx() # instantiate a second axes that shares the same x-axis - ax2.plot(x_axis, result['temp'], 'r-',label='temperature ($^\circ$C)') + temp_line = ax2.plot(x_axis, result['temp'], 'r-',label='temperature ($^\circ$C)') ax2.set_ylim(25, 45) ax2.set_ylabel('temperature ($^\circ$C)') - ax2.legend() - - ax.set_xlim(-2.5,50) + # ax2.legend() + if 'failed' in LOG_FILE: + ax.set_xlim(-0.1,3) + else: + ax.set_xlim(-2.5,50) ax.set_xlabel('time (minutes)') - - ax.legend(markerscale=0.7, scatterpoints=1, loc=2) + + lines = setting_line+temp_line + labels = [l.get_label() for l in lines] + + lgnd = ax.legend(lines, labels, markerscale=0.7, scatterpoints=1, loc=0) + + lgnd.legendHandles[0]._legmarker.set_markersize(7) + ax.grid(True) fig.set_size_inches(8, 4) diff --git a/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.c b/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.c index 16d95dcb..15ef1572 100644 --- a/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.c +++ b/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.c @@ -114,7 +114,7 @@ int main(void) { optical_enable(); // Wait for optical cal to finish - while(optical_getCalibrationFinshed() == 0); + while(optical_getCalibrationFinished() == 0); printf("Cal complete\r\n"); diff --git a/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvoptx b/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvoptx index b2201a3f..cd20c714 100644 --- a/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvoptx +++ b/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvoptx @@ -401,6 +401,30 @@ 0 0 + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + diff --git a/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvprojx b/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvprojx index 2b6769a0..28857cd1 100644 --- a/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvprojx +++ b/scm_v3c/applications/freq_sweep_lc_count/freq_sweep_lc_count.uvprojx @@ -477,6 +477,16 @@ 1 ..\..\scm3c_hw_interface.c + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + diff --git a/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.c b/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.c index cd766239..bd05cc64 100644 --- a/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.c +++ b/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.c @@ -121,7 +121,7 @@ int main(void) { optical_enable(); // Wait for optical cal to finish - while(optical_getCalibrationFinshed() == 0); + while(optical_getCalibrationFinished() == 0); printf("Cal complete\r\n"); diff --git a/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvoptx b/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvoptx index 01b371ee..d5cda82e 100644 --- a/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvoptx +++ b/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvoptx @@ -401,6 +401,30 @@ 0 0 + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + diff --git a/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvprojx b/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvprojx index f6cbff17..10891e6c 100644 --- a/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvprojx +++ b/scm_v3c/applications/freq_sweep_rx/freq_sweep_rx.uvprojx @@ -477,6 +477,16 @@ 1 ..\..\scm3c_hw_interface.c + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + diff --git a/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.c b/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.c index 56d13358..33d7d328 100644 --- a/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.c +++ b/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.c @@ -108,7 +108,7 @@ int main(void) { optical_enable(); // Wait for optical cal to finish - while(optical_getCalibrationFinshed() == 0); + while(optical_getCalibrationFinished() == 0); printf("Cal complete\r\n"); diff --git a/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvoptx b/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvoptx index 9abf18f9..8c169944 100644 --- a/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvoptx +++ b/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvoptx @@ -401,6 +401,30 @@ 0 0 + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + diff --git a/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvprojx b/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvprojx index cfb9fc39..49b37d10 100644 --- a/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvprojx +++ b/scm_v3c/applications/freq_sweep_tx/freq_sweep_tx.uvprojx @@ -477,6 +477,16 @@ 1 ..\..\scm3c_hw_interface.c + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + diff --git a/scm_v3c/applications/pingpong_test/pingpong_test.c b/scm_v3c/applications/pingpong_test/pingpong_test.c index 610acb1a..21798a8c 100644 --- a/scm_v3c/applications/pingpong_test/pingpong_test.c +++ b/scm_v3c/applications/pingpong_test/pingpong_test.c @@ -117,7 +117,7 @@ int main(void) { optical_enable(); // Wait for optical cal to finish - while(optical_getCalibrationFinshed() == 0); + while(optical_getCalibrationFinished() == 0); printf("Cal complete\r\n"); diff --git a/scm_v3c/applications/pingpong_test/pingpong_test.uvoptx b/scm_v3c/applications/pingpong_test/pingpong_test.uvoptx index c748119e..36530970 100644 --- a/scm_v3c/applications/pingpong_test/pingpong_test.uvoptx +++ b/scm_v3c/applications/pingpong_test/pingpong_test.uvoptx @@ -401,6 +401,30 @@ 0 0 + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + diff --git a/scm_v3c/applications/pingpong_test/pingpong_test.uvprojx b/scm_v3c/applications/pingpong_test/pingpong_test.uvprojx index a04a900c..f130b9b2 100644 --- a/scm_v3c/applications/pingpong_test/pingpong_test.uvprojx +++ b/scm_v3c/applications/pingpong_test/pingpong_test.uvprojx @@ -477,6 +477,16 @@ 1 ..\..\scm3c_hw_interface.c + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + diff --git a/scm_v3c/applications/quick_cal/quick_cal.c b/scm_v3c/applications/quick_cal/quick_cal.c index 089bc22b..84ebc2c9 100644 --- a/scm_v3c/applications/quick_cal/quick_cal.c +++ b/scm_v3c/applications/quick_cal/quick_cal.c @@ -219,7 +219,7 @@ int main(void) { optical_enable(); // Wait for optical cal to finish - while(optical_getCalibrationFinshed() == 0); + while(optical_getCalibrationFinished() == 0); printf("Cal complete\r\n"); diff --git a/scm_v3c/applications/quick_cal/quick_cal.uvoptx b/scm_v3c/applications/quick_cal/quick_cal.uvoptx index aa0f8b80..62b697e1 100644 --- a/scm_v3c/applications/quick_cal/quick_cal.uvoptx +++ b/scm_v3c/applications/quick_cal/quick_cal.uvoptx @@ -401,6 +401,30 @@ 0 0 + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\ble.c + ble.c + 0 + 0 + + + 2 + 21 + 5 + 0 + 0 + 0 + ..\..\ble.h + ble.h + 0 + 0 + diff --git a/scm_v3c/applications/quick_cal/quick_cal.uvprojx b/scm_v3c/applications/quick_cal/quick_cal.uvprojx index 578bd129..ea2a88c0 100644 --- a/scm_v3c/applications/quick_cal/quick_cal.uvprojx +++ b/scm_v3c/applications/quick_cal/quick_cal.uvprojx @@ -477,6 +477,16 @@ 1 ..\..\scm3c_hw_interface.c + + ble.c + 1 + ..\..\ble.c + + + ble.h + 5 + ..\..\ble.h + diff --git a/scm_v3c/ble.c b/scm_v3c/ble.c new file mode 100644 index 00000000..309e8000 --- /dev/null +++ b/scm_v3c/ble.c @@ -0,0 +1,517 @@ +#include +#include +#include +#include + +#include "memory_map.h" +#include "scm3c_hw_interface.h" +#include "ble.h" +#include "radio.h" + +//=========================== definition ====================================== + +#define BLE_PKT_LEN 64 // 1 byte preamble + 4 byte address + pkt_len + 3 bytes crc + x bytes (for CTE) +#define MAX_CTE_LEN 20 // in number of 8us + +//=========================== variables ======================================= + +typedef struct { + uint8_t pkt_len; + uint8_t packet[BLE_PKT_LEN]; + uint8_t AdvA[ADVA_LENGTH]; + uint8_t channel; + uint8_t datawhitening_init; + + // BLE packet contents enable. + // The total data length cannot exceed 31 bytes. + bool name_tx_en; + bool lc_freq_codes_tx_en; + bool counters_tx_en; + bool temp_tx_en; + bool data_tx_en; + + // BLE packet data. + char name[NAME_LENGTH]; + uint16_t lc_freq_codes; + uint32_t count_2M; + uint32_t count_32k; + double temp; + uint8_t data[CUSTOM_DATA_LENGTH]; +} ble_vars_t; + +ble_vars_t ble_vars; + +//=========================== prototypes ====================================== + +//=========================== public ========================================== + +void ble_init(void) { + // Clear variables. + memset(&ble_vars, 0, sizeof(ble_vars)); + + // Set default advertiser address. + ble_vars.AdvA[0] = 0x00; + ble_vars.AdvA[1] = 0x02; + ble_vars.AdvA[2] = 0x72; + ble_vars.AdvA[3] = 0x32; + ble_vars.AdvA[4] = 0x80; + ble_vars.AdvA[5] = 0xC6; + + // Set default channel. + ble_vars.channel = 37; + + // Set default name. + ble_vars.name_tx_en = true; + ble_vars.name[0] = 'S'; + ble_vars.name[1] = 'C'; + ble_vars.name[2] = 'U'; + ble_vars.name[3] = 'M'; + ble_vars.name[4] = '3'; +} + +void ble_gen_packet(void) { + uint8_t i = 0, j = 0; + + int k; + uint8_t m; + + uint8_t common; + uint8_t crc3 = 0xAA; + uint8_t crc2 = 0xAA; + uint8_t crc1 = 0xAA; + + uint8_t pdu_crc[PDU_LENGTH + CRC_LENGTH]; + + uint8_t lfsr = ble_vars.datawhitening_init; + + memset(ble_vars.packet, 0, BLE_PKT_LEN * sizeof(uint8_t)); + memset(pdu_crc, 0, (PDU_LENGTH + CRC_LENGTH) * sizeof(uint8_t)); + + ble_vars.packet[i++] = BPREAMBLE; + + ble_vars.packet[i++] = BACCESS_ADDRESS1; + ble_vars.packet[i++] = BACCESS_ADDRESS2; + ble_vars.packet[i++] = BACCESS_ADDRESS3; + ble_vars.packet[i++] = BACCESS_ADDRESS4; + + pdu_crc[j++] = PDU_HEADER1; + pdu_crc[j++] = PDU_HEADER2; + + for (k = ADVA_LENGTH - 1; k >= 0; --k) { + pdu_crc[j++] = flipChar(ble_vars.AdvA[k]); + } + + if (ble_vars.name_tx_en) { + pdu_crc[j++] = NAME_HEADER; + pdu_crc[j++] = NAME_GAP_CODE; + + for (k = 0; k < NAME_LENGTH; ++k) { + pdu_crc[j++] = flipChar(ble_vars.name[k]); + } + } + + if (ble_vars.lc_freq_codes_tx_en) { + pdu_crc[j++] = LC_FREQCODES_HEADER; + pdu_crc[j++] = LC_FREQCODES_GAP_CODE; + + pdu_crc[j++] = flipChar((ble_vars.lc_freq_codes >> 8) & 0xFF); // LC freq codes MSB + pdu_crc[j++] = flipChar(ble_vars.lc_freq_codes & 0xFF); // LC freq codes LSB + } + + if (ble_vars.counters_tx_en) { + pdu_crc[j++] = COUNTERS_HEADER; + pdu_crc[j++] = COUNTERS_GAP_CODE; + + pdu_crc[j++] = flipChar((ble_vars.count_2M >> 24) & 0xFF); // count_2M MSB + pdu_crc[j++] = flipChar((ble_vars.count_2M >> 16) & 0xFF); + pdu_crc[j++] = flipChar((ble_vars.count_2M >> 8) & 0xFF); + pdu_crc[j++] = flipChar(ble_vars.count_2M & 0xFF); // count_2M LSB + + pdu_crc[j++] = flipChar((ble_vars.count_32k >> 24) & 0xFF); // count_32k MSB + pdu_crc[j++] = flipChar((ble_vars.count_32k >> 16) & 0xFF); + pdu_crc[j++] = flipChar((ble_vars.count_32k >> 8) & 0xFF); + pdu_crc[j++] = flipChar(ble_vars.count_32k & 0xFF); // count_32k LSB + } + + if (ble_vars.temp_tx_en) { + double temp_kelvin = ble_vars.temp + 273.15; // Temperature in Kelvin + int temp_payload = 100 * temp_kelvin + 1; // Floating point error + + pdu_crc[j++] = TEMP_HEADER; + pdu_crc[j++] = TEMP_GAP_CODE; + + pdu_crc[j++] = flipChar((temp_payload >> 8) & 0xFF); // Temperature MSB + pdu_crc[j++] = flipChar(temp_payload & 0xFF); // Temperature LSB + } + + if (ble_vars.data_tx_en) { + pdu_crc[j++] = CUSTOM_DATA_HEADER; + pdu_crc[j++] = CUSTOM_DATA_GAP_CODE; + + for (k = 0; k < CUSTOM_DATA_LENGTH; ++k) { + pdu_crc[j++] = flipChar(ble_vars.data[k]); + } + } + + ble_append_crc(&pdu_crc[0] ,PDU_LENGTH); + ble_whitening(&pdu_crc[0], PDU_LENGTH + CRC_LENGTH); + + memcpy(&ble_vars.packet[i], pdu_crc, PDU_LENGTH + CRC_LENGTH); +} + +void ble_prepare_packt(uint8_t* pdu, uint8_t pdu_length){ + + uint16_t i; + uint16_t j; + + memset(ble_vars.packet, 0, BLE_PKT_LEN * sizeof(uint8_t)); + + i = 0; + ble_vars.packet[i++] = BPREAMBLE; + + ble_vars.packet[i++] = BACCESS_ADDRESS1; + ble_vars.packet[i++] = BACCESS_ADDRESS2; + ble_vars.packet[i++] = BACCESS_ADDRESS3; + ble_vars.packet[i++] = BACCESS_ADDRESS4; + + ble_append_crc(&pdu[0], pdu_length); + + printf("pkt : "); + for (j=0;j = ASC<996:999> + // The two LSBs change the mux from cortex mod (00) source to pad (11). + // They can also be used to set the modulation to 0 (10) or 1 (01). + // The other bits are used for inverting the modulation bitstream and can be cleared. + // The goal is to remove the 15.4 DAC from the modulation path. + /* + clear_asc_bit(996); + set_asc_bit(997); + clear_asc_bit(998); + clear_asc_bit(999); + */ + set_asc_bit(996); + clear_asc_bit(997); + clear_asc_bit(998); + clear_asc_bit(999); + + clear_asc_bit(1000); + clear_asc_bit(1001); + clear_asc_bit(1002); + clear_asc_bit(1003); + + // Make sure the BLE modulation mux is set. + // Bit 1013 sets the BLE mod dac to cortex control. + // The BLE tone spacing cannot be set, it is a fixed DAC. + set_asc_bit(1013); + // ---- + + // Set the bypass scan bits of the BLE FIFO and GFSK modules. + set_asc_bit(1041); + set_asc_bit(1042); + + // Ensure cortex control of LO. + clear_asc_bit(964); + + // Ensure cortex control of divider. + clear_asc_bit(1081); + + // Need to set analog_cfg<183> to 0 to select BLE for chips out. + ANALOG_CFG_REG__11 = 0x0000; + + // Set current in LC tank. + set_LC_current(127); + + // Set LDO voltages for PA and LO. + set_PA_supply(127); + set_LO_supply(63,0); + + // Program analog scan chain. + analog_scan_chain_write(); + analog_scan_chain_load(); +} + +// Must set IF clock frequency AFTER calling this function. +void ble_init_rx(void) { + radio_init_rx_ZCC(); + + // Set clock mux to internal RC oscillator. + clear_asc_bit(424); + set_asc_bit(425); + + // Need to turn on ADC clock generation to get /4 output for clock calibration. + set_asc_bit(422); + + // Set gain for I and Q. + set_IF_gain_ASC(63,63); + + // Set gm for stg3 ADC drivers. + set_IF_stg3gm_ASC(7, 7); //(I, Q) + + // Set comparator trims. + //set_IF_comparator_trim_I(0, 7); //(p,n) + //set_IF_comparator_trim_Q(15, 0); //(p,n) + + // Set clock divider value for zcc. + // The IF clock divided by this value must equal 1 MHz for BLE 1M PHY. + set_IF_ZCC_clkdiv(76); + + // Disable feedback. + clear_asc_bit(123); + + // Mixer and polyphase control settings can be driven from either ASC or memory mapped I/O. + // Mixers and polyphase should both be enabled for RX and both disabled for TX. + // -- + // For polyphase (1=enabled), + // mux select signal ASC<746>=0 gives control to ASC<971>. + // mux select signal ASC<746>=1 gives control to analog_cfg<256> (bit 0 of ANALOG_CFG_REG__16). + // -- + // For mixers (0=enabled), both I and Q should be enabled for matched filter mode. + // mux select signals ASC<744>=0 and ASC<745>=0 give control to ASC<298> and ASC<307>. + // mux select signals ASC<744>=1 and ASC<745>=1 give control to analog_cfg<257> analog_cfg<258> (bits 1 and 2 in ANALOG_CFG_REG__16). + + // Set mixer and polyphase control signals to memory mapped I/O. + set_asc_bit(744); + set_asc_bit(745); + set_asc_bit(746); + + // Enable both polyphase and mixers via memory mapped IO (...001 = 0x1). + // To disable both you would invert these values (...110 = 0x6). + ANALOG_CFG_REG__16 = 0x1; + + // Program analog scan chain. + analog_scan_chain_write(); + analog_scan_chain_load(); +} + +void ble_transmit(void) { + + int t; + + ble_load_tx_arb_fifo(); + + // Turn on LO, PA, and DIV. + radio_txEnable(); + + // Wait for LDOs to turn on. + for (t = 0; t < 500; ++t); + + // Send the packet. + ble_txNow_tx_arb_fifo(); + + // Wait for transmission to finish. + // Don't know if there is some way to know when this has finished or just busy wait (?). + // This was determined empirically using trial and error. + for (t = 0; t < 10000; ++t); + + radio_rfOff(); +} + +void ble_append_crc(uint8_t* pdu_crc, uint16_t pdu_lenght){ + + uint16_t j; + int8_t k; + uint8_t common; + uint8_t crc3 = 0xAA; + uint8_t crc2 = 0xAA; + uint8_t crc1 = 0xAA; + + for (j = 0; j < pdu_lenght; ++j) { + for (k = 7; k >= 0; --k) { + common = (crc1 & 1) ^ ((pdu_crc[j] & (1 << k)) >> k); + crc1 = (crc1 >> 1) | ((crc2 & 1) << 7); + crc2 = ((crc2 >> 1) | ((crc3 & 1) << 7)) ^ (common << 6) ^ (common << 5); + crc3 = ((crc3 >> 1) | (common << 7)) ^ (common << 6) ^ (common << 4) ^ (common << 3) ^ (common << 1); + } + } + + crc1 = flipChar(crc1); + crc2 = flipChar(crc2); + crc3 = flipChar(crc3); + + pdu_crc[j++] = crc1; + pdu_crc[j++] = crc2; + pdu_crc[j++] = crc3; +} + +void ble_whitening(uint8_t* pkt, uint16_t lenght){ + + uint8_t i; + int8_t j; + + uint8_t lfsr; + + lfsr = ble_vars.datawhitening_init; + + for (i = 0; i < lenght; ++i) { + for (j = 7; j >= 0; --j) { + pkt[i] = + (pkt[i] & ~(1 << j)) | + ( + (pkt[i] & (1 << j)) ^ ((lfsr & 1) << j) + ); + lfsr = ((lfsr >> 1) | ((lfsr & 1) << 6)) ^ ((lfsr & 1) << 2); + } + } +} + +//=========================== private ========================================= + +void ble_load_tx_arb_fifo(void) { + // Initialize variables. + int i; // used to loop through the bytes + int j; // used to loop through the 8 bits of each individual byte + + uint8_t current_byte; // temporary variable used to get through each byte at a time + uint8_t current_bit; // temporary variable to put the current bit into the GPIO + uint32_t fifo_ctrl_reg = 0x00000000; // local storage for analog CFG register + + // Prepare FIFO for loading. + fifo_ctrl_reg |= 0x00000001; // raise LSB - data in valid + fifo_ctrl_reg &= 0xFFFFFFFB; // lower 3rd bit - data out ready + fifo_ctrl_reg &= 0xFFFFFFDF; // lower clock select bit to clock in from Cortex + + ANALOG_CFG_REG__11 = fifo_ctrl_reg; // load in the configuration settings + + // Load packet into FIFO. + for (i = 0; i < BLE_PKT_LEN; ++i) { + current_byte = ble_vars.packet[i]; // put a byte into the temporary storage + + for (j = 7; j >= 0; --j) { + // current_bit = ((current_byte << (j - 1)) & 0x80) >> 7; + current_bit = (current_byte >> j) & 0x1; + + if (current_bit == 0) { + fifo_ctrl_reg &= 0xFFFFFFFD; + ANALOG_CFG_REG__11 = fifo_ctrl_reg; + } + if (current_bit == 1) { + fifo_ctrl_reg |= 0x00000002; + ANALOG_CFG_REG__11 = fifo_ctrl_reg; + } + + fifo_ctrl_reg |= 0x00000008; + ANALOG_CFG_REG__11 = fifo_ctrl_reg; + fifo_ctrl_reg &= 0xFFFFFFF7; + ANALOG_CFG_REG__11 = fifo_ctrl_reg; // toggle the clock! + } + } +} + +void ble_txNow_tx_arb_fifo(void) { + uint32_t fifo_ctrl_reg = 0x00000000; // local storage for analog CFG register + + // Release data from FIFO + fifo_ctrl_reg |= 0x00000010; // enable div-by-2 + fifo_ctrl_reg &= 0xFFFFFFFE; // lower data in valid (set FIFO to output mode) + fifo_ctrl_reg |= 0x00000004; // raise data out ready (set FIFO to output mode) + fifo_ctrl_reg |= 0x00000020; // set choose clk to 1 + + ANALOG_CFG_REG__11 = fifo_ctrl_reg; +} diff --git a/scm_v3c/ble.h b/scm_v3c/ble.h new file mode 100644 index 00000000..c63a2965 --- /dev/null +++ b/scm_v3c/ble.h @@ -0,0 +1,84 @@ +#ifndef __BLE_H +#define __BLE_H + +#include +#include + +//=========================== define ========================================== + +// BLE packet assembly globals. +#define BPREAMBLE 0x55 +// Split BACCESS_ADDRESS into bytes to avoid big-/little-endianness issue. +#define BACCESS_ADDRESS1 0x6B +#define BACCESS_ADDRESS2 0x7D +#define BACCESS_ADDRESS3 0x91 +#define BACCESS_ADDRESS4 0x71 + +#define PDU_HEADER1 0x40 +#define PDU_HEADER2 0xA4 // PDU is 37 bytes long (6 bytes advertiser address + 31 bytes data). + +// Short name. +#define NAME_LENGTH 5 +#define NAME_HEADER 0x60 // Name is 6 bytes long (1 byte GAP code + 5 bytes data). +#define NAME_GAP_CODE 0x10 + +// LC frequency codes (coarse+mid+fine). +#define LC_FREQCODES_LENGTH 2 +#define LC_FREQCODES_HEADER 0xC0 // LC freq codes are 3 bytes long (1 byte GAP code + 2 bytes data/15 bits). +#define LC_FREQCODES_GAP_CODE 0x03 // Custom GAP code for LC freq codes (0xC0 LSB first). + +// Counters (2M and 32kHz). +#define COUNTERS_LENGTH 8 +#define COUNTERS_HEADER 0x90 // Counters are 9 bytes long (1 byte GAP code + 4 bytes 2M counter + 4 bytes 32k counter). +#define COUNTERS_GAP_CODE 0x43 // Custom GAP code for counters (0xC2 LSB first). + +// Temperature. +#define TEMP_LENGTH 2 +#define TEMP_HEADER 0xC0 // Temperature is 3 bytes long (1 byte GAP code + 2 bytes data). +#define TEMP_GAP_CODE 0x83 // Custom GAP code for temperature (0xC1 LSB first). + +// Custom data. +#define CUSTOM_DATA_LENGTH 4 +#define CUSTOM_DATA_HEADER 0xA0 // Custom data is 5 bytes long (1 byte GAP code + 4 bytes data). +#define CUSTOM_DATA_GAP_CODE 0xC3 // Custom GAP code for custom data (0xC3 LSB first). + +#define ADVA_LENGTH 6 // Advertiser address is 6 bytes long. +#define PDU_LENGTH 0x23 // 2 byte PDU header + 37 bytes PDU. +#define CRC_LENGTH 3 // CRC is 3 bytes long. + +#define MAX_DATA_LENGTH 31 // Maximum data length is 31 bytes. + +//=========================== typedef ========================================= + +//=========================== variables ======================================= + +//=========================== prototypes ====================================== + +void ble_init(void); +void ble_init_tx(void); +void ble_init_rx(void); +void ble_transmit(void); +void ble_append_crc(uint8_t* pdu_crc, uint16_t pdu_lenght); +void ble_whitening(uint8_t* pkt, uint16_t lenght); +void ble_prepare_packt(uint8_t* pdu, uint8_t pdu_length); + +void ble_load_tx_arb_fifo(void); +void ble_txNow_tx_arb_fifo(void); + +void ble_gen_packet(void); +void ble_gen_test_packet(void); +void ble_set_AdvA(uint8_t *AdvA); +void ble_set_channel(uint8_t channel); +void ble_set_name_tx_en(bool name_tx_en); +void ble_set_name(char *name); +void ble_set_lc_freq_codes_tx_en(bool lc_freq_codes_tx_en); +void ble_set_lc_freq_codes(uint16_t lc_freq_codes); +void ble_set_counters_tx_en(bool counters_tx_en); +void ble_set_count_2M(uint32_t count_2M); +void ble_set_count_32k(uint32_t count_32k); +void ble_set_temp_tx_en(bool temp_tx_en); +void ble_set_temp(double temp); +void ble_set_data_tx_en(bool data_tx_en); +void ble_set_data(uint8_t *data); + +#endif diff --git a/scm_v3c/optical.c b/scm_v3c/optical.c index 99760896..77e5b9e1 100644 --- a/scm_v3c/optical.c +++ b/scm_v3c/optical.c @@ -9,12 +9,26 @@ //=========================== defines ========================================= +#define LC_CAL_COARSE_MIN 24 +#define LC_CAL_COARSE_MAX 25 +#define LC_CAL_MID_MIN 0 +#define LC_CAL_MID_MAX 31 +#define LC_CAL_FINE_MIN 15 +#define LC_CAL_FINE_MAX 15 + //=========================== variables ======================================= typedef struct { uint8_t optical_cal_iteration; - uint8_t optical_cal_finished; - + bool optical_cal_finished; + + bool optical_LC_cal_enable; + bool optical_LC_cal_finished; + uint8_t cal_LC_coarse; + uint8_t cal_LC_mid; + uint8_t cal_LC_fine; + uint32_t cal_LC_diff; + uint32_t num_32k_ticks_in_100ms; uint32_t num_2MRC_ticks_in_100ms; uint32_t num_IFclk_ticks_in_100ms; @@ -23,7 +37,9 @@ typedef struct { // reference to calibrate uint32_t LC_target; - uint32_t LC_code; + uint8_t LC_coarse; + uint8_t LC_mid; + uint8_t LC_fine; } optical_vars_t; optical_vars_t optical_vars; @@ -35,18 +51,52 @@ optical_vars_t optical_vars; void optical_init(void) { memset(&optical_vars, 0, sizeof(optical_vars_t)); - - // Target radio LO freq = 2.4025G + // Divide ratio is currently 480*2 // Calibration counts for 100ms - optical_vars.LC_target = REFERENCE_LC_TARGET; - optical_vars.LC_code = DEFUALT_INIT_LC_CODE; + optical_vars.LC_target = REFERENCE_LC_TARGET; + optical_vars.LC_coarse = DEFAULT_INIT_LC_COARSE; + optical_vars.LC_mid = DEFAULT_INIT_LC_MID; + optical_vars.LC_fine = DEFAULT_INIT_LC_FINE; +} + +void optical_enableLCCalibration(void) { + + optical_vars.optical_LC_cal_enable = true; + optical_vars.optical_LC_cal_finished = false; + + optical_vars.cal_LC_coarse = LC_CAL_COARSE_MIN; + optical_vars.cal_LC_mid = LC_CAL_MID_MIN; + optical_vars.cal_LC_fine = LC_CAL_FINE_MIN; + optical_vars.cal_LC_diff = 0xFFFFFFFF; + + LC_FREQCHANGE( + optical_vars.cal_LC_coarse, + optical_vars.cal_LC_mid, + optical_vars.cal_LC_fine + ); } -uint8_t optical_getCalibrationFinshed(void) { +bool optical_getCalibrationFinished(void) { return optical_vars.optical_cal_finished; } +void optical_setLCTarget(uint32_t LC_target) { + optical_vars.LC_target = LC_target; +} + +uint8_t optical_getLCCoarse(void) { + return optical_vars.LC_coarse & 0x1F; +} + +uint8_t optical_getLCMid(void) { + return optical_vars.LC_mid & 0x1F; +} + +uint8_t optical_getLCFine(void) { + return optical_vars.LC_fine & 0x1F; +} + void optical_enable(void){ ISER = 0x1800; // 1 is for enabling GPIO8 ext interrupt (3WB cal) and 8 is for enabling optical interrupt } @@ -146,13 +196,13 @@ void optical_sfd_isr(){ rdata_lsb = *(unsigned int*)(APB_ANALOG_CFG_BASE + 0x300000); rdata_msb = *(unsigned int*)(APB_ANALOG_CFG_BASE + 0x340000); count_IF = rdata_lsb + (rdata_msb << 16); - + // Reset all counters ANALOG_CFG_REG__0 = 0x0000; - + // Enable all counters ANALOG_CFG_REG__0 = 0x3FFF; - + // Don't make updates on the first two executions of this ISR if(optical_vars.optical_cal_iteration > 2){ @@ -178,20 +228,51 @@ void optical_sfd_isr(){ HF_CLOCK_fine++; } } - + set_sys_clk_secondary_freq(HF_CLOCK_coarse, HF_CLOCK_fine); scm3c_hw_interface_set_HF_CLOCK_coarse(HF_CLOCK_coarse); scm3c_hw_interface_set_HF_CLOCK_fine(HF_CLOCK_fine); - + // Do correction on LC - if(count_LC > (optical_vars.LC_target + 0)) { - optical_vars.LC_code -= 1; - } - if(count_LC < (optical_vars.LC_target - 0)) { - optical_vars.LC_code += 1; + if ( + optical_vars.optical_LC_cal_enable && + !optical_vars.optical_LC_cal_finished + ) { + if ((count_LC <= optical_vars.LC_target) && (optical_vars.LC_target - count_LC < optical_vars.cal_LC_diff)) { + optical_vars.cal_LC_diff = optical_vars.LC_target - count_LC; + optical_vars.LC_coarse = optical_vars.cal_LC_coarse; + optical_vars.LC_mid = optical_vars.cal_LC_mid; + optical_vars.LC_fine = optical_vars.cal_LC_fine; + } else if ((count_LC > optical_vars.LC_target) && (count_LC - optical_vars.LC_target < optical_vars.cal_LC_diff)) { + optical_vars.cal_LC_diff = count_LC - optical_vars.LC_target; + optical_vars.LC_coarse = optical_vars.cal_LC_coarse; + optical_vars.LC_mid = optical_vars.cal_LC_mid; + optical_vars.LC_fine = optical_vars.cal_LC_fine; + } + + printf("count_LC: %u, LC_target: %u, LC_diff: %u\r\n", count_LC, optical_vars.LC_target, optical_vars.cal_LC_diff); + + ++optical_vars.cal_LC_fine; + if (optical_vars.cal_LC_fine > LC_CAL_FINE_MAX) { + optical_vars.cal_LC_fine = LC_CAL_FINE_MIN; + ++optical_vars.cal_LC_mid; + if (optical_vars.cal_LC_mid > LC_CAL_MID_MAX) { + optical_vars.cal_LC_mid = LC_CAL_MID_MIN; + ++optical_vars.cal_LC_coarse; + if (optical_vars.cal_LC_coarse > LC_CAL_COARSE_MAX) { + optical_vars.optical_LC_cal_finished = true; + printf("coarse: %u, mid: %u, fine: %u\n", optical_vars.LC_coarse, optical_vars.LC_mid, optical_vars.LC_fine); + } + } + } + + if (!optical_vars.optical_LC_cal_finished) { + LC_FREQCHANGE(optical_vars.cal_LC_coarse, optical_vars.cal_LC_mid, optical_vars.cal_LC_fine); + } else { + LC_FREQCHANGE(optical_vars.LC_coarse, optical_vars.LC_mid, optical_vars.LC_fine); + } } - LC_monotonic(optical_vars.LC_code); - + // Do correction on 2M RC // Coarse step ~1100 counts, fine ~150 counts, superfine ~25 // Too fast @@ -239,17 +320,17 @@ void optical_sfd_isr(){ scm3c_hw_interface_set_IF_fine(IF_fine); analog_scan_chain_write(); - analog_scan_chain_load(); + analog_scan_chain_load(); } // Debugging output - printf("HF=%d-%d 2M=%d-%d,%d,%d LC=%d-%d IF=%d-%d\r\n",count_HFclock,HF_CLOCK_fine,count_2M,RC2M_coarse,RC2M_fine,RC2M_superfine,count_LC,optical_vars.LC_code,count_IF,IF_fine); + printf("HF=%d-%d 2M=%d-%d,%d,%d LC=%d IF=%d-%d\r\n",count_HFclock,HF_CLOCK_fine,count_2M,RC2M_coarse,RC2M_fine,RC2M_superfine,count_LC,count_IF,IF_fine); - if(optical_vars.optical_cal_iteration == 25){ + if(optical_vars.optical_cal_iteration >= 25 && (!optical_vars.optical_LC_cal_enable || optical_vars.optical_LC_cal_finished)){ // Disable this ISR ICER = 0x1800; optical_vars.optical_cal_iteration = 0; - optical_vars.optical_cal_finished = 1; + optical_vars.optical_cal_finished = true; // Store the last count values optical_vars.num_32k_ticks_in_100ms = count_32k; @@ -275,4 +356,4 @@ void optical_sfd_isr(){ // Halt all counters ANALOG_CFG_REG__0 = 0x0000; } -} \ No newline at end of file +} diff --git a/scm_v3c/optical.h b/scm_v3c/optical.h index 46867bef..09b20620 100644 --- a/scm_v3c/optical.h +++ b/scm_v3c/optical.h @@ -1,6 +1,7 @@ #ifndef __OPTICAL_H #define __OPTICAL_H +#include #include //=========================== define ========================================== @@ -13,7 +14,12 @@ //==== admin void optical_init(void); -uint8_t optical_getCalibrationFinshed(void); +void optical_enableLCCalibration(void); +bool optical_getCalibrationFinished(void); +void optical_setLCTarget(uint32_t LC_target); +uint8_t optical_getLCCoarse(void); +uint8_t optical_getLCMid(void); +uint8_t optical_getLCFine(void); void optical_enable(void); void perform_calibration(void); void optical_sfd_isr(); diff --git a/scm_v3c/radio.c b/scm_v3c/radio.c index 24a9b987..d21207ad 100644 --- a/scm_v3c/radio.c +++ b/scm_v3c/radio.c @@ -401,19 +401,16 @@ void radio_loadPacket(uint8_t* packet, uint16_t len){ // Turn on the radio for transmit // This should be done at least ~50 us before txNow() -void radio_txEnable(){ - +void radio_txEnable(){ // Turn on LO, PA, and AUX LDOs - #ifdef DIV_ON - - // Turn on DIV if need read LC_count + // Turn on DIV to read LC_count ANALOG_CFG_REG__10 = 0x0068; #else // Turn on LO, PA, and AUX LDOs ANALOG_CFG_REG__10 = 0x0028; #endif - + // Turn off polyphase and disable mixer ANALOG_CFG_REG__16 = 0x6; } @@ -431,7 +428,7 @@ void radio_rxEnable(){ // Turn on LO, IF, and AUX LDOs via memory mapped register - // Turn on DIV on if need to read LC_div counter + // Turn on DIV to read LC_div counter // Aux is inverted (0 = on) // Memory-mapped LDO control diff --git a/scm_v3c/rftimer.c b/scm_v3c/rftimer.c index 34135689..1a8fb3f7 100644 --- a/scm_v3c/rftimer.c +++ b/scm_v3c/rftimer.c @@ -8,7 +8,7 @@ // ========================== definition ====================================== -#define MINIMUM_COMPAREVALE_ADVANCE 5 +#define MINIMUM_COMPAREVALUE_ADVANCE 5 #define LARGEST_INTERVAL 0xffff #define NUM_INTERRUPTS 8 diff --git a/scm_v3c/scm3c_hw_interface.c b/scm_v3c/scm3c_hw_interface.c index 2435b841..faa151da 100644 --- a/scm_v3c/scm3c_hw_interface.c +++ b/scm_v3c/scm3c_hw_interface.c @@ -3,6 +3,7 @@ #include "memory_map.h" #include "scm3c_hw_interface.h" +#include "ble.h" #include "radio.h" #include "optical.h" #include "rftimer.h" @@ -23,11 +24,11 @@ #define INIT_IF_COARSE 22 #define INIT_IF_FINE 18 -// CRC +//=========================== variable ======================================== #define CRC_VALUE (*((unsigned int *) 0x0000FFFC)) #define CODE_LENGTH (*((unsigned int *) 0x0000FFF8)) -//=========================== variable ======================================== +// default setting // default setting static const uint32_t default_dac_2m_setting[] = {31,31,29,2,2}; @@ -751,7 +752,7 @@ void radio_init_rx_MF(){ scm3c_hw_interface_vars.ASC[15] |= (0xFFE02E03 & ~mask2); //480-511 // Set clock mux to internal RC oscillator - clear_asc_bit(424); + clear_asc_bit(424); set_asc_bit(425); // Set gain for I and Q (63 is the max) @@ -866,7 +867,7 @@ void radio_init_rx_MF(){ // Enable both polyphase and mixers via memory mapped IO (...001 = 0x1) // To disable both you would invert these values (...110 = 0x6) ANALOG_CFG_REG__16 = 0x1; - + } // Must set IF clock frequency AFTER calling this function @@ -995,15 +996,15 @@ void radio_init_tx(){ set_LC_current(127); // Set LDO voltages for PA and LO - set_PA_supply(63); - set_LO_supply(127,0); + set_PA_supply(127); + set_LO_supply(63,0); } void radio_init_divider(unsigned int div_value){ // Set divider LDO value to max - set_DIV_supply(63,0); + set_DIV_supply(127,0); // Set prescaler to div-by-2 prescaler(4); @@ -1159,7 +1160,8 @@ void initialize_mote(){ optical_init(); radio_init(); rftimer_init(); - + ble_init(); + //-------------------------------------------------------- // SCM3C Analog Scan Chain Initialization //-------------------------------------------------------- @@ -1170,37 +1172,38 @@ void initialize_mote(){ // set_VDDD_LDO_voltage(0); // set_AUX_LDO_voltage(0); // set_ALWAYSON_LDO_voltage(0); - + // Select banks for GPIO inputs GPI_control(0,0,1,0); // 1 in 3rd arg connects GPI8 to EXT_INTERRUPT<1> needed for 3WB cal - + // Select banks for GPIO outputs GPO_control(6,6,0,6); // 0 in 3rd arg connects clk_3wb to GPO8 for 3WB cal - + + // Set all GPIOs as outputs // Set GPI enables // Hex entry 2: 0x1 = 1 = 0b0001 = GPI 8 on for 3WB cal clk interrupt GPI_enables(0x0100); - // Set GPO enables + // Set HCLK source as HF_CLOCK GPO_enables(0xFFFF); // Set HCLK source as HF_CLOCK set_asc_bit(1147); - + // Set initial coarse/fine on HF_CLOCK - //coarse 0:4 = 860 861 875b 876b 877b - //fine 0:4 870 871 872 873 874b + // coarse 0:4 = 860 861 875b 876b 877b + // fine 0:4 870 871 872 873 874b set_sys_clk_secondary_freq( scm3c_hw_interface_vars.HF_CLOCK_coarse, scm3c_hw_interface_vars.HF_CLOCK_fine ); - + // Set RFTimer source as HF_CLOCK set_asc_bit(1151); // Disable LF_CLOCK set_asc_bit(553); - + // HF_CLOCK will be trimmed to 20MHz, so set RFTimer div value to 40 to get 500kHz (inverted, so 1101 0111) set_asc_bit(49); set_asc_bit(48); @@ -1210,27 +1213,27 @@ void initialize_mote(){ set_asc_bit(44); set_asc_bit(43); set_asc_bit(42); - + // Set 2M RC as source for chip CLK set_asc_bit(1156); - + // Enable 32k for cal set_asc_bit(623); - + // Enable passthrough on chip CLK divider set_asc_bit(41); - + // Init counter setup - set all to analog_cfg control // scm3c_hw_interface_vars.ASC[0] is leftmost //scm3c_hw_interface_vars.ASC[0] |= 0x6F800000; for(t=2; t<9; t++) set_asc_bit(t); - + // Init RX radio_init_rx_MF(); - + // Init TX radio_init_tx(); - + // Set initial IF ADC clock frequency set_IF_clock_frequency( scm3c_hw_interface_vars.IF_coarse, @@ -1249,18 +1252,17 @@ void initialize_mote(){ // Turn on RC 2M for cal set_asc_bit(1114); - + // Set initial LO frequency - LC_monotonic(DEFUALT_INIT_LC_CODE); - + LC_FREQCHANGE(DEFAULT_INIT_LC_COARSE, DEFAULT_INIT_LC_MID, DEFAULT_INIT_LC_FINE); + // Init divider settings radio_init_divider(2000); - + // Program analog scan chain analog_scan_chain_write(); analog_scan_chain_load(); //-------------------------------------------------------- - } unsigned int estimate_temperature_2M_32k(){ @@ -1497,6 +1499,14 @@ void clear_asc_bit(unsigned int position){ //scm3c_hw_interface_vars.ASC[position/32] &= ~(1 << (position%32)); } +void dump_asc(void){ + + unsigned int i; + for (i = 0; i < ASC_LEN; ++i){ + printf("ASC[%u] = 0x%x\n", i, scm3c_hw_interface_vars.ASC[i]); + } +} + //==== from bucket_o_functions.h @@ -1621,27 +1631,29 @@ void enable_1mhz_ble_ASC() { void disable_1mhz_ble_ASC() { scm3c_hw_interface_vars.ASC[32] |= 0x00060000; } + void set_PA_supply(unsigned int code) { // 7-bit setting (between 0 and 127) // MSB is a "panic" bit that engages the high-voltage settings unsigned int code_ASC = ((~code)&0x0000007F) << 13; scm3c_hw_interface_vars.ASC[30] &= 0xFFF01FFF; scm3c_hw_interface_vars.ASC[30] |= code_ASC; - } + void set_LO_supply(unsigned int code, unsigned char panic) { // 7-bit setting (between 0 and 127) // MSB is a "panic" bit that engages the high-voltage settings unsigned int code_ASC = ((~code)&0x0000007F) << 5; - scm3c_hw_interface_vars.ASC[30] &= 0xFFFFF017; + scm3c_hw_interface_vars.ASC[30] &= 0xFFFFF01F; scm3c_hw_interface_vars.ASC[30] |= code_ASC; } + void set_DIV_supply(unsigned int code, unsigned char panic) { // 7-bit setting (between 0 and 127) // MSB is a "panic" bit that engages the high-voltage settings - unsigned int code_ASC = ((~code)&0x0000007F) << 5; - scm3c_hw_interface_vars.ASC[30] &= 0xFFF01FFF; - scm3c_hw_interface_vars.ASC[30] |= code_ASC; + unsigned int code_ASC = ((~code)&0x0000007F) << 13; + scm3c_hw_interface_vars.ASC[31] &= 0xFFF01FFF; + scm3c_hw_interface_vars.ASC[31] |= code_ASC; } void prescaler(int code) { diff --git a/scm_v3c/scm3c_hw_interface.h b/scm_v3c/scm3c_hw_interface.h index 64df1d65..8cdb6b37 100644 --- a/scm_v3c/scm3c_hw_interface.h +++ b/scm_v3c/scm3c_hw_interface.h @@ -89,6 +89,7 @@ unsigned int flip_lsb8(unsigned int in); void update_PN31_byte(unsigned int* current_lfsr); void set_asc_bit(unsigned int position); void clear_asc_bit(unsigned int position); +void dump_asc(void); //==== from bucket_o_functions.h diff --git a/scm_v3c/scum_defs.h b/scm_v3c/scum_defs.h index f1489006..03e82a6a 100644 --- a/scm_v3c/scum_defs.h +++ b/scm_v3c/scum_defs.h @@ -7,9 +7,10 @@ //=========================== define ========================================== -// LC_code used to the initial LC frequency, before optical calibration -#define DEFUALT_INIT_LC_CODE 698 -#define REFERENCE_LC_TARGET 250260 +#define DEFAULT_INIT_LC_COARSE 23 +#define DEFAULT_INIT_LC_MID 12 +#define DEFAULT_INIT_LC_FINE 15 +#define REFERENCE_LC_TARGET 250260 //=========================== typedef ========================================= diff --git a/tests/test_ble_tx.py b/tests/test_ble_tx.py new file mode 100644 index 00000000..8a9fbdd7 --- /dev/null +++ b/tests/test_ble_tx.py @@ -0,0 +1,50 @@ +import pytest +import os +import time + +# =========================== variables ======================================= + +# =========================== test ============================================ + +def syscall(cmd): + print '>>> {0}'.format(cmd) + return os.system(cmd) + +# ==== tests + +def test_compilation(): + ''' + using the UV4.exe executor to build the project. Pass when return code <=1 + ERRORLEVEL Description + 0 No Errors or Warnings + 1 Warnings Only + 2 Errors + 3 Fatal Errors + 11 Cannot open project file for writing + 12 Device with given name in not found in database + 13 Error writing project file + 15 Error reading import XML file + 20 Error converting project + http://www.keil.com/support/man/docs/uv4/uv4_commandline.htm + ''' + syscall("echo compilation...") + result = syscall("%KEIL_UV_DIR%\\UV4.exe -b scm_v3c\\applications\\ble_tx\\ble_tx.uvprojx -o \"output.txt\"") + assert result <= 1 + +def test_bootload(): + syscall("echo bootload SCuM...") + + result = syscall("python scm_v3c\\bootload\\bootload.py -tp %PORT_TEENSY% -i scm_v3c\\applications\\ble_tx\\Objects\\ble_tx.bin") + assert result == 0 + +def test_logData(): + syscall("echo logging SCuM output...") + + result = syscall("python scm_v3c\\applications\\ble_tx\\ble_tx_logger.py") + assert result == 0 + +def test_verifyResult(): + result = syscall("python scm_v3c\\applications\\ble_tx\\ble_tx_parser.py") + assert result == 0 + + syscall("echo BLE TX Test complete!") diff --git a/tests/test_ble_tx_154_rx.py b/tests/test_ble_tx_154_rx.py new file mode 100644 index 00000000..cfa867fc --- /dev/null +++ b/tests/test_ble_tx_154_rx.py @@ -0,0 +1,50 @@ +import pytest +import os +import time + +# =========================== variables ======================================= + +# =========================== test ============================================ + +def syscall(cmd): + print '>>> {0}'.format(cmd) + return os.system(cmd) + +# ==== tests + +def test_compilation(): + ''' + using the UV4.exe executor to build the project. Pass when return code <=1 + ERRORLEVEL Description + 0 No Errors or Warnings + 1 Warnings Only + 2 Errors + 3 Fatal Errors + 11 Cannot open project file for writing + 12 Device with given name in not found in database + 13 Error writing project file + 15 Error reading import XML file + 20 Error converting project + http://www.keil.com/support/man/docs/uv4/uv4_commandline.htm + ''' + syscall("echo compilation...") + result = syscall("%KEIL_UV_DIR%\\UV4.exe -b scm_v3c\\applications\\ble_tx_154_rx\\ble_tx_154_rx.uvprojx -o \"output.txt\"") + assert result <= 1 + +def test_bootload(): + syscall("echo bootload SCuM...") + + result = syscall("python scm_v3c\\bootload\\bootload.py -tp %PORT_TEENSY% -i scm_v3c\\applications\\ble_tx_154_rx\\Objects\\ble_tx_154_rx.bin") + assert result == 0 + +def test_logData(): + syscall("echo logging SCuM output...") + + result = syscall("python scm_v3c\\applications\\ble_tx_154_rx\\ble_tx_154_rx_logger.py") + assert result == 0 + +def test_verifyResult(): + result = syscall("python scm_v3c\\applications\\ble_tx_154_rx\\ble_tx_154_rx_parser.py") + assert result == 0 + + syscall("echo BLE TX 15.4 RX Test complete!")