Skip to content
Snippets Groups Projects
Commit e5ba5f6b authored by Paulus Kruger's avatar Paulus Kruger
Browse files

add GPIO pin control

parent 7da62ae3
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,15 @@ ...@@ -11,8 +11,15 @@
#define TX_RAW_TIME //This will give the raw time between edges instead of decoding it #define TX_RAW_TIME //This will give the raw time between edges instead of decoding it
//#define SIMULATE_HBAT //Reply on request //#define SIMULATE_HBAT //Reply on request
const uint TX_PIN = 17; //25=LED to test #define PIN0 18
const uint RX_PIN = 17; #define PIN1 17
#define PIN2 16
#define PIN3 20
#define PIN4 19
#define PIN5 25 //LED for test
const uint TX_PIN = 22; //25=LED to test
const uint RX_PIN = 21;
#define TXtimeout 0x1000 #define TXtimeout 0x1000
//#define TXtimeout 0x80 //#define TXtimeout 0x80
...@@ -26,6 +33,18 @@ uint16_t buffer2[BUFFERSIZE]; ...@@ -26,6 +33,18 @@ uint16_t buffer2[BUFFERSIZE];
uint8_t bcnt1=0,bcnt2=0; uint8_t bcnt1=0,bcnt2=0;
uint8_t bcnt3=0,bcnt4=0; uint8_t bcnt3=0,bcnt4=0;
uint32_t dummy; uint32_t dummy;
void set_pins(){
int x = getchar_timeout_us(1000);
if (x==PICO_ERROR_TIMEOUT) return;
// printf("set pin %i\n",x);
gpio_put(PIN0,x&1);
gpio_put(PIN1,x&2);
gpio_put(PIN2,x&4);
gpio_put(PIN3,x&8);
gpio_put(PIN4,x&16);
gpio_put(PIN5,x&32);
}
void core1_entry() { void core1_entry() {
while (1) { while (1) {
// printf("3"); // printf("3");
...@@ -49,6 +68,7 @@ while (1) { ...@@ -49,6 +68,7 @@ while (1) {
// gpio_set_dir(TX_PIN, GPIO_OUT); // gpio_set_dir(TX_PIN, GPIO_OUT);
// gpio_put(TX_PIN,0); // gpio_put(TX_PIN,0);
gpio_set_pulls(TX_PIN,false,true); gpio_set_pulls(TX_PIN,false,true);
set_pins();
} else { } else {
gpio_set_pulls(TX_PIN,true,false); gpio_set_pulls(TX_PIN,true,false);
buffer1[bcnt1]=x; buffer1[bcnt1]=x;
...@@ -75,9 +95,19 @@ int main() { ...@@ -75,9 +95,19 @@ int main() {
printf("Init\n"); printf("Init\n");
// gpio_init(LED_PIN); gpio_init(PIN0);
// gpio_set_dir(LED_PIN, GPIO_OUT); gpio_init(PIN1);
gpio_set_pulls(TX_PIN,true,false); gpio_init(PIN2);
gpio_init(PIN3);
gpio_init(PIN4);
gpio_init(PIN5);
gpio_set_dir(PIN0, GPIO_OUT);
gpio_set_dir(PIN1, GPIO_OUT);
gpio_set_dir(PIN2, GPIO_OUT);
gpio_set_dir(PIN3, GPIO_OUT);
gpio_set_dir(PIN4, GPIO_OUT);
gpio_set_dir(PIN5, GPIO_OUT);
//gpio_set_pulls(TX_PIN,true,false);
// gpio_set_pulls(RX_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_tx, sm , 12500); //Bitrate = 150e6 / val. e.g. 15k = 10kHz
pio_sm_put_blocking(pio_rx, sm1, TXtimeout); //Timeout pio_sm_put_blocking(pio_rx, sm1, TXtimeout); //Timeout
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment