Pico2GPIOerror3V01.c


1
#include <stdio.h>
2
#include "pico/stdlib.h"
3
4
#define GPIOpinX 3
5
6
void showPulls(){
7
  int v=0 ;
8
  v=gpio_is_pulled_up (GPIOpinX) ;
9
  printf("gpio_is_pulled_up (GPIOpinX)=%d\n",v) ;
10
  v=gpio_is_pulled_down (GPIOpinX) ;
11
  printf("gpio_is_pulled_down (GPIOpinX)=%d\n",v) ;
12
  }
13
14
void showGPIO(){
15
  int kk=0 ;  
16
  printf("showGPIO\n") ;
17
  while(1){
18
    int v=gpio_get(GPIOpinX) ;
19
    printf("k=%4d pinX=%d\n",kk++,v) ;
20
    sleep_ms(1000) ;
21
    }
22
  }
23
24
void setup1(){
25
  printf("setup1\n") ;
26
  gpio_init(GPIOpinX);
27
  gpio_set_pulls (GPIOpinX,false , false ) ;
28
  printf("disable pulls on X\n") ;
29
  gpio_set_dir(GPIOpinX, GPIO_IN);
30
  printf("set_dir GPIOin on X \n") ;
31
  showPulls() ;
32
  showGPIO() ;
33
  }    
34
35
void wait(int nn){
36
  for(int kk=0 ; kk<nn ; kk++){
37
    printf("wait k=%d\n",kk) ;
38
    sleep_ms(1000) ;
39
    }
40
  }
41
42
int main(){
43
  stdio_init_all();
44
  wait(8) ;
45
  printf("Pico2GPIOerror2V01\n") ;
46
  setup1() ;
47
  }