/** * @brief The main task for the CAN1 channel * @param pvParameters: * @retval None */ void can1Task(void *pvParameters) { /* Mutex semaphore to manage when it's ok to send and receive new data */ xSemaphore = xSemaphoreCreateMutex(); /* Mutex semaphore for accessing the settings for this channel */ xSettingsSemaphore = xSemaphoreCreateMutex(); /* Create software timers */ prvBuffer1ClearTimer = xTimerCreate("Buf1ClearCan1", 10, pdFALSE, 0, prvBuffer1ClearTimerCallback); prvBuffer2ClearTimer = xTimerCreate("Buf2ClearCan1", 10, pdFALSE, 0, prvBuffer2ClearTimerCallback); /* Initialize hardware */ prvHardwareInit(); /* Wait to make sure the SPI FLASH is initialized */ while (SPI_FLASH_Initialized() == false) { vTaskDelay(100 / portTICK_PERIOD_MS); } /* Try to read the settings from SPI FLASH */ prvReadSettingsFromSpiFlash(); can1Clear(); /* The parameter in vTaskDelayUntil is the absolute time * in ticks at which you want to be woken calculated as * an increment from the time you were last woken. */ TickType_t xNextWakeTime; /* Initialize xNextWakeTime - this only needs to be done once. */ xNextWakeTime = xTaskGetTickCount(); uint8_t count = 0; prvDoneInitializing = true; while (1) { vTaskDelayUntil(&xNextWakeTime, 1000 / portTICK_PERIOD_MS); // /* Transmit debug data */ // if (prvCurrentSettings.connection == CANConnection_Connected) // { // /* Set the data to be transmitted */ // uint8_t data[2] = {0xAA, count}; // can1Transmit(0x321, data, CANDataLength_2, 50); // count++; // // if (count % 10 == 0) // { // uint8_t data2[5] = {0x72, 0x21, 0xDE, 0x03, 0xFA}; // can1Transmit(0x321, data2, CANDataLength_5, 50); // } // } } }
/** * @brief Callback for the clear button * @param Event: The event that caused the callback * @param ButtonId: The button ID that the event happened on * @retval None */ void guiCan1ClearButtonCallback(GUITouchEvent Event, uint32_t ButtonId) { if (Event == GUITouchEvent_Up) { prvClearingInProgress = true; can1Clear(); GUITextBox_ClearAndResetWritePosition(GUITextBoxId_Can1Main); for (uint32_t i = 0; i < MAX_MESSAGES_IN_LIST; i++) { prvMessageList[i].count = 0; // memset(&prvMessageList[i], 0, sizeof(CANDisplayedItem)); } prvNumOfMessagesDisplayed = 0; prvClearingInProgress = false; } }