blob: 3792038e35a55db316b4fe1cce0b7e7ac1ab52c9 [file] [log] [blame]
Brian Silvermanf92396c2013-09-12 20:13:13 -07001#ifndef GYRO_BOARD_USB_DIGITAL_H_
2#define GYRO_BOARD_USB_DIGITAL_H_
3
Brian Silvermancb332812013-10-08 13:33:11 -07004#include "FreeRTOS.h"
5
Brian Silvermanf92396c2013-09-12 20:13:13 -07006#define readGPIO(gpio, chan) ((((gpio)->FIOPIN) >> (chan)) & 1)
7
8// These are the actual pin numbers for all of the digital I(/0) pins on the
9// board.
10//
11// GPIO1 P0.4
12// GPIO2 P0.5
13// GPIO3 P0.6
14// GPIO4 P0.7
15// GPIO5 P0.8
16// GPIO6 P0.9
17// GPIO7 P2.0
18// GPIO8 P2.1
19// GPIO9 P2.2
20// GPIO10 P2.3
21// GPIO11 P2.4
22// GPIO12 P2.5
23//
24// DIP0 P1.29
25// DIP1 P2.13
26// DIP2 P0.11
27// DIP3 P0.10
28//
29// ENC0A 1.20
30// ENC0B 1.23
31// ENC1A 2.11
32// ENC1B 2.12
33// ENC2A 0.21
34// ENC2B 0.22
35// ENC3A 0.19
36// ENC3B 0.20
37
38void digital_init(void);
39
Brian Silvermancb332812013-10-08 13:33:11 -070040inline int digital(int channel) {
41 if (channel < 1) {
42 return -1;
43 } else if (channel < 7) {
44 int chan = channel + 3;
45 return readGPIO(GPIO0, chan);
46 } else if (channel < 13) {
47 int chan = channel - 7;
48 return readGPIO(GPIO2, chan);
49 }
50 return -1;
51}
Brian Silvermanf92396c2013-09-12 20:13:13 -070052
53int dip_switch(int channel);
54
55// Boolean set by digital_init() which says whether or not this is the 3rd
56// robot.
57extern int is_bot3;
58
59#endif // GYRO_BOARD_USB_DIGITAL_H_