Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
260 Kevin 1
#ifndef DEFINES_H
2
#define	DEFINES_H
3
 
4
#include <xc.h>
5
#include <stdint.h>
6
 
7
// <editor-fold defaultstate="collapsed" desc="I/O Pins">
8
    /* Pins Mapping
9
     * 2 - RA5 - LSM303_DRDY
10
     * 3 - RA4 - L3GD20_DRDY
11
     * 5 - RC5 - UART_RX
12
     * 6 - RC4 - UART TX
13
     * 7 - RC3 - ADDR_3
14
     * 8 - RC6 - BTN_CAP_0
15
     * 9 - RC7 - BTN_CAP_1
16
     * 10 - RB7 - SCL_2
17
     * 11 - RB6 - SCL_1
18
     * 12 - RB5 - SDA_2
19
     * 13 - RB4 - SDA_1
20
     * 14 - RC2 - ADDR_2
21
     * 15 - RC1 - ADDR_1
22
     * 16 - RC0 - ADDR_0
23
     * 17 - RA2 - BTN_INT
24
     */
25
#define LSM303_INT_TRIS TRISAbits.TRISA5
26
#define L3GD20_INT_TRIS TRISAbits.TRISA4
27
#define UART_RX_TRIS    TRISCbits.TRISC5
28
#define UART_TX_TRIS    TRISCbits.TRISC4
29
 
30
#define BTN_CAP_0_TRIS  TRISCbits.TRISC6
31
#define BTN_CAP_1_TRIS  TRISCbits.TRISC7
32
 
33
#define BTN_INT_TRIS    TRISAbits.TRISA2
34
 
35
#define I2C_ADDR_3_TRIS TRISCbits.TRISC3
36
#define I2C_ADDR_2_TRIS TRISCbits.TRISC2
37
#define I2C_ADDR_1_TRIS TRISCbits.TRISC1
38
#define I2C_ADDR_0_TRIS TRISCbits.TRISC0
39
 
40
#define I2C_ADDR_3_WPU  WPUCbits.WPUC3
41
#define I2C_ADDR_2_WPU  WPUCbits.WPUC2
42
#define I2C_ADDR_1_WPU  WPUCbits.WPUC1
43
#define I2C_ADDR_0_WPU  WPUCbits.WPUC0
44
 
45
#define I2C_ADDR_3_LAT  LATCbits.LATC3
46
#define I2C_ADDR_2_LAT  LATCbits.LATC2
47
#define I2C_ADDR_1_LAT  LATCbits.LATC1
48
#define I2C_ADDR_0_LAT  LATCbits.LATC0
49
 
50
#define I2C_1_CLK_TRIS  TRISBbits.TRISB6
51
#define I2C_1_DAT_TRIS  TRISBbits.TRISB4
52
 
53
#define I2C_2_CLK_TRIS  TRISBbits.TRISB7
54
#define I2C_2_DAT_TRIS  TRISBbits.TRISB5
55
// </editor-fold>
56
 
57
#define _XTAL_FREQ      32000000
58
 
59
#define CMD_QUERY_BTN   0x0A
60
#define CMD_SET_LEDS    0x0B
61
 
62
typedef union {
63
    struct {
64
        unsigned BTN_L_N    :1;
65
        unsigned BTN_L_E    :1;
270 Kevin 66
        unsigned BTN_R_E    :1;
260 Kevin 67
        unsigned BTN_R_N    :1;
68
        unsigned BTN_R_S    :1;
69
        unsigned BTN_R_W    :1;
270 Kevin 70
        unsigned BTN_L_S    :1;
71
        unsigned BTN_L_W    :1;
260 Kevin 72
    };
73
    uint8_t w;
74
} BTN_STATUS;
75
 
76
typedef union {
77
    struct {
270 Kevin 78
        uint8_t LED_0;
79
        uint8_t LED_1;
80
        uint8_t LED_2;
81
        uint8_t LED_3;
82
        uint8_t LED_4;
83
        uint8_t LED_5;
84
        uint8_t LED_6;
85
        uint8_t LED_7;
86
        uint8_t LED_N;
87
        uint8_t LED_W;
88
        uint8_t LED_E;
89
        uint8_t LED_S;
90
        uint8_t LED_A;
91
        uint8_t LED_B;
92
        uint8_t LED_C;
93
        uint8_t LED_D;
94
    } single;
95
    uint8_t w[16];
96
} LED_VALUES;
260 Kevin 97
 
270 Kevin 98
void Idle_Animation(void);
260 Kevin 99
 
100
#endif	/* DEFINES_H */
101