Microchip® Advanced Software Framework

m2m_hif.c File Reference

This module contains WILC M2M host interface APIs implementation.

Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.

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 (tstrHifinitParam *pstrInitParam)
 
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...
 
sint8 hif_send_optimized (uint8 u8Gid, uint8 u8Opcode, uint8 *buffer, uint16 u16DataSize)
 
sint8 hif_set_receive_buffer (void *pvBuffer, uint16 u16BufferLen)
 
    Handle interrupt received from NMC1500 firmware.
More...
 
static sint8 hif_set_rx_done (void)
 
void hif_set_sleep_mode (uint8 u8Pstype)
 Set the sleep mode of the HIF layer. More...
 
static void isr (void)
 
static void m2m_hif_cb (uint8 u8OpCode, uint16 u16DataSize, uint8 *pu8Buff)
 

Variables

static volatile tstrHifHdr gstrHif __M2M_DMA_BUF_ATT__
 
static volatile uint8 gu8ChipMode = 0
 
static volatile uint8 gu8ChipSleep = 0
 
static volatile uint8 gu8HifSizeDone = 0
 
static volatile uint8 gu8Interrupt = 0
 
tpfHifCallBack pfHifCb = NULL
 
tpfHifCallBack pfWifiCb = NULL
 
tstrHifinitParam strHifInitParam
 

#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)

Referenced by hif_isr(), and hif_receive().

#define WIFI_HOST_RCV_CTRL_2   (0x1078)
#define WIFI_HOST_RCV_CTRL_3   (0x106c)

Referenced by hif_send(), and hif_send_optimized().

#define WIFI_HOST_RCV_CTRL_4   (0x150400)
#define WIFI_HOST_RCV_CTRL_5   (0x1088)

NMI_API sint8 hif_chip_sleep ( void  )

To make the chip sleep.

        To make the chip sleep.
Returns
The function shall return ZERO for successful operation and a negative value otherwise.

References chip_sleep(), gu8ChipMode, gu8ChipSleep, M2M_NO_PS, and M2M_SUCCESS.

Referenced by gpio_ioctl(), hif_send(), hif_send_optimized(), m2m_wifi_get_mac_address(), and m2m_wifi_get_otp_mac_address().

NMI_API sint8 hif_chip_sleep_sc ( void  )

To clear the chip sleep but keep the chip sleep.

        To clear the chip count only but keep the chip awake
Returns
The function shall return ZERO for successful operation and a negative value otherwise.

References gu8ChipSleep, and M2M_SUCCESS.

Referenced by hif_send().

NMI_API sint8 hif_chip_wake ( void  )

To Wakeup the chip.

    To Wakeup the chip.
Returns
The function shall return ZERO for successful operation and a negative value otherwise.

References chip_wake(), gu8ChipMode, gu8ChipSleep, gu8HifSizeDone, M2M_NO_PS, and M2M_SUCCESS.

Referenced by gpio_ioctl(), hif_deinit(), hif_send(), hif_send_optimized(), m2m_wifi_get_mac_address(), and m2m_wifi_get_otp_mac_address().

NMI_API sint8 hif_deinit ( void arg)

To Deinitialize HIF layer.

        To Deinitialize HIF layer.
Parameters
[in]argPointer to the arguments.
Returns
The function shall return ZERO for successful operation and a negative value otherwise.

References hif_chip_wake(), M2M_DBG, M2M_DISABLE_PS, M2M_SUCCESS, nm_bsp_sleep(), and nm_read_reg().

Referenced by m2m_wifi_deinit().

NMI_API uint8 hif_get_sleep_mode ( void  )

Get the sleep mode of the HIF layer.

Returns
The function SHALL return the sleep mode of the HIF layer.

References gu8ChipMode.

Referenced by m2m_wifi_get_sleep_mode(), and m2m_wifi_set_sleep_mode().

hif_handle_isr ( void  )

Handle interrupt received from NMC1500 firmware.

    Handle interrupt received from NMC1500 firmware.
Returns
The function SHALL return 0 for success and a negative value otherwise.

References gu8Interrupt, hif_isr(), M2M_ERR, and M2M_SUCCESS.

Referenced by m2m_wifi_handle_events().

sint8 hif_register_cb ( uint8  u8Grp,
tpfHifCallBack  fn 
)
NMI_API sint8 hif_send ( uint8  u8Gid,
uint8  u8Opcode,
uint8 pu8CtrlBuf,
uint16  u16CtrlBufSize,
uint8 pu8DataBuf,
uint16  u16DataSize,
uint16  u16DataOffset 
)

Send packet using host interface.

Parameters
[in]u8GidGroup ID.
[in]u8OpcodeOperation ID.
[in]pu8CtrlBufPointer to the Control buffer.
[in]u16CtrlBufSizeControl buffer size.
[in]u16DataOffsetPacket Data offset.
[in]pu8DataBufPacket buffer Allocated by the caller.
[in]u16DataSizePacket buffer size (including the HIF header).
Returns
The function shall return ZERO for successful operation and a negative value otherwise.

References hif_chip_sleep(), hif_chip_sleep_sc(), hif_chip_wake(), M2M_DBG, M2M_ERR, M2M_ERR_MEM_ALLOC, M2M_ERR_SEND, M2M_HIF_HDR_OFFSET, M2M_SUCCESS, NBIT7, NM_BSP_B_L_16, nm_read_reg_with_ret(), nm_write_block(), nm_write_reg(), NULL, and WIFI_HOST_RCV_CTRL_3.

Referenced by m2m_wifi_ap_add_black_list(), m2m_wifi_ap_get_assoc_info(), m2m_wifi_change_monitoring_channel(), m2m_wifi_connect(), m2m_wifi_disable_ap(), m2m_wifi_disable_mcast_filter(), m2m_wifi_disable_monitoring_mode(), m2m_wifi_disconnect(), m2m_wifi_download_cert(), m2m_wifi_enable_ap(), m2m_wifi_enable_mac_mcast(), m2m_wifi_enable_mcast_filter(), m2m_wifi_enable_monitoring_mode(), m2m_wifi_get_connection_info(), m2m_wifi_p2p(), m2m_wifi_p2p_disconnect(), m2m_wifi_req_curr_rssi(), m2m_wifi_req_scan_result(), m2m_wifi_request_scan(), m2m_wifi_request_scan_ssid(), m2m_wifi_send_wlan_pkt(), m2m_wifi_set_antenna_mode(), m2m_wifi_set_cust_InfoElement(), m2m_wifi_set_device_name(), m2m_wifi_set_ht_enable(), m2m_wifi_set_lsn_int(), m2m_wifi_set_mac_address(), m2m_wifi_set_max_tx_rate(), m2m_wifi_set_p2p_control_ifc(), m2m_wifi_set_p2p_pin(), m2m_wifi_set_scan_list(), m2m_wifi_set_scan_options(), m2m_wifi_set_scan_region(), m2m_wifi_set_sleep_mode(), m2m_wifi_set_tx_power(), m2m_wifi_wps(), and m2m_wifi_wps_disable().

hif_set_receive_buffer ( void pvBuffer,
uint16  u16BufferLen 
)

    Handle interrupt received from NMC1500 firmware.

Parameters
[in]pvBufferPointer to the buffer.
[in]u16BufferLenSize of the buffer.
Returns
The function SHALL return 0 for success and a negative value otherwise.

References M2M_ERR, tstrHifinitParam::pu8RcvBuff, and tstrHifinitParam::u32RcvBuffSize.

Referenced by m2m_wifi_set_receive_buffer().

NMI_API void hif_set_sleep_mode ( uint8  u8Pstype)

Set the sleep mode of the HIF layer.

Parameters
[in]u8PstypeSleep mode.
Returns
The function SHALL return 0 for success and a negative value otherwise.

References gu8ChipMode.

Referenced by m2m_wifi_set_sleep_mode().

static void isr ( void  )
static
static void m2m_hif_cb ( uint8  u8OpCode,
uint16  u16DataSize,
uint8 pu8Buff 
)
static

Referenced by hif_init().

volatile tstrHifHdr gstrHif __M2M_DMA_BUF_ATT__
static
volatile uint8 gu8ChipMode = 0
static
volatile uint8 gu8ChipSleep = 0
static
volatile uint8 gu8HifSizeDone = 0
static
volatile uint8 gu8Interrupt = 0
static

Referenced by hif_handle_isr(), hif_init(), and isr().

tpfHifCallBack pfHifCb = NULL

Referenced by hif_register_cb().

tpfHifCallBack pfWifiCb = NULL

pointer to Wi-Fi call back function

Referenced by hif_init(), hif_isr(), and hif_register_cb().

tstrHifinitParam strHifInitParam

Referenced by m2m_wifi_init().