73 lines
1.7 KiB
C
73 lines
1.7 KiB
C
/* Board */
|
|
#include "board.h"
|
|
#include "clock_config.h"
|
|
#include "peripherals.h"
|
|
#include "pin_mux.h"
|
|
|
|
/* Debug Console */
|
|
#include "fsl_debug_console.h"
|
|
|
|
/* FreeRTOS */
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
|
|
/* Private */
|
|
#include "app_nh_impl.h"
|
|
|
|
static void initialization_task(void *params);
|
|
|
|
static void report_mac_addresses(void);
|
|
|
|
int main(void) {
|
|
BOARD_InitBootPins();
|
|
BOARD_BootClockFROHF96M();
|
|
BOARD_InitBootPeripherals();
|
|
|
|
BOARD_InitDebugConsole();
|
|
|
|
PRINTF("Hello world!!\r\n");
|
|
|
|
if (xTaskCreate(initialization_task, "INIT", 2048, NULL, 2, NULL) != pdPASS) {
|
|
PRINTF("Failed to create initialization task...\r\n");
|
|
|
|
goto dead_loop;
|
|
}
|
|
|
|
vTaskStartScheduler();
|
|
|
|
dead_loop:
|
|
/* We should never reach here. */
|
|
for (;;) {
|
|
__WFI();
|
|
}
|
|
}
|
|
|
|
static void initialization_task(void *params) {
|
|
PRINTF("Initialization task running...\r\n");
|
|
|
|
/* Do initialization stuff here, since the scheduler is running now. */
|
|
if(app_nh_impl_init() != 0) {
|
|
PRINTF("Failed to init nano_hosted\r\n");
|
|
}
|
|
|
|
report_mac_addresses();
|
|
|
|
PRINTF("Initialization completed, INIT task exit.\r\n");
|
|
|
|
vTaskDelete(NULL);
|
|
}
|
|
|
|
static void report_mac_addresses(void) {
|
|
uint8_t mac_addr[18] = {0x00};
|
|
if (nh_ctrl_api_get_mac_address(&g_nh_ctrl_api, mac_addr, NH_CTRL_WIFI_MODE_STA) != NH_RET_SUCCESS) {
|
|
PRINTF("Failed to acquire MAC address.\r\n");
|
|
} else {
|
|
PRINTF("STA mode MAC address: %s\r\n", mac_addr);
|
|
}
|
|
|
|
if (nh_ctrl_api_get_mac_address(&g_nh_ctrl_api, mac_addr, NH_CTRL_WIFI_MODE_AP) != NH_RET_SUCCESS) {
|
|
PRINTF("Failed to acquire MAC address.\r\n");
|
|
} else {
|
|
PRINTF("AP mode MAC address: %s\r\n", mac_addr);
|
|
}
|
|
} |