-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpio.h
57 lines (47 loc) · 1.73 KB
/
pio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _PIO_H_
#define _PIO_H_
#define SIO_TXFL (1 << 0) /* 1= Transmit buffer full */
#define SIO_RXRD (1 << 1) /* 1= Receive buffer full */
#define SIO_FRER (1 << 2) /* 1= Framing error occured */
#define MAX_DEVICE 2
#define DEVICE_D0 (1 << 0)
#define DEVICE_D1 (1 << 1)
#define DEVICE_D2 (1 << 2)
#define DEVICE_D3 (1 << 3)
#define DEVICE_TL (1 << 4)
#define DEVICE_TR (1 << 5)
#define DEVICE_TH (1 << 6)
#define DEVICE_ALL (DEVICE_D0 | DEVICE_D1 | DEVICE_D2 | DEVICE_D3 | DEVICE_TL | DEVICE_TR | DEVICE_TH)
#define PIN_LVL_LO 0 /* Pin outputs 0V */
#define PIN_LVL_HI 1 /* Pin outputs +5V */
#define PIN_DIR_OUT 0 /* Pin is is an active driving output */
#define PIN_DIR_IN 1 /* Pin is in active-low input mode */
enum {
PORT_A = 0, /* I/O port A */
PORT_B = 1 /* I/O port B */
};
enum {
DEVICE_NONE = 0, /* No peripheral */
DEVICE_PAD2B = 1, /* Standard 2-button digital joystick/gamepad */
DEVICE_PADDLE = 2 /* Paddle controller; rotary dial with fire button */
};
typedef struct {
uint8 tr_level[2]; /* TR pin output level */
uint8 th_level[2]; /* TH pin output level */
uint8 tr_dir[2]; /* TR pin direction */
uint8 th_dir[2]; /* TH pin direction */
} io_state;
/* Global variables */
extern io_state io_lut[2][256];
extern io_state *io_current;
/* Function prototypes */
void pio_init(void);
void pio_reset(void);
void pio_shutdown(void);
void system_assign_device(int port, int type);
void io_lut_init(void);
void ioctrl_w(uint8 data);
uint8 input_r(int offset);
void sio_w(int offset, int data);
uint8 sio_r(int offset);
#endif /* _PIO_H_ */