NNN50 WIFI_API library

Dependents:   NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2m_hif.h Source File

m2m_hif.h

Go to the documentation of this file.
00001 /**
00002  *
00003  * \file
00004  *
00005  * \brief This module contains M2M host interface APIs implementation.
00006  *
00007  * Copyright (c) 2016-2017 Atmel Corporation. All rights reserved.
00008  *
00009  * \asf_license_start
00010  *
00011  * \page License
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions are met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright notice,
00017  *    this list of conditions and the following disclaimer.
00018  *
00019  * 2. Redistributions in binary form must reproduce the above copyright notice,
00020  *    this list of conditions and the following disclaimer in the documentation
00021  *    and/or other materials provided with the distribution.
00022  *
00023  * 3. The name of Atmel may not be used to endorse or promote products derived
00024  *    from this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00027  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00028  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00029  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
00030  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00031  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00032  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00033  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00034  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00035  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * \asf_license_stop
00039  *
00040  */
00041 
00042 #ifndef _M2M_HIF_
00043 #define _M2M_HIF_
00044 
00045 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
00046 INCLUDES
00047 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
00048 
00049 #include "common/include/nm_common.h"
00050 /*!< Include depends on UNO Board is used or not*/
00051 #ifdef ENABLE_UNO_BOARD
00052 #include "m2m_uno_hif.h"
00053 #endif
00054 
00055 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
00056 MACROS
00057 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
00058 
00059 #define M2M_HIF_MAX_PACKET_SIZE      (1600 - 4)
00060 /*!< Maximum size of the buffer could be transferred between Host and Firmware.
00061 */
00062 
00063 #define M2M_HIF_HDR_OFFSET (sizeof(tstrHifHdr) + 4)
00064 
00065 /**
00066 *   @struct     tstrHifHdr
00067 *   @brief      Structure to hold HIF header
00068 */
00069 typedef struct
00070 {
00071     uint8   u8Gid;      /*!< Group ID */
00072     uint8   u8Opcode;   /*!< OP code */
00073     uint16  u16Length;  /*!< Payload length */
00074 }tstrHifHdr;
00075 
00076 #ifdef __cplusplus
00077      extern "C" {
00078 #endif
00079 
00080 /*!
00081 @typedef typedef void (*tpfHifCallBack)(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr);
00082 @brief  used to point to Wi-Fi call back function depend on Arduino project or other projects.
00083 @param [in] u8OpCode
00084                 HIF Opcode type.
00085 @param [in] u16DataSize
00086                 HIF data length.
00087 @param [in] u32Addr
00088                 HIF address.
00089 @param [in] grp
00090                 HIF group type.
00091 */
00092 typedef void (*tpfHifCallBack)(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr);
00093 /**
00094 *   @fn         NMI_API sint8 hif_init(void * arg);
00095 *   @brief
00096                 To initialize HIF layer.
00097 *   @param [in] arg
00098 *               Pointer to the arguments.
00099 *   @return
00100                 The function shall return ZERO for successful operation and a negative value otherwise.
00101 */
00102 NMI_API sint8 hif_init(void * arg);
00103 /**
00104 *   @fn         NMI_API sint8 hif_deinit(void * arg);
00105 *   @brief
00106                 To Deinitialize HIF layer.
00107 *   @param [in] arg
00108 *               Pointer to the arguments.
00109 *    @return
00110                 The function shall return ZERO for successful operation and a negative value otherwise.
00111 */
00112 NMI_API sint8 hif_deinit(void * arg);
00113 /**
00114 *   @fn     NMI_API sint8 hif_send(uint8 u8Gid,uint8 u8Opcode,uint8 *pu8CtrlBuf,uint16 u16CtrlBufSize,
00115                        uint8 *pu8DataBuf,uint16 u16DataSize, uint16 u16DataOffset)
00116 *   @brief  Send packet using host interface.
00117 
00118 *   @param [in] u8Gid
00119 *               Group ID.
00120 *   @param [in] u8Opcode
00121 *               Operation ID.
00122 *   @param [in] pu8CtrlBuf
00123 *               Pointer to the Control buffer.
00124 *   @param [in] u16CtrlBufSize
00125                 Control buffer size.
00126 *   @param [in] u16DataOffset
00127                 Packet Data offset.
00128 *   @param [in] pu8DataBuf
00129 *               Packet buffer Allocated by the caller.
00130 *   @param [in] u16DataSize
00131                 Packet buffer size (including the HIF header).
00132 *    @return    The function shall return ZERO for successful operation and a negative value otherwise.
00133 */
00134 NMI_API sint8 hif_send(uint8 u8Gid,uint8 u8Opcode,uint8 *pu8CtrlBuf,uint16 u16CtrlBufSize,
00135                        uint8 *pu8DataBuf,uint16 u16DataSize, uint16 u16DataOffset);
00136 /*
00137 *   @fn     hif_receive
00138 *   @brief  Host interface interrupt serviece routine
00139 *   @param [in] u32Addr
00140 *               Receive start address
00141 *   @param [out] pu8Buf
00142 *               Pointer to receive buffer. Allocated by the caller
00143 *   @param [in]  u16Sz
00144 *               Receive buffer size
00145 *   @param [in] isDone
00146 *               If you don't need any more packets send True otherwise send false
00147 *   @return
00148                 The function shall return ZERO for successful operation and a negative value otherwise.
00149 */
00150 
00151 NMI_API sint8 hif_receive(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone);
00152 /**
00153 *   @fn         hif_register_cb
00154 *   @brief
00155                 To set Callback function for every  Component.
00156 
00157 *   @param [in] u8Grp
00158 *               Group to which the Callback function should be set.
00159 
00160 *   @param [in] fn
00161 *               function to be set to the specified group.
00162 *   @return
00163                 The function shall return ZERO for successful operation and a negative value otherwise.
00164 */
00165 NMI_API sint8 hif_register_cb(uint8 u8Grp,tpfHifCallBack fn);
00166 /**
00167 *   @fn     NMI_API sint8 hif_chip_sleep(void);
00168 *   @brief
00169                 To make the chip sleep.
00170 *   @return
00171                 The function shall return ZERO for successful operation and a negative value otherwise.
00172 */
00173 NMI_API sint8 hif_chip_sleep(void);
00174 /**
00175 *   @fn     NMI_API sint8 hif_chip_sleep_sc(void);
00176 *   @brief
00177                 To clear the chip count only but keep the chip awake
00178 *   @return
00179                 The function shall return ZERO for successful operation and a negative value otherwise.
00180 */
00181 NMI_API sint8 hif_chip_sleep_sc(void);
00182 /**
00183 *   @fn     NMI_API sint8 hif_chip_wake(void);
00184 *   @brief
00185             To Wakeup the chip.
00186 *   @return
00187             The function shall return ZERO for successful operation and a negative value otherwise.
00188 */
00189 
00190 NMI_API sint8 hif_chip_wake(void);
00191 /*!
00192 @fn \
00193             NMI_API void hif_set_sleep_mode(uint8 u8Pstype);
00194 
00195 @brief
00196             Set the sleep mode of the HIF layer.
00197 
00198 @param [in] u8Pstype
00199                 Sleep mode.
00200 
00201 @return
00202             The function SHALL return 0 for success and a negative value otherwise.
00203 */
00204 
00205 NMI_API void hif_set_sleep_mode(uint8 u8Pstype);
00206 /*!
00207 @fn \
00208     NMI_API uint8 hif_get_sleep_mode(void);
00209 
00210 @brief
00211     Get the sleep mode of the HIF layer.
00212 
00213 @return
00214     The function SHALL return the sleep mode of the HIF layer.
00215 */
00216 
00217 NMI_API uint8 hif_get_sleep_mode(void);
00218 
00219 #ifdef CORTUS_APP
00220 /**
00221 *   @fn     hif_Resp_handler(uint8 *pu8Buffer, uint16 u16BufferSize)
00222 *   @brief
00223                 Response handler for HIF layer.
00224 
00225 *   @param [in] pu8Buffer
00226                 Pointer to the buffer.
00227 
00228 *   @param [in] u16BufferSize
00229                 Buffer size.
00230 
00231 *   @return
00232                 The function SHALL return 0 for success and a negative value otherwise.
00233 */
00234 NMI_API sint8 hif_Resp_handler(uint8 *pu8Buffer, uint16 u16BufferSize);
00235 #endif
00236 
00237 /**
00238 *   @fn     hif_handle_isr(void)
00239 *   @brief
00240             Handle interrupt received from NMC1500 firmware.
00241 *   @return
00242             The function SHALL return 0 for success and a negative value otherwise.
00243 */
00244 NMI_API sint8 hif_handle_isr(void);
00245 
00246 #ifdef __cplusplus
00247 }
00248 #endif
00249 #endif
00250 
00251