44 #if (defined NM_EDGE_INTERRUPT)&&(defined NM_LEVEL_INTERRUPT) 45 #error "only one type of interrupt NM_EDGE_INTERRUPT,NM_LEVEL_INTERRUPT" 48 #if !((defined NM_EDGE_INTERRUPT)||(defined NM_LEVEL_INTERRUPT)) 49 #error "define interrupt type NM_EDGE_INTERRUPT,NM_LEVEL_INTERRUPT" 53 #define NMI_AHB_DATA_MEM_BASE 0x30000 54 #define NMI_AHB_SHARE_MEM_BASE 0xd0000 56 #define WIFI_HOST_RCV_CTRL_0 (0x1070) 57 #define WIFI_HOST_RCV_CTRL_1 (0x1084) 58 #define WIFI_HOST_RCV_CTRL_2 (0x1078) 59 #define WIFI_HOST_RCV_CTRL_3 (0x106c) 60 #define WAKE_VALUE (0x5678) 61 #define SLEEP_VALUE (0x4321) 62 #define WAKE_REG (0x1074) 64 #define INTERRUPT_CORTUS_0_3000D0 (0x10a8) 65 #define INTERRUPT_CORTUS_1_3000D0 (0x10ac) 66 #define INTERRUPT_CORTUS_2_3000D0 (0x10b0) 67 #define INTERRUPT_CORTUS_3_3000D0 (0x10b4) 79 #define HIF_OTA_RB_ONLY 0xFFFF 80 #define HIFCODE_OTA_RB ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_ROLLBACK) 81 #define HIFCODE_OTA_SW ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_SWITCH_FIRMWARE) 82 #define HIFCODE_SSL_WRITECERT ((M2M_REQ_GROUP_SSL << 8) | M2M_SSL_REQ_WRITE_OWN_CERTS) 83 #define HIFCODE_WIFI_PASSIVESCAN ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_PASSIVE_SCAN) 89 #define NEW_HIF_LIST HIF_OTA_RB_ONLY, HIFCODE_SSL_WRITECERT, HIFCODE_WIFI_PASSIVESCAN 95 #define HIF_BLACKLIST_SZ (sizeof(gau16HifBlacklist)/sizeof(gau16HifBlacklist[0])) 108 #ifdef NM_LEVEL_INTERRUPT 117 #ifdef NM_EDGE_INTERRUPT 136 #ifdef NM_LEVEL_INTERRUPT 300 M2M_DBG(
"failed to stop power save\n");
379 M2M_ERR(
"HIF access limited to OTA Switch/Rollback only\n");
404 M2M_ERR(
"HIF OTA rb/sw only\n");
411 M2M_ERR(
"HIF message unsupported\n");
446 strHif.
u8Gid = u8Gid;
448 if(pu8DataBuf !=
NULL)
450 strHif.
u16Length += u16DataOffset + u16DataSize;
466 volatile uint32 reg, dma_addr = 0;
471 reg |= ((
uint32)u8Opcode<<8);
492 for(cnt = 0; cnt < 1000*5; cnt ++)
515 volatile uint32 u32CurrAddr;
516 u32CurrAddr = dma_addr;
522 if(pu8CtrlBuf !=
NULL)
526 u32CurrAddr += u16CtrlBufSize;
528 if(pu8DataBuf !=
NULL)
530 u32CurrAddr += (u16DataOffset - u16CtrlBufSize);
533 u32CurrAddr += u16DataSize;
552 M2M_DBG(
"Failed to alloc rx size\n");
560 M2M_ERR(
"(HIF)Fail to wakup the chip\n");
603 M2M_ERR(
"(hif) WIFI_HOST_RCV_CTRL_0 bus fail\n");
608 size = (
uint16)((reg >> 2) & 0xfff);
617 M2M_ERR(
"(hif) WIFI_HOST_RCV_CTRL_1 bus fail\n");
625 M2M_ERR(
"(hif) address bus fail\n");
629 if(strHif.u16Length != size)
631 if((size - strHif.u16Length) > 4)
633 M2M_ERR(
"(hif) Corrupted packet Size = %u <L = %u, G = %u, OP = %02X>\n",
634 size, strHif.u16Length, strHif.u8Gid, strHif.u8Opcode);
669 M2M_ERR(
"(hif) invalid group ID\n");
673 #ifndef ENABLE_UNO_BOARD 676 M2M_ERR(
"(hif) host app didn't set RX Done\n");
691 M2M_ERR(
"(hif) False interrupt %lx",reg);
697 M2M_ERR(
"(hif) Fail to Read interrupt reg\n");
737 M2M_ERR(
"(HIF) Fail to handle interrupt %d try Again..\n",ret);
744 M2M_ERR(
"(hif) FAIL to wakeup the chip\n");
768 if(u32Addr == 0 || pu8Buf ==
NULL || u16Sz == 0)
777 if((u32Addr == 0) && (pu8Buf ==
NULL) && (u16Sz == 0))
782 M2M_ERR(
" hif_receive: Invalid argument\n");
790 size = (
uint16)((reg >> 2) & 0xfff);
801 M2M_ERR(
"APP Requested Size is larger than the recived buffer size <%d><%d>\n",u16Sz, size);
804 if((u32Addr < address)||((u32Addr + u16Sz)>(address+size)))
807 M2M_ERR(
"APP Requested Address beyond the recived buffer address and length\n");
812 if(isDone || (((address+size) - (u32Addr+u16Sz)) == 0) ||
813 ((4 - ((u32Addr+u16Sz) & 3)) == ((address+size) - (u32Addr+u16Sz))))
sint8 hif_chip_wake(void)
To Wakeup the chip.
void(* tpfHifCallBack)(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
used to point to Wi-Fi call back function depend on Arduino project or other projects.
WINC3400 Peripherals Application Interface.
sint8 nm_read_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz)
This module contains common APIs declarations.
sint8 nm_get_hif_info(uint16 *pu16FwHifInfo, uint16 *pu16OtaHifInfo)
Get Hif info of images in both partitions (Firmware and Ota).
#define M2M_HIF_BLOCK_VALUE
signed char sint8
Range of values between -128 to 127.
static volatile uint8 gu8ChipMode
Structure to hold HIF header.
#define M2M_GET_HIF_MINOR(hif_info)
#define WIFI_HOST_RCV_CTRL_3
sint8 nm_read_reg_with_ret(uint32 u32Addr, uint32 *pu32RetVal)
This module contains WINC3400 M2M driver APIs declarations.
sint8 nm_write_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz)
void hif_yield(void)
Yields control from interrupt event handler.
void nm_bsp_register_isr(tpfNmBspIsr pfIsr)
sint8 hif_handle_isr(void)
Handle interrupt received from NMC1500 firmware.
static volatile uint8 gu8Yield
#define M2M_HIF_HDR_OFFSET
#define M2M_GET_HIF_MAJOR(hif_info)
#define M2M_ERR_MEM_ALLOC
#define WIFI_HOST_RCV_CTRL_0
static volatile uint8 gu8HifSizeDone
WINC3400 IoT Application Interface Internal Types.
#define WIFI_HOST_RCV_CTRL_2
void nm_bsp_interrupt_ctrl(uint8 u8Enable)
Enable/Disable interrupts.
sint8 hif_init(void *arg)
To initialize HIF layer.
#define INTERRUPT_CORTUS_2_3000D0
unsigned short uint16
Range of values between 0 to 65535.
sint8 hif_check_code(uint8 u8Gid, uint8 u8OpCode)
To check that a particular hif message is supported with the current driver/firmware pair...
sint8 hif_check_compatibility(uint16 u16HifInfo)
To check the compatibility of an image with the current driver.
sint8 hif_register_cb(uint8 u8Grp, tpfHifCallBack fn)
static uint16 gau16HifBlacklist[]
This module contains WINC3400 ASIC specific internal APIs.
void nm_bsp_sleep(uint32 u32TimeMsec)
static sint8 hif_isr(void)
Host interface interrupt service routine.
sint8 nm_write_reg(uint32 u32Addr, uint32 u32Val)
static sint8 hif_set_rx_done(void)
static volatile uint8 gu8ChipSleep
#define INTERRUPT_CORTUS_1_3000D0
#define M2M_HIF_MAJOR_VALUE
#define WIFI_HOST_RCV_CTRL_1
#define INTERRUPT_CORTUS_0_3000D0
sint8 hif_enable_access(void)
To enable access to HIF layer, based on HIF level of Firmware. This function reads HIF level directly...
sint8 hif_send(uint8 u8Gid, uint8 u8Opcode, uint8 *pu8CtrlBuf, uint16 u16CtrlBufSize, uint8 *pu8DataBuf, uint16 u16DataSize, uint16 u16DataOffset)
Send packet using host interface.
uint32 nmi_get_chipid(void)
This module contains WINC3400 bus APIs implementation.
static void m2m_hif_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
WiFi call back function.
uint8 hif_get_sleep_mode(void)
Get the sleep mode of the HIF layer.
unsigned long uint32
Range of values between 0 to 4294967295.
This module contains WINC3400 BSP APIs declarations.
unsigned char uint8
Range of values between 0 to 255.
static uint8 gu8HifBlOffset
sint8 hif_chip_sleep(void)
To make the chip sleep.
#define M2M_ERR_FW_VER_MISMATCH
void hif_set_sleep_mode(uint8 u8Pstype)
Set the sleep mode of the HIF layer.
This module contains M2M host interface APIs implementation.
sint8 nm_clkless_wake(void)
Wakeup the chip using clockless registers.
uint32 nm_read_reg(uint32 u32Addr)
#define M2M_GET_HIF_BLOCK(hif_info)
static volatile uint8 gu8Interrupt
sint8 hif_receive(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone)
sint8 hif_deinit(void *arg)
To Deinitialize HIF layer.