int CANTiva_read(CAN_Handle handle,uint8_t *readdata) { unsigned int key; CANTiva_Object *object = handle->object; CANTiva_HWAttrs const *hwAttrs = handle->hwAttrs; tCANMsgObject sCANMessage; uint32_t ui32MsgData; uint8_t *pui8MsgData; pui8MsgData = (uint8_t *)&ui32MsgData; unsigned int uIdx,i; object->readBuf = readdata; *((unsigned char *)object->readBuf) = 0xaa; // *readdata = 0xaa; // // Initialize a message object to be used for receiving CAN messages with // any CAN ID. In order to receive any CAN ID, the ID and mask must both // be set to 0, and the ID filter enabled. // ui32MsgData = 0; sCANMessage.ui32MsgID = 0; sCANMessage.ui32MsgIDMask = 0; sCANMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER; sCANMessage.ui32MsgLen = 8; // Now load the message object into the CAN peripheral. Once loaded the // CAN will receive any message on the bus, and an interrupt will occur. // Use message object 1 for receiving messages (this is not the same as // the CAN ID which can be any value in this example). // CANMessageSet(hwAttrs->baseAddr, 1, &sCANMessage, MSG_OBJ_TYPE_RX); return (0); } static void CANTiva_hwiIntFxn(UArg arg) { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //TO CHECK TIME PERIOD OF WAVEFORM // Enable the GPIO pins for the LEDs (PN0 & PN1). GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4); uint32_t status,i; CANTiva_Object *object = ((CAN_Handle)arg)->object; CANTiva_HWAttrs const *hwAttrs = ((CAN_Handle)arg)->hwAttrs; uint32_t ui32Status; // Read the CAN interrupt status to find the cause of the interrupt ui32Status = CANIntStatus(hwAttrs->baseAddr, CAN_INT_STS_CAUSE); *((unsigned char *)object->readBuf) = 0xbb; GPIO_write(0, ~0); // If the cause is a controller status interrupt, then get the status if(ui32Status == CAN_INT_INTID_STATUS) { GPIO_write(1, 1); // Read the controller status. This will return a field of status // error bits that can indicate various errors. Error processing // is not done in this example for simplicity. Refer to the // API documentation for details about the error status bits. // The act of reading this status will clear the interrupt. If the // CAN peripheral is not connected to a CAN bus with other CAN devices // present, then errors will occur and will be indicated in the // controller status. ui32Status = CANStatusGet(hwAttrs->baseAddr, CAN_STS_CONTROL); *((unsigned char *)object->readBuf) = 0x11; // Set a flag to indicate some errors may have occurred. object->g_bErrFlag = 1; } // Check if the cause is message object 1, which what we are using for // receiving messages. else if(ui32Status == 1) { // Getting to this point means that the TX interrupt occurred on // message object 1, and the message TX is complete. Clear the // message object interrupt. CANIntClear(hwAttrs->baseAddr, 1); // // Set flag to indicate received message is pending. // object->g_bRXFlag = 1; *((unsigned char *)object->readBuf) = 0xcc; CANread(object , hwAttrs); object->g_bErrFlag = 0; } else if(ui32Status == 2) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 1); CANIntClear(hwAttrs->baseAddr, 2); // Increment a counter to keep track of how many messages have been // sent. In a real application this could be used to set flags to // indicate when a message is sent. // g_ui32MsgCount++; } // Otherwise, something unexpected caused the interrupt. This should // never happen. else { // Spurious interrupt handling can go here. } GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, 16); } FSR = 0x0000 HFSR = 0x40000000 DFSR = 0x0000000b MMAR = 0xe000ed34 BFAR = 0xe000ed38 AFSR = 0x00000000