|
| 1 | + |
| 2 | +/* |
| 3 | + * Copyright (c) 2024 Nordic Semiconductor ASA |
| 4 | + * |
| 5 | + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
| 6 | + */ |
| 7 | + |
| 8 | +#include "ipc_if.h" |
| 9 | +//#include "qspi.h" |
| 10 | +//#include "bal_structs.h" |
| 11 | +//#include "hal_structs.h" |
| 12 | + |
| 13 | +/* Define addresses to use for the free queues */ |
| 14 | +#define EVENT_FREEQ_ADDR 0x2FC08000 |
| 15 | +#define CMD_FREEQ_ADDR 0x2FC05000 |
| 16 | + |
| 17 | +#define NUM_INSTANCES 3 |
| 18 | +#define NUM_ENDPOINTS 1 |
| 19 | + |
| 20 | +struct device *ipc_instances[NUM_INSTANCES]; |
| 21 | +struct ipc_ept ept[NUM_ENDPOINTS]; |
| 22 | +struct ipc_ept_cfg ept_cfg[NUM_ENDPOINTS]; |
| 23 | + |
| 24 | +static WIFI_IPC_T wifi_event; |
| 25 | +static WIFI_IPC_T wifi_cmd; |
| 26 | +static WIFI_IPC_T wifi_tx; |
| 27 | + |
| 28 | +static int (*callback_func)(void *data); |
| 29 | + |
| 30 | +static void event_recv(void *data, void *priv) |
| 31 | +{ |
| 32 | + // struct nrf_wifi_bus_qspi_dev_ctx *dev_ctx = NULL; |
| 33 | + // struct nrf_wifi_bal_dev_ctx *bal_dev_ctx = NULL; |
| 34 | + // struct nrf_wifi_hal_dev_ctx *hal_dev_ctx = NULL; |
| 35 | + printf(" EVENT RECIEVED\n "); |
| 36 | + printf(" data adress is 0x%x\n",data); |
| 37 | +// dev_ctx = (struct nrf_wifi_bus_qspi_dev_ctx *) priv; |
| 38 | +// bal_dev_ctx = (struct nrf_wifi_bal_dev_ctx *) dev_ctx->bal_dev_ctx; |
| 39 | +// hal_dev_ctx = (struct nrf_wifi_hal_dev_ctx *) bal_dev_ctx->hal_dev_ctx; |
| 40 | + |
| 41 | +// hal_dev_ctx->ipc_msg = data; |
| 42 | + callback_func(priv); |
| 43 | +} |
| 44 | + |
| 45 | +int ipc_init() { |
| 46 | + wifi_ipc_host_event_init(&wifi_event, EVENT_FREEQ_ADDR); |
| 47 | + wifi_ipc_host_cmd_init(&wifi_cmd, CMD_FREEQ_ADDR); |
| 48 | + return 0; |
| 49 | +} |
| 50 | + |
| 51 | +int ipc_deinit(void) { |
| 52 | + return 0; |
| 53 | +} |
| 54 | + |
| 55 | +int ipc_recv(ipc_ctx_t ctx, const void *data, int len) { |
| 56 | + return 0; |
| 57 | +} |
| 58 | + |
| 59 | +int ipc_send(ipc_ctx_t ctx, void *data, int len) { |
| 60 | + |
| 61 | + int ret; |
| 62 | + |
| 63 | + switch (ctx.inst) { |
| 64 | + case IPC_INSTANCE_CMD_CTRL: |
| 65 | + |
| 66 | + /* IPC service on RPU may not have been established. Keep trying. */ |
| 67 | + do { |
| 68 | + ret = wifi_ipc_host_cmd_send_memcpy(&wifi_cmd, data, len); |
| 69 | + } while (ret == WIFI_IPC_STATUS_BUSYQ_NOTREADY); |
| 70 | + |
| 71 | + /* Critical error during IPC service transfer. Should never happen. */ |
| 72 | + if (ret == WIFI_IPC_STATUS_BUSYQ_CRITICAL_ERR) { |
| 73 | + return -1; |
| 74 | + } |
| 75 | + |
| 76 | + break; |
| 77 | + case IPC_INSTANCE_CMD_TX: |
| 78 | + |
| 79 | + /* IPC service on RPU may not have been established. Keep trying. */ |
| 80 | + |
| 81 | + do { |
| 82 | + printf(" adress of data cmd is 0x%x\n",data); |
| 83 | + ret = wifi_ipc_host_tx_send(&wifi_tx, data); |
| 84 | + } while (ret == WIFI_IPC_STATUS_BUSYQ_NOTREADY); |
| 85 | + printf("Data cmd critical error is %d\n",ret); |
| 86 | + /* Critical error during IPC service transfer. Should never happen. */ |
| 87 | + if (ret == WIFI_IPC_STATUS_BUSYQ_CRITICAL_ERR) { |
| 88 | + return -1; |
| 89 | + } |
| 90 | + |
| 91 | + break; |
| 92 | + case IPC_INSTANCE_RX: |
| 93 | + break; |
| 94 | + default: |
| 95 | + break; |
| 96 | + } |
| 97 | + |
| 98 | + return 0; |
| 99 | +} |
| 100 | + |
| 101 | +int ipc_register_rx_cb(int (*rx_handler)(void *priv), void *data) { |
| 102 | + callback_func = rx_handler; |
| 103 | +#ifdef NOTYET |
| 104 | + int ret = wifi_ipc_bind_ipc_service_tx_rx(&wifi_cmd, &wifi_event, DEVICE_DT_GET(DT_NODELABEL(ipc0)), event_recv, data); |
| 105 | + if (ret != WIFI_IPC_STATUS_OK) { |
| 106 | + return -1; |
| 107 | + } |
| 108 | + |
| 109 | + ret = wifi_ipc_bind_ipc_service(&wifi_tx, DEVICE_DT_GET(DT_NODELABEL(ipc1)), event_recv, data); |
| 110 | + return (ret == WIFI_IPC_STATUS_OK ? 0 : -1); |
| 111 | +#endif |
| 112 | +} |
0 commit comments