///////////////////////////////////////////////////////////////////////////// // This task is called periodically each mS to handle sequencer requests ///////////////////////////////////////////////////////////////////////////// static void TASK_SEQ(void *pvParameters) { portTickType xLastExecutionTime; // Initialise the xLastExecutionTime variable on task entry xLastExecutionTime = xTaskGetTickCount(); while( 1 ) { vTaskDelayUntil(&xLastExecutionTime, 1 / portTICK_RATE_MS); // execute sequencer handler SEQ_Handler(); // send timestamped MIDI events SEQ_MIDI_OUT_Handler(); } }
///////////////////////////////////////////////////////////////////////////// // This task is called periodically each mS to handle sequencer requests ///////////////////////////////////////////////////////////////////////////// static void TASK_SEQ(void *pvParameters) { portTickType xLastExecutionTime; u16 sdcard_check_ctr = 0; // Initialise the xLastExecutionTime variable on task entry xLastExecutionTime = xTaskGetTickCount(); while( 1 ) { vTaskDelayUntil(&xLastExecutionTime, 1 / portTICK_RATE_MS); // execute sequencer handler SEQ_Handler(); // send timestamped MIDI events SEQ_MIDI_OUT_Handler(); // each second: check if SD Card (still) available if( ++sdcard_check_ctr >= 1000 ) { sdcard_check_ctr = 0; // use a mutex if multiple tasks access the SD Card! MUTEX_SDCARD_TAKE; s32 status = FILE_CheckSDCard(); if( status == 1 ) { MIOS32_MIDI_SendDebugMessage("SD Card connected: %s\n", FILE_VolumeLabel()); } else if( status == 2 ) { MIOS32_MIDI_SendDebugMessage("SD Card disconnected\n"); // stop sequencer SEQ_BPM_Stop(); // change filename sprintf(MID_FILE_UI_NameGet(), "No SD Card"); } else if( status == 3 ) { if( !FILE_SDCardAvailable() ) { MIOS32_MIDI_SendDebugMessage("SD Card not found\n"); // change filename sprintf(MID_FILE_UI_NameGet(), "No SD Card"); } else if( !FILE_VolumeAvailable() ) { MIOS32_MIDI_SendDebugMessage("ERROR: SD Card contains invalid FAT!\n"); MIOS32_BOARD_LED_Set(0x1, 0x0); // turn off LED // change filename sprintf(MID_FILE_UI_NameGet(), "No FAT"); // stop sequencer SEQ_BPM_Stop(); } else { // change filename sprintf(MID_FILE_UI_NameGet(), "SDCard found"); // if in auto mode and BPM generator is clocked in slave mode: // change to master mode SEQ_BPM_CheckAutoMaster(); // reset sequencer SEQ_Reset(1); // request to play the first file SEQ_PlayFileReq(0); // start sequencer SEQ_BPM_Start(); } } MUTEX_SDCARD_GIVE; } } }