Subversion Repositories Code-Repo

Rev

Rev 290 | Details | Compare with Previous | 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:
290 Kevin 11
#define CEREBOT_32MX7
12
// #define CEREBOT_MX7CK
212 Kevin 13
 
199 Kevin 14
#define CPU_CLOCK_HZ    80000000UL
15
#define PERIPHERAL_CLOCK_HZ 80000000UL
16
#define CPU_CT_HZ       (CPU_CLOCK_HZ/2UL)
17
#define MS_TO_CT_TICKS  (CPU_CLOCK_HZ/2000UL)
18
#define US_TO_CT_TICKS  (CPU_CLOCK_HZ/2000000UL)
19
 
193 Kevin 20
#define ADDRESS_EEPROM 0x50
234 Kevin 21
#define ADDRESS_CONTROLLER_1 0x24
22
#define ADDRESS_CONTROLLER_2 0x25
193 Kevin 23
 
200 Kevin 24
// LED1 = G12, LED2 = G13, LED3 = G14, LED4 = G15 (active high)
193 Kevin 25
#define LED1_TRIS TRISGbits.TRISG12
234 Kevin 26
#define LED1_LAT LATGbits.LATG12
193 Kevin 27
#define LED2_TRIS TRISGbits.TRISG13
234 Kevin 28
#define LED2_LAT LATGbits.LATG13
193 Kevin 29
#define LED3_TRIS TRISGbits.TRISG14
234 Kevin 30
#define LED3_LAT LATGbits.LATG14
193 Kevin 31
#define LED4_TRIS TRISGbits.TRISG15
234 Kevin 32
#define LED4_LAT LATGbits.LATG15
193 Kevin 33
 
237 Kevin 34
// Reset conditions
35
#define RESET_POR   0x01    // Power on reset
36
#define RESET_BOR   0x02    // Brown out reset
37
#define RESET_SWR   0x03    // Software reset
38
#define RESET_WDT   0x04    // Watchdog timer reset
39
#define RESET_PIN   0x05    // MCLR pin reset
40
#define RESET_CFG   0x06    // Config mismatch reset
41
 
42
// Board 'modes' (idle/games/etc)
261 Kevin 43
#define BOARD_MODE_IDLE     0x1
44
#define BOARD_MODE_SNAKE    0x2
45
#define BOARD_MODE_TRON     0x3
46
#define BOARD_MODE_ETHERNET 0x4
237 Kevin 47
 
231 Kevin 48
void Delay_MS(uint32_t delay_ms);
49
void Delay_US(uint32_t delay_us);
237 Kevin 50
uint8_t Get_Reset_Condition(void);
240 Kevin 51
uint8_t Get_Board_State(void);
52
void Reset_Board(uint8_t next_state);
237 Kevin 53
void Idle_Animation_Sequence(void);
199 Kevin 54
 
231 Kevin 55
#endif /* DEFINES_H */