This module contains M2M host interface APIs implementation.
Copyright (c) 2017-2021 Microchip Technology Inc. and its subsidiaries.
#include "common/include/nm_common.h"
#include "driver/source/nmbus.h"
#include "driver/source/nmdrv.h"
#include "bsp/include/nm_bsp.h"
#include "m2m_hif.h"
#include "driver/include/m2m_types.h"
#include "driver/source/nmasic.h"
#include "driver/include/m2m_periph.h"
#include "socket/include/m2m_socket_host_if.h"
Data Structures | |
struct | tstrHifContext |
Functions | |
sint8 | hif_check_code (uint8 u8Gid, uint8 u8OpCode) |
To check that a particular hif message is supported with the current driver/firmware pair.More... | |
sint8 | hif_check_compatibility (uint16 u16HifInfo) |
To check the compatibility of an image with the current driver.More... | |
sint8 | hif_chip_sleep (void) |
To make the chip sleep. More... | |
static sint8 | hif_chip_sleep_sc (void) |
To clear the chip sleep but keep the chip sleep. More... | |
sint8 | hif_chip_wake (void) |
To Wakeup the chip. More... | |
sint8 | hif_deinit (void *arg) |
To Deinitialize HIF layer. More... | |
sint8 | hif_enable_access (void) |
To enable access to HIF layer, based on HIF level of Firmware.More... | |
uint8 | hif_get_sleep_mode (void) |
Get the sleep mode of the HIF layer. More... | |
sint8 | hif_handle_isr (void) |
Handle interrupt received from NMC1500 firmware.More... | |
sint8 | hif_init (void *arg) |
To initialize HIF layer. More... | |
static sint8 | hif_isr (void) |
Host interface interrupt service routine. More... | |
sint8 | hif_receive (uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone) |
sint8 | hif_register_cb (uint8 u8Grp, tpfHifCallBack fn) |
sint8 | hif_send (uint8 u8Gid, uint8 u8Opcode, uint8 *pu8CtrlBuf, uint16 u16CtrlBufSize, uint8 *pu8DataBuf, uint16 u16DataSize, uint16 u16DataOffset) |
Send packet using host interface. More... | |
static sint8 | hif_set_rx_done (void) |
void | hif_set_sleep_mode (uint8 u8Pstype) |
Set the sleep mode of the HIF layer. More... | |
void | hif_yield (void) |
Yields control from interrupt event handler. More... | |
static void | isr (void) |
static void | m2m_hif_cb (uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr) |
WiFi call back function. More... | |
Variables | |
static uint16 | gau16HifBlacklist [] = {NEW_HIF_LIST} |
volatile tstrHifContext | gstrHifCxt |
static uint8 | gu8HifBlOffset = 0 |
#define HIF_BLACKLIST_SZ (sizeof(gau16HifBlacklist)/sizeof(gau16HifBlacklist[0])) |
Referenced by hif_check_code(), and hif_enable_access().
#define HIF_OTA_RB_ONLY 0xFFFF |
#define HIFCODE_IP_RAW_SOCK_OPT ((M2M_REQ_GROUP_IP << 8) | SOCKET_CMD_RAW_SET_SOCK_OPT) |
#define HIFCODE_IP_SECURE ((M2M_REQ_GROUP_IP << 8) | SOCKET_CMD_SECURE) |
#define HIFCODE_OTA_RB ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_ROLLBACK) |
Referenced by hif_check_code().
#define HIFCODE_OTA_SW ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_SWITCH_FIRMWARE) |
Referenced by hif_check_code().
#define HIFCODE_SSL_WRITECERT ((M2M_REQ_GROUP_SSL << 8) | M2M_SSL_REQ_WRITE_OWN_CERTS) |
#define HIFCODE_WIFI_CONN ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_CONN) |
#define HIFCODE_WIFI_CONN_PARAM ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_IND_CONN_PARAM) |
#define HIFCODE_WIFI_DELETE_CRED ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQRSP_DELETE_APID) |
#define HIFCODE_WIFI_ENABLE_AP ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_ENABLE_AP) |
#define HIFCODE_WIFI_PASSIVESCAN ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_PASSIVE_SCAN) |
#define HIFCODE_WIFI_ROAMING ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_ROAMING) |
#define HIFCODE_WIFI_SCAN_SSID_LIST ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_SCAN_SSID_LIST) |
#define HIFCODE_WIFI_SET_STOP_SCAN_OPTION ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_SET_STOP_SCAN_OPTION) |
#define HIFCODE_WIFI_START_PROV_MODE ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_START_PROVISION_MODE) |
#define INTERRUPT_CORTUS_0_3000D0 (0x10a8) |
Referenced by hif_set_rx_done().
#define INTERRUPT_CORTUS_1_3000D0 (0x10ac) |
Referenced by hif_send().
#define INTERRUPT_CORTUS_2_3000D0 (0x10b0) |
Referenced by hif_send().
#define INTERRUPT_CORTUS_3_3000D0 (0x10b4) |
#define NEW_HIF_LIST |
#define NMI_AHB_DATA_MEM_BASE 0x30000 |
#define NMI_AHB_SHARE_MEM_BASE 0xd0000 |
#define WIFI_HOST_RCV_CTRL_0 (0x1070) |
Referenced by hif_isr(), and hif_set_rx_done().
#define WIFI_HOST_RCV_CTRL_1 (0x1084) |
Referenced by hif_isr().
#define WIFI_HOST_RCV_CTRL_2 (0x1078) |
Referenced by hif_send().
#define WIFI_HOST_RCV_CTRL_3 (0x106c) |
Referenced by hif_send().
#define WIFI_HOST_RCV_CTRL_4 (0x150400) |
Referenced by hif_send().
To check that a particular hif message is supported with the current driver/firmware pair.
[in] | u8Gid | Group ID. |
[in] | u8Opcode | Operation ID. |
[in] | u8Gid | Group ID. |
[in] | u8Opcode | Operation ID. |
References gau16HifBlacklist, gu8HifBlOffset, HIF_BLACKLIST_SZ, HIFCODE_OTA_RB, HIFCODE_OTA_SW, M2M_ERR, M2M_ERR_SEND, and M2M_SUCCESS.
Referenced by hif_send().
To check the compatibility of an image with the current driver.
[in] | u16HifInfo | HIF info of image to be checked. |
References M2M_ERR_FW_VER_MISMATCH, M2M_GET_HIF_BLOCK, M2M_GET_HIF_MAJOR, M2M_HIF_BLOCK_VALUE, M2M_HIF_MAJOR_VALUE, M2M_SUCCESS, and ret.
Referenced by hif_enable_access(), and m2m_wifi_check_ota_rb().
To make the chip sleep.
To make the chip sleep.
Referenced by gpio_ioctl(), hif_init(), hif_send(), m2m_ota_get_firmware_version(), m2m_wifi_get_firmware_version(), m2m_wifi_get_mac_address(), and m2m_wifi_get_otp_mac_address().
To clear the chip sleep but keep the chip sleep.
References M2M_SUCCESS, and tstrHifContext::u8ChipSleep.
Referenced by hif_send().
To Wakeup the chip.
To Wakeup the chip.
Referenced by gpio_ioctl(), hif_deinit(), hif_send(), m2m_ota_get_firmware_version(), m2m_wifi_get_firmware_version(), m2m_wifi_get_mac_address(), and m2m_wifi_get_otp_mac_address().
To Deinitialize HIF layer.
To De-initialize HIF layer.
To Deinitialize HIF layer.
[in] | arg | Pointer to the arguments. |
[in] | arg | Pointer to the arguments. |
Referenced by m2m_wifi_deinit().
sint8 hif_enable_access | ( | void | ) |
To enable access to HIF layer, based on HIF level of Firmware.
This function reads HIF level directly from a register written by Firmware.
References gu8HifBlOffset, HIF_BLACKLIST_SZ, hif_check_compatibility(), M2M_ERR, M2M_GET_HIF_MINOR, M2M_SUCCESS, nm_get_hif_info(), NULL, and ret.
Referenced by m2m_wifi_init_start().
Get the sleep mode of the HIF layer.
Referenced by m2m_wifi_get_sleep_mode(), and m2m_wifi_request_sleep().
hif_handle_isr | ( | void | ) |
Handle interrupt received from NMC1500 firmware.
Handle interrupt received from NMC1500 firmware.
Referenced by m2m_wifi_handle_events().
To initialize HIF layer.
To initialize HIF layer.
[in] | arg | Pointer to the arguments. |
[in] | arg | Pointer to the arguments. |
Referenced by m2m_wifi_init_start().
|
static |
Host interface interrupt service routine.
start bus transfer
References hif_set_rx_done(), M2M_ERR, M2M_ERR_BUS_FAIL, M2M_ERR_RCV, M2M_HIF_HDR_OFFSET, M2M_REQ_GROUP_IP, M2M_REQ_GROUP_OTA, M2M_REQ_GROUP_SIGMA, M2M_REQ_GROUP_SSL, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, NBIT0, NM_BSP_B_L_16, nm_read_block(), nm_read_reg_with_ret(), nm_write_reg(), tstrHifContext::pfIpCb, tstrHifContext::pfOtaCb, tstrHifContext::pfSigmaCb, tstrHifContext::pfSslCb, tstrHifContext::pfWifiCb, ret, tstrHifHdr::u16Length, tstrHifContext::u32RxAddr, tstrHifContext::u32RxSize, tstrHifHdr::u8Gid, tstrHifContext::u8HifRXDone, tstrHifHdr::u8Opcode, WIFI_HOST_RCV_CTRL_0, WIFI_HOST_RCV_CTRL_1, and x1.
Referenced by hif_handle_isr().
sint8 hif_register_cb | ( | uint8 | u8Grp, |
tpfHifCallBack | fn | ||
) |
Referenced by hif_init(), m2m_ota_init(), m2m_ssl_init(), m2m_wifi_init_start(), socketDeinit(), and socketInit().
NMI_API sint8 hif_send | ( | uint8 | u8Gid, |
uint8 | u8Opcode, | ||
uint8 * | pu8CtrlBuf, | ||
uint16 | u16CtrlBufSize, | ||
uint8 * | pu8DataBuf, | ||
uint16 | u16DataSize, | ||
uint16 | u16DataOffset | ||
) |
Send packet using host interface.
[in] | u8Gid | Group ID. |
[in] | u8Opcode | Operation ID. |
[in] | pu8CtrlBuf | Pointer to the Control buffer. |
[in] | u16CtrlBufSize | Control buffer size. |
[in] | u16DataOffset | Packet Data offset. |
[in] | pu8DataBuf | Packet buffer Allocated by the caller. |
[in] | u16DataSize | Packet buffer size (including the HIF header). |
[in] | u8Gid | Group ID. |
[in] | u8Opcode | Operation ID. |
[in] | pu8CtrlBuf | Pointer to the Control buffer. |
[in] | u16CtrlBufSize | Control buffer size. |
[in] | u16DataOffset | Packet Data offset. |
[in] | pu8DataBuf | Packet buffer Allocated by the caller. |
[in] | u16DataSize | Packet buffer size (including the HIF header). |
Referenced by m2m_ota_abort(), m2m_ota_host_file_erase(), m2m_ota_host_file_get(), m2m_ota_host_file_read_hif(), m2m_ota_init(), m2m_ota_notif_check_for_update(), m2m_ota_notif_sched(), m2m_ota_notif_set_url(), m2m_ota_rollback(), m2m_ota_start_update(), m2m_ota_switch_firmware(), m2m_ssl_handshake_rsp(), m2m_ssl_send_certs_to_winc(), m2m_ssl_set_active_ciphersuites(), m2m_wifi_ble_api_send(), m2m_wifi_ble_set_gain_table(), m2m_wifi_conf_auto_rate(), m2m_wifi_configure_sntp(), m2m_wifi_connect_1x_mschap2(), m2m_wifi_connect_1x_tls(), m2m_wifi_connect_open(), m2m_wifi_connect_psk(), m2m_wifi_connect_wep(), m2m_wifi_default_connect(), m2m_wifi_delete_sc(), m2m_wifi_disable_ap(), m2m_wifi_disable_roaming(), m2m_wifi_disconnect(), m2m_wifi_enable_ap_ext(), m2m_wifi_enable_dhcp(), m2m_wifi_enable_firmware_logs(), m2m_wifi_enable_roaming(), m2m_wifi_enable_sntp(), m2m_wifi_enable_XO_during_sleep(), m2m_wifi_get_connection_info(), m2m_wifi_get_system_time(), m2m_wifi_p2p(), m2m_wifi_p2p_disconnect(), m2m_wifi_prng_get_random_bytes(), m2m_wifi_req_client_ctrl(), m2m_wifi_req_curr_rssi(), m2m_wifi_req_restrict_ble(), m2m_wifi_req_scan_result(), m2m_wifi_req_server_init(), m2m_wifi_req_unrestrict_ble(), m2m_wifi_request_scan(), m2m_wifi_request_scan_passive(), m2m_wifi_request_scan_ssid_list(), m2m_wifi_request_sleep(), m2m_wifi_send_crl(), m2m_wifi_send_ethernet_pkt(), m2m_wifi_set_battery_voltage(), m2m_wifi_set_cust_InfoElement(), m2m_wifi_set_device_name(), m2m_wifi_set_gain_table_idx(), m2m_wifi_set_gains(), m2m_wifi_set_lsn_int(), m2m_wifi_set_mac_address(), m2m_wifi_set_power_profile(), m2m_wifi_set_scan_options(), m2m_wifi_set_scan_region(), m2m_wifi_set_sleep_mode(), m2m_wifi_set_static_ip(), m2m_wifi_set_stop_scan_on_first(), m2m_wifi_set_system_time(), m2m_wifi_set_tx_power(), m2m_wifi_start_provision_mode_ext(), m2m_wifi_stop_provision_mode(), m2m_wifi_wps(), and m2m_wifi_wps_disable().
|
static |
References INTERRUPT_CORTUS_0_3000D0, ISNMC3400, M2M_SUCCESS, NBIT1, nm_bsp_interrupt_ctrl(), nm_read_reg_with_ret(), nm_write_reg(), nmi_get_chipid(), ret, tstrHifContext::u8HifRXDone, and WIFI_HOST_RCV_CTRL_0.
Referenced by hif_isr(), and hif_receive().
Set the sleep mode of the HIF layer.
[in] | u8Pstype | Sleep mode. |
Referenced by m2m_wifi_set_sleep_mode().
hif_yield | ( | void | ) |
Yields control from interrupt event handler.
Yields control from interrupt event handler.
Referenced by m2m_wifi_yield().
|
static |
References nm_bsp_interrupt_ctrl(), and tstrHifContext::u8Interrupt.
Referenced by DMAC_Handler(), and hif_init().
WiFi call back function.
[in] | u8OpCode | HIF Opcode type. |
[in] | u16DataSize | HIF data length. |
[in] | u32Addr | HIF address. |
Referenced by hif_init().
|
static |
Referenced by hif_check_code().
volatile tstrHifContext gstrHifCxt |
|
static |
Referenced by hif_check_code(), and hif_enable_access().