Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
199 Kevin 1
// PIC32MX795F512L
2
 
231 Kevin 3
#ifndef DEFINES_H
4
#define	DEFINES_H
5
 
6
#include <xc.h>
7
#include <plib.h>
8
#include <stdint.h>
9
 
212 Kevin 10
// Uncomment ONE of the following:
266 Kevin 11
//#define CEREBOT_32MX7
12
 #define CEREBOT_MX7CK
212 Kevin 13
 
193 Kevin 14
// Power supply must be 5V for proper operation of the board!
15
 
199 Kevin 16
#define CPU_CLOCK_HZ    80000000UL
17
#define PERIPHERAL_CLOCK_HZ 80000000UL
18
#define CPU_CT_HZ       (CPU_CLOCK_HZ/2UL)
19
#define MS_TO_CT_TICKS  (CPU_CLOCK_HZ/2000UL)
20
#define US_TO_CT_TICKS  (CPU_CLOCK_HZ/2000000UL)
21
 
193 Kevin 22
#define ADDRESS_EEPROM 0x50
234 Kevin 23
#define ADDRESS_CONTROLLER_1 0x24
24
#define ADDRESS_CONTROLLER_2 0x25
193 Kevin 25
 
200 Kevin 26
// LED1 = G12, LED2 = G13, LED3 = G14, LED4 = G15 (active high)
193 Kevin 27
#define LED1_TRIS TRISGbits.TRISG12
234 Kevin 28
#define LED1_LAT LATGbits.LATG12
193 Kevin 29
#define LED2_TRIS TRISGbits.TRISG13
234 Kevin 30
#define LED2_LAT LATGbits.LATG13
193 Kevin 31
#define LED3_TRIS TRISGbits.TRISG14
234 Kevin 32
#define LED3_LAT LATGbits.LATG14
193 Kevin 33
#define LED4_TRIS TRISGbits.TRISG15
234 Kevin 34
#define LED4_LAT LATGbits.LATG15
193 Kevin 35
 
237 Kevin 36
// Reset conditions
37
#define RESET_POR   0x01    // Power on reset
38
#define RESET_BOR   0x02    // Brown out reset
39
#define RESET_SWR   0x03    // Software reset
40
#define RESET_WDT   0x04    // Watchdog timer reset
41
#define RESET_PIN   0x05    // MCLR pin reset
42
#define RESET_CFG   0x06    // Config mismatch reset
43
 
44
// Board 'modes' (idle/games/etc)
261 Kevin 45
#define BOARD_MODE_IDLE     0x1
46
#define BOARD_MODE_SNAKE    0x2
47
#define BOARD_MODE_TRON     0x3
48
#define BOARD_MODE_ETHERNET 0x4
237 Kevin 49
 
231 Kevin 50
void Delay_MS(uint32_t delay_ms);
51
void Delay_US(uint32_t delay_us);
237 Kevin 52
uint8_t Get_Reset_Condition(void);
240 Kevin 53
uint8_t Get_Board_State(void);
54
void Reset_Board(uint8_t next_state);
237 Kevin 55
void Idle_Animation_Sequence(void);
199 Kevin 56
 
231 Kevin 57
#endif /* DEFINES_H */