Browse Source

gpio

pull/1/head
Rafael Zurita 6 years ago
parent
commit
9a7bd6ff99
  1. 10
      lib/avr_gpio.c

10
lib/avr_gpio.c

@ -1,9 +1,10 @@
/* avr_gpio.c - little lib to set/unset AVR digital out pins */
void gpio_write(char p, unsigned char v) void gpio_write(char p, unsigned char v)
{ {
volatile unsigned char * DDR; /* port b _B = 0x24; direccion de DDR B */ volatile unsigned char * DDR; /* port b _B = 0x24; DDR B address */
volatile unsigned char * PORT; /* port b = 0x25; /* direccion de PUERTO B */ volatile unsigned char * PORT; /* port b = 0x25; PORT address */
switch (p) { switch (p) {
case 'b': case 'b':
DDR = 0x24; DDR = 0x24;
@ -23,8 +24,8 @@ void gpio_write(char p, unsigned char v)
/* p : port. e.g. 'b' */ /* p : port. e.g. 'b' */
char gpio_read(char p) char gpio_read(char p)
{ {
volatile unsigned char * DDR; /* port b _B = 0x24; direccion de DDR B */ volatile unsigned char * DDR; /* port b _B = 0x24; DDR B address */
volatile unsigned char * PORT; /* port b = 0x25; /* direccion de PUERTO B */ volatile unsigned char * PORT; /* port b = 0x25; PORT address */
char v; char v;
switch (p) { switch (p) {
@ -42,6 +43,7 @@ char gpio_read(char p)
} }
/* digital set high/low using arduino board pin number */
gpio_arduino_write(char pin, unsigned char v) gpio_arduino_write(char pin, unsigned char v)
{ {
char p; char p;

Loading…
Cancel
Save