0,0 → 1,101 |
#ifndef DEFINES_H |
#define DEFINES_H |
|
#include <xc.h> |
#include <stdint.h> |
|
// <editor-fold defaultstate="collapsed" desc="I/O Pins"> |
/* Pins Mapping |
* 2 - RA5 - LSM303_DRDY |
* 3 - RA4 - L3GD20_DRDY |
* 5 - RC5 - UART_RX |
* 6 - RC4 - UART TX |
* 7 - RC3 - ADDR_3 |
* 8 - RC6 - BTN_CAP_0 |
* 9 - RC7 - BTN_CAP_1 |
* 10 - RB7 - SCL_2 |
* 11 - RB6 - SCL_1 |
* 12 - RB5 - SDA_2 |
* 13 - RB4 - SDA_1 |
* 14 - RC2 - ADDR_2 |
* 15 - RC1 - ADDR_1 |
* 16 - RC0 - ADDR_0 |
* 17 - RA2 - BTN_INT |
*/ |
#define LSM303_INT_TRIS TRISAbits.TRISA5 |
#define L3GD20_INT_TRIS TRISAbits.TRISA4 |
#define UART_RX_TRIS TRISCbits.TRISC5 |
#define UART_TX_TRIS TRISCbits.TRISC4 |
|
#define BTN_CAP_0_TRIS TRISCbits.TRISC6 |
#define BTN_CAP_1_TRIS TRISCbits.TRISC7 |
|
#define BTN_INT_TRIS TRISAbits.TRISA2 |
|
#define I2C_ADDR_3_TRIS TRISCbits.TRISC3 |
#define I2C_ADDR_2_TRIS TRISCbits.TRISC2 |
#define I2C_ADDR_1_TRIS TRISCbits.TRISC1 |
#define I2C_ADDR_0_TRIS TRISCbits.TRISC0 |
|
#define I2C_ADDR_3_WPU WPUCbits.WPUC3 |
#define I2C_ADDR_2_WPU WPUCbits.WPUC2 |
#define I2C_ADDR_1_WPU WPUCbits.WPUC1 |
#define I2C_ADDR_0_WPU WPUCbits.WPUC0 |
|
#define I2C_ADDR_3_LAT LATCbits.LATC3 |
#define I2C_ADDR_2_LAT LATCbits.LATC2 |
#define I2C_ADDR_1_LAT LATCbits.LATC1 |
#define I2C_ADDR_0_LAT LATCbits.LATC0 |
|
#define I2C_1_CLK_TRIS TRISBbits.TRISB6 |
#define I2C_1_DAT_TRIS TRISBbits.TRISB4 |
|
#define I2C_2_CLK_TRIS TRISBbits.TRISB7 |
#define I2C_2_DAT_TRIS TRISBbits.TRISB5 |
// </editor-fold> |
|
#define _XTAL_FREQ 32000000 |
|
#define CMD_QUERY_BTN 0x0A |
#define CMD_SET_LEDS 0x0B |
|
typedef union { |
struct { |
unsigned BTN_L_N :1; |
unsigned BTN_L_E :1; |
unsigned BTN_R_E :1; |
unsigned BTN_R_N :1; |
unsigned BTN_R_S :1; |
unsigned BTN_R_W :1; |
unsigned BTN_L_S :1; |
unsigned BTN_L_W :1; |
}; |
uint8_t w; |
} BTN_STATUS; |
|
typedef union { |
struct { |
uint8_t LED_0; |
uint8_t LED_1; |
uint8_t LED_2; |
uint8_t LED_3; |
uint8_t LED_4; |
uint8_t LED_5; |
uint8_t LED_6; |
uint8_t LED_7; |
uint8_t LED_N; |
uint8_t LED_W; |
uint8_t LED_E; |
uint8_t LED_S; |
uint8_t LED_A; |
uint8_t LED_B; |
uint8_t LED_C; |
uint8_t LED_D; |
} single; |
uint8_t w[16]; |
} LED_VALUES; |
|
void Idle_Animation(void); |
|
#endif /* DEFINES_H */ |
|