diff --git a/bc832-watt/fw/watt-bc832-recv/watt-bc832-recv.ino b/bc832-watt/fw/watt-bc832-recv/watt-bc832-recv.ino index 53b3b3be410f9bd55e9c9b10203eff5859bc8cbf..0b519a4bdba99328eac3aa50525a05ecf0305c10 100644 --- a/bc832-watt/fw/watt-bc832-recv/watt-bc832-recv.ino +++ b/bc832-watt/fw/watt-bc832-recv/watt-bc832-recv.ino @@ -1,7 +1,7 @@ #define N_SAMPLES 12 #define PACKET_BASE_ADDRESS_LENGTH (2UL) //Packet base address length field size in bytes -static uint8_t packet = 52; //declare a buffer for our packet to use with easydma +//static uint8_t packet = 52; //declare a buffer for our packet to use with easydma const uint8_t pin_rx = 8; const uint8_t pin_tx = 6; @@ -9,6 +9,7 @@ uint16_t last_tx_time = 0; uint16_t tx_period = 100; //ms static int16_t data_buffer[N_SAMPLES] = {0}; +//static int16_t packet[N_SAMPLES] = {0}; //declare a buffer for our packet to use with easydma // //RADIO @@ -31,13 +32,13 @@ void radio_setup(){ // Packet configuration NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S1LEN_Pos) | (0 << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos); NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | - (1 << RADIO_PCNF1_STATLEN_Pos) | + ((2*N_SAMPLES) << RADIO_PCNF1_STATLEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | (2 << RADIO_PCNF1_BALEN_Pos); NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Disabled << RADIO_CRCCNF_LEN_Pos); // Number of checksum bits NRF_RADIO->MODECNF0 |= RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos; //turn on fast ramp up NRF_RADIO->SHORTS = 0; //turn off all shortcuts, for debug - NRF_RADIO->PACKETPTR = (uint32_t)&packet; //set pointer to packet buffer + NRF_RADIO->PACKETPTR = (uint32_t)&data_buffer; //set pointer to packet buffer //start HFCLK NRF_CLOCK->TASKS_HFCLKSTART = 1; while(!(NRF_CLOCK->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk)); //wait for hfclk to start @@ -79,28 +80,18 @@ void uarte_setup(){ | ((UARTE_CONFIG_HWFC_Disabled << UARTE_CONFIG_HWFC_Pos) & UARTE_CONFIG_HWFC_Msk); NRF_UARTE0->BAUDRATE = UART_BAUDRATE_BAUDRATE_Baud1M; NRF_UARTE0->ENABLE = (UARTE_ENABLE_ENABLE_Enabled << UARTE_ENABLE_ENABLE_Pos) & UARTE_ENABLE_ENABLE_Msk; - NRF_UARTE0->TXD.MAXCNT = N_SAMPLES; } void setup() { uarte_setup(); radio_setup(); - Serial.begin(1000000); - - while(true){ if (millis() - last_tx_time > tx_period){ radio_recv(); - Serial.println(packet); - //debug for ascii - //data_buffer[0] = packet; - //data_buffer[1] = packet; - //data_buffer[2] = packet; - //data_buffer[3] = 10; //start a transmission of the tx buffer - //NRF_UARTE0->TXD.PTR = (uint32_t)(&data_buffer); //reset pointer to start of buffer - //NRF_UARTE0->TASKS_STARTTX = 1; //trigger start task + NRF_UARTE0->TXD.PTR = (uint32_t)(&data_buffer); //reset pointer to start of buffer + NRF_UARTE0->TASKS_STARTTX = 1; //trigger start task last_tx_time = millis(); } } diff --git a/bc832-watt/fw/watt-bc832/watt-bc832.ino b/bc832-watt/fw/watt-bc832/watt-bc832.ino index 1623865b3405307245fdd54e9e380a2d9684d6d4..7620caee912e2b4ac698c9c3593bc2c3f56a2568 100644 --- a/bc832-watt/fw/watt-bc832/watt-bc832.ino +++ b/bc832-watt/fw/watt-bc832/watt-bc832.ino @@ -1,7 +1,6 @@ #define N_SAMPLES 12 #define PACKET_BASE_ADDRESS_LENGTH (2UL) //Packet base address length field size in bytes -static uint8_t packet = 12; //declare a buffer for our packet to use with easydma const uint8_t pin_rx = 8; const uint8_t pin_tx = 6; @@ -9,6 +8,7 @@ uint16_t last_tx_time = 0; uint16_t tx_period = 100; //ms static int16_t data_buffer[N_SAMPLES] = {0}; +static int16_t packet[N_SAMPLES] = {0}; //declare a buffer for our packet to use with easydma // //ADC @@ -90,13 +90,13 @@ void radio_setup(){ // Packet configuration NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S1LEN_Pos) | (0 << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos); NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | - (1 << RADIO_PCNF1_STATLEN_Pos) | + ((2*N_SAMPLES) << RADIO_PCNF1_STATLEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | (2 << RADIO_PCNF1_BALEN_Pos); NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Disabled << RADIO_CRCCNF_LEN_Pos); // Number of checksum bits NRF_RADIO->MODECNF0 |= RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos; //turn on fast ramp up NRF_RADIO->SHORTS = 0; //turn off all shortcuts, for debug - NRF_RADIO->PACKETPTR = (uint32_t)&packet; //set pointer to packet buffer + NRF_RADIO->PACKETPTR = (uint32_t)&data_buffer; //set pointer to packet buffer //start HFCLK NRF_CLOCK->TASKS_HFCLKSTART = 1; while(!(NRF_CLOCK->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk)); //wait for hfclk to start @@ -143,19 +143,13 @@ void uarte_setup(){ } void setup() { - //uarte_setup(); adc_setup(); radio_setup(); while(true){ if (millis() - last_tx_time > tx_period){ take_adc_samples(); - //start a transmission of the tx buffer - //NRF_UARTE0->TXD.PTR = (uint32_t)(&data_buffer); //reset pointer to start of buffer - //NRF_UARTE0->TASKS_STARTTX = 1; //trigger start task - radio_send(); - last_tx_time = millis(); - + last_tx_time = millis(); } } } diff --git a/bc832-watt/host/watt_host.py b/bc832-watt/host/watt_host.py index d4a41d8d524ae91c6f8b2fc9fce43c241dcd8ce2..1b804859c3d49be60ecae7cceb61a9ec82461130 100644 --- a/bc832-watt/host/watt_host.py +++ b/bc832-watt/host/watt_host.py @@ -27,7 +27,7 @@ def read(ser=None): def main(): try: - ser = serial.Serial(port='/dev/tty.usbserial-FT9L3KWR',baudrate=1000000,timeout=1.) + ser = serial.Serial(port='/dev/tty.usbserial-FTFMIM12',baudrate=1000000,timeout=1.) ser.isOpen() print "Established serial connection." except(OSError):