| 228 |
Kevin |
1 |
#ifndef DEFINES_H
|
|
|
2 |
#define DEFINES_H
|
|
|
3 |
|
|
|
4 |
// <editor-fold defaultstate="collapsed" desc="I/O Pins">
|
|
|
5 |
#define BTN_L_N_TRIS TRISAbits.TRISA1
|
|
|
6 |
#define BTN_L_N_PORT PORTAbits.RA1
|
|
|
7 |
#define BTN_L_N_WPU WPUAbits.WPUA1
|
|
|
8 |
|
|
|
9 |
#define BTN_L_S_TRIS TRISAbits.TRISA0
|
|
|
10 |
#define BTN_L_S_PORT PORTAbits.RA0
|
|
|
11 |
#define BTN_L_S_WPU WPUAbits.WPUA0
|
|
|
12 |
|
|
|
13 |
#define BTN_R_N_TRIS TRISCbits.TRISC2
|
|
|
14 |
#define BTN_R_N_PORT PORTCbits.RC2
|
|
|
15 |
#define BTN_R_N_WPU WPUCbits.WPUC2
|
|
|
16 |
|
|
|
17 |
#define BTN_R_E_TRIS TRISAbits.TRISA3
|
|
|
18 |
#define BTN_R_E_PORT PORTAbits.RA3
|
|
|
19 |
#define BTN_R_E_WPU WPUAbits.WPUA3
|
|
|
20 |
|
|
|
21 |
#define BTN_R_S_TRIS TRISAbits.TRISA5
|
|
|
22 |
#define BTN_R_S_PORT PORTAbits.RA5
|
|
|
23 |
#define BTN_R_S_WPU WPUAbits.WPUA5
|
|
|
24 |
|
|
|
25 |
#define BTN_R_W_TRIS TRISAbits.TRISA2
|
|
|
26 |
#define BTN_R_W_PORT PORTAbits.RA2
|
|
|
27 |
#define BTN_R_W_WPU WPUAbits.WPUA2
|
|
|
28 |
|
|
|
29 |
#define LED_1_TRIS TRISCbits.TRISC3
|
|
|
30 |
#define LED_1_LAT LATCbits.LATC3
|
|
|
31 |
|
|
|
32 |
#define LED_2_TRIS TRISCbits.TRISC4
|
|
|
33 |
#define LED_2_LAT LATCbits.LATC4
|
|
|
34 |
|
|
|
35 |
#define LED_3_TRIS TRISCbits.TRISC5
|
|
|
36 |
#define LED_3_LAT LATCbits.LATC5
|
|
|
37 |
|
|
|
38 |
#define LED_4_TRIS TRISAbits.TRISA4
|
|
|
39 |
#define LED_4_LAT LATAbits.LATA4
|
|
|
40 |
|
|
|
41 |
#define I2C_CLK_TRIS TRISCbits.TRISC0
|
|
|
42 |
#define I2C_DAT_TRIS TRISCbits.TRISC1
|
|
|
43 |
// </editor-fold>
|
|
|
44 |
|
|
|
45 |
#define _XTAL_FREQ 32000000
|
|
|
46 |
|
|
|
47 |
#define CMD_QUERY_BTN 0x10
|
|
|
48 |
#define CMD_SET_LEDS 0x11
|
|
|
49 |
|
|
|
50 |
typedef union {
|
|
|
51 |
struct {
|
|
|
52 |
unsigned BTN_L_N :1;
|
|
|
53 |
unsigned BTN_L_S :1;
|
|
|
54 |
unsigned BTN_R_N :1;
|
|
|
55 |
unsigned BTN_R_E :1;
|
|
|
56 |
unsigned BTN_R_S :1;
|
|
|
57 |
unsigned BTN_R_W :1;
|
|
|
58 |
unsigned :2;
|
|
|
59 |
};
|
|
|
60 |
char value;
|
|
|
61 |
} BTN_STATUS;
|
|
|
62 |
|
|
|
63 |
typedef union {
|
|
|
64 |
struct {
|
|
|
65 |
unsigned LED_1 :1;
|
|
|
66 |
unsigned LED_2 :1;
|
|
|
67 |
unsigned LED_3 :1;
|
|
|
68 |
unsigned LED_4 :1;
|
|
|
69 |
};
|
|
|
70 |
char value;
|
|
|
71 |
} LED_STATUS;
|
|
|
72 |
|
|
|
73 |
void Pins_Read(BTN_STATUS *btns);
|
|
|
74 |
void Leds_Write(LED_STATUS *leds);
|
|
|
75 |
|
|
|
76 |
#endif /* DEFINES_H */
|
|
|
77 |
|