parent
605db95a06
commit
84d34b6e62
|
@ -4,6 +4,8 @@
|
|||
#include "nh_shared_if.h"
|
||||
#include "nh_ctrl_api.h"
|
||||
|
||||
extern nh_ctrl_api_t g_nh_ctrl_api;
|
||||
|
||||
int app_nh_impl_init(void);
|
||||
|
||||
#endif // APP_NH_IMPL_H
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 59d47eb3427e730ccc94c2ec3ce05ce074a29c41
|
||||
Subproject commit 9add7e515b450d4cb1ba5e369d59004ff661e6a2
|
|
@ -31,6 +31,7 @@ static void app_nh_impl_hs_callback(pint_pin_int_t pintr, uint32_t pmatch_status
|
|||
|
||||
static nh_ret_t app_nh_impl_ops_xfer(void *handle, uint8_t *tx_data, uint8_t *rx_data, uint32_t len);
|
||||
static nh_ret_t app_nh_impl_ops_drdy_read(void *handle, bool *rdy);
|
||||
static nh_ret_t app_nh_impl_ops_hs_poll(void *handle, uint32_t timeout_ms);
|
||||
static void app_nh_impl_cb_startup(void *handle, nh_event_init_t *init_data);
|
||||
|
||||
static void app_nh_impl_cb_init(void *handle);
|
||||
|
@ -74,6 +75,7 @@ static nh_shared_if_t s_nh_shared_if = {
|
|||
{
|
||||
.xfer = app_nh_impl_ops_xfer,
|
||||
.drdy_read = app_nh_impl_ops_drdy_read,
|
||||
.hs_poll = app_nh_impl_ops_hs_poll,
|
||||
},
|
||||
.cb =
|
||||
{
|
||||
|
@ -81,7 +83,7 @@ static nh_shared_if_t s_nh_shared_if = {
|
|||
},
|
||||
};
|
||||
|
||||
static nh_ctrl_api_t s_nh_ctrl_api = {
|
||||
nh_ctrl_api_t g_nh_ctrl_api = {
|
||||
.osa = &s_nh_osa,
|
||||
.shared_if = &s_nh_shared_if,
|
||||
.cb =
|
||||
|
@ -112,11 +114,11 @@ int app_nh_impl_init(void) {
|
|||
return -4;
|
||||
}
|
||||
|
||||
if (nh_ctrl_api_init(&s_nh_ctrl_api) != NH_RET_SUCCESS) {
|
||||
if (nh_ctrl_api_init(&g_nh_ctrl_api) != NH_RET_SUCCESS) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
if (xTaskCreate(app_nh_impl_ctrl_task, "NH_CTRL", 512, &s_nh_ctrl_api, 2, NULL) != pdPASS) {
|
||||
if (xTaskCreate(app_nh_impl_ctrl_task, "NH_CTRL", 512, &g_nh_ctrl_api, 2, NULL) != pdPASS) {
|
||||
return -6;
|
||||
}
|
||||
|
||||
|
@ -126,13 +128,6 @@ int app_nh_impl_init(void) {
|
|||
PRINTF("Did not received ESPInit event in time, bailing out (assumed soft reset).\r\n");
|
||||
}
|
||||
|
||||
uint8_t mac_addr[18] = {0x00};
|
||||
if (nh_ctrl_api_get_mac_address(&s_nh_ctrl_api, mac_addr) != NH_RET_SUCCESS) {
|
||||
PRINTF("Failed to acquire MAC address.\r\n");
|
||||
} else {
|
||||
PRINTF("STA mode MAC address: %s\r\n", mac_addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -208,6 +203,19 @@ static nh_ret_t app_nh_impl_ops_drdy_read(void *handle, bool *rdy) {
|
|||
return NH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static nh_ret_t app_nh_impl_ops_hs_poll(void *handle, uint32_t timeout_ms) {
|
||||
TickType_t tick_start = xTaskGetTickCount();
|
||||
|
||||
while (GPIO_PinRead(GPIO, BOARD_INITMIKROEPINS_ESP_HS_PORT, BOARD_INITMIKROEPINS_ESP_HS_PIN) == 0) {
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
if (xTaskGetTickCount() - tick_start > pdMS_TO_TICKS(timeout_ms)) {
|
||||
return NH_RET_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
return NH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static nh_ret_t app_nh_impl_ops_xfer(void *handle, uint8_t *tx_data, uint8_t *rx_data, uint32_t len) {
|
||||
spi_transfer_t xfer = {
|
||||
.txData = tx_data,
|
||||
|
@ -436,7 +444,7 @@ static void app_nh_impl_shared_if_task(void *parameters) {
|
|||
|
||||
static void app_nh_impl_ctrl_task(void *parameters) {
|
||||
for (;;) {
|
||||
nh_ctrl_api_task(&s_nh_ctrl_api);
|
||||
nh_ctrl_api_task(&g_nh_ctrl_api);
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
|
|
19
src/main.c
19
src/main.c
|
@ -16,6 +16,8 @@
|
|||
|
||||
static void initialization_task(void *params);
|
||||
|
||||
static void report_mac_addresses(void);
|
||||
|
||||
int main(void) {
|
||||
BOARD_InitBootPins();
|
||||
BOARD_BootClockFROHF96M();
|
||||
|
@ -48,7 +50,24 @@ static void initialization_task(void *params) {
|
|||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue