static void appTaskCanReceive(void *pdata) { uint8_t error; canMessage_t msg; /* Install the CAN interrupt handler and start the OS ticker * (must be done in the highest priority task) */ canRxInterrupt(canHandler); osStartTick(); /* * Now execute the main task loop for this task */ while ( true ) { OSSemPend(can1RxSem, 0, &error); msg = can1RxBuf; interfaceLedToggle(D1_LED); OSMutexPend(displayMutex, 0, &error); lcdSetTextPos(2,1); lcdWrite("ID : %08x", msg.id); lcdSetTextPos(2,2); lcdWrite("LEN : %08x", msg.len); lcdSetTextPos(2,3); lcdWrite("DATA_A : %08x", msg.dataA); lcdSetTextPos(2,4); lcdWrite("DATA_B : %08x", msg.dataB); error = OSMutexPost(displayMutex); } }
/* * appTaskEmergencyStop - Emergency stop task * This task handles the emergency stop and stop tasks in * the robot 2 subsystem. */ static void appTaskEmergencyStop(void *pdata) { /* Start the OS ticker * (must be done in the highest priority task) */ osStartTick(); canRxInterrupt(canHandler); while(true) { if(emergencyStop) { ledToggle(USB_LINK_LED); } else if (stopped) { ledToggle(USB_CONNECT_LED); } else { OSTimeDlyHMSM(0,0,0,500); } } }
static void appTaskCANRead(void *pdata) { canRxInterrupt(canHandler); // configure CAN to interrupt on message reception while ( true ) { if (can2RxDone) { // could be handled better with a semaphore can2RxDone = false; lcdSetTextPos(2,1); lcdWrite("ID : %x", can2RxBuffer.id); lcdSetTextPos(2,2); lcdWrite("LEN : %x", can2RxBuffer.len); lcdSetTextPos(2,3); lcdWrite("DATA_A: %x", can2RxBuffer.dataA); lcdSetTextPos(2,4); lcdWrite("DATA_B: %x", can2RxBuffer.dataB); rxCount += 1; } OSTimeDly(100); } }
/* Emergency Stop Task * This task handles the pause, stop and emergency stop functions * in the system. */ static void appTaskEmergencyStop(void *pdata) { // Start the OS ticker osStartTick(); canRxInterrupt(canHandler); while(true) { if(emergencyStop) { ledToggle(USB_LINK_LED); conveyorSetState(CONVEYOR_OFF); } else if(paused){ pausedState = conveyorGetState(); conveyorSetState(CONVEYOR_OFF); } else if (stopped){ ledToggle(USB_CONNECT_LED); } else{ OSTimeDlyHMSM(0,0,0,500); } } }