diff options
author | Erich Eckner <git@eckner.net> | 2018-10-22 14:19:25 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-22 14:19:25 +0200 |
commit | ae75b15e6241232c2adb3ae3b53819d3a4dd638d (patch) | |
tree | 4a4c738c2bfa8fff0ac2dbe0a90444120bb566c5 /multiplexer.h | |
parent | 9cbc55a81c76dd3bfb480b9f280f9958ce6ef592 (diff) | |
download | anzeige-ae75b15e6241232c2adb3ae3b53819d3a4dd638d.tar.xz |
split of logical parts into separate files
Diffstat (limited to 'multiplexer.h')
-rw-r--r-- | multiplexer.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/multiplexer.h b/multiplexer.h new file mode 100644 index 0000000..806ef19 --- /dev/null +++ b/multiplexer.h @@ -0,0 +1,52 @@ +// +// How to access GPIO registers from C-code on the Raspberry-Pi +// Example program +// 15-January-2012 +// Dom and Gert +// Revised: 15-Feb-2013 + +#ifndef __arm__ +#define SKIP_GPIO +#endif + +// Access from ARM Running Linux + +#define BCM2708_PERI_BASE 0x20000000 +#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ + +#define PAGE_SIZE (4*1024) +#define BLOCK_SIZE (4*1024) + +#define SER_DAT_PIN 26 +#define SER_CLK_PIN 19 +#define GATE_PIN 13 +#define PAR_CLK_PIN 6 +#define SENSE_PIN 5 + +int mem_fd; +void *gpio_map; + +typedef struct { + char buf[3][40]; + int should_buf, is_buf, keep_running; +} t_display_data; + +// I/O access +volatile unsigned *gpio; + +// GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y) +#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) // sets bits which are 1 ignores bits which are 0 +#define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0 +#define GPIO_ALTER(a) *(gpio+(a==0?10:7)) // alters (a==0: clear, else: set) bits which are 1 ignores bits which are 0 + +#define GET_GPIO(g) (*(gpio+13)&(1<<g)) // 0 if LOW, (1<<g) if HIGH + +#define GPIO_PULL *(gpio+37) // Pull up/pull down +#define GPIO_PULLCLK0 *(gpio+38) // Pull up/pull down clock + +void multiplexer_setup_root(); +pthread_t multiplexer_setup_non_root(t_display_data *display_data); |