//***************************************************************************** // // The CAN controller Interrupt handler. // //***************************************************************************** void CANHandler(void) { unsigned long ulStatus; // // Find the cause of the interrupt, if it is a status interrupt then just // acknowledge the interrupt by reading the status register. // ulStatus = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE); switch(ulStatus) { // // Let the forground loop handle sending this, just set a flag to // indicate that the data should be sent. // case MSGOBJ_NUM_BUTTON: { // // Read the Button Message. // CANMessageGet(CAN0_BASE, MSGOBJ_NUM_BUTTON, &g_MsgObjectButton, 1); // // Only respond to buttons being release. // if(g_MsgObjectButton.pucMsgData[0] == EVENT_BUTTON_RELEASED) { // // Check if the up button was released. // if(g_MsgObjectButton.pucMsgData[1] == TARGET_BUTTON_UP) { // // Adjust the volume up by 10. // AudioVolumeUp(10); } // // Check if the down button was released. // if(g_MsgObjectButton.pucMsgData[1] == TARGET_BUTTON_DN) { // // Adjust the volume down by 10. // AudioVolumeDown(10); } } break; } // // When the LED message object interrupts, just clear the flag so that // more LED messages are allowed to transfer. // case MSGOBJ_NUM_LED: { g_ulFlags &= (~FLAG_LED_TX_PEND); break; } // // When the transmit data message object interrupts, clear the // flag so that more data can be trasferred. // case MSGOBJ_NUM_DATA_TX: { g_ulFlags &= (~FLAG_DATA_TX_PEND); break; } // // When a receive data message object interrupts, set the flag to // indicate that new data is ready. // case MSGOBJ_NUM_DATA_RX: { g_ulFlags |= FLAG_DATA_RECV; break; } // // This was a status interrupt so read the current status to // clear the interrupt and return. // default: { // // Read the controller status to acknowledge this interrupt. // CANStatusGet(CAN0_BASE, CAN_STS_CONTROL); // // If there was a LED transmission pending, then stop it and // clear the flag. // if(g_ulFlags & FLAG_LED_TX_PEND) { // // Disable this message object until we retry it later. // CANMessageClear(CAN0_BASE, MSGOBJ_NUM_LED); // // Clear the transmit pending flag. // g_ulFlags &= (~FLAG_LED_TX_PEND); } // // If there was a Data transmission pending, then stop it and // clear the flag. // if(g_ulFlags & FLAG_DATA_TX_PEND) { // // Disable this message object until we retry it later. // CANMessageClear(CAN0_BASE, MSGOBJ_NUM_DATA_TX); // // Clear the transmit pending flag. // g_ulFlags &= (~FLAG_DATA_TX_PEND); } return; } } // // Acknowledge the CAN controller interrupt has been handled. // CANIntClear(CAN0_BASE, ulStatus); }
void CANMessageObject::clear() { CANMessageClear(getBase(), _mob_num); get(false); }