diff options
author | yzrh <yzrh@noema.org> | 2020-10-10 17:16:14 +0000 |
---|---|---|
committer | yzrh <yzrh@noema.org> | 2020-10-10 17:37:53 +0000 |
commit | b9b74e88028f81e7b169a5e168102138e8c2c46c (patch) | |
tree | 2b8f9f8896db3a6871c56215acf71cb502fe7be4 /src/gpio.h | |
download | snake-sdl-b9b74e88028f81e7b169a5e168102138e8c2c46c.tar.gz snake-sdl-b9b74e88028f81e7b169a5e168102138e8c2c46c.tar.zst |
Initial commit.
Diffstat (limited to 'src/gpio.h')
-rw-r--r-- | src/gpio.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gpio.h b/src/gpio.h new file mode 100644 index 0000000..0b6b75d --- /dev/null +++ b/src/gpio.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019-2020, yzrh <yzrh@noema.org> + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define GPIO_LOW 0x00 +#define GPIO_HIGH 0x01 + +#ifdef __FreeBSD__ + +#include <stdint.h> + +#include <sys/gpio.h> + +#define GPIO_IN GPIO_PIN_INPUT +#define GPIO_OUT GPIO_PIN_OUTPUT +#define GPIO_INT GPIO_INTR_EDGE_FALLING + +#elif __linux__ + +#define GPIO_IN 0x00 +#define GPIO_OUT 0x01 +/* + * 0: falling + * 1: rising + */ +#define GPIO_INT 0 + +#endif /* __FreeBSD__ */ + +/* Raspberry Pi 3 */ +#define GPIO_PIN_IN0 4 /* 7: DPAD_LEFT */ +#define GPIO_PIN_IN1 14 /* 8: DPAD_UP */ +#define GPIO_PIN_IN2 15 /* 10: DPAD_DOWN */ +#define GPIO_PIN_IN3 17 /* 11: DPAD_RIGHT */ + +#define GPIO_PIN_IN4 18 /* 12: BACK */ +#define GPIO_PIN_IN5 27 /* 13: GUIDE */ +#define GPIO_PIN_IN6 22 /* 15: START */ + +#define GPIO_PIN_IN7 23 /* 16: A */ +#define GPIO_PIN_IN8 24 /* 18: B */ +#define GPIO_PIN_IN9 10 /* 19: X */ +#define GPIO_PIN_IN10 9 /* 21: Y */ + +#define GPIO_PIN_IN11 25 /* 22: LEFTSHOULDER */ +#define GPIO_PIN_IN12 11 /* 23: RIGHTSHOULDER */ + +#define GPIO_PIN_IN13 8 /* 24: LEFTSTICK */ +#define GPIO_PIN_IN14 7 /* 26: RIGHTSTICK */ + +/* Second controller */ +#define GPIO_PIN_IN15 0 /* 27: DPAD_LEFT */ +#define GPIO_PIN_IN16 1 /* 28: DPAD_UP */ +#define GPIO_PIN_IN17 5 /* 29: DPAD_DOWN */ +#define GPIO_PIN_IN18 6 /* 31: DPAD_RIGHT */ + +/* Unused */ +#define GPIO_PIN_IN19 12 /* 32: NULL */ +#define GPIO_PIN_IN20 13 /* 33: NULL */ +#define GPIO_PIN_IN21 19 /* 35: NULL */ +#define GPIO_PIN_IN22 16 /* 36: NULL */ +#define GPIO_PIN_IN23 26 /* 37: NULL */ +#define GPIO_PIN_IN24 20 /* 38: NULL */ +#define GPIO_PIN_IN25 21 /* 40: NULL */ |