12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef IO_H
- #define IO_H
- #ifdef __linux__
-
- #include <unistd.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <time.h>
- #include <fcntl.h>
- #include <pthread.h>
- #define ARM 1
- #define BCM2708_PERI_BASE 0x20000000
- #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- #include <unistd.h>
-
- #define PAGE_SIZE (4*1024)
- #define BLOCK_SIZE (4*1024)
-
- extern int mem_fd;
- extern void *gpio_map;
-
- /* I/O access */
- extern volatile unsigned *gpio;
-
- #define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
- #define OUT_GPIO(g) *(gpio+((g)/10)) |= (1<<(((g)%10)*3))
- #define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
-
- #define GPIO_SET *(gpio+7)
- #define GPIO_CLR *(gpio+10)
- #define GPIO_WRITE(gpio, value) ((value)?(GPIO_SET = 1 << gpio):(GPIO_CLR = 1 << gpio))
-
- #define GET_GPIO(g) ((*(gpio+13)&(1<<g))?1:0)
-
- #define GPIO_PULL *(gpio+37)
- #define GPIO_PULLCLK0 *(gpio+38)
- void setup_io();
- #else
- #include <Arduino.h>
- #include <avr/wdt.h>
- #include <avr/sleep.h>
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #endif
- #endif
|