Macros | Functions | Variables
m2m_hif.c File Reference

This module contains M2M host interface APIs implementation. More...

#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 dependency graph for m2m_hif.c:

Go to the source code of this file.

Macros

#define HIF_BLACKLIST_SZ   (sizeof(gau16HifBlacklist)/sizeof(gau16HifBlacklist[0]))
 
#define HIF_OTA_RB_ONLY   0xFFFF
 
#define HIFCODE_OTA_RB   ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_ROLLBACK)
 
#define HIFCODE_OTA_SW   ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_SWITCH_FIRMWARE)
 
#define HIFCODE_SSL_WRITECERT   ((M2M_REQ_GROUP_SSL << 8) | M2M_SSL_REQ_WRITE_OWN_CERTS)
 
#define HIFCODE_WIFI_PASSIVESCAN   ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_PASSIVE_SCAN)
 
#define INTERRUPT_CORTUS_0_3000D0   (0x10a8)
 
#define INTERRUPT_CORTUS_1_3000D0   (0x10ac)
 
#define INTERRUPT_CORTUS_2_3000D0   (0x10b0)
 
#define INTERRUPT_CORTUS_3_3000D0   (0x10b4)
 
#define NEW_HIF_LIST   HIF_OTA_RB_ONLY, HIFCODE_SSL_WRITECERT, HIFCODE_WIFI_PASSIVESCAN
 
#define NMI_AHB_DATA_MEM_BASE   0x30000
 
#define NMI_AHB_SHARE_MEM_BASE   0xd0000
 
#define SLEEP_VALUE   (0x4321)
 
#define WAKE_REG   (0x1074)
 
#define WAKE_VALUE   (0x5678)
 
#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)
 

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...
 
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. This function reads HIF level directly from a register written by 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}
 
static volatile uint8 gu8ChipMode = 0
 
static volatile uint8 gu8ChipSleep = 0
 
static uint8 gu8HifBlOffset = 0
 
static volatile uint8 gu8HifSizeDone = 0
 
static volatile uint8 gu8Interrupt = 0
 
static volatile uint8 gu8Yield = 0
 
tpfHifCallBack pfHifCb = NULL
 
tpfHifCallBack pfIpCb = NULL
 
tpfHifCallBack pfOtaCb = NULL
 
tpfHifCallBack pfSigmaCb = NULL
 
tpfHifCallBack pfSSLCb = NULL
 
tpfHifCallBack pfWifiCb = NULL
 

Detailed Description

This module contains M2M host interface APIs implementation.

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

Definition in file m2m_hif.c.

Macro Definition Documentation

◆ HIF_BLACKLIST_SZ

#define HIF_BLACKLIST_SZ   (sizeof(gau16HifBlacklist)/sizeof(gau16HifBlacklist[0]))

Definition at line 95 of file m2m_hif.c.

◆ HIF_OTA_RB_ONLY

#define HIF_OTA_RB_ONLY   0xFFFF

Definition at line 79 of file m2m_hif.c.

◆ HIFCODE_OTA_RB

#define HIFCODE_OTA_RB   ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_ROLLBACK)

Definition at line 80 of file m2m_hif.c.

◆ HIFCODE_OTA_SW

#define HIFCODE_OTA_SW   ((M2M_REQ_GROUP_OTA << 8) | M2M_OTA_REQ_SWITCH_FIRMWARE)

Definition at line 81 of file m2m_hif.c.

◆ HIFCODE_SSL_WRITECERT

#define HIFCODE_SSL_WRITECERT   ((M2M_REQ_GROUP_SSL << 8) | M2M_SSL_REQ_WRITE_OWN_CERTS)

Definition at line 82 of file m2m_hif.c.

◆ HIFCODE_WIFI_PASSIVESCAN

#define HIFCODE_WIFI_PASSIVESCAN   ((M2M_REQ_GROUP_WIFI << 8) | M2M_WIFI_REQ_PASSIVE_SCAN)

Definition at line 83 of file m2m_hif.c.

◆ INTERRUPT_CORTUS_0_3000D0

#define INTERRUPT_CORTUS_0_3000D0   (0x10a8)

Definition at line 64 of file m2m_hif.c.

◆ INTERRUPT_CORTUS_1_3000D0

#define INTERRUPT_CORTUS_1_3000D0   (0x10ac)

Definition at line 65 of file m2m_hif.c.

◆ INTERRUPT_CORTUS_2_3000D0

#define INTERRUPT_CORTUS_2_3000D0   (0x10b0)

Definition at line 66 of file m2m_hif.c.

◆ INTERRUPT_CORTUS_3_3000D0

#define INTERRUPT_CORTUS_3_3000D0   (0x10b4)

Definition at line 67 of file m2m_hif.c.

◆ NEW_HIF_LIST

Definition at line 89 of file m2m_hif.c.

◆ NMI_AHB_DATA_MEM_BASE

#define NMI_AHB_DATA_MEM_BASE   0x30000

Definition at line 53 of file m2m_hif.c.

◆ NMI_AHB_SHARE_MEM_BASE

#define NMI_AHB_SHARE_MEM_BASE   0xd0000

Definition at line 54 of file m2m_hif.c.

◆ SLEEP_VALUE

#define SLEEP_VALUE   (0x4321)

Definition at line 61 of file m2m_hif.c.

◆ WAKE_REG

#define WAKE_REG   (0x1074)

Definition at line 62 of file m2m_hif.c.

◆ WAKE_VALUE

#define WAKE_VALUE   (0x5678)

Definition at line 60 of file m2m_hif.c.

◆ WIFI_HOST_RCV_CTRL_0

#define WIFI_HOST_RCV_CTRL_0   (0x1070)

Definition at line 56 of file m2m_hif.c.

◆ WIFI_HOST_RCV_CTRL_1

#define WIFI_HOST_RCV_CTRL_1   (0x1084)

Definition at line 57 of file m2m_hif.c.

◆ WIFI_HOST_RCV_CTRL_2

#define WIFI_HOST_RCV_CTRL_2   (0x1078)

Definition at line 58 of file m2m_hif.c.

◆ WIFI_HOST_RCV_CTRL_3

#define WIFI_HOST_RCV_CTRL_3   (0x106c)

Definition at line 59 of file m2m_hif.c.

Function Documentation

◆ hif_check_code()

sint8 hif_check_code ( uint8  u8Gid,
uint8  u8OpCode 
)

To check that a particular hif message is supported with the current driver/firmware pair.

Parameters
[in]u8GidGroup ID.
[in]u8OpcodeOperation ID.
Returns
The function shall return ZERO for support and a negative value otherwise.

Definition at line 394 of file m2m_hif.c.

◆ hif_check_compatibility()

sint8 hif_check_compatibility ( uint16  u16HifInfo)

To check the compatibility of an image with the current driver.

Parameters
[in]u16HifInfoHIF info of image to be checked.
Returns
The function shall return ZERO for compatible image and a negative value otherwise.

Definition at line 327 of file m2m_hif.c.

◆ hif_chip_sleep()

NMI_API sint8 hif_chip_sleep ( void  )

To make the chip sleep.

Returns
The function shall return ZERO for successful operation and a negative value otherwise.

Definition at line 226 of file m2m_hif.c.

◆ hif_chip_wake()

NMI_API sint8 hif_chip_wake ( void  )

To Wakeup the chip.

Returns
The function shall return ZERO for successful operation and a negative value otherwise.

Definition at line 167 of file m2m_hif.c.

◆ hif_deinit()

NMI_API sint8 hif_deinit ( void *  arg)

To Deinitialize HIF layer.

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

Definition at line 289 of file m2m_hif.c.

◆ hif_enable_access()

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.

Returns
The function shall return ZERO for full match operation and a negative value if operation is restricted.

Definition at line 343 of file m2m_hif.c.

◆ hif_get_sleep_mode()

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.

Definition at line 216 of file m2m_hif.c.

◆ hif_handle_isr()

hif_handle_isr ( void  )

Handle interrupt received from NMC1500 firmware.

Returns
The function SHALL return 0 for success and a negative value otherwise.

Definition at line 716 of file m2m_hif.c.

◆ hif_init()

NMI_API sint8 hif_init ( void *  arg)

To initialize HIF layer.

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

Definition at line 266 of file m2m_hif.c.

◆ hif_isr()

hif_isr ( void  )
static

Host interface interrupt service routine.

Author
M. Abdelmawla
Date
15 July 2012
Returns
1 in case of interrupt received else 0 will be returned
Version
1.0

start bus transfer

Definition at line 576 of file m2m_hif.c.

◆ hif_receive()

sint8 hif_receive ( uint32  u32Addr,
uint8 pu8Buf,
uint16  u16Sz,
uint8  isDone 
)

Definition at line 762 of file m2m_hif.c.

◆ hif_register_cb()

sint8 hif_register_cb ( uint8  u8Grp,
tpfHifCallBack  fn 
)

Definition at line 839 of file m2m_hif.c.

◆ hif_send()

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.

Definition at line 439 of file m2m_hif.c.

◆ hif_set_rx_done()

static sint8 hif_set_rx_done ( void  )
static

Definition at line 113 of file m2m_hif.c.

◆ hif_set_sleep_mode()

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.

Definition at line 201 of file m2m_hif.c.

◆ hif_yield()

hif_yield ( void  )

Yields control from interrupt event handler.

Definition at line 711 of file m2m_hif.c.

◆ isr()

static void isr ( void  )
static

Definition at line 105 of file m2m_hif.c.

◆ m2m_hif_cb()

static void m2m_hif_cb ( uint8  u8OpCode,
uint16  u16DataSize,
uint32  u32Addr 
)
static

WiFi call back function.

Parameters
[in]u8OpCodeHIF Opcode type.
[in]u16DataSizeHIF data length.
[in]u32AddrHIF address.
Author
Date
Version
1.0

Definition at line 156 of file m2m_hif.c.

Variable Documentation

◆ gau16HifBlacklist

uint16 gau16HifBlacklist[] = {NEW_HIF_LIST}
static

Definition at line 94 of file m2m_hif.c.

◆ gu8ChipMode

volatile uint8 gu8ChipMode = 0
static

Definition at line 70 of file m2m_hif.c.

◆ gu8ChipSleep

volatile uint8 gu8ChipSleep = 0
static

Definition at line 71 of file m2m_hif.c.

◆ gu8HifBlOffset

uint8 gu8HifBlOffset = 0
static

Definition at line 96 of file m2m_hif.c.

◆ gu8HifSizeDone

volatile uint8 gu8HifSizeDone = 0
static

Definition at line 72 of file m2m_hif.c.

◆ gu8Interrupt

volatile uint8 gu8Interrupt = 0
static

Definition at line 73 of file m2m_hif.c.

◆ gu8Yield

volatile uint8 gu8Yield = 0
static

Definition at line 74 of file m2m_hif.c.

◆ pfHifCb

tpfHifCallBack pfHifCb = NULL

Definition at line 102 of file m2m_hif.c.

◆ pfIpCb

tpfHifCallBack pfIpCb = NULL

pointer to Socket call back function

Definition at line 99 of file m2m_hif.c.

◆ pfOtaCb

tpfHifCallBack pfOtaCb = NULL

pointer to OTA call back function

Definition at line 100 of file m2m_hif.c.

◆ pfSigmaCb

tpfHifCallBack pfSigmaCb = NULL

Definition at line 101 of file m2m_hif.c.

◆ pfSSLCb

tpfHifCallBack pfSSLCb = NULL

Definition at line 103 of file m2m_hif.c.

◆ pfWifiCb

tpfHifCallBack pfWifiCb = NULL

pointer to Wi-Fi call back function

Definition at line 98 of file m2m_hif.c.



inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:59