Root/
| Source at commit 2c7d7b78b0e47d4974072fe4013f79b286ea5ddb created 11 years 17 days ago. By Werner Almesberger, tornado/fw/sim/alg.c: dampen more, to also absorb chain jumps | |
|---|---|
| 1 | /* |
| 2 | * ben/io.h - I/O helper macros (for cross-platform testing on the Ben) |
| 3 | * |
| 4 | * Written 2012 by Werner Almesberger |
| 5 | * Copyright 2012 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef BEN_IO_H |
| 14 | #define BEN_IO_H |
| 15 | |
| 16 | #include <stdint.h> |
| 17 | |
| 18 | |
| 19 | #define CARD_nPWR (1 << 2) /* PD02 */ |
| 20 | #define CARD_DAT2 (1 << 12) /* PD12 */ |
| 21 | #define CARD_DAT3 (1 << 13) /* PD13 */ |
| 22 | #define CARD_CMD (1 << 8) /* PD08 */ |
| 23 | #define CARD_CLK (1 << 9) /* PD09 */ |
| 24 | #define CARD_DAT0 (1 << 10) /* PD10 */ |
| 25 | #define CARD_DAT1 (1 << 11) /* PD11 */ |
| 26 | |
| 27 | |
| 28 | #define REG(n) (*(volatile uint32_t *) (ben_mem+(n))) |
| 29 | |
| 30 | #define GPIO(n) REG(0x10000+(n)) |
| 31 | |
| 32 | #define PDPIN GPIO(0x300) /* port D pin level */ |
| 33 | #define PDDATS GPIO(0x314) /* port D data set */ |
| 34 | #define PDDATC GPIO(0x318) /* port D data clear */ |
| 35 | #define PDFUNS GPIO(0x344) /* port D function set */ |
| 36 | #define PDFUNC GPIO(0x348) /* port D function clear */ |
| 37 | #define PDDIRS GPIO(0x364) /* port D direction set */ |
| 38 | #define PDDIRC GPIO(0x368) /* port D direction clear */ |
| 39 | |
| 40 | #define SET(mask) PDDATS = mask |
| 41 | #define CLR(mask) PDDATC = mask |
| 42 | #define OUT(mask) PDDIRS = mask |
| 43 | #define IN(mask) PDDIRC = mask |
| 44 | #define PIN(mask) (!!(PDPIN & (mask))) |
| 45 | |
| 46 | |
| 47 | extern void *ben_mem; |
| 48 | |
| 49 | #endif /* BEN_IO_H */ |
| 50 | |
Branches:
master
tornado-v1
