Rock, Paper, Scissors game - remote controller

Dependencies:   fsl_phy_mcr20a fsl_smac mbed-rtos mbed

Fork of mcr20_RPS_GameController by Freescale

Committer:
mnorman4
Date:
Tue Nov 17 17:15:28 2015 +0000
Revision:
0:7654345263e0
Initial commit of Rock, Paper, Scissors game remote control

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mnorman4 0:7654345263e0 1 #include "mbed.h"
mnorman4 0:7654345263e0 2 #include "rtos.h"
mnorman4 0:7654345263e0 3 #include "Phy.h"
mnorman4 0:7654345263e0 4 #include "SMAC_Interface.h"
mnorman4 0:7654345263e0 5 #include "SMAC_Config.h"
mnorman4 0:7654345263e0 6 #include "MemManager.h"
mnorman4 0:7654345263e0 7 #include "circular_buffer.h"
mnorman4 0:7654345263e0 8
mnorman4 0:7654345263e0 9 /* Hardware Resources */
mnorman4 0:7654345263e0 10 /* LEDs */
mnorman4 0:7654345263e0 11 DigitalOut k64f_led_red(LED_RED, 1);
mnorman4 0:7654345263e0 12 DigitalOut k64f_led_green(LED_GREEN, 1);
mnorman4 0:7654345263e0 13 DigitalOut k64f_led_blue(LED_BLUE, 1);
mnorman4 0:7654345263e0 14 DigitalOut cr20a_led_red(PTC11, 1);
mnorman4 0:7654345263e0 15 DigitalOut cr20a_led_green(PTC10, 1);
mnorman4 0:7654345263e0 16 DigitalOut cr20a_led_blue(PTB11, 1);
mnorman4 0:7654345263e0 17
mnorman4 0:7654345263e0 18 #define LED_ON (0)
mnorman4 0:7654345263e0 19 #define LED_OFF (1)
mnorman4 0:7654345263e0 20
mnorman4 0:7654345263e0 21 /* Pushbuttons */
mnorman4 0:7654345263e0 22 InterruptIn k64f_sw2(SW2);
mnorman4 0:7654345263e0 23 InterruptIn k64f_sw3(SW3);
mnorman4 0:7654345263e0 24 InterruptIn cr20a_sw1(PTB23);
mnorman4 0:7654345263e0 25 InterruptIn cr20a_sw2(PTA1);
mnorman4 0:7654345263e0 26 InterruptIn cr20a_sw3(PTC4);
mnorman4 0:7654345263e0 27
mnorman4 0:7654345263e0 28 #define gPushbutton_K64F_SW2 (1<<0)
mnorman4 0:7654345263e0 29 #define gPushbutton_K64F_SW3 (1<<1)
mnorman4 0:7654345263e0 30 #define gPushbutton_CR20A_SW1 (1<<2)
mnorman4 0:7654345263e0 31 #define gPushbutton_CR20A_SW2 (1<<3)
mnorman4 0:7654345263e0 32 #define gPushbutton_CR20A_SW3 (1<<4)
mnorman4 0:7654345263e0 33
mnorman4 0:7654345263e0 34 #define gResultWin (1<<0)
mnorman4 0:7654345263e0 35 #define gResultLose (1<<1)
mnorman4 0:7654345263e0 36 #define gResultDraw (1<<2)
mnorman4 0:7654345263e0 37
mnorman4 0:7654345263e0 38 /* OpenSDA Serial Port (UART) */
mnorman4 0:7654345263e0 39 Serial uart(USBTX, USBRX);
mnorman4 0:7654345263e0 40 CircularBuffer uartBuf;
mnorman4 0:7654345263e0 41 #define gDefaultBaudRate_UART_c 115200UL
mnorman4 0:7654345263e0 42
mnorman4 0:7654345263e0 43 /* Event Flags */
mnorman4 0:7654345263e0 44 #define gMcps_Cnf_EVENT_c (1<<1)
mnorman4 0:7654345263e0 45 #define gMcps_Ind_EVENT_c (1<<2)
mnorman4 0:7654345263e0 46 #define gMlme_EdCnf_EVENT_c (1<<3)
mnorman4 0:7654345263e0 47 #define gMlme_CcaCnf_EVENT_c (1<<4)
mnorman4 0:7654345263e0 48 #define gMlme_TimeoutInd_EVENT_c (1<<5)
mnorman4 0:7654345263e0 49 #define gWUSelf_EVENT_c (1<<6)
mnorman4 0:7654345263e0 50
mnorman4 0:7654345263e0 51 #ifdef VERBOSE
mnorman4 0:7654345263e0 52 static bool_t bCCAFailed;
mnorman4 0:7654345263e0 53 static bool_t bACKFailed;
mnorman4 0:7654345263e0 54 #endif
mnorman4 0:7654345263e0 55
mnorman4 0:7654345263e0 56 uint32_t gTaskEventFlags;
mnorman4 0:7654345263e0 57 static uint8_t gau8TxDataBuffer[gMaxSmacSDULength_c + sizeof(rxPacket_t)];
mnorman4 0:7654345263e0 58 txPacket_t *gAppTxPacket;
mnorman4 0:7654345263e0 59 rxPacket_t *gAppRxPacket;
mnorman4 0:7654345263e0 60 static txContextConfig_t txConfigContext;
mnorman4 0:7654345263e0 61
mnorman4 0:7654345263e0 62 void InitProject(void);
mnorman4 0:7654345263e0 63 void InitApp(void);
mnorman4 0:7654345263e0 64
mnorman4 0:7654345263e0 65 extern smacErrors_t smacToAppMlmeSap(smacToAppMlmeMessage_t* pMsg, instanceId_t instance);
mnorman4 0:7654345263e0 66 extern smacErrors_t smacToAppMcpsSap(smacToAppDataMessage_t* pMsg, instanceId_t instance);
mnorman4 0:7654345263e0 67
mnorman4 0:7654345263e0 68 osThreadId PushbuttonThreadID;
mnorman4 0:7654345263e0 69 osThreadId ResultThreadID;
mnorman4 0:7654345263e0 70 osThreadId EventsThreadID;
mnorman4 0:7654345263e0 71 osThreadId MainThreadID;
mnorman4 0:7654345263e0 72
mnorman4 0:7654345263e0 73 void k64f_sw2_press(void) { osSignalSet(PushbuttonThreadID, gPushbutton_K64F_SW2); }
mnorman4 0:7654345263e0 74 void k64f_sw3_press(void) { osSignalSet(PushbuttonThreadID, gPushbutton_K64F_SW3); }
mnorman4 0:7654345263e0 75 void cr20a_sw1_press(void) { osSignalSet(PushbuttonThreadID, gPushbutton_CR20A_SW1); }
mnorman4 0:7654345263e0 76 void cr20a_sw2_press(void) { osSignalSet(PushbuttonThreadID, gPushbutton_CR20A_SW2); }
mnorman4 0:7654345263e0 77 void cr20a_sw3_press(void) { osSignalSet(PushbuttonThreadID, gPushbutton_CR20A_SW3); }
mnorman4 0:7654345263e0 78
mnorman4 0:7654345263e0 79 void HeartbeatThread(void const *argument)
mnorman4 0:7654345263e0 80 {
mnorman4 0:7654345263e0 81 while (true) {
mnorman4 0:7654345263e0 82 k64f_led_green = LED_ON;
mnorman4 0:7654345263e0 83 Thread::wait(50);
mnorman4 0:7654345263e0 84 k64f_led_green = LED_OFF;
mnorman4 0:7654345263e0 85 Thread::wait(1950);
mnorman4 0:7654345263e0 86 }
mnorman4 0:7654345263e0 87 }
mnorman4 0:7654345263e0 88
mnorman4 0:7654345263e0 89 void ResultThread(void const *argument)
mnorman4 0:7654345263e0 90 {
mnorman4 0:7654345263e0 91 ResultThreadID = Thread::gettid();
mnorman4 0:7654345263e0 92 osEvent event;
mnorman4 0:7654345263e0 93 DigitalOut *led;
mnorman4 0:7654345263e0 94
mnorman4 0:7654345263e0 95 while (true) {
mnorman4 0:7654345263e0 96 event = Thread::signal_wait(0, osWaitForever);
mnorman4 0:7654345263e0 97 if (event.value.signals & gResultWin) {
mnorman4 0:7654345263e0 98 led = &cr20a_led_green;
mnorman4 0:7654345263e0 99 }
mnorman4 0:7654345263e0 100 else if (event.value.signals & gResultDraw) {
mnorman4 0:7654345263e0 101 led = &cr20a_led_blue;
mnorman4 0:7654345263e0 102 }
mnorman4 0:7654345263e0 103 else {
mnorman4 0:7654345263e0 104 led = &cr20a_led_red;
mnorman4 0:7654345263e0 105 }
mnorman4 0:7654345263e0 106 *led = LED_ON;
mnorman4 0:7654345263e0 107 Thread::wait(200);
mnorman4 0:7654345263e0 108 *led = LED_OFF;
mnorman4 0:7654345263e0 109 Thread::wait(200);
mnorman4 0:7654345263e0 110 *led = LED_ON;
mnorman4 0:7654345263e0 111 Thread::wait(200);
mnorman4 0:7654345263e0 112 *led = LED_OFF;
mnorman4 0:7654345263e0 113 Thread::wait(200);
mnorman4 0:7654345263e0 114 *led = LED_ON;
mnorman4 0:7654345263e0 115 Thread::wait(200);
mnorman4 0:7654345263e0 116 *led = LED_OFF;
mnorman4 0:7654345263e0 117 Thread::wait(200);
mnorman4 0:7654345263e0 118 *led = LED_ON;
mnorman4 0:7654345263e0 119 Thread::wait(200);
mnorman4 0:7654345263e0 120 *led = LED_OFF;
mnorman4 0:7654345263e0 121 Thread::wait(200);
mnorman4 0:7654345263e0 122 *led = LED_ON;
mnorman4 0:7654345263e0 123 Thread::wait(200);
mnorman4 0:7654345263e0 124 *led = LED_OFF;
mnorman4 0:7654345263e0 125 Thread::wait(200);
mnorman4 0:7654345263e0 126 *led = LED_ON;
mnorman4 0:7654345263e0 127 Thread::wait(200);
mnorman4 0:7654345263e0 128 *led = LED_OFF;
mnorman4 0:7654345263e0 129 }
mnorman4 0:7654345263e0 130 }
mnorman4 0:7654345263e0 131
mnorman4 0:7654345263e0 132 /* Constants used to build the single byte game selection and results */
mnorman4 0:7654345263e0 133 char const PlayerA = 0xA0;
mnorman4 0:7654345263e0 134 char const PlayerB = 0xB0;
mnorman4 0:7654345263e0 135 char const Player = PlayerB;
mnorman4 0:7654345263e0 136 char const Rock = 0x01;
mnorman4 0:7654345263e0 137 char const Paper = 0x02;
mnorman4 0:7654345263e0 138 char const Scissors = 0x03;
mnorman4 0:7654345263e0 139 char const Winner = 0x08;
mnorman4 0:7654345263e0 140 char const Loser = 0x0F;
mnorman4 0:7654345263e0 141 char const Draw = 0xFF;
mnorman4 0:7654345263e0 142
mnorman4 0:7654345263e0 143 void PushbuttonThread(void const *argument)
mnorman4 0:7654345263e0 144 {
mnorman4 0:7654345263e0 145 PushbuttonThreadID = Thread::gettid();
mnorman4 0:7654345263e0 146 osEvent event;
mnorman4 0:7654345263e0 147
mnorman4 0:7654345263e0 148 while (true) {
mnorman4 0:7654345263e0 149 event = Thread::signal_wait(0, osWaitForever);
mnorman4 0:7654345263e0 150 if (event.value.signals & gPushbutton_CR20A_SW1) {
mnorman4 0:7654345263e0 151 (void)uartBuf.addToBuffer(uint8_t(Player | Rock));
mnorman4 0:7654345263e0 152 }
mnorman4 0:7654345263e0 153 if (event.value.signals & gPushbutton_CR20A_SW2) {
mnorman4 0:7654345263e0 154 (void)uartBuf.addToBuffer(uint8_t(Player | Paper));
mnorman4 0:7654345263e0 155 }
mnorman4 0:7654345263e0 156 if (event.value.signals & gPushbutton_CR20A_SW3) {
mnorman4 0:7654345263e0 157 (void)uartBuf.addToBuffer(uint8_t(Player | Scissors));
mnorman4 0:7654345263e0 158 }
mnorman4 0:7654345263e0 159 if (uartBuf.getCount())
mnorman4 0:7654345263e0 160 {
mnorman4 0:7654345263e0 161 gTaskEventFlags |= gWUSelf_EVENT_c;
mnorman4 0:7654345263e0 162 osSignalSet(EventsThreadID, 0x1);
mnorman4 0:7654345263e0 163 }
mnorman4 0:7654345263e0 164
mnorman4 0:7654345263e0 165 Thread::wait(500);
mnorman4 0:7654345263e0 166 osSignalClear(PushbuttonThreadID, 0xFF);
mnorman4 0:7654345263e0 167 }
mnorman4 0:7654345263e0 168 }
mnorman4 0:7654345263e0 169
mnorman4 0:7654345263e0 170 void CheckReceivedData (uint8_t data)
mnorman4 0:7654345263e0 171 {
mnorman4 0:7654345263e0 172 uint8_t player = (data & 0xF0);
mnorman4 0:7654345263e0 173 uint8_t result = (data & 0x0F);
mnorman4 0:7654345263e0 174
mnorman4 0:7654345263e0 175 if (result == Winner) {
mnorman4 0:7654345263e0 176 if (player == Player)
mnorman4 0:7654345263e0 177 osSignalSet(ResultThreadID, gResultWin);
mnorman4 0:7654345263e0 178 else
mnorman4 0:7654345263e0 179 osSignalSet(ResultThreadID, gResultLose);
mnorman4 0:7654345263e0 180 }
mnorman4 0:7654345263e0 181 if (data == Draw)
mnorman4 0:7654345263e0 182 osSignalSet(ResultThreadID, gResultDraw);
mnorman4 0:7654345263e0 183 }
mnorman4 0:7654345263e0 184
mnorman4 0:7654345263e0 185 void EventsThread(void const *argument)
mnorman4 0:7654345263e0 186 {
mnorman4 0:7654345263e0 187 EventsThreadID = Thread::gettid();
mnorman4 0:7654345263e0 188 uint8_t rcvd = 0, c = 0;
mnorman4 0:7654345263e0 189
mnorman4 0:7654345263e0 190 while (true)
mnorman4 0:7654345263e0 191 {
mnorman4 0:7654345263e0 192 Thread::signal_wait(0x1);
mnorman4 0:7654345263e0 193 if(gMcps_Cnf_EVENT_c == (gTaskEventFlags & gMcps_Cnf_EVENT_c))
mnorman4 0:7654345263e0 194 {
mnorman4 0:7654345263e0 195 MLMERXEnableRequest(gAppRxPacket, 0);
mnorman4 0:7654345263e0 196 }
mnorman4 0:7654345263e0 197 if(gMcps_Ind_EVENT_c == (gTaskEventFlags & gMcps_Ind_EVENT_c))
mnorman4 0:7654345263e0 198 {
mnorman4 0:7654345263e0 199 rcvd = gAppRxPacket->smacPdu.smacPdu[0];
mnorman4 0:7654345263e0 200 //uart.printf("%c", rcvd);
mnorman4 0:7654345263e0 201 CheckReceivedData(rcvd);
mnorman4 0:7654345263e0 202 MLMERXEnableRequest(gAppRxPacket, 0);
mnorman4 0:7654345263e0 203 }
mnorman4 0:7654345263e0 204 if(gMlme_TimeoutInd_EVENT_c == (gTaskEventFlags & gMlme_TimeoutInd_EVENT_c))
mnorman4 0:7654345263e0 205 {
mnorman4 0:7654345263e0 206 uart.printf("MlmeTimeoutInd: \r\n");
mnorman4 0:7654345263e0 207 }
mnorman4 0:7654345263e0 208 if(gMlme_EdCnf_EVENT_c == (gTaskEventFlags & gMlme_EdCnf_EVENT_c))
mnorman4 0:7654345263e0 209 {
mnorman4 0:7654345263e0 210 uart.printf("EdCnf: \r\n");
mnorman4 0:7654345263e0 211 }
mnorman4 0:7654345263e0 212 if(gMlme_CcaCnf_EVENT_c == (gTaskEventFlags & gMlme_CcaCnf_EVENT_c))
mnorman4 0:7654345263e0 213 {
mnorman4 0:7654345263e0 214 uart.printf("CcaCnf: \r\n");
mnorman4 0:7654345263e0 215 }
mnorman4 0:7654345263e0 216 if(gWUSelf_EVENT_c == (gTaskEventFlags & gWUSelf_EVENT_c))
mnorman4 0:7654345263e0 217 {
mnorman4 0:7654345263e0 218 if (buffer_Ok_c == uartBuf.getFromBuffer(&c))
mnorman4 0:7654345263e0 219 {
mnorman4 0:7654345263e0 220 gAppTxPacket->smacPdu.smacPdu[0] = c;
mnorman4 0:7654345263e0 221 gAppTxPacket->u8DataLength = 1;
mnorman4 0:7654345263e0 222 (void)MLMERXDisableRequest();
mnorman4 0:7654345263e0 223 (void)MCPSDataRequest(gAppTxPacket);
mnorman4 0:7654345263e0 224 }
mnorman4 0:7654345263e0 225 }
mnorman4 0:7654345263e0 226
mnorman4 0:7654345263e0 227 gTaskEventFlags = 0;
mnorman4 0:7654345263e0 228 }
mnorman4 0:7654345263e0 229 }
mnorman4 0:7654345263e0 230
mnorman4 0:7654345263e0 231 int main()
mnorman4 0:7654345263e0 232 {
mnorman4 0:7654345263e0 233 MEM_Init();
mnorman4 0:7654345263e0 234
mnorman4 0:7654345263e0 235 /* Init the threads */
mnorman4 0:7654345263e0 236 Thread heartbeat(HeartbeatThread);
mnorman4 0:7654345263e0 237 Thread pushbuttons(PushbuttonThread);
mnorman4 0:7654345263e0 238 Thread events(EventsThread);
mnorman4 0:7654345263e0 239 Thread result(ResultThread);
mnorman4 0:7654345263e0 240 MainThreadID = Thread::gettid();
mnorman4 0:7654345263e0 241
mnorman4 0:7654345263e0 242 Phy_Init();
mnorman4 0:7654345263e0 243 InitSmac();
mnorman4 0:7654345263e0 244
mnorman4 0:7654345263e0 245 //Tell SMAC who to call when it needs to pass a message to the application thread.
mnorman4 0:7654345263e0 246 Smac_RegisterSapHandlers((SMAC_APP_MCPS_SapHandler_t)smacToAppMcpsSap,(SMAC_APP_MLME_SapHandler_t)smacToAppMlmeSap,0);
mnorman4 0:7654345263e0 247
mnorman4 0:7654345263e0 248 InitApp();
mnorman4 0:7654345263e0 249
mnorman4 0:7654345263e0 250 if (Player == 0xA0)
mnorman4 0:7654345263e0 251 uart.printf("Player A is online\r\n");
mnorman4 0:7654345263e0 252 else
mnorman4 0:7654345263e0 253 uart.printf("Player B is online\r\n");
mnorman4 0:7654345263e0 254
mnorman4 0:7654345263e0 255 while (true)
mnorman4 0:7654345263e0 256 {
mnorman4 0:7654345263e0 257 Thread::yield();
mnorman4 0:7654345263e0 258 }
mnorman4 0:7654345263e0 259 }
mnorman4 0:7654345263e0 260
mnorman4 0:7654345263e0 261 void InitApp()
mnorman4 0:7654345263e0 262 {
mnorman4 0:7654345263e0 263 gAppTxPacket = (txPacket_t*)gau8TxDataBuffer; //Map TX packet to buffer
mnorman4 0:7654345263e0 264 gAppRxPacket = (rxPacket_t*)MEM_BufferAlloc(gMaxSmacSDULength_c + sizeof(rxPacket_t));
mnorman4 0:7654345263e0 265
mnorman4 0:7654345263e0 266 InitProject();
mnorman4 0:7654345263e0 267
mnorman4 0:7654345263e0 268 SMACFillHeader(&(gAppTxPacket->smacHeader), gDefaultAddress_c);
mnorman4 0:7654345263e0 269
mnorman4 0:7654345263e0 270 (void)MLMEPAOutputAdjust(gDefaultOutputPower_c);
mnorman4 0:7654345263e0 271 (void)MLMESetChannelRequest(gDefaultChannelNumber_c);
mnorman4 0:7654345263e0 272 (void)MLMEConfigureTxContext(&txConfigContext);
mnorman4 0:7654345263e0 273 //AppDelayTmr = TMR_AllocateTimer();
mnorman4 0:7654345263e0 274 gAppRxPacket->u8MaxDataLength = gMaxSmacSDULength_c;
mnorman4 0:7654345263e0 275 (void)MLMERXEnableRequest(gAppRxPacket, 0);
mnorman4 0:7654345263e0 276 }
mnorman4 0:7654345263e0 277
mnorman4 0:7654345263e0 278 /* (Management) Sap handler for managing timeout indication and ED confirm
mnorman4 0:7654345263e0 279 This is running in INTERRUPT context, so need to send messages to one of the task */
mnorman4 0:7654345263e0 280 smacErrors_t smacToAppMlmeSap(smacToAppMlmeMessage_t* pMsg, instanceId_t instance)
mnorman4 0:7654345263e0 281 {
mnorman4 0:7654345263e0 282 switch(pMsg->msgType)
mnorman4 0:7654345263e0 283 {
mnorman4 0:7654345263e0 284 case gMlmeEdCnf_c:
mnorman4 0:7654345263e0 285 gTaskEventFlags |= gMlme_EdCnf_EVENT_c;
mnorman4 0:7654345263e0 286 break;
mnorman4 0:7654345263e0 287 case gMlmeCcaCnf_c:
mnorman4 0:7654345263e0 288 gTaskEventFlags |= gMlme_CcaCnf_EVENT_c;
mnorman4 0:7654345263e0 289 break;
mnorman4 0:7654345263e0 290 case gMlmeTimeoutInd_c:
mnorman4 0:7654345263e0 291 gTaskEventFlags |= gMlme_TimeoutInd_EVENT_c;
mnorman4 0:7654345263e0 292 break;
mnorman4 0:7654345263e0 293 default:
mnorman4 0:7654345263e0 294 break;
mnorman4 0:7654345263e0 295 }
mnorman4 0:7654345263e0 296 osSignalSet(EventsThreadID, 0x1);
mnorman4 0:7654345263e0 297 MEM_BufferFree(pMsg);
mnorman4 0:7654345263e0 298 return gErrorNoError_c;
mnorman4 0:7654345263e0 299 }
mnorman4 0:7654345263e0 300
mnorman4 0:7654345263e0 301 /* (Data) Sap handler for managing data confirm and data indication
mnorman4 0:7654345263e0 302 This is running in INTERRUPT context, so need to send messages to one of the task */
mnorman4 0:7654345263e0 303 smacErrors_t smacToAppMcpsSap(smacToAppDataMessage_t* pMsg, instanceId_t instance)
mnorman4 0:7654345263e0 304 {
mnorman4 0:7654345263e0 305 switch(pMsg->msgType)
mnorman4 0:7654345263e0 306 {
mnorman4 0:7654345263e0 307 case gMcpsDataInd_c:
mnorman4 0:7654345263e0 308 if(pMsg->msgData.dataInd.pRxPacket->rxStatus == rxSuccessStatus_c)
mnorman4 0:7654345263e0 309 {
mnorman4 0:7654345263e0 310 gTaskEventFlags |= gMcps_Ind_EVENT_c;
mnorman4 0:7654345263e0 311 }
mnorman4 0:7654345263e0 312 break;
mnorman4 0:7654345263e0 313
mnorman4 0:7654345263e0 314 case gMcpsDataCnf_c:
mnorman4 0:7654345263e0 315 #ifdef VERBOSE
mnorman4 0:7654345263e0 316 if(pMsg->msgData.dataCnf.status == gErrorChannelBusy_c)
mnorman4 0:7654345263e0 317 {
mnorman4 0:7654345263e0 318 bCCAFailed = TRUE;
mnorman4 0:7654345263e0 319 }
mnorman4 0:7654345263e0 320
mnorman4 0:7654345263e0 321 if(pMsg->msgData.dataCnf.status == gErrorNoAck_c)
mnorman4 0:7654345263e0 322 {
mnorman4 0:7654345263e0 323 bACKFailed = TRUE;
mnorman4 0:7654345263e0 324 }
mnorman4 0:7654345263e0 325 #endif
mnorman4 0:7654345263e0 326
mnorman4 0:7654345263e0 327 gTaskEventFlags |= gMcps_Cnf_EVENT_c;
mnorman4 0:7654345263e0 328 break;
mnorman4 0:7654345263e0 329
mnorman4 0:7654345263e0 330 default:
mnorman4 0:7654345263e0 331 break;
mnorman4 0:7654345263e0 332 }
mnorman4 0:7654345263e0 333 osSignalSet(EventsThreadID, 0x1);
mnorman4 0:7654345263e0 334 MEM_BufferFree(pMsg);
mnorman4 0:7654345263e0 335
mnorman4 0:7654345263e0 336 return gErrorNoError_c;
mnorman4 0:7654345263e0 337 }
mnorman4 0:7654345263e0 338
mnorman4 0:7654345263e0 339 void InitProject(void)
mnorman4 0:7654345263e0 340 {
mnorman4 0:7654345263e0 341 /*Global Data init*/
mnorman4 0:7654345263e0 342 #ifdef VERBOSE
mnorman4 0:7654345263e0 343 bACKFailed = FALSE;
mnorman4 0:7654345263e0 344 bCCAFailed = FALSE;
mnorman4 0:7654345263e0 345 #endif
mnorman4 0:7654345263e0 346
mnorman4 0:7654345263e0 347 gTaskEventFlags = 0;
mnorman4 0:7654345263e0 348
mnorman4 0:7654345263e0 349 txConfigContext.autoAck = FALSE;
mnorman4 0:7654345263e0 350 txConfigContext.ccaBeforeTx = FALSE;
mnorman4 0:7654345263e0 351 txConfigContext.retryCountAckFail = 0;
mnorman4 0:7654345263e0 352 txConfigContext.retryCountCCAFail = 0;
mnorman4 0:7654345263e0 353
mnorman4 0:7654345263e0 354 /* Setup UART */
mnorman4 0:7654345263e0 355 uart.baud(gDefaultBaudRate_UART_c);
mnorman4 0:7654345263e0 356
mnorman4 0:7654345263e0 357 /* Setup Pushbutton Interrupt Callbacks */
mnorman4 0:7654345263e0 358 k64f_sw2.fall(&k64f_sw2_press);
mnorman4 0:7654345263e0 359 k64f_sw3.fall(&k64f_sw3_press);
mnorman4 0:7654345263e0 360 cr20a_sw1.fall(&cr20a_sw1_press);
mnorman4 0:7654345263e0 361 cr20a_sw2.fall(&cr20a_sw2_press);
mnorman4 0:7654345263e0 362 cr20a_sw3.fall(&cr20a_sw3_press);
mnorman4 0:7654345263e0 363 }