-
Notifications
You must be signed in to change notification settings - Fork 8
/
DSC_Globals.h
126 lines (107 loc) · 3.89 KB
/
DSC_Globals.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
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
121
122
123
124
125
126
/* DSC_Globals.h
* Part of DSC Library
* See COPYRIGHT.txt and LICENSE.txt for more information.
*
* It contains definition of global items which are used by the DSC class.
* They have to be declared global in scope because they are accessed by
* the ISR and you cannot pass parameters nor objects to an ISR routine.
*
* In general, applications would not include this file.
*/
#ifndef DSC_Globals_h
#define DSC_Globals_h
#include <Arduino.h>
#include "DSC_Constants.h"
/*
* OLD STUFF - In case I need it
* Timing data is stored in a buffer by the receiver object. It is an array of
* uint16_t that should be at least 100 entries as defined by this default below.
* However some IR sequences will require longer buffers especially those used for
* air conditioner controls. In general we recommend you keep this value below 255
* so that the index into the array can remain 8 bits. This library can handle larger
* arrays however it will make your code longer in addition to taking more RAM.
#define PNL_BUF_LENGTH 128
#define KPD_BUF_LENGTH 128
#if (PNL_BUF_LENGTH > 255)
typedef uint16_t bufIndex_t;
#else
typedef uint8_t bufIndex_t;
#endif
#if (KPD_BUF_LENGTH > 255)
typedef uint16_t bufIndex_t;
#else
typedef uint8_t bufIndex_t;
#endif
*/
// ----- Input/Output Pins -----
extern byte CLK; // Keybus Yellow (Clock Line)
extern byte DTA_IN; // Keybus Green (Data Line via V divider)
extern byte DTA_OUT; // Keybus Green Output (Data Line through driver)
extern byte LED; // LED pin on the arduino
/*
* OLD STUFF - In case I need it
* Receiver states. This previously was enum but changed it to uint8_t
* to guarantee it was a single atomic 8-bit value.
#define STATE_UNKNOWN 0
#define STATE_NEW_WORD_MARK 1
#define STATE_TIMING_MARK 2
#define STATE_TIMING_SPACE 3
#define STATE_FINISHED 4
#define STATE_RUNNING 5
typedef uint8_t currentState_t;
*/
/* The structure contains information used by the ISR routine. Because we cannot
* pass parameters to an ISR, vars must be global. Values which can be changed by
* the ISR but are accessed outside the ISR must be volatile (for the most part)
*/
typedef struct
{
// ----- Time Variables -----
unsigned long lastStatus;
unsigned long lastData;
// Volatile time variables, modified within ISR
volatile unsigned long intervalTimer;
volatile unsigned long clockChange;
volatile unsigned long lastChange;
volatile unsigned long lastRise; // NOT USED
volatile unsigned long lastFall; // NOT USED
// ----- Keybus Bit/Byte Counter -----
volatile byte bitCount;
}
timing_t;
extern timing_t timing; //declared in DSC.cpp
typedef struct
{
// ----- Keybus Word Command Var -----
byte cmd;
// ----- Keybus Bit/Byte Counters -----
volatile byte bit;
volatile byte elem; // Using "elem" as element instead of "byte"
// ----- Keybus Byte Arrays -----
volatile byte newArray[ARR_SIZE];
volatile byte array[ARR_SIZE];
volatile byte oldArray[ARR_SIZE];
// ----- Keybus Byte Lengths -----
volatile byte newArrayLen;
volatile byte arrayLen; //oldLen;
}
keybus_t;
extern keybus_t panel; //declared in DSC.cpp
extern keybus_t keypad; //declared in DSC.cpp
typedef struct
{
// ----- Send wait/readiness status -----
volatile bool waiting;
volatile bool ready;
volatile bool sent;
// ----- Keybus Bit/Byte Counters -----
volatile byte bit;
volatile byte elem; // Using "elem" as element instead of "byte"
// ----- Keybus Byte Arrays -----
volatile byte array[ARR_SIZE];
// ----- Keybus Byte Lengths -----
volatile byte arrayLen;
}
keysend_t;
extern keysend_t keysend; //declared in DSC.cpp
#endif