-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLEDL.c
More file actions
93 lines (83 loc) · 3.49 KB
/
Copy pathLEDL.c
File metadata and controls
93 lines (83 loc) · 3.49 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
//This file will cover all stack up events
#include <msp430.h>
#include <ctl.h>
#include <ARCbus.h>
#include <Error.h>
#include <SDlib.h>
#include "subsystem.h"
CTL_EVENT_SET_t SYS_evt; // This creates the event struct,change SYS to actual subsystem
//handle subsystem specific commands - this is for I2C commands on the BUS that are not SUB events, so system specific commands.
int SUB_parseCmd(unsigned char src,unsigned char cmd,unsigned char *dat,unsigned short len){
switch(cmd){
default:
return ERR_UNKNOWN_CMD;
}
}
//parse subsystem events
void sub_events(void *p) __toplevel{
unsigned int e,len;
int i;
unsigned char buf[10],*ptr;
extern unsigned char async_addr;
for(;;){
e=ctl_events_wait(CTL_EVENT_WAIT_ANY_EVENTS_WITH_AUTO_CLEAR,&SUB_events,SUB_EV_ALL|SUB_EV_ASYNC_OPEN|SUB_EV_ASYNC_CLOSE,CTL_TIMEOUT_NONE,0);
if(e&SUB_EV_PWR_OFF){ //**************************************** Sent when the subsystem receives the power off command **********************************
//print message
puts("System Powering Down\r");
}
if(e&SUB_EV_PWR_ON){ //***************************************** Sent when the subsystem receives the power on command ************************************
//print message
puts("System Powering Up\r");
}
if(e&SUB_EV_SEND_STAT){ // ************************************* Sent when the subsystem receives the send status command ********************************
//send status
puts("Sending status\r");
//setup packet
//ptr=BUS_cmd_init(buf,CMD_SYS_STAT); // replace CMD_SYS_STAT with actual subsystem ie CMD_COMM_STAT
//send command
//BUS_cmd_tx(BUS_ADDR_CDH,buf,0,0); //sending status contained in "buf" CDH
// FOR TESTING SEND_I2C command!!
}
if(e&SUB_EV_SPI_DAT){ // ************************************** Sent when SPI data is received correctly **************************************************
puts("SPI data rx\r");
}
if(e&SUB_EV_SPI_ERR_CRC){ // ********************************* Sent when SPI transaction was rejected because of busy buffer *****************************
puts("SPI bad CRC\r");
}
if(e&SUB_EV_SPI_ERR_BUSY){
puts("SPI Busy\r");
}
if(e&SUB_EV_ASYNC_OPEN){ // ********************************** An async connection was opened remotely **************************************************
//close async connection, not supported
puts("Async open called");
}
if(e&SUB_EV_ASYNC_CLOSE){ // ********************************** An async connection was closed remotely *************************************************
//close async connection, not supported
puts("Async close called");
}
if(e&SUB_EV_INT_0){ // ************************************** Event on interrupt bus pin 0 *************************************************************
puts("EV 0 has been called.");
}
}
}
void sys_events(void *p) __toplevel{
unsigned int e;
ctl_events_init(&SYS_evt,0); //Initialize Event
for(;;){
// wait for events
e=ctl_events_wait(CTL_EVENT_WAIT_ANY_EVENTS_WITH_AUTO_CLEAR,&SYS_evt,SYS_EVT_ALL,CTL_TIMEOUT_NONE,0);
//*************************************************** Events to be processed for system ****************************************************************
if(e&SYS_EV_1){
puts("SYS_EV_1 called");
}
if(e&SYS_EV_2){
puts("SYS_EV_2 called");
}
if(e&SYS_EV_3){
puts("SYS_EV_3 called");
}
if(e&SYS_EV_4){
puts("SYS_EV_4 called");
}
}
}