bool DispatchStage::execute(InstRef &IR) { const InstrDesc &Desc = IR.getInstruction()->getDesc(); if (!isAvailable(Desc.NumMicroOps) || !canDispatch(IR)) return false; dispatch(IR); return true; }
DWORD canReceiveLoop(CAN_PORT port) { Message m; while(((CANPort*)port)->used) { if(m_canReceive(((CANPort*)port)->fd, &m) != 0) break; EnterMutex(); canDispatch(((CANPort*)port)->d, &m); LeaveMutex(); } return 0; }
void can_irq_handler(void) /****************************************************************************** CAN Interrupt ******************************************************************************/ { volatile unsigned int status; static Message m = Message_Initializer; // contain a CAN message status = AT91F_CAN_GetStatus(AT91C_BASE_CAN) & AT91F_CAN_GetInterruptMaskStatus(AT91C_BASE_CAN); if(status & RX_INT_MSK) { // Rx Interrupt if (canReceive(&m)) // a message received canDispatch(&ObjDict_Data, &m); // process it } }
int main(void) { sys_init(); // Initialize system canInit(CAN_BAUDRATE); // Initialize the CANopen bus initTimer(); // Start timer for the CANopen stack nodeID = read_bcd(); // Read node ID first setNodeId (&ObjDict_Data, nodeID); setState(&ObjDict_Data, Initialisation); // Init the state for(;;) // forever loop { if (sys_timer) // Cycle timer, invoke action on every time slice { reset_sys_timer(); // Reset timer digital_input[0] = get_inputs(); digital_input_handler(&ObjDict_Data, digital_input, sizeof(digital_input)); digital_output_handler(&ObjDict_Data, digital_output, sizeof(digital_output)); set_outputs(digital_output[0]); // Check if CAN address has been changed if(!( nodeID == read_bcd())) { nodeID = read_bcd(); // Save the new CAN adress setState(&ObjDict_Data, Stopped); // Stop the node, to change the node ID setNodeId(&ObjDict_Data, nodeID); // Now the CAN adress is changed setState(&ObjDict_Data, Pre_operational); // Set to Pre_operational, master must boot it again } } // a message was received pass it to the CANstack if (canReceive(&m)) // a message reveived canDispatch(&ObjDict_Data, &m); // process it else { // Enter sleep mode #ifdef WD_SLEEP // Watchdog and Sleep wdt_reset(); sleep_enable(); sleep_cpu(); #endif // Watchdog and Sleep } } }
uint8_t can_process() { uint8_t res = 0; if(can_state.init_return!=RET_OK){ return 0; } while(canReceive(&rec_m)){ /***********This code will start any board which sends out a pre-operational CANOpen code*/ // if(rec_m.cob_id&0x0F){ // if(rec_m.data[0] == 0x7F){ // can_enable_slave_heartbeat((UNS16)rec_m.cob_id&0x0FF,100); // can_start_node(rec_m.cob_id&0x0FF); // } // } canDispatch(&Sensor_Board_Data, &rec_m); //send packet to CanFestival res = 1; } switch(getState(&Sensor_Board_Data)){ case Initialisation: LED_2 = 0; LED_3 = 0; break; case Pre_operational: LED_2 = 1; LED_3 = 0; break; case Operational: LED_2 = 0; LED_3 = 1; break; default: LED_2 = 1; LED_3 = 1; break; }; return res; }