2022-12-17 11:12:59 +00:00
|
|
|
#include "board.h"
|
|
|
|
#include "clock_config.h"
|
|
|
|
#include "peripherals.h"
|
|
|
|
#include "pin_mux.h"
|
|
|
|
|
|
|
|
/* Debug console */
|
|
|
|
#include "fsl_debug_console.h"
|
|
|
|
|
2022-12-17 14:26:24 +00:00
|
|
|
/* FreeRTOS */
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "task.h"
|
|
|
|
|
|
|
|
/* App */
|
|
|
|
#include "app_sdio.h"
|
|
|
|
|
|
|
|
#define INITIALIZE_TASK_STACK_DEPTH (2048)
|
|
|
|
|
|
|
|
static void initialize_task(void *parameters);
|
|
|
|
|
2022-12-17 11:12:59 +00:00
|
|
|
int main(void) {
|
|
|
|
BOARD_InitBootPins();
|
|
|
|
BOARD_InitBootClocks();
|
|
|
|
BOARD_InitBootPeripherals();
|
|
|
|
BOARD_ConfigMPU();
|
|
|
|
|
|
|
|
BOARD_InitDebugConsole();
|
|
|
|
|
|
|
|
CLOCK_SetMode(kCLOCK_ModeRun);
|
|
|
|
|
|
|
|
PRINTF("CPU frequency: %d\r\n", CLOCK_GetCoreSysClkFreq());
|
|
|
|
|
2022-12-17 14:26:24 +00:00
|
|
|
if (xTaskCreate(initialize_task, "INIT", INITIALIZE_TASK_STACK_DEPTH, NULL, 2, NULL) != pdPASS) {
|
|
|
|
PRINTF("Failed to create initialization task.\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
vTaskStartScheduler();
|
|
|
|
|
2022-12-17 11:12:59 +00:00
|
|
|
for (;;) {
|
|
|
|
__WFI();
|
|
|
|
}
|
|
|
|
}
|
2022-12-17 14:26:24 +00:00
|
|
|
|
|
|
|
static void initialize_task(void *parameters) {
|
|
|
|
PRINTF("Initialization task running...\r\n");
|
|
|
|
|
|
|
|
int ret = app_sdio_init();
|
|
|
|
if (ret != 0) {
|
|
|
|
PRINTF("SDIO card initialization failed...\r\n");
|
|
|
|
} else {
|
|
|
|
PRINTF("SDIO card initialization succeeded.\r\n");
|
|
|
|
|
|
|
|
uint32_t mfid = app_sdio_get_id();
|
|
|
|
|
|
|
|
PRINTF("Read card VID/PID: %04x:%04x\r\n", (mfid >> 16U), (mfid & 0xFFFFU));
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINTF("Initialization task exit.\r\n");
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
}
|