diff --git a/build/test.uf2 b/build/test.uf2 new file mode 100644 index 0000000000000000000000000000000000000000..2c128c1eb5c568f094cbe31cece2056e8eeede80 Binary files /dev/null and b/build/test.uf2 differ diff --git a/test.c b/test.c index db31a00d98abb396e4d3f561749bc43402269217..44abb43865d3cc82cd82cbd724075a18e5bb0059 100644 --- a/test.c +++ b/test.c @@ -8,14 +8,14 @@ #include "hba_tx.pio.h" #include "hba_rx.pio.h" -//#define TX_RAW_TIME //This will give the raw time between edges instead of decoding it -#define SIMULATE_HBAT //Reply on request +#define TX_RAW_TIME //This will give the raw time between edges instead of decoding it +//#define SIMULATE_HBAT //Reply on request -const uint TX_PIN = 14; //25=LED to test -const uint RX_PIN = 14; +const uint TX_PIN = 17; //25=LED to test +const uint RX_PIN = 17; -///#define TXtimeout 0x1000 -#define TXtimeout 0x80 +#define TXtimeout 0x1000 +//#define TXtimeout 0x80 //Need to change norm delay constants if time is changed!! This can be done using TX_RAW_TIME and python scripts. inline uint16_t NormDelay(uint16_t x){ return (TXtimeout-x+19)/20; } @@ -25,7 +25,7 @@ char buffer1[BUFFERSIZE]; uint16_t buffer2[BUFFERSIZE]; uint8_t bcnt1=0,bcnt2=0; uint8_t bcnt3=0,bcnt4=0; -uint16_t dummy; +uint32_t dummy; void core1_entry() { while (1) { // printf("3"); @@ -45,8 +45,15 @@ while (1) { else { int x = getchar_timeout_us(0); if (x!=PICO_ERROR_TIMEOUT){ - buffer1[bcnt1]=x; - bcnt1++;bcnt1%=BUFFERSIZE; + if (x==0) { +// gpio_set_dir(TX_PIN, GPIO_OUT); +// gpio_put(TX_PIN,0); + gpio_set_pulls(TX_PIN,false,true); + } else { + gpio_set_pulls(TX_PIN,true,false); + buffer1[bcnt1]=x; + bcnt1++;bcnt1%=BUFFERSIZE; + } } } }}; @@ -70,7 +77,7 @@ int main() { printf("Init\n"); // gpio_init(LED_PIN); // gpio_set_dir(LED_PIN, GPIO_OUT); -// gpio_set_pulls(TX_PIN,true,false); + gpio_set_pulls(TX_PIN,true,false); // gpio_set_pulls(RX_PIN,true,false); pio_sm_put_blocking(pio_tx, sm , 12500); //Bitrate = 150e6 / val. e.g. 15k = 10kHz pio_sm_put_blocking(pio_rx, sm1, TXtimeout); //Timeout @@ -85,7 +92,7 @@ int main() { } else if ((pio_sm_get_tx_fifo_level(pio_tx, sm)<4) && (bcnt1!=bcnt2)) { //Second priority: Keep TX FIFO full pio_sm_put_blocking(pio_tx, sm, buffer1[bcnt2]); bcnt2++;bcnt2%=BUFFERSIZE; - } else if (dummy++==0) printf("."); + } else if (dummy++==0) printf("\n"); } #endif //TX_RAW_TIME