-
Notifications
You must be signed in to change notification settings - Fork 0
/
CEC_LogicalDevice.h
112 lines (89 loc) · 3.16 KB
/
CEC_LogicalDevice.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
#ifndef CEC_H__
#define CEC_H__
#include "CECWire.h"
#define SEND_QUEUE_SIZE 5
class CEC_LogicalDevice : public CEC_Electrical
{
public:
typedef enum {
CDT_TV,
CDT_RECORDING_DEVICE,
CDT_PLAYBACK_DEVICE,
CDT_TUNER,
CDT_AUDIO_SYSTEM,
CDT_OTHER, // Not a real CEC type..
} CEC_DEVICE_TYPE;
public:
CEC_LogicalDevice(int physicalAddress);
void Initialize(CEC_DEVICE_TYPE type);
virtual void Run();
virtual bool TransmitFrame(int targetAddress, unsigned char* buffer, int count);
virtual bool TransmitWait(int targetAddress, unsigned char* buffer, int count);
virtual bool TransmitMsg(int targetAddress, unsigned char message);
virtual bool TransmitMsg(int targetAddress, unsigned char message, unsigned char param1);
virtual bool TransmitMsg(int targetAddress, unsigned char message, unsigned char param1, unsigned char param2);
virtual bool TransmitMsg(int targetAddress, unsigned char message, unsigned char param1, unsigned char param2, unsigned char param3);
virtual bool TransmitMsg(int targetAddress, unsigned char message, unsigned char param1, unsigned char param2, unsigned char param3, unsigned char param4);
virtual bool TransmitMsgQ(int targetAddress, unsigned char message);
virtual bool TransmitMsgQ(int targetAddress, unsigned char message, unsigned char param1);
virtual bool TransmitMsgQ(int targetAddress, unsigned char message, unsigned char param1, unsigned char param2);
virtual bool TransmitMsgQ(int targetAddress, unsigned char message, unsigned char param1, unsigned char param2, unsigned char param3);
virtual bool TransmitMsgQ(int targetAddress, unsigned char message, unsigned char param1, unsigned char param2, unsigned char param3, unsigned char param4);
void SendQueued();
virtual unsigned char getLogical();
virtual int getPhysical();
protected:
virtual bool IsISRTriggered() = 0;
bool ProcessStateMachine(bool* success);
virtual void OnReceiveComplete(unsigned char* buffer, int count);
virtual void OnTransmitComplete(bool);
virtual void OnReady() {;}
virtual void OnReceive(int sourceAddress, int targetAddress, unsigned char* buffer, int count) = 0;
int _logicalAddress;
int _physicalAddress;
CEC_DEVICE_TYPE _deviceType;
short _queuedToSend;
unsigned char* _sendQueue[SEND_QUEUE_SIZE];
char _sendQueueCount[SEND_QUEUE_SIZE];
char _sendQueueDest[SEND_QUEUE_SIZE];
private:
typedef enum {
CLA_TV = 0,
CLA_RECORDING_DEVICE_1,
CLA_RECORDING_DEVICE_2,
CLA_TUNER_1,
CLA_PLAYBACK_DEVICE_1,
CLA_AUDIO_SYSTEM,
CLA_TUNER_2,
CLA_TUNER_3,
CLA_PLAYBACK_DEVICE_2,
CLA_RECORDING_DEVICE_3,
CLA_TUNER_4,
CLA_PLAYBACK_DEVICE_3,
CLA_RESERVED_1,
CLA_RESERVED_2,
CLA_FREE_USE,
CLA_UNREGISTERED,
} CEC_LOGICAL_ADDRESS;
typedef enum {
CEC_IDLE,
CEC_READY,
CEC_ALLOCATE_LOGICAL_ADDRESS,
} CEC_PRIMARY_STATE;
typedef enum {
CEC_XMIT_POLLING_MESSAGE,
CEC_RCV_POLLING_MESSAGE,
} CEC_SECONDARY_STATE;
typedef enum {
} CEC_TERTIARY_STATE;
private:
static int _validLogicalAddresses[6][5];
unsigned long _waitTime;
bool _done;
CEC_PRIMARY_STATE _primaryState;
CEC_SECONDARY_STATE _secondaryState;
int _tertiaryState;
bool _waitingTransmit;
bool _transmitResult;
};
#endif // CEC_H__