-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
71 lines (57 loc) · 1.35 KB
/
common.h
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
/*
* File: common.h
* Author: Bryan
*
* Created on March 16, 2016, 12:48 PM
*/
#ifndef COMMON_H
#define COMMON_H
//#define DEBUG_I2C
#define GLCD
#define FCY (7370000 / 2)
/* Common headers */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <xc.h>
#include <libpic30.h>
/* GLCD Library Headers */
#if defined(GLCD)
#include "glcd/glcd.h"
#include "glcd/font5x7.h"
#endif
/* Define shorthanded named types */
typedef unsigned char byte;
typedef unsigned short uint16;
typedef signed short int16;
typedef unsigned long uint32;
typedef unsigned long long uint64;
typedef signed long long int64;
typedef signed long int32;
/* Define debug string bugger */
#define DEBUG_BUFFER_SIZE 60
extern char debug[DEBUG_BUFFER_SIZE];
void empty(char * x, ...);
const char * byte_to_binary(int x);
void delay_routine(void);
extern int debugWriteLcd;
#ifdef DEBUG
#ifdef GLCD
#define DEBUG_WRITE(format, args...) \
if (debugWriteLcd) { \
sprintf(debug, format , ##args); \
GLCD_WRITE(debug); }
#else
#define DEBUG_WRITE(format, args...) printf(format , ##args)
#endif
#else
#define DEBUG_WRITE(format, args...) empty(format, ##args)
#endif //DEBUG
#ifdef DEBUG_I2C
#define I2CDebug(x, y...) {\
DEBUG_WRITE(x , ##y); \
delay_routine(); }
#else
#define I2CDebug(x, args...) empty(x , ##args)
#endif // DEBUG_I2C
#endif /* COMMON_H */