-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpic.h
More file actions
120 lines (98 loc) · 3.12 KB
/
pic.h
File metadata and controls
120 lines (98 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*! \file pic.h
\brief PIC includes and configuration
*/
// Standard Includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
// Hardware Includes
#include <pwm.h>
#include <timers.h>
#include <adc.h>
#include <delays.h>
#include <reset.h>
// Include for the PIC
#include <p18F2525.h>
#ifndef __pic_H
#define __pic_H
#define CLOCK_HZ 32000000 /// This is here for proper timing calculation.
#define TIMER0_PRESCALER 256 /// Timer 0 prescaler
#define EEPROM_SIZE 1024 /// Size of EEPROM in bytes
#define FARROM const far rom char /// This is used often to store text in ROM (FLASH)
////////////////////////////////////////////////
// PIN Definitions
////////////////////////////////////////////////
#define PIN0 PORTBbits.RB0
#define PIN1 PORTBbits.RB1
#define PIN2 PORTBbits.RB2
#define PIN3 PORTBbits.RB3
#define PIN4 PORTBbits.RB4
#define PIN5 PORTBbits.RB5
#define PIN6 PORTBbits.RB6
#define Status_LED PORTCbits.RC5
void PIN0_ON(void);
void PIN1_ON(void);
void PIN2_ON(void);
void PIN3_ON(void);
void PIN4_ON(void);
void PIN5_ON(void);
void PIN6_ON(void);
void PIN0_OFF(void);
void PIN1_OFF(void);
void PIN2_OFF(void);
void PIN3_OFF(void);
void PIN4_OFF(void);
void PIN5_OFF(void);
void PIN6_OFF(void);
////////////////////////////////////////////////////
// Command Serial Definitions
////////////////////////////////////////////////////
#define ttyS0 0
#define ttyS1 1
#define ttyS2 2
#define ttyS3 3
#define COM0 0
#define COM1 1
#define COM2 2
#define COM3 3
#define NO_TX_INTERRUPTS 0
#define NO_RX_INTERRUPTS 0
#define TX_INTERRUPTS 1
#define RX_INTERRUPTS 1
#define SEND_NOW 1
#define SEND_LATER 0
#define I2C_MASTER 0
#define I2C_SLAVE 1
#define I2C_INTERRUPTS_ENABLED 1
#define I2C_INTERRUPTS_DISABLED 0
#define DEVICE_SERIAL_PORTS 1
///////////////////////////////////////////////////
/// Structure for holding status information
////////////////////////////////////////////////
typedef struct {
unsigned long Loop_Cycles; /// Configured when calling Configure_Loop. Ticks per loop
unsigned char TimeOut; /// if the timer elapses we have a problem and this is set.
unsigned int Sequence; /// Block number. Number of iterations
unsigned int Loop_Latency; /// This tracks how far off we are on the timing
int Loop_Frequency; ///
} _STATUS_;
extern _STATUS_ Status; /// Global status variable
extern char szText[128]; /// Variable used for creating strings for display. Placed here due to memory limitations
//////////////////////////////////////////
/// Structure for abort codes
//////////////////////////////////////////
typedef struct {
unsigned User:1;
unsigned Example:1;
} _ABORT;
extern _ABORT Abort;
extern char STDERR;
void Initialize_PIC(void);
char BIT_GET(unsigned char *data, char i);
char BIT_SET(unsigned char *data, char i);
char BIT_CLEAR(unsigned char *data,char i);
void Log_Error(FARROM *string);
void CheckReset(char port);
#endif