-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomputeEvents.h
More file actions
120 lines (99 loc) · 4.38 KB
/
computeEvents.h
File metadata and controls
120 lines (99 loc) · 4.38 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
/*
Routines for CBUS FLiM operations - part of CBUS libraries for PIC 18F
This work is licensed under the:
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit:
http://creativecommons.org/licenses/by-nc-sa/4.0/
or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
License summary:
You are free to:
Share, copy and redistribute the material in any medium or format
Adapt, remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Attribution : You must give appropriate credit, provide a link to the license,
and indicate if changes were made. You may do so in any reasonable manner,
but not in any way that suggests the licensor endorses you or your use.
NonCommercial : You may not use the material for commercial purposes. **(see note below)
ShareAlike : If you remix, transform, or build upon the material, you must distribute
your contributions under the same license as the original.
No additional restrictions : You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.
** For commercial use, please contact the original copyright holder(s) to agree licensing terms
**************************************************************************************************************
The FLiM routines have no code or definitions that are specific to any
module, so they can be used to provide FLiM facilities for any module
using these libraries.
*/
/*
* File: mioEvents.h
* Author: Ian
*
* Created on 17 April 2017, 13:14
*/
#ifndef COMPUTEEVENTS_H
#define COMPUTEEVENTS_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* This is where all the module specific actions are defined.
* The following definitions are required by the FLiM code:
* NUM_PRODUCER_ACTIONS, NUM_CONSUMER_ACTIONS, HASH_LENGTH, EVT_NUM,
* EVperEVT, NUM_CONSUMED_EVENTS
*
* For MIO an action is a BYTE (unsigned char). The upper bit is used
* to indicate a sequential action. It would be nice to define:
*
* typedef union {
* unsigned char action_byte;
* struct {
* unsigned char action :7;
* unsigned char sequential :1;
* }
* } ACTION_T;
* but C spec doesn't define what size this would be. Therefore I just use
* BYTE (unsigned char).
*
* The actions are defined below - but remember consumed actions may also have MSB
* set indicating sequential.
*/
#include "cancompute.h"
extern void computeEventsInit(void);
// These are chosen so we don't use too much memory 32*20 = 640 bytes.
// Used to size the hash table used to lookup events in the events2actions table.
#define HASH_LENGTH 32
#define CHAIN_LENGTH 20
#define NUM_EVENTS 100U // must be less than 256 otherwise loops fail. These will have EV#1 with 0..99
#define EVENT_TABLE_WIDTH 1 // Width of eventTable
#define EVperEVT 1 // Max number of EVs per event
#define AT_EVENTS (AT_NV - ((NUM_EVENTS)*sizeof(EventTable))) // Size=NUM_EVENTS * 7 = 700(0x2BC) bytes or 800 (0x320)
// We'll also be using configurable produced events
#define PRODUCED_EVENTS
#define ConsumedActionType BYTE;
#define HAPPENING_BASE 0
#define NUM_HAPPENINGS 256 // Since we are using 255 for SOD this must be beyond the expected NUM_EVENTS
#define ACTION_PRODUCER_SOD 255 // EV#1 with 255 indicates the Produced SOD
extern void processEvent(BYTE eventIndex, BYTE* message);
extern void processActions(void);
extern BYTE findEventByEV1(BYTE ev);
extern BYTE countEvent(BYTE eventNo);
extern BOOL receivedEvent(BYTE eventNo);
extern void doAcdat(void);
extern BYTE sequence2(BYTE event1, BYTE event2);
extern BYTE sequenceMulti(BYTE num, BYTE nvIndex);
typedef enum {
EVENT_STATE_UNKNOWN = 2,
EVENT_STATE_ON = 1,
EVENT_STATE_OFF = 0
} EventState;
extern EventState currentEventState[NUM_EVENTS];
typedef struct {
BYTE eventNoAndOnOff;
WORD time;
} RxBuffer;
#define NUM_BUFFERS 128
#include "events.h"
#ifdef __cplusplus
}
#endif
#endif /* COMPUTEEVENTS_H */