This module contains M2M host interface APIs implementation.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
#include "common/include/nm_common.h"
#include "driver/source/nmbus.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"
Data Structures | |
struct | tstrHifContext |
Macros | |
#define | NMI_AHB_DATA_MEM_BASE 0x30000 |
#define | NMI_AHB_SHARE_MEM_BASE 0xd0000 |
#define | WIFI_HOST_RCV_CTRL_0 (0x1070) |
#define | WIFI_HOST_RCV_CTRL_1 (0x1084) |
#define | WIFI_HOST_RCV_CTRL_2 (0x1078) |
#define | WIFI_HOST_RCV_CTRL_3 (0x106c) |
#define | WIFI_HOST_RCV_CTRL_4 (0x150400) |
#define | WIFI_HOST_RCV_CTRL_5 (0x1088) |
Functions | |
sint8 | hif_chip_sleep (void) |
To make the chip sleep. More... | |
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... | |
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 | |
volatile tstrHifContext | gstrHifCxt |
#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().
#define WIFI_HOST_RCV_CTRL_5 (0x1088) |
sint8 hif_chip_sleep | ( | void | ) |
To make the chip sleep.
To make the chip sleep.
References chip_sleep(), M2M_NO_PS, M2M_SUCCESS, tstrHifContext::u8ChipMode, and tstrHifContext::u8ChipSleep.
To clear the chip sleep but keep the chip sleep.
To clear the chip count only but keep the chip awake
References M2M_SUCCESS, and tstrHifContext::u8ChipSleep.
sint8 hif_chip_wake | ( | void | ) |
To Wakeup the chip.
To Wakeup the chip.
References chip_wake(), M2M_NO_PS, M2M_SUCCESS, tstrHifContext::u8ChipMode, tstrHifContext::u8ChipSleep, and tstrHifContext::u8HifRXDone.
sint8 hif_deinit | ( | void * | arg | ) |
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. |
References hif_chip_wake(), m2m_memset(), and M2M_SUCCESS.
uint8 hif_get_sleep_mode | ( | void | ) |
Get the sleep mode of the HIF layer.
References tstrHifContext::u8ChipMode.
sint8 hif_handle_isr | ( | void | ) |
Handle interrupt received from NMC1500 firmware.
Handle interrupt received from NMC1500 firmware.
References hif_isr(), M2M_ERR, M2M_SUCCESS, nm_bsp_interrupt_ctrl(), tstrHifContext::u8Interrupt, and tstrHifContext::u8Yield.
sint8 hif_init | ( | void * | arg | ) |
To initialize HIF layer.
To initialize HIF layer.
[in] | arg | Pointer to the arguments. |
[in] | arg | Pointer to the arguments. |
References hif_chip_sleep(), hif_register_cb(), isr(), m2m_hif_cb(), m2m_memset(), M2M_REQ_GROUP_HIF, M2M_SUCCESS, and nm_bsp_register_isr().
|
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_CRYPTO, 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::pfCryptoCb, tstrHifContext::pfIpCb, tstrHifContext::pfOtaCb, tstrHifContext::pfSigmaCb, tstrHifContext::pfSslCb, tstrHifContext::pfWifiCb, tstrHifHdr::u16Length, tstrHifContext::u32RxAddr, tstrHifContext::u32RxSize, tstrHifHdr::u8Gid, tstrHifContext::u8HifRXDone, tstrHifHdr::u8Opcode, WIFI_HOST_RCV_CTRL_0, and WIFI_HOST_RCV_CTRL_1.
Referenced by hif_handle_isr().
References hif_set_rx_done(), M2M_ERR, M2M_ERR_FAIL, M2M_SUCCESS, nm_read_block(), NULL, tstrHifContext::u32RxAddr, and tstrHifContext::u32RxSize.
sint8 hif_register_cb | ( | uint8 | u8Grp, |
tpfHifCallBack | fn | ||
) |
References M2M_ERR, M2M_ERR_FAIL, M2M_REQ_GROUP_CRYPTO, M2M_REQ_GROUP_HIF, M2M_REQ_GROUP_IP, M2M_REQ_GROUP_OTA, M2M_REQ_GROUP_SIGMA, M2M_REQ_GROUP_SSL, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, tstrHifContext::pfCryptoCb, tstrHifContext::pfHifCb, tstrHifContext::pfIpCb, tstrHifContext::pfOtaCb, tstrHifContext::pfSigmaCb, tstrHifContext::pfSslCb, and tstrHifContext::pfWifiCb.
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). |
References hif_check_code(), hif_chip_sleep(), hif_chip_sleep_sc(), hif_chip_wake(), INTERRUPT_CORTUS_1_3000D0, INTERRUPT_CORTUS_2_3000D0, ISNMC3400, M2M_DBG, M2M_ERR, M2M_ERR_MEM_ALLOC, M2M_ERR_SEND, M2M_HIF_HDR_OFFSET, M2M_HIF_MAX_PACKET_SIZE, M2M_INFO, M2M_REQ_GROUP_IP, M2M_SUCCESS, NBIT1, NBIT2, NBIT3, NBIT7, NM_BSP_B_L_16, nm_bsp_sleep(), nm_read_reg_with_ret(), nm_write_block(), nm_write_reg(), nmi_get_chipid(), NMI_STATE_REG, NULL, tstrHifHdr::u16Length, tstrHifHdr::u8Gid, tstrHifHdr::u8Opcode, WIFI_HOST_RCV_CTRL_2, WIFI_HOST_RCV_CTRL_3, and WIFI_HOST_RCV_CTRL_4.
|
static |
References M2M_SUCCESS, NBIT1, nm_bsp_interrupt_ctrl(), nm_read_reg_with_ret(), nm_write_reg(), tstrHifContext::u8HifRXDone, and WIFI_HOST_RCV_CTRL_0.
Referenced by hif_isr(), and hif_receive().
void hif_set_sleep_mode | ( | uint8 | u8Pstype | ) |
Set the sleep mode of the HIF layer.
[in] | u8Pstype | Sleep mode. |
References tstrHifContext::u8ChipMode.
void hif_yield | ( | void | ) |
Yields control from interrupt event handler.
Yields control from interrupt event handler.
References tstrHifContext::u8Yield.
|
static |
References nm_bsp_interrupt_ctrl(), and tstrHifContext::u8Interrupt.
Referenced by hif_init().
WiFi call back function.
[in] | u8OpCode | HIF Opcode type. |
[in] | u16DataSize | HIF data length. |
[in] | u32Addr | HIF address. |
[in] | grp | HIF group type. |
Referenced by hif_init().
volatile tstrHifContext gstrHifCxt |