Commit 0fc9db0c authored by Sam Calisch's avatar Sam Calisch

now transmitting adc values

parent 401fb9f9
Pipeline #739 passed with stage
in 2 seconds
#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();
}
}
......
#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();
}
}
}
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment