Update WINC1500 driver to 19.4.4

This commit is contained in:
iabdalkader 2016-04-05 22:30:00 +02:00
parent b8e338138c
commit dae73f6250
22 changed files with 3044 additions and 1062 deletions

View File

@ -2,7 +2,7 @@
*
* \file
*
* \brief This module contains common APIs declarations.
* \brief WINC Driver Common API Declarations.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
@ -139,16 +139,6 @@ Invalid argument
#define BYTE_3(word) ((uint8)(((word) >> 0 ) & 0x000000FFUL))
#endif
typedef enum{
M2M_REQ_GRP_MAIN = 0, M2M_REQ_GRP_WIFI, M2M_REQ_GRP_IP, M2M_REQ_GRP_HIF, M2M_REQ_GRP_OTA
}tenuM2mReqGrp;
typedef enum{
M2M_REQ_CONFIG_PKT,
M2M_REQ_DATA_PKT = NBIT7
}tenuM2mReqPkt;
/**@}*/
#ifdef __cplusplus
extern "C" {

View File

@ -57,21 +57,21 @@
#define M2M_LOG_REQ 3
#define M2M_LOG_DBG 4
#if (defined __APP_APS3_CORTUS__)
#if (defined __APS3_CORTUS__)
#define M2M_LOG_LEVEL M2M_LOG_ERROR
#else
#define M2M_LOG_LEVEL M2M_LOG_REQ
#endif
/**/
#if !((defined __MSP430FR5739)||(defined __MCF964548__))
#define M2M_ERR(...)
#define M2M_INFO(...)
#define M2M_REQ(...)
#define M2M_DBG(...)
#define M2M_PRINT(...)
#if (CONF_WINC_DEBUG == 1)
#undef M2M_PRINT
#define M2M_PRINT(...) do{CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#if (M2M_LOG_LEVEL >= M2M_LOG_ERROR)
#undef M2M_ERR
@ -85,41 +85,11 @@
#if (M2M_LOG_LEVEL >= M2M_LOG_DBG)
#undef M2M_DBG
#define M2M_DBG(...) do{CONF_WINC_PRINTF("(APP)(DBG)[%s][%d]",__FUNCTION__,__LINE__); CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#endif
#endif
#endif
#endif
#else
#define M2M_ERR(...)
#define M2M_DBG(...)
#define M2M_REQ(...)
#define M2M_INFO(...)
#define M2M_PRINT(...)
#endif
#else
#if (!defined __MCF964548__)||(!defined __SAMD21J18A__)
static void M2M_ERR(const char *_format, ...) //__attribute__ ((__format__ (M2M_ERR, 1, 2)))
{
}
static void M2M_DBG(const char *_format, ...) //__attribute__ ((__format__ (M2M_DBG, 1, 2)))
{
}
static void M2M_REQ(const char *_format, ...) //__attribute__ ((__format__ (M2M_DBG, 1, 2)))
{
}
static void M2M_INFO(const char *_format, ...) // __attribute__ ((__format__ (M2M_INFO, 1, 2)))
{
}
static void M2M_PRINT(const char *_format, ...) // __attribute__ ((__format__ (M2M_INFO, 1, 2)))
{
}
static void CONF_WINC_PRINTF(const char *_format, ...)
{
}
#endif
#endif
#endif /*M2M_LOG_DBG*/
#endif /*M2M_LOG_REQ*/
#endif /*M2M_LOG_INFO*/
#endif /*M2M_LOG_ERROR*/
#endif /*CONF_WINC_DEBUG */
/**@}*/
#endif /* _NM_DEBUG_H_ */
#endif /* _NM_DEBUG_H_ */

View File

@ -2,7 +2,7 @@
*
* \file
*
* \brief NMC1500 Peripherals Application Interface.
* \brief WINC ATE Test Driver Interface.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
@ -209,6 +209,15 @@ typedef enum {
M2M_ATE_TX_MODE_CW = 0x01,
}tenuM2mAteTxMode;
/*!
*@enum tenuM2mAteRxPwrMode
*@brief Used to define type of RX mode either high power or low power
*/
typedef enum {
M2M_ATE_RX_PWR_HIGH = 0x00,
M2M_ATE_RX_PWR_LOW = 0x01,
}tenuM2mAteRxPwrMode;
/*!
*@enum tenuM2mAteChannels
*@brief Available channels for TX and RX
@ -246,6 +255,16 @@ typedef struct {
*/
} tstrM2mAteRxStatus;
/*!
*@struct tstrM2mAteRxStatus
*@brief Used to save statistics of RX case
*/
typedef struct {
uint8 u8RxPwrMode;
/*!< RX power mode review tenuM2mAteRxPwrMode
*/
} tstrM2mAteInit;
/*!
*@struct tstrM2mAteTx
*@brief Used as data source in case of enabling TX test case
@ -345,6 +364,19 @@ FUNCTION PROTOTYPES
*/
sint8 m2m_ate_init(void);
/*!
@fn \
sint8 m2m_ate_init(tstrM2mAteInit *pstrInit);
@brief
This function used to download ATE firmware from flash and start it
@return
The function SHALL return 0 for success and a negative value otherwise.
*/
sint8 m2m_ate_init_param(tstrM2mAteInit *pstrInit);
/*!
@fn \
sint8 m2m_ate_deinit(void);

View File

@ -0,0 +1,245 @@
/**
*
* \file
*
* \brief WINC Crypto Application Interface.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
#ifndef __M2M_CRYPTO_H__
#define __M2M_CRYPTO_H__
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
INCLUDES
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
#include "common/include/nm_common.h"
#include "driver/include/m2m_types.h"
#include "driver/include/m2m_hif.h"
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
MACROS
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
#define M2M_MAX_RSA_LEN (256)
#define M2M_SHA256_DIGEST_LEN 32
#define M2M_SHA256_MAX_DATA (M2M_BUFFER_MAX_SIZE - M2M_SHA256_CONTEXT_BUFF_LEN - M2M_HIF_HDR_OFFSET)
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
DATA TYPES
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
/*!
@struct \
tstrM2mSha256Ctxt
@brief
SHA256 context data
*/
typedef struct sha256ctxt{
uint32 au32Sha256CtxtBuff[M2M_SHA256_CONTEXT_BUFF_LEN/sizeof(uint32)];
} tstrM2mSha256Ctxt;
/*!
@enum \
tenuRsaSignStatus
@brief
RSA Signature status: pass or fail.
*/
typedef enum{
M2M_RSA_SIGN_OK,
M2M_RSA_SIGN_FAIL
} tenuRsaSignStatus;
/*!
@typedef \
tpfAppCryproCb
@brief
@param [in] u8MsgType
@param [in] pvMsg
A pointer to a buffer containing the notification parameters (if any). It should be
Casted to the correct data type corresponding to the notification type.
*/
typedef void (*tpfAppCryproCb) (uint8 u8MsgType,void * pvResp, void * pvMsg);
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
FUNCTION PROTOTYPES
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
#ifdef __cplusplus
extern "C" {
#endif
/*!
@fn \
sint8 m2m_crypto_init();
@brief crypto initialization
@param[in] pfAppCryproCb
*/
sint8 m2m_crypto_init(tpfAppCryproCb pfAppCryproCb);
/*!
@fn \
sint8 m2m_sha256_hash_init(tstrM2mSha256Ctxt *psha256Ctxt);
@brief SHA256 hash initialization
@param[in] psha256Ctxt
Pointer to a sha256 context allocated by the caller.
*/
sint8 m2m_crypto_sha256_hash_init(tstrM2mSha256Ctxt *psha256Ctxt);
/*!
@fn \
sint8 m2m_sha256_hash_update(tstrM2mSha256Ctxt *psha256Ctxt, uint8 *pu8Data, uint16 u16DataLength);
@brief SHA256 hash update
@param [in] psha256Ctxt
Pointer to the sha256 context.
@param [in] pu8Data
Buffer holding the data submitted to the hash.
@param [in] u16DataLength
Size of the data bufefr in bytes.
*/
sint8 m2m_crypto_sha256_hash_update(tstrM2mSha256Ctxt *psha256Ctxt, uint8 *pu8Data, uint16 u16DataLength);
/*!
@fn \
sint8 m2m_sha256_hash_finish(tstrM2mSha256Ctxt *psha256Ctxt, uint8 *pu8Sha256Digest);
@brief SHA256 hash finalization
@param[in] psha256Ctxt
Pointer to a sha256 context allocated by the caller.
@param [in] pu8Sha256Digest
Buffer allocated by the caller which will hold the resultant SHA256 Digest. It must be allocated no less than M2M_SHA256_DIGEST_LEN.
*/
sint8 m2m_crypto_sha256_hash_finish(tstrM2mSha256Ctxt *psha256Ctxt, uint8 *pu8Sha256Digest);
/*!
@fn \
sint8 m2m_rsa_sign_verify(uint8 *pu8N, uint16 u16NSize, uint8 *pu8E, uint16 u16ESize, uint8 *pu8SignedMsgHash, \
uint16 u16HashLength, uint8 *pu8RsaSignature);
@brief RSA Signature Verification
The function shall request the RSA Signature verification from the WINC Firmware for the given message. The signed message shall be
compressed to the corresponding hash algorithm before calling this function.
The hash type is identified by the given hash length. For example, if the hash length is 32 bytes, then it is SHA256.
@param[in] pu8N
RSA Key modulus n.
@param[in] u16NSize
Size of the RSA modulus n in bytes.
@param[in] pu8E
RSA public exponent.
@param[in] u16ESize
Size of the RSA public exponent in bytes.
@param[in] pu8SignedMsgHash
The hash digest of the signed message.
@param[in] u16HashLength
The length of the hash digest.
@param[out] pu8RsaSignature
Signature value to be verified.
*/
sint8 m2m_crypto_rsa_sign_verify(uint8 *pu8N, uint16 u16NSize, uint8 *pu8E, uint16 u16ESize, uint8 *pu8SignedMsgHash,
uint16 u16HashLength, uint8 *pu8RsaSignature);
/*!
@fn \
sint8 m2m_rsa_sign_gen(uint8 *pu8N, uint16 u16NSize, uint8 *pu8d, uint16 u16dSize, uint8 *pu8SignedMsgHash, \
uint16 u16HashLength, uint8 *pu8RsaSignature);
@brief RSA Signature Generation
The function shall request the RSA Signature generation from the WINC Firmware for the given message. The signed message shall be
compressed to the corresponding hash algorithm before calling this function.
The hash type is identified by the given hash length. For example, if the hash length is 32 bytes, then it is SHA256.
@param[in] pu8N
RSA Key modulus n.
@param[in] u16NSize
Size of the RSA modulus n in bytes.
@param[in] pu8d
RSA private exponent.
@param[in] u16dSize
Size of the RSA private exponent in bytes.
@param[in] pu8SignedMsgHash
The hash digest of the signed message.
@param[in] u16HashLength
The length of the hash digest.
@param[out] pu8RsaSignature
Pointer to a user buffer allocated by teh caller shall hold the generated signature.
*/
sint8 m2m_crypto_rsa_sign_gen(uint8 *pu8N, uint16 u16NSize, uint8 *pu8d, uint16 u16dSize, uint8 *pu8SignedMsgHash,
uint16 u16HashLength, uint8 *pu8RsaSignature);
#ifdef __cplusplus
}
#endif
#endif /* __M2M_CRYPTO_H__ */

View File

@ -2,7 +2,7 @@
*
* \file
*
* \brief NMC1500 IoT OTA Interface.
* \brief WINC OTA Upgrade API Interface.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
@ -48,8 +48,9 @@ INCLUDES
#include "common/include/nm_common.h"
#include "driver/include/m2m_types.h"
/**@defgroup OTATYPEDEF WLANTypedef
* @ingroup WlanEnums
#include "driver/include/nmdrv.h"
/**@addtogroup WlanEnums Enumerations and Typedefs
* @ingroup m2m_wifi
*/
/* @{ */
@ -321,6 +322,17 @@ NMI_API sint8 m2m_ota_rollback(void);
The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise.
*/
NMI_API sint8 m2m_ota_switch_firmware(void);
/*!
@fn \
NMI_API sint8 m2m_ota_get_firmware_version(void);
@brief
Get the OTA Firmware version.
@return
The function SHALL return 0 for success and a negative value otherwise.
*/
NMI_API sint8 m2m_ota_get_firmware_version(tstrM2mRev *pstrRev);
/**@}*/
NMI_API sint8 m2m_ota_test(void);

View File

@ -2,7 +2,7 @@
*
* \file
*
* \brief NMC1500 Peripherals Application Interface.
* \brief WINC Peripherals Application Interface.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
@ -79,6 +79,10 @@ typedef struct {
A list of GPIO numbers configurable through the m2m_periph module.
*/
typedef enum {
M2M_PERIPH_GPIO3, /*!< GPIO15 pad */
M2M_PERIPH_GPIO4, /*!< GPIO16 pad */
M2M_PERIPH_GPIO5, /*!< GPIO18 pad */
M2M_PERIPH_GPIO6, /*!< GPIO18 pad */
M2M_PERIPH_GPIO15, /*!< GPIO15 pad */
M2M_PERIPH_GPIO16, /*!< GPIO16 pad */
M2M_PERIPH_GPIO18, /*!< GPIO18 pad */
@ -165,35 +169,35 @@ typedef enum {
*/
typedef enum {
M2M_PERIPH_PULLUP_HOST_WAKEUP = (1ul << 0),
M2M_PERIPH_PULLUP_RTC_CLK = (1ul << 1),
M2M_PERIPH_PULLUP_IRQN = (1ul << 2),
M2M_PERIPH_PULLUP_GPIO_3 = (1ul << 3),
M2M_PERIPH_PULLUP_GPIO_4 = (1ul << 4),
M2M_PERIPH_PULLUP_GPIO_5 = (1ul << 5),
M2M_PERIPH_PULLUP_SD_DAT3 = (1ul << 6),
M2M_PERIPH_PULLUP_SD_DAT2_SPI_RXD = (1ul << 7),
M2M_PERIPH_PULLUP_SD_DAT1_SPI_SSN = (1ul << 8),
M2M_PERIPH_PULLUP_SD_CMD_SPI_SCK = (1ul << 9),
M2M_PERIPH_PULLUP_SD_DAT0_SPI_TXD = (1ul << 10),
M2M_PERIPH_PULLUP_GPIO_6 = (1ul << 11),
M2M_PERIPH_PULLUP_SD_CLK = (1ul << 12),
M2M_PERIPH_PULLUP_I2C_SCL = (1ul << 13),
M2M_PERIPH_PULLUP_I2C_SDA = (1ul << 14),
M2M_PERIPH_PULLUP_GPIO_11 = (1ul << 15),
M2M_PERIPH_PULLUP_GPIO_12 = (1ul << 16),
M2M_PERIPH_PULLUP_GPIO_13 = (1ul << 17),
M2M_PERIPH_PULLUP_GPIO_14 = (1ul << 18),
M2M_PERIPH_PULLUP_GPIO_15 = (1ul << 19),
M2M_PERIPH_PULLUP_GPIO_16 = (1ul << 20),
M2M_PERIPH_PULLUP_GPIO_17 = (1ul << 21),
M2M_PERIPH_PULLUP_GPIO_18 = (1ul << 22),
M2M_PERIPH_PULLUP_GPIO_19 = (1ul << 23),
M2M_PERIPH_PULLUP_GPIO_20 = (1ul << 24),
M2M_PERIPH_PULLUP_GPIO_21 = (1ul << 25),
M2M_PERIPH_PULLUP_GPIO_22 = (1ul << 26),
M2M_PERIPH_PULLUP_GPIO_23 = (1ul << 27),
M2M_PERIPH_PULLUP_GPIO_24 = (1ul << 28),
M2M_PERIPH_PULLUP_DIS_HOST_WAKEUP = (1ul << 0),
M2M_PERIPH_PULLUP_DIS_RTC_CLK = (1ul << 1),
M2M_PERIPH_PULLUP_DIS_IRQN = (1ul << 2),
M2M_PERIPH_PULLUP_DIS_GPIO_3 = (1ul << 3),
M2M_PERIPH_PULLUP_DIS_GPIO_4 = (1ul << 4),
M2M_PERIPH_PULLUP_DIS_GPIO_5 = (1ul << 5),
M2M_PERIPH_PULLUP_DIS_SD_DAT3 = (1ul << 6),
M2M_PERIPH_PULLUP_DIS_SD_DAT2_SPI_RXD = (1ul << 7),
M2M_PERIPH_PULLUP_DIS_SD_DAT1_SPI_SSN = (1ul << 9),
M2M_PERIPH_PULLUP_DIS_SD_CMD_SPI_SCK = (1ul << 10),
M2M_PERIPH_PULLUP_DIS_SD_DAT0_SPI_TXD = (1ul << 11),
M2M_PERIPH_PULLUP_DIS_GPIO_6 = (1ul << 12),
M2M_PERIPH_PULLUP_DIS_SD_CLK = (1ul << 13),
M2M_PERIPH_PULLUP_DIS_I2C_SCL = (1ul << 14),
M2M_PERIPH_PULLUP_DIS_I2C_SDA = (1ul << 15),
M2M_PERIPH_PULLUP_DIS_GPIO_11 = (1ul << 16),
M2M_PERIPH_PULLUP_DIS_GPIO_12 = (1ul << 17),
M2M_PERIPH_PULLUP_DIS_GPIO_13 = (1ul << 18),
M2M_PERIPH_PULLUP_DIS_GPIO_14 = (1ul << 19),
M2M_PERIPH_PULLUP_DIS_GPIO_15 = (1ul << 20),
M2M_PERIPH_PULLUP_DIS_GPIO_16 = (1ul << 21),
M2M_PERIPH_PULLUP_DIS_GPIO_17 = (1ul << 22),
M2M_PERIPH_PULLUP_DIS_GPIO_18 = (1ul << 23),
M2M_PERIPH_PULLUP_DIS_GPIO_19 = (1ul << 24),
M2M_PERIPH_PULLUP_DIS_GPIO_20 = (1ul << 25),
M2M_PERIPH_PULLUP_DIS_GPIO_21 = (1ul << 26),
M2M_PERIPH_PULLUP_DIS_GPIO_22 = (1ul << 27),
M2M_PERIPH_PULLUP_DIS_GPIO_23 = (1ul << 28),
M2M_PERIPH_PULLUP_DIS_GPIO_24 = (1ul << 29),
} tenuPullupMask;
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

View File

@ -2,7 +2,7 @@
*
* \file
*
* \brief NMC1500 IoT Application Interface Internal Types.
* \brief WINC Application Interface Internal Types.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
@ -95,6 +95,16 @@ MACROS
( ((uint32)M2M_MAKE_VERSION((fw_major), (fw_minor), (fw_patch))) << M2M_FW_VERSION_SHIFT) | \
( ((uint32)M2M_MAKE_VERSION((drv_major), (drv_minor), (drv_patch))) << M2M_DRV_VERSION_SHIFT))
#define REL_19_4_1_VER M2M_MAKE_VERSION_INFO(19,4,1,19,3,0)
#define REL_19_4_0_VER M2M_MAKE_VERSION_INFO(19,4,0,19,3,0)
#define REL_19_3_1_VER M2M_MAKE_VERSION_INFO(19,3,1,19,3,0)
#define REL_19_3_0_VER M2M_MAKE_VERSION_INFO(19,3,0,19,3,0)
#define REL_19_2_2_VER M2M_MAKE_VERSION_INFO(19,2,2,19,2,0)
#define REL_19_2_1_VER M2M_MAKE_VERSION_INFO(19,2,1,19,2,0)
#define REL_19_2_0_VER M2M_MAKE_VERSION_INFO(19,2,0,19,2,0)
#define REL_19_1_0_VER M2M_MAKE_VERSION_INFO(19,1,0,18,2,0)
#define REL_19_0_0_VER M2M_MAKE_VERSION_INFO(19,0,0,18,1,1)
/*======*======*======*======*
FIRMWARE VERSION NO INFO
*======*======*======*======*/
@ -104,11 +114,11 @@ MACROS
*/
#define M2M_FIRMWARE_VERSION_MINOR_NO (3)
#define M2M_FIRMWARE_VERSION_MINOR_NO (4)
/*!< Firmware Minor release version number.
*/
#define M2M_FIRMWARE_VERSION_PATCH_NO (0)
#define M2M_FIRMWARE_VERSION_PATCH_NO (4)
/*!< Firmware patch release version number.
*/
@ -191,7 +201,10 @@ MACROS
#define M2M_CUST_IE_LEN_MAX 252
/*!< The maximum size of IE (Information Element).
*/
/*********************
*
* WIFI GROUP requests
*/
#define M2M_CONFIG_CMD_BASE 1
/*!< The base value of all the host configuration commands opcodes.
@ -205,13 +218,28 @@ MACROS
#define M2M_P2P_CMD_BASE 90
/*!< The base value of all the P2P mode host commands opcodes.
*/
#define M2M_OTA_CMD_BASE 100
/*!< The base value of all the OTA mode host commands opcodes.
*/
#define M2M_SERVER_CMD_BASE 120
#define M2M_SERVER_CMD_BASE 100
/*!< The base value of all the power save mode host commands codes.
*/
/**********************
* OTA GROUP requests
*/
#define M2M_OTA_CMD_BASE 100
/*!< The base value of all the OTA mode host commands opcodes.
* The OTA Have special group so can extended from 1-M2M_MAX_GRP_NUM_REQ
*/
/***********************
*
* CRYPTO group requests
*/
#define M2M_CRYPTO_CMD_BASE 1
/*!< The base value of all the crypto mode host commands opcodes.
* The crypto Have special group so can extended from 1-M2M_MAX_GRP_NUM_REQ
*/
#define M2M_MAX_GRP_NUM_REQ (127)
/*!< max number of request in one group equal to 127 as the last bit reserved for config or data pkt
*/
#define WEP_40_KEY_STRING_SIZE ((uint8)10)
/*!< Indicate the wep key size in bytes for 40 bit string passphrase.
@ -223,72 +251,47 @@ MACROS
#define WEP_KEY_MAX_INDEX ((uint8)4)
/*!< Indicate the max key index value for WEP authentication
*/
#define M2M_SHA256_CONTEXT_BUFF_LEN (128)
/*!< sha256 context size
*/
#define M2M_SCAN_DEFAULT_NUM_SLOTS (2)
/*!< The default. number of scan slots performed by the WINC board.
*/
#define M2M_SCAN_DEFAULT_SLOT_TIME (20)
#define M2M_SCAN_DEFAULT_SLOT_TIME (30)
/*!< The default. duration in miliseconds of a scan slots performed by the WINC board.
*/
#define M2M_SCAN_DEFAULT_NUM_PROBE (2)
/*!< The default. number of scan slots performed by the WINC board.
*/
#define M2M_SCAN_FAIL ((uint8)1)
/*!< Indicate that the WINC board has failed to perform the scan operation.
*/
#define M2M_JOIN_FAIL ((uint8)2)
/*!< Indicate that the WINC board has failed to join the BSS .
*/
#define M2M_AUTH_FAIL ((uint8)3)
/*!< Indicate that the WINC board has failed to authenticate with the AP.
*/
#define M2M_ASSOC_FAIL ((uint8)4)
/*!< Indicate that the WINC board has failed to associate with the AP.
*/
#define M2M_SCAN_ERR_WIFI ((sint8)-2)
/*!< currently not used.
*/
#define M2M_SCAN_ERR_IP ((sint8)-3)
/*!< currently not used.
*/
#define M2M_SCAN_ERR_AP ((sint8)-4)
/*!< currently not used.
*/
#define M2M_SCAN_ERR_P2P ((sint8)-5)
/*!< currently not used.
*/
#define M2M_SCAN_ERR_WPS ((sint8)-6)
/*!< currently not used.
*/
#define M2M_DEFAULT_CONN_EMPTY_LIST ((sint8)-20)
/*!<
A failure response that indicates an empty network list as
a result to the function call m2m_default_connect.
*/
#define M2M_DEFAULT_CONN_SCAN_MISMATCH ((sint8)-21)
/*!<
/*======*======*======*======*
CONNECTION ERROR DEFINITIONS
*======*======*======*======*/
typedef enum {
M2M_DEFAULT_CONN_INPROGRESS = ((sint8)-23),
/*!<
A failure that indicates that a default connection or forced connection is in progress
*/
M2M_DEFAULT_CONN_FAIL,
/*!<
A failure response that indicates that the winc failed to connect to the cached network
*/
M2M_DEFAULT_CONN_SCAN_MISMATCH,
/*!<
A failure response that indicates that no one of the cached networks
was found in the scan results, as a result to the function call m2m_default_connect.
*/
#define M2M_DEFAULT_CONN_FAIL ((sint8)-22)
*/
M2M_DEFAULT_CONN_EMPTY_LIST
/*!<
A failure response that indicates an empty network list as
a result to the function call m2m_default_connect.
*/
}tenuM2mDefaultConnErrcode;
/*!<
A failure response that indicates that the winc failed to connect to the cached network
*/
/*======*======*======*======*
MONTIORING MODE DEFINITIONS
*======*======*======*======*/
#define M2M_WIFI_FRAME_TYPE_ANY 0xFF
/*!< Set monitor mode to receive any of the frames types
*/
#define M2M_WIFI_FRAME_SUB_TYPE_ANY 0xFF
/*!< Set monitor mode to receive frames with any sub type
*/
/*======*======*======*======*
OTA DEFINITIONS
@ -306,6 +309,12 @@ MACROS
/*!<
Magic value set at the beginning of the OTA image header
*/
#define OTA_FORMAT_VER_0 (0) /*Till 19.2.2 format*/
#define OTA_FORMAT_VER_1 (1) /*starting from 19.3.0 CRC is used and sequence number is used*/
/*!<
Control structure format version
*/
#define OTA_SHA256_DIGEST_SIZE (32)
/*!<
Sha256 digest size in the OTA image,
@ -350,9 +359,35 @@ MACROS
/**@}*/
/**
* @addtogroup WlanEnums
* @addtogroup WlanEnums Enumerations and Typedefs
* @ingroup m2m_wifi
*/
/**@{*/
/*!
@enum \
tenuM2mConnChangedErrcode
@brief
*/
typedef enum {
M2M_ERR_SCAN_FAIL = ((uint8)1),
/*!< Indicate that the WINC board has failed to perform the scan operation.
*/
M2M_ERR_JOIN_FAIL,
/*!< Indicate that the WINC board has failed to join the BSS .
*/
M2M_ERR_AUTH_FAIL,
/*!< Indicate that the WINC board has failed to authenticate with the AP.
*/
M2M_ERR_ASSOC_FAIL,
/*!< Indicate that the WINC board has failed to associate with the AP.
*/
M2M_ERR_CONN_INPROGRESS,
/*!< Indicate that the WINC board has another connection request in progress.
*/
}tenuM2mConnChangedErrcode;
/*!
@enum \
tenuM2mWepKeyIndex
@ -380,11 +415,11 @@ typedef enum {
PWR_AUTO = ((uint8) 1),
/*!< FW will decide the best power mode to use internally. */
PWR_LOW1,
/*low power mode #1. RX current 60mA, sensitivity Ok.*/
/*low power mode #1*/
PWR_LOW2,
/*low power mode #2, RX current 55mA, sensitivity is less by 3dBm*/
/*low power mode #2*/
PWR_HIGH,
/* high power mode: RX current 100mA.*/
/* high power mode*/
}tenuM2mPwrMode;
/*!
@ -467,6 +502,33 @@ typedef struct {
*/
}tstrM2mBatteryVoltage;
/*!
@enum \
tenuM2mReqGroup
@brief
*/
typedef enum{
M2M_REQ_GROUP_MAIN = 0,
M2M_REQ_GROUP_WIFI,
M2M_REQ_GROUP_IP,
M2M_REQ_GROUP_HIF,
M2M_REQ_GROUP_OTA,
M2M_REQ_GROUP_SSL,
M2M_REQ_GROUP_CRYPTO,
M2M_REQ_GROUP_SIGMA,
}tenuM2mReqGroup;
/*!
@enum \
tenuM2mReqpkt
@brief
*/
typedef enum{
M2M_REQ_CONFIG_PKT,
M2M_REQ_DATA_PKT = 0x80 /*BIT7*/
}tenuM2mReqpkt;
/*!
@enum \
tenuM2mConfigCmd
@ -583,6 +645,12 @@ typedef enum {
M2M_WIFI_REQ_SET_MAC_MCAST,
/*!< Set the WINC multicast filters.
*/
M2M_WIFI_REQ_GET_PRNG,
/*!< Request PRNG.
*/
M2M_WIFI_RESP_GET_PRNG,
/*!< Response for PRNG.
*/
M2M_WIFI_MAX_CONFIG_ALL,
}tenuM2mConfigCmd;
@ -700,6 +768,24 @@ typedef enum {
}tenuM2mP2pCmd;
/*!
@enum \
tenuM2mServerCmd
@brief
This enum contains all the WINC commands while in PS mode.
These command are currently not supported.
*/
typedef enum {
M2M_WIFI_REQ_CLIENT_CTRL = M2M_SERVER_CMD_BASE,
M2M_WIFI_RESP_CLIENT_INFO,
M2M_WIFI_REQ_SERVER_INIT,
M2M_WIFI_MAX_SERVER_ALL
}tenuM2mServerCmd;
/*!
@enum \
tenuM2mOtaCmd
@ -720,24 +806,26 @@ typedef enum {
M2M_OTA_MAX_ALL,
}tenuM2mOtaCmd;
/*!
@enum \
tenuM2mServerCmd
tenuM2mCryptoCmd
@brief
This enum contains all the WINC commands while in PS mode.
These command are currently not supported.
*/
typedef enum {
M2M_WIFI_REQ_CLIENT_CTRL = M2M_SERVER_CMD_BASE,
M2M_WIFI_RESP_CLIENT_INFO,
M2M_WIFI_REQ_SERVER_INIT,
M2M_WIFI_MAX_SERVER_ALL
}tenuM2mServerCmd;
M2M_CRYPTO_REQ_SHA256_INIT = M2M_CRYPTO_CMD_BASE,
M2M_CRYPTO_RESP_SHA256_INIT,
M2M_CRYPTO_REQ_SHA256_UPDATE,
M2M_CRYPTO_RESP_SHA256_UPDATE,
M2M_CRYPTO_REQ_SHA256_FINSIH,
M2M_CRYPTO_RESP_SHA256_FINSIH,
M2M_CRYPTO_REQ_RSA_SIGN_GEN,
M2M_CRYPTO_RESP_RSA_SIGN_GEN,
M2M_CRYPTO_REQ_RSA_SIGN_VERIFY,
M2M_CRYPTO_RESP_RSA_SIGN_VERIFY,
M2M_CRYPTO_MAX_ALL,
}tenuM2mCryptoCmd;
/*!
@enum \
@ -753,6 +841,28 @@ typedef enum {
M2M_IP_REQ_DISABLE_DHCP
} tenuM2mIpCmd;
/*!
@enum \
tenuM2mSigmaCmd
@brief
*/
typedef enum {
/* Request IDs corresponding to the IP GROUP. */
M2M_SIGMA_ENABLE = ((uint8) 3),
M2M_SIGMA_TA_START,
M2M_SIGMA_TA_STATS,
M2M_SIGMA_TA_RECEIVE_STOP,
M2M_SIGMA_ICMP_ARP,
M2M_SIGMA_ICMP_RX,
M2M_SIGMA_ICMP_TX,
M2M_SIGMA_UDP_TX,
M2M_SIGMA_UDP_TX_DEFER,
M2M_SIGMA_SECURITY_POLICY,
M2M_SIGMA_SET_SYSTIME
} tenuM2mSigmaCmd;
/*!
@enum \
@ -918,9 +1028,16 @@ typedef enum {
M2M_WIFI_MODE_NORMAL = ((uint8) 1),
/*!< Normal Mode means to run customer firmware version.
*/
M2M_WIFI_MODE_CONFIG,
/*!< Config Mode means to run production test firmware version which is known as ATE (Burst) firmware.
M2M_WIFI_MODE_ATE_HIGH,
/*!< Config Mode in HIGH POWER means to run production test firmware version which is known as ATE (Burst) firmware.
*/
M2M_WIFI_MODE_ATE_LOW,
/*!< Config Mode in LOW POWER means to run production test firmware version which is known as ATE (Burst) firmware.
*/
M2M_WIFI_MODE_ETHERNET,
/*!< etherent Mode
*/
M2M_WIFI_MODE_MAX,
}tenuM2mWifiMode;
/*!
@ -1081,9 +1198,6 @@ typedef struct {
@sa
tenuM2mSecType
@todo
Use different error codes to differentiate error types.
*/
typedef struct{
uint8 u8AuthType;
@ -1189,6 +1303,21 @@ typedef struct {
}tstrM2MScan;
/*!
@struct \
tstrCyptoResp
@brief
crypto response
*/
typedef struct {
sint8 s8Resp;
/***/
uint8 __PAD24__[3];
/*
*/
}tstrCyptoResp;
/*!
@struct \
@ -1269,14 +1398,14 @@ typedef struct {
Wi-Fi Connection State
@sa
M2M_WIFI_DISCONNECTED, M2M_WIFI_CONNECTED, M2M_WIFI_REQ_CON_STATE_CHANGED
M2M_WIFI_DISCONNECTED, M2M_WIFI_CONNECTED, M2M_WIFI_REQ_CON_STATE_CHANGED,tenuM2mConnChangedErrcode
*/
typedef struct {
uint8 u8CurrState;
/*!< Current Wi-Fi connection state
*/
uint8 u8ErrCode;
/*!< Error type
/*!< Error type review tenuM2mConnChangedErrcode
*/
uint8 __PAD16__[2];
/*!< Padding bytes for forcing 4-byte alignment
@ -1736,6 +1865,7 @@ typedef struct{
*/
}tstrOtaInitHdr;
/*!
@struct \
tstrOtaControlSec
@ -1752,6 +1882,8 @@ typedef struct {
*/
uint32 u32OtaFormatVersion;
/*!<
NA NA NA Flash version cs struct version
00 00 00 00 00
Control structure format version, the value will be incremented in case of structure changed or updated
*/
uint32 u32OtaSequenceNumber;
@ -1834,6 +1966,12 @@ typedef enum {
/*!< An OTA operation is already enabled. */
OTA_STATUS_UPDATE_INPROGRESS = 6,
/*!< An OTA operation update is in progress */
OTA_STATUS_IMAGE_VERIF_FAILED = 7,
/*!< OTA Verfication failed */
OTA_STATUS_CONNECTION_ERROR = 8,
/*!< OTA connection error */
OTA_STATUS_SERVER_ERROR = 9,
/*!< OTA server Error (file not found or else ...) */
} tenuOtaUpdateStatus;
/*!
@enum \
@ -1956,6 +2094,28 @@ typedef struct{
*/
}tstrM2MMulticastMac;
/*!
@struct \
tstrPrng
@brief
M2M Request PRNG
*/
typedef struct {
/*!<
return buffer address
*/
uint8 *pu8RngBuff;
/*!<
PRNG size requested
*/
uint16 u16PrngSize;
/*!<
PRNG pads
*/
uint8 __PAD16__[2];
}tstrPrng;
/**@}*/

File diff suppressed because it is too large Load Diff

View File

@ -47,11 +47,13 @@
#define NMI_CHIPID (NMI_PERIPH_REG_BASE)
#define rNMI_GP_REG_0 (0x149c)
#define rNMI_GP_REG_1 (0x14A0)
#define rNMI_GP_REG_2 (0xc0008)
#define rNMI_GLB_RESET (0x1400)
#define rNMI_BOOT_RESET_MUX (0x1118)
#define NMI_STATE_REG (0x108c)
#define BOOTROM_REG (0xc000c)
#define NMI_REV_REG (0x207ac) /*Also, Used to load ATE firmware from SPI Flash and to ensure that it is running too*/
#define NMI_REV_REG_ATE (0x1048) /*Revision info register in case of ATE FW*/
#define M2M_WAIT_FOR_HOST_REG (0x207bc)
#define M2M_FINISH_INIT_STATE 0x02532636UL
#define M2M_FINISH_BOOT_ROM 0x10add09eUL
@ -77,7 +79,12 @@
#define rHAVE_EXT_PA_INV_TX_RX (NBIT4)
#define rHAVE_LEGACY_RF_SETTINGS (NBIT5)
#define rHAVE_LOGS_DISABLED_BIT (NBIT6)
#define rHAVE_ETHERNET_MODE_BIT (NBIT7)
typedef struct{
uint32 u32Mac_efuse_mib;
uint32 u32Firmware_Ota_rev;
}tstrGpRegs;
#ifdef __cplusplus
extern "C" {

View File

@ -45,11 +45,11 @@
#include "common/include/nm_common.h"
/**
* @struct tstrM2mWifiGetRevision
* @brief Structure holding firmware version parameters
* @sa M2M_WIFI_AUTH_WEB, M2M_WIFI_AUTH_WPA, M2M_WIFI_AUTH_WPA2
* @struct tstrM2mRev
* @brief Structure holding firmware version parameters and build date/time
*/
typedef struct {
uint32 u32Chipid; /* HW revision which will be basically the chip ID */
uint8 u8FirmwareMajor; /* Version Major Number which represents the official release base */
uint8 u8FirmwareMinor; /* Version Minor Number which represents the engineering release base */
uint8 u8FirmwarePatch; /* Version pathc Number which represents the pathces release base */
@ -58,7 +58,7 @@ typedef struct {
uint8 u8DriverPatch; /* Version Patch Number which represents the pathces release base */
uint8 BuildDate[sizeof(__DATE__)];
uint8 BuildTime[sizeof(__TIME__)];
uint32 u32Chipid; /* HW revision which will be basically the chip ID */
uint8 _PAD8_;
} tstrM2mRev;
#ifdef __cplusplus
@ -72,6 +72,23 @@ typedef struct {
* @version 1.0
*/
sint8 nm_get_firmware_info(tstrM2mRev* M2mRev);
/**
* @fn nm_get_firmware_full_info(tstrM2mRev* pstrRev)
* @brief Get Firmware version info
* @param [out] M2mRev
* pointer holds address of structure "tstrM2mRev" that contains the firmware version parameters
* @version 1.0
*/
sint8 nm_get_firmware_full_info(tstrM2mRev* pstrRev);
/**
* @fn nm_get_ota_firmware_info(tstrM2mRev* pstrRev)
* @brief Get Firmware version info
* @param [out] M2mRev
* pointer holds address of structure "tstrM2mRev" that contains the firmware version parameters
* @version 1.0
*/
sint8 nm_get_ota_firmware_info(tstrM2mRev* pstrRev);
/*
* @fn nm_drv_init
* @brief Initialize NMC1000 driver

View File

@ -63,10 +63,10 @@ MACROS
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
#ifdef _FIRMWARE_
#define HOSTNAME_MAX_SIZE (64)
#define HOSTNAME_MAX_SIZE (64)
#endif
#define SSL_MAX_OPT_LEN HOSTNAME_MAX_SIZE
#define SSL_MAX_OPT_LEN HOSTNAME_MAX_SIZE
@ -76,7 +76,7 @@ MACROS
*/
#define SOCKET_CMD_BIND 0x41
#define SOCKET_CMD_BIND 0x41
/*!<
Socket Binding command value.
*/
@ -94,19 +94,19 @@ MACROS
*/
#define SOCKET_CMD_CONNECT 0x44
#define SOCKET_CMD_CONNECT 0x44
/*!<
Socket Connecting command value.
*/
#define SOCKET_CMD_SEND 0x45
#define SOCKET_CMD_SEND 0x45
/*!<
Socket send command value.
*/
#define SOCKET_CMD_RECV 0x46
#define SOCKET_CMD_RECV 0x46
/*!<
Socket Recieve command value.
*/
@ -118,7 +118,7 @@ MACROS
*/
#define SOCKET_CMD_RECVFROM 0x48
#define SOCKET_CMD_RECVFROM 0x48
/*!<
Socket RecieveFrom command value.
*/
@ -130,25 +130,25 @@ MACROS
*/
#define SOCKET_CMD_DNS_RESOLVE 0x4A
#define SOCKET_CMD_DNS_RESOLVE 0x4A
/*!<
Socket DNS Resolve command value.
*/
#define SOCKET_CMD_SSL_CONNECT 0x4B
#define SOCKET_CMD_SSL_CONNECT 0x4B
/*!<
SSL-Socket Connect command value.
*/
#define SOCKET_CMD_SSL_SEND 0x4C
#define SOCKET_CMD_SSL_SEND 0x4C
/*!<
SSL-Socket Send command value.
*/
#define SOCKET_CMD_SSL_RECV 0x4D
#define SOCKET_CMD_SSL_RECV 0x4D
/*!<
SSL-Socket Recieve command value.
*/
@ -171,12 +171,12 @@ MACROS
*/
#define SOCKET_CMD_SSL_SET_SOCK_OPT 0x51
#define SOCKET_CMD_SSL_SET_SOCK_OPT 0x51
#define SOCKET_CMD_PING 0x52
#define SOCKET_CMD_SSL_SET_CS_LIST 0x53
#define PING_ERR_SUCCESS 0
@ -297,7 +297,11 @@ typedef struct{
typedef struct{
SOCKET sock;
sint8 s8Error;
uint16 u16SessionID;
uint16 u16AppDataOffset;
/*!<
In further packet send requests the host interface should put the user application
data at this offset in the allocated shared data packet.
*/
}tstrConnectReply;
@ -309,7 +313,7 @@ typedef struct{
uint8 u8Void;
uint16 u16DataSize;
tstrSockAddr strAddr;
uint16 u16SessionID;
uint16 u16SessionID;
uint16 u16Void;
}tstrSendCmd;
@ -405,6 +409,11 @@ typedef struct{
uint8 __PAD24__[3];
}tstrPingReply;
typedef struct{
uint32 u32CsBMP;
}tstrSslSetActiveCsList;
#ifdef __cplusplus
}
#endif /* __cplusplus */

File diff suppressed because it is too large Load Diff

View File

@ -133,13 +133,32 @@ FUNCTION IMPLEMENTATION
sint8 m2m_ate_init(void)
{
sint8 s8Ret = M2M_SUCCESS;
uint8 u8WifiMode = M2M_WIFI_MODE_CONFIG;
uint8 u8WifiMode = M2M_WIFI_MODE_ATE_HIGH;
s8Ret = nm_drv_init(&u8WifiMode);
return s8Ret;
}
/*!
@fn \
sint8 m2m_ate_init(tstrM2mAteInit *pstrInit);
@brief
This function used to download ATE firmware from flash and start it
@return
The function SHALL return 0 for success and a negative value otherwise.
*/
sint8 m2m_ate_init_param(tstrM2mAteInit *pstrInit)
{
sint8 s8Ret = M2M_SUCCESS;
s8Ret = nm_drv_init((void*)&pstrInit->u8RxPwrMode);
return s8Ret;
}
/*!
@fn \
sint8 m2m_ate_deinit(void);
@ -465,7 +484,7 @@ sint8 m2m_ate_get_rx_status(void)
*/
sint8 m2m_ate_start_rx(tstrM2mAteRx * strM2mAteRxStr)
{
sint8 s8Ret = M2M_SUCCESS;
sint8 s8Ret = M2M_SUCCESS;
uint32 val32;
if(NULL == strM2mAteRxStr)
{

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,9 @@ static volatile uint8 gu8Interrupt = 0;
tpfHifCallBack pfWifiCb = NULL; /*!< pointer to Wi-Fi call back function */
tpfHifCallBack pfIpCb = NULL; /*!< pointer to Socket call back function */
tpfHifCallBack pfOtaCb = NULL; /*!< pointer to OTA call back function */
tpfHifCallBack pfSigmaCb = NULL;
tpfHifCallBack pfHifCb = NULL;
tpfHifCallBack pfCryptoCb = NULL;
static void isr(void)
{
@ -202,7 +204,7 @@ sint8 hif_chip_sleep(void)
{
gu8ChipSleep--;
}
if(gu8ChipSleep == 0)
{
if((gu8ChipMode == M2M_PS_DEEP_AUTOMATIC)||(gu8ChipMode == M2M_PS_MANUAL))
@ -245,7 +247,7 @@ sint8 hif_init(void * arg)
gu8Interrupt = 0;
nm_bsp_register_isr(isr);
hif_register_cb(M2M_REQ_GRP_HIF,m2m_hif_cb);
hif_register_cb(M2M_REQ_GROUP_HIF,m2m_hif_cb);
return M2M_SUCCESS;
}
@ -370,11 +372,17 @@ sint8 hif_send(uint8 u8Gid,uint8 u8Opcode,uint8 *pu8CtrlBuf,uint16 u16CtrlBufSiz
u32CurrAddr = dma_addr;
strHif.u16Length=NM_BSP_B_L_16(strHif.u16Length);
ret = nm_write_block(u32CurrAddr, (uint8*)&strHif, M2M_HIF_HDR_OFFSET);
#ifdef CONF_WINC_USE_I2C
nm_bsp_sleep(1);
#endif
if(M2M_SUCCESS != ret) goto ERR1;
u32CurrAddr += M2M_HIF_HDR_OFFSET;
if(pu8CtrlBuf != NULL)
{
ret = nm_write_block(u32CurrAddr, pu8CtrlBuf, u16CtrlBufSize);
#ifdef CONF_WINC_USE_I2C
nm_bsp_sleep(1);
#endif
if(M2M_SUCCESS != ret) goto ERR1;
u32CurrAddr += u16CtrlBufSize;
}
@ -382,6 +390,9 @@ sint8 hif_send(uint8 u8Gid,uint8 u8Opcode,uint8 *pu8CtrlBuf,uint16 u16CtrlBufSiz
{
u32CurrAddr += (u16DataOffset - u16CtrlBufSize);
ret = nm_write_block(u32CurrAddr, pu8DataBuf, u16DataSize);
#ifdef CONF_WINC_USE_I2C
nm_bsp_sleep(1);
#endif
if(M2M_SUCCESS != ret) goto ERR1;
u32CurrAddr += u16DataSize;
}
@ -426,7 +437,7 @@ static sint8 hif_isr(void)
ret = hif_chip_wake();
if(ret == M2M_SUCCESS)
{
ret = nm_read_reg_with_ret(0x1070, &reg);
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0, &reg);
if(M2M_SUCCESS == ret)
{
if(reg & 0x1) /* New interrupt has been received */
@ -435,19 +446,9 @@ static sint8 hif_isr(void)
nm_bsp_interrupt_ctrl(0);
/*Clearing RX interrupt*/
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0,&reg);
if(ret != M2M_SUCCESS)goto ERR1;
reg &= ~(1<<0);
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_0,reg);
if(ret != M2M_SUCCESS)goto ERR1;
/* read the rx size */
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0, &reg);
if(M2M_SUCCESS != ret)
{
M2M_ERR("(hif) WIFI_HOST_RCV_CTRL_0 bus fail\n");
nm_bsp_interrupt_ctrl(1);
goto ERR1;
}
gu8HifSizeDone = 0;
size = (uint16)((reg >> 2) & 0xfff);
if (size > 0) {
@ -482,22 +483,32 @@ static sint8 hif_isr(void)
}
}
if(M2M_REQ_GRP_WIFI == strHif.u8Gid)
if(M2M_REQ_GROUP_WIFI == strHif.u8Gid)
{
if(pfWifiCb)
pfWifiCb(strHif.u8Opcode,strHif.u16Length - M2M_HIF_HDR_OFFSET, address + M2M_HIF_HDR_OFFSET);
}
else if(M2M_REQ_GRP_IP == strHif.u8Gid)
else if(M2M_REQ_GROUP_IP == strHif.u8Gid)
{
if(pfIpCb)
pfIpCb(strHif.u8Opcode,strHif.u16Length - M2M_HIF_HDR_OFFSET, address + M2M_HIF_HDR_OFFSET);
}
else if(M2M_REQ_GRP_OTA == strHif.u8Gid)
else if(M2M_REQ_GROUP_OTA == strHif.u8Gid)
{
if(pfOtaCb)
pfOtaCb(strHif.u8Opcode,strHif.u16Length - M2M_HIF_HDR_OFFSET, address + M2M_HIF_HDR_OFFSET);
}
else if(M2M_REQ_GROUP_CRYPTO == strHif.u8Gid)
{
if(pfCryptoCb)
pfCryptoCb(strHif.u8Opcode,strHif.u16Length - M2M_HIF_HDR_OFFSET, address + M2M_HIF_HDR_OFFSET);
}
else if(M2M_REQ_GROUP_SIGMA == strHif.u8Gid)
{
if(pfSigmaCb)
pfSigmaCb(strHif.u8Opcode,strHif.u16Length - M2M_HIF_HDR_OFFSET, address + M2M_HIF_HDR_OFFSET);
}
else
{
M2M_ERR("(hif) invalid group ID\n");
@ -596,13 +607,15 @@ sint8 hif_receive(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone)
if(isDone)
{
gu8HifSizeDone = 1;
/* set RX done */
ret = hif_set_rx_done();
}
ret = M2M_ERR_FAIL;
M2M_ERR(" hif_receive: Invalid argument\n");
else
{
ret = M2M_ERR_FAIL;
M2M_ERR(" hif_receive: Invalid argument\n");
}
goto ERR1;
}
@ -614,9 +627,6 @@ sint8 hif_receive(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone)
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_1,&address);
if(ret != M2M_SUCCESS)goto ERR1;
/* Receive the payload */
ret = nm_read_block(u32Addr, pu8Buf, u16Sz);
if(ret != M2M_SUCCESS)goto ERR1;
if(u16Sz > size)
{
@ -630,9 +640,13 @@ sint8 hif_receive(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone)
M2M_ERR("APP Requested Address beyond the recived buffer address and length\n");
goto ERR1;
}
/* Receive the payload */
ret = nm_read_block(u32Addr, pu8Buf, u16Sz);
if(ret != M2M_SUCCESS)goto ERR1;
/* check if this is the last packet */
if((((address+size) - (u32Addr+u16Sz)) <= 0) || isDone)
if((((address + size) - (u32Addr + u16Sz)) <= 0) || isDone)
{
gu8HifSizeDone = 1;
@ -661,18 +675,24 @@ sint8 hif_register_cb(uint8 u8Grp,tpfHifCallBack fn)
sint8 ret = M2M_SUCCESS;
switch(u8Grp)
{
case M2M_REQ_GRP_IP:
case M2M_REQ_GROUP_IP:
pfIpCb = fn;
break;
case M2M_REQ_GRP_WIFI:
case M2M_REQ_GROUP_WIFI:
pfWifiCb = fn;
break;
case M2M_REQ_GRP_OTA:
case M2M_REQ_GROUP_OTA:
pfOtaCb = fn;
break;
case M2M_REQ_GRP_HIF:
case M2M_REQ_GROUP_HIF:
pfHifCb = fn;
break;
case M2M_REQ_GROUP_CRYPTO:
pfCryptoCb = fn;
break;
case M2M_REQ_GROUP_SIGMA:
pfSigmaCb = fn;
break;
default:
M2M_ERR("GRp ? %d\n",u8Grp);
ret = M2M_ERR_FAIL;

View File

@ -44,7 +44,6 @@
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
INCLUDES
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
#include "common/include/nm_common.h"
#include "driver/include/m2m_types.h"
#include "driver/include/m2m_ota.h"
@ -140,7 +139,7 @@ NMI_API sint8 m2m_ota_init(tpfOtaUpdateCb pfOtaUpdateCb, tpfOtaNotifCb pfOtaNot
M2M_ERR("Invaild Ota notify cb\n");
}
hif_register_cb(M2M_REQ_GRP_OTA,m2m_ota_cb);
hif_register_cb(M2M_REQ_GROUP_OTA,m2m_ota_cb);
return ret;
}
@ -164,7 +163,7 @@ NMI_API sint8 m2m_ota_notif_set_url(uint8 * u8Url)
/*Todo: we may change it to data pkt but we need to give it higer priority
but the priorty is not implemnted yet in data pkt
*/
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_START_UPDATE,u8Url,u16UrlSize,NULL,0,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_START_UPDATE,u8Url,u16UrlSize,NULL,0,0);
return ret;
}
@ -182,7 +181,7 @@ NMI_API sint8 m2m_ota_notif_set_url(uint8 * u8Url)
NMI_API sint8 m2m_ota_notif_check_for_update(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_NOTIF_CHECK_FOR_UPDATE,NULL,0,NULL,0,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_NOTIF_CHECK_FOR_UPDATE,NULL,0,NULL,0,0);
return ret;
}
@ -202,7 +201,7 @@ NMI_API sint8 m2m_ota_notif_check_for_update(void)
NMI_API sint8 m2m_ota_notif_sched(uint32 u32Period)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_NOTIF_CHECK_FOR_UPDATE,NULL,0,NULL,0,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_NOTIF_CHECK_FOR_UPDATE,NULL,0,NULL,0,0);
return ret;
}
@ -227,7 +226,7 @@ NMI_API sint8 m2m_ota_start_update(uint8 * u8DownloadUrl)
/*Todo: we may change it to data pkt but we need to give it higer priority
but the priorty is not implemnted yet in data pkt
*/
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_START_UPDATE,u8DownloadUrl,u16DurlSize,NULL,0,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_START_UPDATE,u8DownloadUrl,u16DurlSize,NULL,0,0);
return ret;
}
@ -245,7 +244,7 @@ NMI_API sint8 m2m_ota_start_update(uint8 * u8DownloadUrl)
NMI_API sint8 m2m_ota_rollback(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_ROLLBACK,NULL,0,NULL,0,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_ROLLBACK,NULL,0,NULL,0,0);
return ret;
}
@ -263,7 +262,28 @@ NMI_API sint8 m2m_ota_rollback(void)
NMI_API sint8 m2m_ota_switch_firmware(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_SWITCH_FIRMWARE,NULL,0,NULL,0,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_SWITCH_FIRMWARE,NULL,0,NULL,0,0);
return ret;
}
/*!
@fn \
NMI_API sint8 m2m_ota_get_firmware_version(tstrM2mRev * pstrRev);
@brief
Get the OTA Firmware version.
@return
The function SHALL return 0 for success and a negative value otherwise.
*/
NMI_API sint8 m2m_ota_get_firmware_version(tstrM2mRev * pstrRev)
{
sint8 ret = M2M_SUCCESS;
ret = hif_chip_wake();
if(ret == M2M_SUCCESS)
{
ret = nm_get_ota_firmware_info(pstrRev);
hif_chip_sleep();
}
return ret;
}
#if 0
@ -301,7 +321,7 @@ NMI_API sint8 m2m_ota_test(void)
}
printf("page %d\n", (int)page);
fread(buffer,page,1,fp);
ret = hif_send(M2M_REQ_GRP_OTA,M2M_OTA_REQ_TEST|M2M_REQ_DATA_PKT,NULL,0,(uint8*)&buffer,page,0);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_TEST|M2M_REQ_DATA_PKT,NULL,0,(uint8*)&buffer,page,0);
if(ret != M2M_SUCCESS)
{
M2M_ERR("\n");

View File

@ -67,6 +67,10 @@ static sint8 get_gpio_idx(uint8 u8GpioNum)
if(u8GpioNum == M2M_PERIPH_GPIO15) { return 15;
} else if(u8GpioNum == M2M_PERIPH_GPIO16) { return 16;
} else if(u8GpioNum == M2M_PERIPH_GPIO18) { return 18;
} else if(u8GpioNum == M2M_PERIPH_GPIO3) { return 3;
} else if(u8GpioNum == M2M_PERIPH_GPIO4) { return 4;
} else if(u8GpioNum == M2M_PERIPH_GPIO5) { return 5;
} else if(u8GpioNum == M2M_PERIPH_GPIO6) { return 6;
} else {
return -2;
}

View File

@ -54,8 +54,8 @@ static uint8* gau8ethRcvBuf=NULL;
static uint16 gu16ethRcvBufSize ;
#endif
#define CONF_MGMT
//#define CONF_MGMT
#ifdef CONF_MGMT
static tpfAppMonCb gpfAppMonCb = NULL;
static struct _tstrMgmtCtrl
@ -147,7 +147,7 @@ static void m2m_wifi_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
uint32 u32ConflictedIP;
if(hif_receive(u32Addr, (uint8 *)&u32ConflictedIP, sizeof(u32ConflictedIP), 0) == M2M_SUCCESS)
{
M2M_INFO("Conflicted IP \" %u.%u.%u.%u \" \n",
M2M_INFO("Conflicted IP \" %u.%u.%u.%u \" \n",
BYTE_0(u32ConflictedIP),BYTE_1(u32ConflictedIP),BYTE_2(u32ConflictedIP),BYTE_3(u32ConflictedIP));
if (gpfAppWifiCb)
gpfAppWifiCb(M2M_WIFI_RESP_IP_CONFLICT, NULL);
@ -208,31 +208,47 @@ static void m2m_wifi_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
gpfAppWifiCb(M2M_WIFI_RESP_DEFAULT_CONNECT, &strResp);
}
}
#ifdef ETH_MODE
else if(u8OpCode == M2M_WIFI_RESP_ETHERNET_RX_PACKET)
else if(u8OpCode == M2M_WIFI_RESP_GET_PRNG)
{
tstrPrng strPrng;
if(hif_receive(u32Addr, (uint8*)&strPrng,sizeof(tstrPrng), 0) == M2M_SUCCESS)
{
if(hif_receive(u32Addr, rx_buf ,sizeof(tstrM2mIpRsvdPkt), 0) == M2M_SUCCESS)
if(hif_receive(u32Addr + sizeof(tstrPrng),strPrng.pu8RngBuff,strPrng.u16PrngSize, 1) == M2M_SUCCESS)
{
if(gpfAppWifiCb)
gpfAppWifiCb(M2M_WIFI_RESP_GET_PRNG,&strPrng);
}
}
}
#ifdef ETH_MODE
else if(u8OpCode == M2M_WIFI_RESP_ETHERNET_RX_PACKET)
{
uint8 u8SetRxDone;
tstrM2mIpRsvdPkt strM2mRsvd;
if(hif_receive(u32Addr, &strM2mRsvd ,sizeof(tstrM2mIpRsvdPkt), 0) == M2M_SUCCESS)
{
tstrM2mIpRsvdPkt * pstrM2MIpRxPkt = (tstrM2mIpRsvdPkt*)rx_buf;
tstrM2mIpCtrlBuf strM2mIpCtrlBuf;
uint16 u16Offset = pstrM2MIpRxPkt->u16PktOffset;
strM2mIpCtrlBuf.u16RemainigDataSize = pstrM2MIpRxPkt->u16PktSz;
if((gpfAppEthCb) &&(gau8ethRcvBuf)&& (gu16ethRcvBufSize > 0))
uint16 u16Offset = strM2mRsvd.u16PktOffset;
strM2mIpCtrlBuf.u16RemainigDataSize = strM2mRsvd.u16PktSz;
if((gpfAppEthCb) && (gau8ethRcvBuf) && (gu16ethRcvBufSize > 0))
{
while (strM2mIpCtrlBuf.u16RemainigDataSize > 0)
do
{
u8SetRxDone = 1;
if(strM2mIpCtrlBuf.u16RemainigDataSize > gu16ethRcvBufSize)
{
strM2mIpCtrlBuf.u16DataSize = gu16ethRcvBufSize ;
u8SetRxDone = 0;
strM2mIpCtrlBuf.u16DataSize = gu16ethRcvBufSize;
}
else
{
strM2mIpCtrlBuf.u16DataSize = strM2mIpCtrlBuf.u16RemainigDataSize;
}
if(hif_receive(u32Addr+u16Offset, gau8ethRcvBuf, strM2mIpCtrlBuf.u16DataSize, 0) == M2M_SUCCESS)
if(hif_receive(u32Addr + u16Offset, gau8ethRcvBuf, strM2mIpCtrlBuf.u16DataSize, u8SetRxDone) == M2M_SUCCESS)
{
strM2mIpCtrlBuf.u16RemainigDataSize -= strM2mIpCtrlBuf.u16DataSize;
strM2mIpCtrlBuf.u16RemainigDataSize -= strM2mIpCtrlBuf.u16DataSize;
u16Offset += strM2mIpCtrlBuf.u16DataSize;
gpfAppEthCb(M2M_WIFI_RESP_ETHERNET_RX_PACKET, gau8ethRcvBuf, &(strM2mIpCtrlBuf));
}
@ -240,15 +256,15 @@ static void m2m_wifi_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
{
break;
}
}
}while (strM2mIpCtrlBuf.u16RemainigDataSize > 0);
}
}
}
#endif
#endif /* ETH_MODE */
#ifdef CONF_MGMT
else if(u8OpCode == M2M_WIFI_RESP_WIFI_RX_PACKET)
{
tstrM2MWifiRxPacketInfo strRxPacketInfo;
if(u16DataSize >= sizeof(tstrM2MWifiRxPacketInfo)) {
if(hif_receive(u32Addr, (uint8*)&strRxPacketInfo, sizeof(tstrM2MWifiRxPacketInfo), 0) == M2M_SUCCESS)
@ -261,10 +277,7 @@ static void m2m_wifi_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
u16DataSize = gstrMgmtCtrl.u16Sz;
}
u32Addr += sizeof(tstrM2MWifiRxPacketInfo) + gstrMgmtCtrl.u16Offset;
if(hif_receive(u32Addr , gstrMgmtCtrl.pu8Buf, u16DataSize, 1) != M2M_SUCCESS)
{
u16DataSize = 0;
}
if(hif_receive(u32Addr , gstrMgmtCtrl.pu8Buf, u16DataSize, 1) != M2M_SUCCESS) return;
}
if(gpfAppMonCb)
gpfAppMonCb(&strRxPacketInfo, gstrMgmtCtrl.pu8Buf,u16DataSize);
@ -409,7 +422,9 @@ static sint8 m2m_validate_scan_options(tstrM2MScanOption* ptstrM2MScanOption)
sint8 m2m_wifi_init(tstrWifiInitParam * param)
{
tstrM2mRev strtmp;
sint8 ret = M2M_SUCCESS;
uint8 u8WifiMode = M2M_WIFI_MODE_NORMAL;
if(param == NULL) {
ret = M2M_ERR_FAIL;
@ -417,25 +432,36 @@ sint8 m2m_wifi_init(tstrWifiInitParam * param)
}
gpfAppWifiCb = param->pfAppWifiCb;
#ifdef ETH_MODE
gpfAppEthCb = param->strEthInitParam.pfAppEthCb;
gpfAppEthCb = param->strEthInitParam.pfAppEthCb;
gau8ethRcvBuf = param->strEthInitParam.au8ethRcvBuf;
gu16ethRcvBufSize = param->strEthInitParam.u16ethRcvBufSize;
#endif
u8WifiMode = param->strEthInitParam.u8EthernetEnable;
#endif /* ETH_MODE */
#ifdef CONF_MGMT
gpfAppMonCb = param->pfAppMonCb;
#endif
gu8scanInProgress = 0;
/* Apply device specific initialization. */
ret = nm_drv_init(NULL);
ret = nm_drv_init(&u8WifiMode);
if(ret != M2M_SUCCESS) goto _EXIT0;
/* Initialize host interface module */
ret = hif_init(NULL);
if(ret != M2M_SUCCESS) goto _EXIT1;
hif_register_cb(M2M_REQ_GRP_WIFI,m2m_wifi_cb);
hif_register_cb(M2M_REQ_GROUP_WIFI,m2m_wifi_cb);
ret = nm_get_firmware_info(&strtmp);
M2M_INFO("Firmware ver : %u.%u.%u\n", strtmp.u8FirmwareMajor, strtmp.u8FirmwareMinor, strtmp.u8FirmwarePatch);
M2M_INFO("Min driver ver : %u.%u.%u\n", strtmp.u8DriverMajor, strtmp.u8DriverMinor, strtmp.u8DriverPatch);
M2M_INFO("Curr driver ver: %u.%u.%u\n", M2M_DRIVER_VERSION_MAJOR_NO, M2M_DRIVER_VERSION_MINOR_NO, M2M_DRIVER_VERSION_PATCH_NO);
if(M2M_ERR_FW_VER_MISMATCH == ret)
{
M2M_ERR("Mismatch Firmawre Version\n");
}
goto _EXIT0;
@ -463,7 +489,7 @@ sint8 m2m_wifi_handle_events(void * arg)
sint8 m2m_wifi_default_connect(void)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DEFAULT_CONNECT, NULL, 0,NULL, 0,0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DEFAULT_CONNECT, NULL, 0,NULL, 0,0);
}
sint8 m2m_wifi_connect(char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *pvAuthInfo, uint16 u16Ch)
@ -484,6 +510,21 @@ sint8 m2m_wifi_connect_sc(char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *
ret = M2M_ERR_FAIL;
goto ERR1;
}
if((u8SecType == M2M_WIFI_SEC_WPA_PSK) && (m2m_strlen(pvAuthInfo) == (M2M_MAX_PSK_LEN-1)))
{
uint8 i = 0;
uint8* pu8Psk = (uint8*)pvAuthInfo;
while(i < (M2M_MAX_PSK_LEN-1))
{
if(pu8Psk[i]<'0' || (pu8Psk[i]>'9' && pu8Psk[i] < 'A')|| (pu8Psk[i]>'F' && pu8Psk[i] < 'a') || pu8Psk[i] > 'f')
{
M2M_ERR("Invalid Key\n");
ret = M2M_ERR_FAIL;
goto ERR1;
}
i++;
}
}
}
if((u8SsidLen<=0)||(u8SsidLen>=M2M_MAX_SSID_LEN))
{
@ -562,7 +603,7 @@ sint8 m2m_wifi_connect_sc(char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *
goto ERR1;
}
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_CONNECT, (uint8*)&strConnect, sizeof(tstrM2mWifiConnect),NULL, 0,0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_CONNECT, (uint8*)&strConnect, sizeof(tstrM2mWifiConnect),NULL, 0,0);
ERR1:
return ret;
@ -570,13 +611,13 @@ ERR1:
sint8 m2m_wifi_disconnect(void)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DISCONNECT, NULL, 0, NULL, 0,0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISCONNECT, NULL, 0, NULL, 0,0);
}
sint8 m2m_wifi_set_mac_address(uint8 au8MacAddress[6])
{
tstrM2mSetMacAddress strTmp;
m2m_memcpy((uint8*) strTmp.au8Mac, (uint8*) au8MacAddress, 6);
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_MAC_ADDRESS,
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_MAC_ADDRESS,
(uint8*) &strTmp, sizeof(tstrM2mSetMacAddress), NULL, 0,0);
}
@ -588,7 +629,7 @@ sint8 m2m_wifi_set_static_ip(tstrM2MIPConfig * pstrStaticIPConf)
pstrStaticIPConf->u32StaticIP);
pstrStaticIPConf->u32SubnetMask = NM_BSP_B_L_32(
pstrStaticIPConf->u32SubnetMask);
return hif_send(M2M_REQ_GRP_IP, M2M_IP_REQ_STATIC_IP_CONF,
return hif_send(M2M_REQ_GROUP_IP, M2M_IP_REQ_STATIC_IP_CONF,
(uint8*) pstrStaticIPConf, sizeof(tstrM2MIPConfig), NULL, 0,0);
}
@ -611,26 +652,35 @@ sint8 m2m_wifi_request_dhcp_server(uint8* addr)
@return The function SHALL return 0 for success and a negative value otherwise.
@sa tstrM2mLsnInt , m2m_wifi_set_sleep_mode
@pre m2m_wifi_set_sleep_mode shall be called first
@warning The Function called once after initialization.
@warning The Function called once after initialization.
*/
sint8 m2m_wifi_enable_dhcp(uint8 u8DhcpEn )
{
uint8 u8Req;
u8Req = u8DhcpEn ? M2M_IP_REQ_ENABLE_DHCP : M2M_IP_REQ_DISABLE_DHCP;
return hif_send(M2M_REQ_GRP_IP, u8Req, NULL, 0, NULL, 0, 0);
return hif_send(M2M_REQ_GROUP_IP, u8Req, NULL, 0, NULL, 0, 0);
}
sint8 m2m_wifi_set_lsn_int(tstrM2mLsnInt* pstrM2mLsnInt)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_LSN_INT, (uint8*)pstrM2mLsnInt, sizeof(tstrM2mLsnInt), NULL, 0, 0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_LSN_INT, (uint8*)pstrM2mLsnInt, sizeof(tstrM2mLsnInt), NULL, 0, 0);
}
sint8 m2m_wifi_set_cust_InfoElement(uint8* pau8M2mCustInfoElement)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_CUST_INFO_ELEMENT, (uint8*)pau8M2mCustInfoElement, pau8M2mCustInfoElement[0]+1, NULL, 0, 0);
sint8 ret = M2M_ERR_FAIL;
if(pau8M2mCustInfoElement != NULL)
{
if((pau8M2mCustInfoElement[0] + 1) < M2M_CUST_IE_LEN_MAX)
{
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_CUST_INFO_ELEMENT|M2M_REQ_DATA_PKT, (uint8*)pau8M2mCustInfoElement, pau8M2mCustInfoElement[0]+1, NULL, 0, 0);
}
}
return ret;
}
sint8 m2m_wifi_set_scan_options(tstrM2MScanOption* ptstrM2MScanOption)
@ -638,7 +688,7 @@ sint8 m2m_wifi_set_scan_options(tstrM2MScanOption* ptstrM2MScanOption)
sint8 s8Ret = M2M_ERR_FAIL;
if(m2m_validate_scan_options (ptstrM2MScanOption) == M2M_SUCCESS)
{
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_SCAN_OPTION, (uint8*)ptstrM2MScanOption, sizeof(tstrM2MScanOption),NULL, 0,0);
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_SCAN_OPTION, (uint8*)ptstrM2MScanOption, sizeof(tstrM2MScanOption),NULL, 0,0);
}
return s8Ret;
}
@ -647,7 +697,7 @@ sint8 m2m_wifi_set_scan_region(uint16 ScanRegion)
sint8 s8Ret = M2M_ERR_FAIL;
tstrM2MScanRegion strScanRegion;
strScanRegion.u16ScanRegion = ScanRegion;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_SCAN_REGION, (uint8*)&strScanRegion, sizeof(tstrM2MScanRegion),NULL, 0,0);
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_SCAN_REGION, (uint8*)&strScanRegion, sizeof(tstrM2MScanRegion),NULL, 0,0);
return s8Ret;
}
sint8 m2m_wifi_request_scan(uint8 ch)
@ -660,7 +710,7 @@ sint8 m2m_wifi_request_scan(uint8 ch)
{
tstrM2MScan strtmp;
strtmp.u8ChNum = ch;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SCAN, (uint8*)&strtmp, sizeof(tstrM2MScan),NULL, 0,0);
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SCAN, (uint8*)&strtmp, sizeof(tstrM2MScan),NULL, 0,0);
if(s8Ret == M2M_SUCCESS)
{
gu8scanInProgress = 1;
@ -688,24 +738,24 @@ sint8 m2m_wifi_wps(uint8 u8TriggerType,const char *pcPinNumber)
/*If WPS is using PIN METHOD*/
if (u8TriggerType == WPS_PIN_TRIGGER)
m2m_memcpy ((uint8*)strtmp.acPinNumber,(uint8*) pcPinNumber,8);
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_WPS, (uint8*)&strtmp,sizeof(tstrM2MWPSConnect), NULL, 0,0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_WPS, (uint8*)&strtmp,sizeof(tstrM2MWPSConnect), NULL, 0,0);
}
sint8 m2m_wifi_wps_disable(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DISABLE_WPS, NULL,0, NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISABLE_WPS, NULL,0, NULL, 0, 0);
return ret;
}
/*!
@fn NMI_API sint8 m2m_wifi_req_client_ctrl(uint8 cmd);
@brief Send a command to the PS Client (An WINC1500 board running the ps_firmware),
@brief Send a command to the PS Client (An WINC1500 board running the ps_firmware),
if the PS client send any commands it will be received in wifi_cb M2M_WIFI_RESP_CLIENT_INFO
@param [in] cmd
Control command sent from PS Server to PS Client (command values defined by the application)
@return The function SHALL return M2M_SUCCESE for success and a negative value otherwise.
@sa m2m_wifi_req_server_init, M2M_WIFI_RESP_CLIENT_INFO
@pre m2m_wifi_req_server_init should be called first
@warning
@warning
*/
sint8 m2m_wifi_req_client_ctrl(uint8 u8Cmd)
{
@ -714,7 +764,7 @@ sint8 m2m_wifi_req_client_ctrl(uint8 u8Cmd)
#ifdef _PS_SERVER_
tstrM2Mservercmd strCmd;
strCmd.u8cmd = u8Cmd;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_CLIENT_CTRL, (uint8*)&strCmd, sizeof(tstrM2Mservercmd), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_CLIENT_CTRL, (uint8*)&strCmd, sizeof(tstrM2Mservercmd), NULL, 0, 0);
#else
M2M_ERR("_PS_SERVER_ is not defined\n");
#endif
@ -722,7 +772,7 @@ sint8 m2m_wifi_req_client_ctrl(uint8 u8Cmd)
}
/*!
@fn NMI_API sint8 m2m_wifi_req_server_init(uint8 ch);
@brief Initialize the PS Server, The WINC1500 support Non secure communication with another WINC1500,
@brief Initialize the PS Server, The WINC1500 support Non secure communication with another WINC1500,
(SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup
@param [in] ch
Server listening channel
@ -736,7 +786,7 @@ sint8 m2m_wifi_req_server_init(uint8 ch)
#ifdef _PS_SERVER_
tstrM2mServerInit strServer;
strServer.u8Channel = ch;
ret = hif_send(M2M_REQ_GRP_WIFI,M2M_WIFI_REQ_SERVER_INIT, (uint8*)&strServer, sizeof(tstrM2mServerInit), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI,M2M_WIFI_REQ_SERVER_INIT, (uint8*)&strServer, sizeof(tstrM2mServerInit), NULL, 0, 0);
#else
M2M_ERR("_PS_SERVER_ is not defined\n");
#endif
@ -749,7 +799,7 @@ sint8 m2m_wifi_p2p(uint8 u8Channel)
{
tstrM2MP2PConnect strtmp;
strtmp.u8ListenChannel = u8Channel;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_ENABLE_P2P, (uint8*)&strtmp, sizeof(tstrM2MP2PConnect), NULL, 0,0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_ENABLE_P2P, (uint8*)&strtmp, sizeof(tstrM2MP2PConnect), NULL, 0,0);
}
else
{
@ -761,7 +811,7 @@ sint8 m2m_wifi_p2p(uint8 u8Channel)
sint8 m2m_wifi_p2p_disconnect(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DISABLE_P2P, NULL, 0, NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISABLE_P2P, NULL, 0, NULL, 0, 0);
return ret;
}
sint8 m2m_wifi_enable_ap(CONST tstrM2MAPConfig* pstrM2MAPConfig)
@ -769,27 +819,27 @@ sint8 m2m_wifi_enable_ap(CONST tstrM2MAPConfig* pstrM2MAPConfig)
sint8 ret = M2M_ERR_FAIL;
if(M2M_SUCCESS == m2m_validate_ap_parameters(pstrM2MAPConfig))
{
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_ENABLE_AP, (uint8 *)pstrM2MAPConfig, sizeof(tstrM2MAPConfig), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_ENABLE_AP, (uint8 *)pstrM2MAPConfig, sizeof(tstrM2MAPConfig), NULL, 0, 0);
}
return ret;
}
sint8 m2m_wifi_disable_ap(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DISABLE_AP, NULL, 0, NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISABLE_AP, NULL, 0, NULL, 0, 0);
return ret;
}
/*!
@fn NMI_API sint8 m2m_wifi_req_curr_rssi(void);
@brief Request the current RSSI for the current connected AP,
the response received in wifi_cb M2M_WIFI_RESP_CURRENT_RSSI
@sa M2M_WIFI_RESP_CURRENT_RSSI
@brief Request the current RSSI for the current connected AP,
the response received in wifi_cb M2M_WIFI_RESP_CURRENT_RSSI
@sa M2M_WIFI_RESP_CURRENT_RSSI
@return The function shall return M2M_SUCCESS for success and a negative value otherwise.
*/
sint8 m2m_wifi_req_curr_rssi(void)
{
sint8 ret = M2M_SUCCESS;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_CURRENT_RSSI, NULL, 0, NULL,0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_CURRENT_RSSI, NULL, 0, NULL,0, 0);
return ret;
}
sint8 m2m_wifi_send_ethernet_pkt(uint8* pu8Packet,uint16 u16PacketSize)
@ -801,7 +851,7 @@ sint8 m2m_wifi_send_ethernet_pkt(uint8* pu8Packet,uint16 u16PacketSize)
strTxPkt.u16PacketSize = u16PacketSize;
strTxPkt.u16HeaderLength = M2M_ETHERNET_HDR_LEN;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SEND_ETHERNET_PACKET | M2M_REQ_DATA_PKT,
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SEND_ETHERNET_PACKET | M2M_REQ_DATA_PKT,
(uint8*)&strTxPkt, sizeof(tstrM2MWifiTxPacketInfo), pu8Packet, u16PacketSize, M2M_ETHERNET_HDR_OFFSET - M2M_HIF_HDR_OFFSET);
}
return s8Ret;
@ -809,14 +859,14 @@ sint8 m2m_wifi_send_ethernet_pkt(uint8* pu8Packet,uint16 u16PacketSize)
/*!
@fn NMI_API sint8 m2m_wifi_get_otp_mac_address(uint8 *pu8MacAddr, uint8 * pu8IsValid);
@brief Request the MAC address stored on the OTP (one time programmable) memory of the device.
(the function is Blocking until response received)
(the function is Blocking until response received)
@param [out] pu8MacAddr
Output MAC address buffer of 6 bytes size. Valid only if *pu8Valid=1.
@param [out] pu8IsValid
A output boolean value to indicate the validity of pu8MacAddr in OTP.
Output zero if the OTP memory is not programmed, non-zero otherwise.
A output boolean value to indicate the validity of pu8MacAddr in OTP.
Output zero if the OTP memory is not programmed, non-zero otherwise.
@return The function shall return M2M_SUCCESS for success and a negative value otherwise.
@sa m2m_wifi_get_mac_address
@sa m2m_wifi_get_mac_address
@pre m2m_wifi_init required to call any WIFI/socket function
*/
sint8 m2m_wifi_get_otp_mac_address(uint8 *pu8MacAddr, uint8* pu8IsValid)
@ -836,11 +886,11 @@ sint8 m2m_wifi_get_otp_mac_address(uint8 *pu8MacAddr, uint8* pu8IsValid)
/*!
@fn NMI_API sint8 m2m_wifi_get_mac_address(uint8 *pu8MacAddr)
@brief Request the current MAC address of the device (the working mac address).
(the function is Blocking until response received)
(the function is Blocking until response received)
@param [out] pu8MacAddr
Output MAC address buffer of 6 bytes size.
Output MAC address buffer of 6 bytes size.
@return The function shall return M2M_SUCCESS for success and a negative value otherwise.
@sa m2m_wifi_get_otp_mac_address
@sa m2m_wifi_get_otp_mac_address
@pre m2m_wifi_init required to call any WIFI/socket function
*/
sint8 m2m_wifi_get_mac_address(uint8 *pu8MacAddr)
@ -860,18 +910,18 @@ sint8 m2m_wifi_get_mac_address(uint8 *pu8MacAddr)
}
/*!
@fn NMI_API sint8 m2m_wifi_req_scan_result(uint8 index);
@brief Reads the AP information from the Scan Result list with the given index,
the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT,
the response pointer should be casted with tstrM2mWifiscanResult structure
@param [in] index
Index for the requested result, the index range start from 0 till number of AP's found
@sa tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
@brief Reads the AP information from the Scan Result list with the given index,
the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT,
the response pointer should be casted with tstrM2mWifiscanResult structure
@param [in] index
Index for the requested result, the index range start from 0 till number of AP's found
@sa tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
@return The function shall return M2M_SUCCESE for success and a negative value otherwise
@pre m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found
@pre m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found
to get the number of AP's found
@warning Function used only in STA mode only. the scan result updated only if scan request called,
else it will be cashed in firmware for the host scan request result,
which mean if large delay occur between the scan request and the scan result request,
else it will be cashed in firmware for the host scan request result,
which mean if large delay occur between the scan request and the scan result request,
the result will not be up-to-date
*/
@ -880,18 +930,18 @@ sint8 m2m_wifi_req_scan_result(uint8 index)
sint8 ret = M2M_SUCCESS;
tstrM2mReqScanResult strReqScanRlt;
strReqScanRlt.u8Index = index;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SCAN_RESULT, (uint8*) &strReqScanRlt, sizeof(tstrM2mReqScanResult), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SCAN_RESULT, (uint8*) &strReqScanRlt, sizeof(tstrM2mReqScanResult), NULL, 0, 0);
return ret;
}
/*!
@fn NMI_API uint8 m2m_wifi_get_num_ap_found(void);
@brief Reads the number of AP's found in the last Scan Request,
The function read the number of AP's from global variable which updated in the
wifi_cb in M2M_WIFI_RESP_SCAN_DONE.
@sa m2m_wifi_request_scan
@brief Reads the number of AP's found in the last Scan Request,
The function read the number of AP's from global variable which updated in the
wifi_cb in M2M_WIFI_RESP_SCAN_DONE.
@sa m2m_wifi_request_scan
@return Return the number of AP's found in the last Scan Request.
@pre m2m_wifi_request_scan need to be called first
@warning That function need to be called in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE,
@pre m2m_wifi_request_scan need to be called first
@warning That function need to be called in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE,
calling that function in any other place will return undefined/undated numbers.
Function used only in STA mode only.
*/
@ -911,17 +961,17 @@ uint8 m2m_wifi_get_sleep_mode(void)
}
/*!
@fn NMI_API sint8 m2m_wifi_set_sleep_mode(uint8 PsTyp, uint8 BcastEn);
@brief Set the power saving mode for the WINC1500.
@brief Set the power saving mode for the WINC1500.
@param [in] PsTyp
Desired power saving mode. Supported types are defined in tenuPowerSaveModes.
@param [in] BcastEn
Broadcast reception enable flag.
Broadcast reception enable flag.
If it is 1, the WINC1500 must be awake each DTIM Beacon for receiving Broadcast traffic.
If it is 0, the WINC1500 will not wakeup at the DTIM Beacon, but its wakeup depends only
on the the configured Listen Interval.
If it is 0, the WINC1500 will not wakeup at the DTIM Beacon, but its wakeup depends only
on the the configured Listen Interval.
@return The function SHALL return 0 for success and a negative value otherwise.
@sa tenuPowerSaveModes
@warning The function called once after initialization.
@warning The function called once after initialization.
*/
sint8 m2m_wifi_set_sleep_mode(uint8 PsTyp, uint8 BcastEn)
{
@ -929,7 +979,7 @@ sint8 m2m_wifi_set_sleep_mode(uint8 PsTyp, uint8 BcastEn)
tstrM2mPsType strPs;
strPs.u8PsType = PsTyp;
strPs.u8BcastEn = BcastEn;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SLEEP, (uint8*) &strPs,sizeof(tstrM2mPsType), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SLEEP, (uint8*) &strPs,sizeof(tstrM2mPsType), NULL, 0, 0);
M2M_INFO("POWER SAVE %d\n",PsTyp);
hif_set_sleep_mode(PsTyp);
return ret;
@ -938,10 +988,10 @@ sint8 m2m_wifi_set_sleep_mode(uint8 PsTyp, uint8 BcastEn)
@fn NMI_API sint8 m2m_wifi_request_sleep(void)
@brief Request from WINC1500 device to Sleep for specific time in the M2M_PS_MANUAL Power save mode (only).
@param [in] u32SlpReqTime
Request Sleep in ms
Request Sleep in ms
@return The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
@sa tenuPowerSaveModes , m2m_wifi_set_sleep_mode
@warning the Function should be called in M2M_PS_MANUAL power save only
@warning the Function should be called in M2M_PS_MANUAL power save only
*/
sint8 m2m_wifi_request_sleep(uint32 u32SlpReqTime)
{
@ -952,7 +1002,7 @@ sint8 m2m_wifi_request_sleep(uint32 u32SlpReqTime)
{
tstrM2mSlpReqTime strPs;
strPs.u32SleepTime = u32SlpReqTime;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DOZE, (uint8*) &strPs,sizeof(tstrM2mSlpReqTime), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DOZE, (uint8*) &strPs,sizeof(tstrM2mSlpReqTime), NULL, 0, 0);
}
return ret;
}
@ -964,7 +1014,7 @@ sint8 m2m_wifi_request_sleep(uint32 u32SlpReqTime)
@param [in] u8DeviceNameLength
Length of the device name.
@return The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
@warning The Function called once after initialization.
@warning The Function called once after initialization.
*/
sint8 m2m_wifi_set_device_name(uint8 *pu8DeviceName, uint8 u8DeviceNameLength)
{
@ -976,9 +1026,20 @@ sint8 m2m_wifi_set_device_name(uint8 *pu8DeviceName, uint8 u8DeviceNameLength)
//pu8DeviceName[u8DeviceNameLength] = '\0';
u8DeviceNameLength ++;
m2m_memcpy(strDeviceName.au8DeviceName, pu8DeviceName, u8DeviceNameLength);
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_DEVICE_NAME,
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_DEVICE_NAME,
(uint8*)&strDeviceName, sizeof(tstrM2MDeviceNameConfig), NULL, 0,0);
}
sint8 m2m_wifi_get_firmware_version(tstrM2mRev *pstrRev)
{
sint8 ret = M2M_SUCCESS;
ret = hif_chip_wake();
if(ret == M2M_SUCCESS)
{
ret = nm_get_firmware_full_info(pstrRev);
hif_chip_sleep();
}
return ret;
}
#ifdef CONF_MGMT
sint8 m2m_wifi_enable_monitoring_mode(tstrM2MWifiMonitorModeCtrl *pstrMtrCtrl, uint8 *pu8PayloadBuffer,
uint16 u16BufferSize, uint16 u16DataOffset)
@ -989,18 +1050,15 @@ sint8 m2m_wifi_enable_monitoring_mode(tstrM2MWifiMonitorModeCtrl *pstrMtrCtrl, u
gstrMgmtCtrl.pu8Buf = pu8PayloadBuffer;
gstrMgmtCtrl.u16Sz = u16BufferSize;
gstrMgmtCtrl.u16Offset = u16DataOffset;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_ENABLE_MONITORING,
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_ENABLE_MONITORING,
(uint8*)pstrMtrCtrl, sizeof(tstrM2MWifiMonitorModeCtrl), NULL, 0,0);
}
return s8Ret;
}
sint8 m2m_wifi_get_firmware_version(tstrM2mRev *M2mRev)
{
return nm_get_firmware_info(M2mRev);
}
sint8 m2m_wifi_disable_monitoring_mode(void)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DISABLE_MONITORING, NULL, 0, NULL, 0,0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISABLE_MONITORING, NULL, 0, NULL, 0,0);
}
sint8 m2m_wifi_send_wlan_pkt(uint8 *pu8WlanPacket, uint16 u16WlanHeaderLength, uint16 u16WlanPktSize)
@ -1012,7 +1070,7 @@ sint8 m2m_wifi_send_wlan_pkt(uint8 *pu8WlanPacket, uint16 u16WlanHeaderLength, u
strTxPkt.u16PacketSize = u16WlanPktSize;
strTxPkt.u16HeaderLength = u16WlanHeaderLength;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SEND_WIFI_PACKET | M2M_REQ_DATA_PKT,
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SEND_WIFI_PACKET | M2M_REQ_DATA_PKT,
(uint8*)&strTxPkt, sizeof(tstrM2MWifiTxPacketInfo), pu8WlanPacket, u16WlanPktSize, sizeof(tstrM2MWifiTxPacketInfo));
}
return s8Ret;
@ -1036,11 +1094,11 @@ sint8 m2m_wifi_start_provision_mode(tstrM2MAPConfig *pstrAPConfig, char *pcHttpS
}
m2m_memcpy((uint8*)strProvConfig.acHttpServerDomainName, (uint8*)pcHttpServerDomainName, 64);
strProvConfig.u8EnableRedirect = bEnableHttpRedirect;
/* Stop Scan if it is ongoing.
*/
gu8scanInProgress = 0;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_START_PROVISION_MODE | M2M_REQ_DATA_PKT,
s8Ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_START_PROVISION_MODE | M2M_REQ_DATA_PKT,
(uint8*)&strProvConfig, sizeof(tstrM2MProvisionModeConfig), NULL, 0, 0);
}
else
@ -1054,17 +1112,20 @@ ERR1:
sint8 m2m_wifi_stop_provision_mode(void)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_STOP_PROVISION_MODE, NULL, 0, NULL, 0, 0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_STOP_PROVISION_MODE, NULL, 0, NULL, 0, 0);
}
sint8 m2m_wifi_get_connection_info(void)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_GET_CONN_INFO, NULL, 0, NULL, 0, 0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_GET_CONN_INFO, NULL, 0, NULL, 0, 0);
}
sint8 m2m_wifi_set_sytem_time(uint32 u32UTCSeconds)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_SYS_TIME, (uint8*)&u32UTCSeconds, sizeof(tstrSystemTime), NULL, 0, 0);
/*
The firmware accepts timestamps relative to 1900 like NTP Timestamp.
*/
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_SYS_TIME, (uint8*)&u32UTCSeconds, sizeof(tstrSystemTime), NULL, 0, 0);
}
/*!
* @fn NMI_API sint8 m2m_wifi_get_sytem_time(void);
@ -1076,7 +1137,7 @@ sint8 m2m_wifi_set_sytem_time(uint32 u32UTCSeconds)
*/
sint8 m2m_wifi_get_sytem_time(void)
{
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_GET_SYS_TIME, NULL,0, NULL, 0, 0);
return hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_GET_SYS_TIME, NULL,0, NULL, 0, 0);
}
sint8 m2m_wifi_enable_sntp(uint8 bEnable)
@ -1084,7 +1145,7 @@ sint8 m2m_wifi_enable_sntp(uint8 bEnable)
uint8 u8Req;
u8Req = bEnable ? M2M_WIFI_REQ_ENABLE_SNTP_CLIENT : M2M_WIFI_REQ_DISABLE_SNTP_CLIENT;
return hif_send(M2M_REQ_GRP_WIFI, u8Req, NULL, 0, NULL, 0, 0);
return hif_send(M2M_REQ_GROUP_WIFI, u8Req, NULL, 0, NULL, 0, 0);
}
/*!
@fn NMI_API sint8 m2m_wifi_set_power_profile(uint8 u8PwrMode);
@ -1102,7 +1163,7 @@ sint8 m2m_wifi_set_power_profile(uint8 u8PwrMode)
sint8 ret = M2M_SUCCESS;
tstrM2mPwrMode strM2mPwrMode;
strM2mPwrMode.u8PwrMode = u8PwrMode;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_POWER_PROFILE, (uint8*)&strM2mPwrMode,sizeof(tstrM2mPwrMode), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_POWER_PROFILE, (uint8*)&strM2mPwrMode,sizeof(tstrM2mPwrMode), NULL, 0, 0);
return ret;
}
/*!
@ -1120,7 +1181,7 @@ sint8 m2m_wifi_set_tx_power(uint8 u8TxPwrLevel)
sint8 ret = M2M_SUCCESS;
tstrM2mTxPwrLevel strM2mTxPwrLevel;
strM2mTxPwrLevel.u8TxPwrLevel = u8TxPwrLevel;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_TX_POWER, (uint8*)&strM2mTxPwrLevel,sizeof(tstrM2mTxPwrLevel), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_TX_POWER, (uint8*)&strM2mTxPwrLevel,sizeof(tstrM2mTxPwrLevel), NULL, 0, 0);
return ret;
}
@ -1140,7 +1201,7 @@ sint8 m2m_wifi_enable_firmware_logs(uint8 u8Enable)
sint8 ret = M2M_SUCCESS;
tstrM2mEnableLogs strM2mEnableLogs;
strM2mEnableLogs.u8Enable = u8Enable;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_ENABLE_LOGS, (uint8*)&strM2mEnableLogs,sizeof(tstrM2mEnableLogs), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_ENABLE_LOGS, (uint8*)&strM2mEnableLogs,sizeof(tstrM2mEnableLogs), NULL, 0, 0);
return ret;
}
@ -1160,10 +1221,34 @@ sint8 m2m_wifi_set_battery_voltage(uint16 u16BattVoltx100)
sint8 ret = M2M_SUCCESS;
tstrM2mBatteryVoltage strM2mBattVol = {0};
strM2mBattVol.u16BattVolt = u16BattVoltx100;
ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_BATTERY_VOLTAGE, (uint8*)&strM2mBattVol,sizeof(tstrM2mBatteryVoltage), NULL, 0, 0);
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_BATTERY_VOLTAGE, (uint8*)&strM2mBattVol,sizeof(tstrM2mBatteryVoltage), NULL, 0, 0);
return ret;
}
/*!
@fn sint8 m2m_wifi_prng_get_random_bytes(uint8 * pu8PrngBuff,uint16 u16PrngSize)
@brief Get random bytes using the PRNG bytes.
@param [in] u16PrngSize
Size of the required random bytes to be generated.
@param [in] pu8PrngBuff
Pointer to user allocated buffer.
@return The function SHALL return M2M_SUCCESE for success and a negative value otherwise.
*/
sint8 m2m_wifi_prng_get_random_bytes(uint8 * pu8PrngBuff,uint16 u16PrngSize)
{
sint8 ret = M2M_ERR_FAIL;
tstrPrng strRng = {0};
if((u16PrngSize < (M2M_BUFFER_MAX_SIZE - sizeof(tstrPrng)))&&(pu8PrngBuff != NULL))
{
strRng.u16PrngSize = u16PrngSize;
strRng.pu8RngBuff = pu8PrngBuff;
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_GET_PRNG|M2M_REQ_DATA_PKT,(uint8 *)&strRng, sizeof(tstrPrng),NULL,0, 0);
}
else
{
M2M_ERR("PRNG Buffer exceeded maximum size %d or NULL Buffer\n",u16PrngSize);
}
return ret;
}
#ifdef ETH_MODE
/*!
@fn \
@ -1190,7 +1275,7 @@ NMI_API sint8 m2m_wifi_enable_mac_mcast(uint8* pu8MulticastMacAddress, uint8 u8A
strMulticastMac.u8AddRemove = u8AddRemove;
m2m_memcpy(strMulticastMac.au8macaddress,pu8MulticastMacAddress,M2M_MAC_ADDRES_LEN);
M2M_DBG("mac multicast: %x:%x:%x:%x:%x:%x\r\n",strMulticastMac.au8macaddress[0],strMulticastMac.au8macaddress[1],strMulticastMac.au8macaddress[2],strMulticastMac.au8macaddress[3],strMulticastMac.au8macaddress[4],strMulticastMac.au8macaddress[5]);
s8ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_MAC_MCAST, (uint8 *)&strMulticastMac,sizeof(tstrM2MMulticastMac),NULL,0,0);
s8ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_MAC_MCAST, (uint8 *)&strMulticastMac,sizeof(tstrM2MMulticastMac),NULL,0,0);
}
return s8ret;
@ -1227,5 +1312,5 @@ NMI_API sint8 m2m_wifi_set_receive_buffer(void* pvBuffer,uint16 u16BufferLen)
}
return s8ret;
}
#endif
#endif /* ETH_MODE */

View File

@ -43,15 +43,16 @@
#include "driver/include/nmbus.h"
#include "bsp/include/nm_bsp.h"
#include "driver/include/nmasic.h"
#include "driver/include/m2m_types.h"
#define NMI_GLB_RESET_0 (NMI_PERIPH_REG_BASE + 0x400)
#define NMI_INTR_REG_BASE (NMI_PERIPH_REG_BASE+0xa00)
#define NMI_PIN_MUX_0 (NMI_PERIPH_REG_BASE + 0x408)
#define NMI_INTR_ENABLE (NMI_INTR_REG_BASE)
#define GET_UINT32(X,Y) (X[0+Y] + ((uint32)X[1+Y]<<8) + ((uint32)X[2+Y]<<16) +((uint32)X[3+Y]<<24))
#define NMI_GLB_RESET_0 (NMI_PERIPH_REG_BASE + 0x400)
#define NMI_INTR_REG_BASE (NMI_PERIPH_REG_BASE + 0xa00)
#define NMI_PIN_MUX_0 (NMI_PERIPH_REG_BASE + 0x408)
#define NMI_INTR_ENABLE (NMI_INTR_REG_BASE)
#define GET_UINT32(X,Y) (X[0+Y] + ((uint32)X[1+Y]<<8) + ((uint32)X[2+Y]<<16) +((uint32)X[3+Y]<<24))
#define TIMEOUT (2000)
#define M2M_DISABLE_PS 0xD0UL
#define TIMEOUT (2000)
#define M2M_DISABLE_PS (0xd0ul)
static uint32 clk_status_reg_adr = 0xf; /* Assume initially it is B0 chip */
@ -135,9 +136,20 @@ sint8 nm_clkless_wake(void)
/* wait 1ms, spi data read */
nm_bsp_sleep(1);
ret = nm_read_reg_with_ret(clk_status_reg_adr, &clk_status_reg);
if(ret != M2M_SUCCESS) {
M2M_ERR("Bus error (2). Wake up failed\n");
goto _WAKE_EXIT;
/* Aelmeleh 24-08-2015*/
/* Check for C3000 rev. D0 value */
if( (ret != M2M_SUCCESS) || ((ret == M2M_SUCCESS) && (clk_status_reg == 0)) ) {
clk_status_reg_adr = 0x13;
/* wait 1ms, spi data read */
nm_bsp_sleep(1);
ret = nm_read_reg_with_ret(clk_status_reg_adr, &clk_status_reg);
if(ret != M2M_SUCCESS) {
M2M_ERR("Bus error (2). Wake up failed\n");
goto _WAKE_EXIT;
}
}
}
@ -263,7 +275,6 @@ uint32 nmi_get_chipid(void)
static uint32 chipid = 0;
if (chipid == 0) {
//uint32 revid;
uint32 rfrevid;
if((nm_read_reg_with_ret(0x1000, &chipid)) != M2M_SUCCESS) {
@ -290,7 +301,13 @@ uint32 nmi_get_chipid(void)
} else /* if(rfrevid == 5) */ { /* 1002B2 */
chipid = 0x1002b2;
}
} else if(chipid == 0x1000F0) {
if((nm_read_reg_with_ret(0x3B0000, &chipid)) != M2M_SUCCESS) {
chipid = 0;
return 0;
}
} else {
}
//#define PROBE_FLASH
#ifdef PROBE_FLASH
@ -361,14 +378,21 @@ void nmi_set_sys_clk_src_to_xo(void)
/* Do PLL update */
nmi_update_pll();
}
static uint8 check_3000_id(void)
{
return ((nmi_get_chipid() & (0xf00000)) == 0x300000);
}
sint8 chip_wake(void)
{
sint8 ret = M2M_SUCCESS;
ret = nm_clkless_wake();
if(ret != M2M_SUCCESS) return ret;
enable_rf_blocks();
if(!check_3000_id())
{
enable_rf_blocks();
}
return ret;
}
@ -381,29 +405,27 @@ sint8 chip_reset_and_cpu_halt(void)
if(ret != M2M_SUCCESS) {
return ret;
}
chip_reset();
ret = nm_read_reg_with_ret(0x1118, &reg);
if (M2M_SUCCESS != ret) {
ret = M2M_ERR_BUS_FAIL;
M2M_ERR("[nmi start]: fail read reg 0x1118 ...\n");
}
reg |= (1 << 0);
ret = nm_write_reg(0x1118, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, &reg);
if ((reg & (1ul << 10)) == (1ul << 10)) {
reg &= ~(1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
if(!check_3000_id())
{
chip_reset();
ret = nm_read_reg_with_ret(0x1118, &reg);
if (M2M_SUCCESS != ret) {
ret = M2M_ERR_BUS_FAIL;
M2M_ERR("[nmi start]: fail read reg 0x1118 ...\n");
}
reg |= (1 << 0);
ret = nm_write_reg(0x1118, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, &reg);
if ((reg & (1ul << 10)) == (1ul << 10)) {
reg &= ~(1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, &reg);
}
nm_write_reg(BOOTROM_REG,0);
nm_write_reg(NMI_STATE_REG,0);
nm_write_reg(NMI_REV_REG,0);
nm_write_reg(NMI_PIN_MUX_0, 0x11111000);
}
#if 0
reg |= (1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, &reg);
#endif
nm_write_reg(BOOTROM_REG,0);
nm_write_reg(NMI_STATE_REG,0);
nm_write_reg(NMI_REV_REG,0);
nm_write_reg(NMI_PIN_MUX_0, 0x11111000);
return ret;
}
sint8 chip_reset(void)
@ -424,6 +446,7 @@ sint8 wait_for_bootrom(uint8 arg)
{
sint8 ret = M2M_SUCCESS;
uint32 reg = 0, cnt = 0;
uint32 u32GpReg1 = 0;
reg = 0;
while(1) {
@ -453,20 +476,26 @@ sint8 wait_for_bootrom(uint8 arg)
}
}
}
if(2 == arg) {
if(M2M_WIFI_MODE_ATE_HIGH == arg) {
nm_write_reg(NMI_REV_REG, M2M_ATE_FW_START_VALUE);
nm_write_reg(NMI_STATE_REG, NBIT20);
}else if(M2M_WIFI_MODE_ATE_LOW == arg) {
nm_write_reg(NMI_REV_REG, M2M_ATE_FW_START_VALUE);
nm_write_reg(NMI_STATE_REG, 0);
}else if(M2M_WIFI_MODE_ETHERNET == arg){
u32GpReg1 = rHAVE_ETHERNET_MODE_BIT;
} else {
/*bypass this step*/
}
if(REV(nmi_get_chipid()) == REV_3A0)
{
chip_apply_conf(rHAVE_USE_PMU_BIT);
chip_apply_conf(u32GpReg1 | rHAVE_USE_PMU_BIT);
}
else
{
chip_apply_conf(0);
chip_apply_conf(u32GpReg1);
}
nm_write_reg(BOOTROM_REG,M2M_START_FIRMWARE);
@ -483,22 +512,25 @@ sint8 wait_for_firmware_start(uint8 arg)
{
sint8 ret = M2M_SUCCESS;
uint32 reg = 0, cnt = 0;
uint32 u32Timeout = TIMEOUT;
volatile uint32 regAddress = NMI_STATE_REG;
volatile uint32 checkValue = M2M_FINISH_INIT_STATE;
if(2 == arg) {
if((M2M_WIFI_MODE_ATE_HIGH == arg)||(M2M_WIFI_MODE_ATE_LOW == arg)) {
regAddress = NMI_REV_REG;
checkValue = M2M_ATE_FW_IS_UP_VALUE;
} else {
/*bypass this step*/
}
while (checkValue != reg)
{
nm_bsp_sleep(2); /* TODO: Why bus error if this delay is not here. */
M2M_DBG("%x %x %x\n",(unsigned int)nm_read_reg(0x108c),(unsigned int)nm_read_reg(0x108c),(unsigned int)nm_read_reg(0x14A0));
reg = nm_read_reg(regAddress);
if(++cnt > TIMEOUT)
if(++cnt >= u32Timeout)
{
M2M_DBG("Time out for wait firmware Run\n");
ret = M2M_ERR_INIT;
@ -636,10 +668,15 @@ sint8 nmi_get_otp_mac_address(uint8 *pu8MacAddr, uint8 * pu8IsValid)
sint8 ret;
uint32 u32RegValue;
uint8 mac[6];
tstrGpRegs strgp = {0};
ret = nm_read_reg_with_ret(rNMI_GP_REG_0, &u32RegValue);
ret = nm_read_reg_with_ret(rNMI_GP_REG_2, &u32RegValue);
if(ret != M2M_SUCCESS) goto _EXIT_ERR;
ret = nm_read_block(u32RegValue|0x30000,(uint8*)&strgp,sizeof(tstrGpRegs));
if(ret != M2M_SUCCESS) goto _EXIT_ERR;
u32RegValue = strgp.u32Mac_efuse_mib;
if(!EFUSED_MAC(u32RegValue)) {
M2M_DBG("Default MAC\n");
m2m_memset(pu8MacAddr, 0, 6);
@ -648,7 +685,7 @@ sint8 nmi_get_otp_mac_address(uint8 *pu8MacAddr, uint8 * pu8IsValid)
M2M_DBG("OTP MAC\n");
u32RegValue >>=16;
nm_read_block(u32RegValue|0x30000, mac, 6);
ret = nm_read_block(u32RegValue|0x30000, mac, 6);
m2m_memcpy(pu8MacAddr,mac,6);
if(pu8IsValid) *pu8IsValid = 1;
return ret;
@ -663,12 +700,17 @@ sint8 nmi_get_mac_address(uint8 *pu8MacAddr)
sint8 ret;
uint32 u32RegValue;
uint8 mac[6];
tstrGpRegs strgp = {0};
ret = nm_read_reg_with_ret(rNMI_GP_REG_0, &u32RegValue);
ret = nm_read_reg_with_ret(rNMI_GP_REG_2, &u32RegValue);
if(ret != M2M_SUCCESS) goto _EXIT_ERR;
ret = nm_read_block(u32RegValue|0x30000,(uint8*)&strgp,sizeof(tstrGpRegs));
if(ret != M2M_SUCCESS) goto _EXIT_ERR;
u32RegValue = strgp.u32Mac_efuse_mib;
u32RegValue &=0x0000ffff;
nm_read_block(u32RegValue|0x30000, mac, 6);
ret = nm_read_block(u32RegValue|0x30000, mac, 6);
m2m_memcpy(pu8MacAddr, mac, 6);
return ret;

View File

@ -45,6 +45,7 @@
#include "driver/include/nmdrv.h"
#include "driver/include/nmasic.h"
#include "driver/include/m2m_types.h"
#include "spi_flash/include/spi_flash.h"
#ifdef CONF_WINC_USE_SPI
#include "driver/include/nmspi.h"
@ -55,9 +56,6 @@
* @brief Get Firmware version info
* @param [out] M2mRev
* pointer holds address of structure "tstrM2mRev" that contains the firmware version parameters
* @author Ahmad.Mohammad.Yahya
* @date 27 MARCH 2013
* @version 1.0
*/
sint8 nm_get_firmware_info(tstrM2mRev* M2mRev)
@ -67,7 +65,12 @@ sint8 nm_get_firmware_info(tstrM2mRev* M2mRev)
sint8 ret = M2M_SUCCESS;
ret = nm_read_reg_with_ret(NMI_REV_REG, &reg);
//In case the Firmware running is ATE fw
if(M2M_ATE_FW_IS_UP_VALUE == reg)
{
//Read FW info again from the register specified for ATE
ret = nm_read_reg_with_ret(NMI_REV_REG_ATE, &reg);
}
M2mRev->u8DriverMajor = M2M_GET_DRV_MAJOR(reg);
M2mRev->u8DriverMinor = M2M_GET_DRV_MINOR(reg);
M2mRev->u8DriverPatch = M2M_GET_DRV_PATCH(reg);
@ -90,7 +93,132 @@ sint8 nm_get_firmware_info(tstrM2mRev* M2mRev)
}
return ret;
}
/**
* @fn nm_get_firmware_info(tstrM2mRev* M2mRev)
* @brief Get Firmware version info
* @param [out] M2mRev
* pointer holds address of structure "tstrM2mRev" that contains the firmware version parameters
* @version 1.0
*/
sint8 nm_get_firmware_full_info(tstrM2mRev* pstrRev)
{
uint16 curr_drv_ver, min_req_drv_ver,curr_firm_ver;
uint32 reg = 0;
sint8 ret = M2M_SUCCESS;
tstrGpRegs strgp = {0};
if (pstrRev != NULL)
{
m2m_memset((uint8*)pstrRev,0,sizeof(tstrM2mRev));
ret = nm_read_reg_with_ret(rNMI_GP_REG_2, &reg);
if(ret == M2M_SUCCESS)
{
if(reg != 0)
{
ret = nm_read_block(reg|0x30000,(uint8*)&strgp,sizeof(tstrGpRegs));
if(ret == M2M_SUCCESS)
{
reg = strgp.u32Firmware_Ota_rev;
reg &= 0x0000ffff;
if(reg != 0)
{
ret = nm_read_block(reg|0x30000,(uint8*)pstrRev,sizeof(tstrM2mRev));
if(ret == M2M_SUCCESS)
{
curr_firm_ver = M2M_MAKE_VERSION(pstrRev->u8FirmwareMajor, pstrRev->u8FirmwareMinor,pstrRev->u8FirmwarePatch);
curr_drv_ver = M2M_MAKE_VERSION(M2M_DRIVER_VERSION_MAJOR_NO, M2M_DRIVER_VERSION_MINOR_NO, M2M_DRIVER_VERSION_PATCH_NO);
min_req_drv_ver = M2M_MAKE_VERSION(pstrRev->u8DriverMajor, pstrRev->u8DriverMinor,pstrRev->u8DriverPatch);
if((curr_firm_ver == 0)||(min_req_drv_ver == 0)||(min_req_drv_ver == 0)){
ret = M2M_ERR_FAIL;
goto EXIT;
}
if(curr_drv_ver < min_req_drv_ver) {
/*The current driver version should be larger or equal
than the min driver that the current firmware support */
ret = M2M_ERR_FW_VER_MISMATCH;
goto EXIT;
}
if(curr_drv_ver > curr_firm_ver) {
/*The current driver should be equal or less than the firmware version*/
ret = M2M_ERR_FW_VER_MISMATCH;
goto EXIT;
}
}
}else {
ret = M2M_ERR_FAIL;
}
}
}else{
ret = M2M_ERR_FAIL;
}
}
}
EXIT:
return ret;
}
/**
* @fn nm_get_ota_firmware_info(tstrM2mRev* pstrRev)
* @brief Get Firmware version info
* @param [out] M2mRev
* pointer holds address of structure "tstrM2mRev" that contains the firmware version parameters
* @version 1.0
*/
sint8 nm_get_ota_firmware_info(tstrM2mRev* pstrRev)
{
uint16 curr_drv_ver, min_req_drv_ver,curr_firm_ver;
uint32 reg = 0;
sint8 ret;
tstrGpRegs strgp = {0};
if (pstrRev != NULL)
{
m2m_memset((uint8*)pstrRev,0,sizeof(tstrM2mRev));
ret = nm_read_reg_with_ret(rNMI_GP_REG_2, &reg);
if(ret == M2M_SUCCESS)
{
if(reg != 0)
{
ret = nm_read_block(reg|0x30000,(uint8*)&strgp,sizeof(tstrGpRegs));
if(ret == M2M_SUCCESS)
{
reg = strgp.u32Firmware_Ota_rev;
reg >>= 16;
if(reg != 0)
{
ret = nm_read_block(reg|0x30000,(uint8*)pstrRev,sizeof(tstrM2mRev));
if(ret == M2M_SUCCESS)
{
curr_firm_ver = M2M_MAKE_VERSION(pstrRev->u8FirmwareMajor, pstrRev->u8FirmwareMinor,pstrRev->u8FirmwarePatch);
curr_drv_ver = M2M_MAKE_VERSION(M2M_DRIVER_VERSION_MAJOR_NO, M2M_DRIVER_VERSION_MINOR_NO, M2M_DRIVER_VERSION_PATCH_NO);
min_req_drv_ver = M2M_MAKE_VERSION(pstrRev->u8DriverMajor, pstrRev->u8DriverMinor,pstrRev->u8DriverPatch);
if((curr_firm_ver == 0)||(min_req_drv_ver == 0)||(min_req_drv_ver == 0)){
ret = M2M_ERR_FAIL;
goto EXIT;
}
if(curr_drv_ver < min_req_drv_ver) {
/*The current driver version should be larger or equal
than the min driver that the current firmware support */
ret = M2M_ERR_FW_VER_MISMATCH;
}
if(curr_drv_ver > curr_firm_ver) {
/*The current driver should be equal or less than the firmware version*/
ret = M2M_ERR_FW_VER_MISMATCH;
}
}
}else{
ret = M2M_ERR_FAIL;
}
}
}else{
ret = M2M_ERR_FAIL;
}
}
} else {
ret = M2M_ERR_INVALID_ARG;
}
EXIT:
return ret;
}
@ -114,6 +242,12 @@ sint8 nm_drv_init_download_mode()
goto ERR1;
}
/**
reset the chip and halt the cpu in case of no wait efuse is set.
*/
chip_reset_and_cpu_halt();
#ifdef CONF_WINC_USE_SPI
/* Must do this after global reset to set SPI data packet size. */
@ -141,18 +275,16 @@ ERR1:
*/
sint8 nm_drv_init(void * arg)
{
tstrM2mRev strtmp;
sint8 ret = M2M_SUCCESS;
uint8 u8Mode = M2M_WIFI_MODE_NORMAL;
uint8 u8Mode;
if(NULL != arg) {
if(M2M_WIFI_MODE_CONFIG == *((uint8 *)arg)) {
u8Mode = M2M_WIFI_MODE_CONFIG;
} else {
/*continue running*/
u8Mode = *((uint8 *)arg);
if((u8Mode < M2M_WIFI_MODE_NORMAL)||(u8Mode >= M2M_WIFI_MODE_MAX)) {
u8Mode = M2M_WIFI_MODE_NORMAL;
}
} else {
/*continue running*/
u8Mode = M2M_WIFI_MODE_NORMAL;
}
ret = nm_bus_iface_init(NULL);
@ -205,7 +337,7 @@ sint8 nm_drv_init(void * arg)
goto ERR2;
}
if(M2M_WIFI_MODE_CONFIG == u8Mode) {
if((M2M_WIFI_MODE_ATE_HIGH == u8Mode)||(M2M_WIFI_MODE_ATE_LOW == u8Mode)) {
goto ERR1;
} else {
/*continue running*/
@ -217,18 +349,6 @@ sint8 nm_drv_init(void * arg)
goto ERR2;
}
ret = nm_get_firmware_info(&strtmp);
M2M_INFO("Firmware ver : %u.%u.%u\n", strtmp.u8FirmwareMajor, strtmp.u8FirmwareMinor, strtmp.u8FirmwarePatch);
M2M_INFO("Min driver ver : %u.%u.%u\n", strtmp.u8DriverMajor, strtmp.u8DriverMinor, strtmp.u8DriverPatch);
M2M_INFO("Curr driver ver: %u.%u.%u\n", M2M_DRIVER_VERSION_MAJOR_NO, M2M_DRIVER_VERSION_MINOR_NO, M2M_DRIVER_VERSION_PATCH_NO);
if(strtmp.u8FirmwareMajor != M2M_DRIVER_VERSION_MAJOR_NO
|| strtmp.u8FirmwareMinor != M2M_DRIVER_VERSION_MINOR_NO)
{
ret = M2M_ERR_FW_VER_MISMATCH;
M2M_ERR("Firmware version mismatch!\n");
}
return ret;
ERR2:
nm_bus_iface_deinit();
@ -252,6 +372,13 @@ sint8 nm_drv_deinit(void * arg)
M2M_ERR("[nmi stop]: chip_deinit fail\n");
goto ERR1;
}
/* Disable SPI flash to save power when the chip is off */
ret = spi_flash_enable(0);
if (M2M_SUCCESS != ret) {
M2M_ERR("[nmi stop]: SPI flash disable fail\n");
goto ERR1;
}
ret = nm_bus_iface_deinit();
if (M2M_SUCCESS != ret) {

View File

@ -84,17 +84,12 @@
#define N_RESET -1
#define N_RETRY -2
#define DATA_PKT_SZ_256 256
#define DATA_PKT_SZ_512 512
#define DATA_PKT_SZ_1K 1024
#define DATA_PKT_SZ_4K (4 * 1024)
#define DATA_PKT_SZ_8K (8 * 1024)
#ifdef SAMG55
#define DATA_PKT_SZ DATA_PKT_SZ_1K
#else
#define DATA_PKT_SZ DATA_PKT_SZ_8K
#endif
static uint8 gu8Crc_off = 0;
@ -176,25 +171,6 @@ static uint8 crc7(uint8 crc, const uint8 *buffer, uint32 len)
********************************************/
#define CMD_DMA_WRITE 0xc1
#define CMD_DMA_READ 0xc2
#define CMD_INTERNAL_WRITE 0xc3
#define CMD_INTERNAL_READ 0xc4
#define CMD_TERMINATE 0xc5
#define CMD_REPEAT 0xc6
#define CMD_DMA_EXT_WRITE 0xc7
#define CMD_DMA_EXT_READ 0xc8
#define CMD_SINGLE_WRITE 0xc9
#define CMD_SINGLE_READ 0xca
#define CMD_RESET 0xcf
#define DATA_PKT_SZ_256 256
#define DATA_PKT_SZ_512 512
#define DATA_PKT_SZ_1K 1024
#define DATA_PKT_SZ_4K (4 * 1024)
#define DATA_PKT_SZ_8K (8 * 1024)
#define DATA_PKT_SZ DATA_PKT_SZ_8K
static sint8 spi_cmd(uint8 cmd, uint32 adr, uint32 u32data, uint32 sz,uint8 clockless)
{
uint8 bc[9];

View File

@ -47,6 +47,7 @@ INCLUDES
#include "socket/include/socket.h"
#include "driver/include/m2m_hif.h"
#include "socket/include/socket_internal.h"
#include "driver/include/m2m_types.h"
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
MACROS
@ -66,11 +67,15 @@ MACROS
#define SSL_TX_PACKET_OFFSET (TCP_TX_PACKET_OFFSET + TLS_RECORD_HEADER_LENGTH)
#define SOCKET_REQUEST(reqID, reqArgs, reqSize, reqPayload, reqPayloadSize, reqPayloadOffset) \
hif_send(M2M_REQ_GRP_IP, reqID, reqArgs, reqSize, reqPayload, reqPayloadSize, reqPayloadOffset)
hif_send(M2M_REQ_GROUP_IP, reqID, reqArgs, reqSize, reqPayload, reqPayloadSize, reqPayloadOffset)
#define SSL_FLAGS_ACTIVE 0x01
#define SSL_FLAGS_BYPASS_X509 0x02
#define SSL_FLAGS_ACTIVE NBIT0
#define SSL_FLAGS_BYPASS_X509 NBIT1
#define SSL_FLAGS_2_RESERVD NBIT2
#define SSL_FLAGS_3_RESERVD NBIT3
#define SSL_FLAGS_CACHE_SESSION NBIT4
#define SSL_FLAGS_NO_TX_COPY NBIT5
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
PRIVATE DATA TYPES
@ -93,10 +98,11 @@ typedef struct{
typedef struct{
uint8 *pu8UserBuffer;
uint16 u16UserBufferSize;
uint16 u16SessionID;
uint16 u16DataOffset;
uint8 bIsUsed;
uint8 u8SSLFlags;
uint8 bIsRecvPending;
uint16 u16SessionID;
}tstrSocket;
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
@ -113,6 +119,7 @@ volatile tpfAppSocketCb gpfAppSocketCb;
volatile tpfAppResolveCb gpfAppResolveCb;
volatile uint8 gbSocketInit = 0;
volatile tpfPingCb gfpPingCb;
/*********************************************************************
Function
Socket_ReadSocketData
@ -255,6 +262,10 @@ static void m2m_ip_cb(uint8 u8OpCode, uint16 u16BufferSize,uint32 u32Address)
{
strConnMsg.sock = strConnectReply.sock;
strConnMsg.s8Error = strConnectReply.s8Error;
if(strConnectReply.s8Error == SOCK_ERR_NO_ERROR)
{
gastrSockets[strConnectReply.sock].u16DataOffset = strConnectReply.u16AppDataOffset - M2M_HIF_HDR_OFFSET;
}
if(gpfAppSocketCb)
gpfAppSocketCb(strConnectReply.sock,SOCKET_MSG_CONNECT, &strConnMsg);
}
@ -400,12 +411,11 @@ void socketInit(void)
if(gbSocketInit==0)
{
m2m_memset((uint8*)gastrSockets, 0, MAX_SOCKET * sizeof(tstrSocket));
hif_register_cb(M2M_REQ_GRP_IP,m2m_ip_cb);
hif_register_cb(M2M_REQ_GROUP_IP,m2m_ip_cb);
gbSocketInit=1;
gu16SessionID = 0;
}
}
/*********************************************************************
Function
socketDeinit
@ -427,13 +437,11 @@ Date
void socketDeinit(void)
{
m2m_memset((uint8*)gastrSockets, 0, MAX_SOCKET * sizeof(tstrSocket));
hif_register_cb(M2M_REQ_GRP_IP, NULL);
hif_register_cb(M2M_REQ_GROUP_IP, NULL);
gpfAppSocketCb = NULL;
gpfAppResolveCb = NULL;
gbSocketInit = 0;
}
/*********************************************************************
Function
registerSocketCallback
@ -480,9 +488,10 @@ Date
*********************************************************************/
SOCKET WINC1500_EXPORT(socket)(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
{
SOCKET sock = -1;
uint8 u8Count,u8SocketCount = MAX_SOCKET;
SOCKET sock = -1;
uint8 u8Count,u8SocketCount = MAX_SOCKET;
volatile tstrSocket *pstrSock;
/* The only supported family is the AF_INET for UDP and TCP transport layer protocols. */
if(u16Domain == AF_INET)
{
@ -502,17 +511,20 @@ SOCKET WINC1500_EXPORT(socket)(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
for(;u8Count < u8SocketCount; u8Count ++)
{
if(gastrSockets[u8Count].bIsUsed == 0)
pstrSock = &gastrSockets[u8Count];
if(pstrSock->bIsUsed == 0)
{
gastrSockets[u8Count].bIsUsed = 1;
m2m_memset((uint8*)pstrSock, 0, sizeof(tstrSocket));
pstrSock->bIsUsed = 1;
/* The session ID is used to distinguish different socket connections
by comparing the assigned session ID to the one reported by the firmware*/
++gu16SessionID;
if(gu16SessionID == 0)
++gu16SessionID;
gastrSockets[u8Count].u16SessionID = gu16SessionID;
pstrSock->u16SessionID = gu16SessionID;
M2M_DBG("1 Socket %d session ID = %d\r\n",u8Count, gu16SessionID );
sock = (SOCKET)u8Count;
@ -520,7 +532,7 @@ SOCKET WINC1500_EXPORT(socket)(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
{
tstrSSLSocketCreateCmd strSSLCreate;
strSSLCreate.sslSock = sock;
gastrSockets[u8Count].u8SSLFlags = SSL_FLAGS_ACTIVE;
pstrSock->u8SSLFlags = SSL_FLAGS_ACTIVE | SSL_FLAGS_NO_TX_COPY;
SOCKET_REQUEST(SOCKET_CMD_SSL_CREATE, (uint8*)&strSSLCreate, sizeof(tstrSSLSocketCreateCmd), 0, 0, 0);
}
break;
@ -558,7 +570,6 @@ sint8 WINC1500_EXPORT(bind)(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8Addr
/* Build the bind request. */
strBind.sock = sock;
m2m_memcpy((uint8 *)&strBind.strAddr, (uint8 *)pstrAddr, sizeof(tstrSockAddr));
//strBind.strAddr = *((tstrSockAddr*)pstrAddr);
strBind.strAddr.u16Family = strBind.strAddr.u16Family;
strBind.strAddr.u16Port = strBind.strAddr.u16Port;
@ -675,9 +686,6 @@ sint8 WINC1500_EXPORT(connect)(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8A
strConnect.sock = sock;
m2m_memcpy((uint8 *)&strConnect.strAddr, (uint8 *)pstrAddr, sizeof(tstrSockAddr));
strConnect.strAddr.u16Family = strConnect.strAddr.u16Family;
strConnect.strAddr.u16Port = strConnect.strAddr.u16Port;
strConnect.strAddr.u32IPAddr = strConnect.strAddr.u32IPAddr;
strConnect.u16SessionID = gastrSockets[sock].u16SessionID;
s8Ret = SOCKET_REQUEST(u8Cmd, (uint8*)&strConnect,sizeof(tstrConnectCmd), NULL, 0, 0);
if(s8Ret != SOCK_ERR_NO_ERROR)
@ -717,9 +725,9 @@ sint16 WINC1500_EXPORT(send)(SOCKET sock, void *pvSendBuffer, uint16 u16SendLeng
u8Cmd = SOCKET_CMD_SEND;
u16DataOffset = TCP_TX_PACKET_OFFSET;
strSend.sock = sock;
strSend.u16DataSize = NM_BSP_B_L_16(u16SendLength);
strSend.u16SessionID = gastrSockets[sock].u16SessionID;
strSend.sock = sock;
strSend.u16DataSize = NM_BSP_B_L_16(u16SendLength);
strSend.u16SessionID = gastrSockets[sock].u16SessionID;
if(sock >= TCP_SOCK_MAX)
{
@ -728,7 +736,7 @@ sint16 WINC1500_EXPORT(send)(SOCKET sock, void *pvSendBuffer, uint16 u16SendLeng
if(gastrSockets[sock].u8SSLFlags & SSL_FLAGS_ACTIVE)
{
u8Cmd = SOCKET_CMD_SSL_SEND;
u16DataOffset = SSL_TX_PACKET_OFFSET;
u16DataOffset = gastrSockets[sock].u16DataOffset;
}
s16Ret = SOCKET_REQUEST(u8Cmd|M2M_REQ_DATA_PKT, (uint8*)&strSend, sizeof(tstrSendCmd), pvSendBuffer, u16SendLength, u16DataOffset);
@ -770,7 +778,7 @@ sint16 WINC1500_EXPORT(sendto)(SOCKET sock, void *pvSendBuffer, uint16 u16SendLe
strSendTo.sock = sock;
strSendTo.u16DataSize = NM_BSP_B_L_16(u16SendLength);
strSendTo.u16SessionID = gastrSockets[sock].u16SessionID;
strSendTo.u16SessionID = gastrSockets[sock].u16SessionID;
if(pstrDestAddr != NULL)
{
@ -1060,7 +1068,7 @@ Version
Date
9 September 2014
*********************************************************************/
sint8 sslSetSockOpt(SOCKET sock, uint8 u8Opt, const void *pvOptVal, uint16 u16OptLen)
static sint8 sslSetSockOpt(SOCKET sock, uint8 u8Opt, const void *pvOptVal, uint16 u16OptLen)
{
sint8 s8Ret = SOCK_ERR_INVALID_ARG;
if(sock < TCP_SOCK_MAX)
@ -1080,6 +1088,19 @@ sint8 sslSetSockOpt(SOCKET sock, uint8 u8Opt, const void *pvOptVal, uint16 u16O
}
s8Ret = SOCK_ERR_NO_ERROR;
}
else if(u8Opt == SO_SSL_ENABLE_SESSION_CACHING)
{
int optVal = *((int*)pvOptVal);
if(optVal)
{
gastrSockets[sock].u8SSLFlags |= SSL_FLAGS_CACHE_SESSION;
}
else
{
gastrSockets[sock].u8SSLFlags &= ~SSL_FLAGS_CACHE_SESSION;
}
s8Ret = SOCK_ERR_NO_ERROR;
}
else if(u8Opt == SO_SSL_SNI)
{
if(u16OptLen < HOSTNAME_MAX_SIZE)
@ -1222,3 +1243,33 @@ sint8 m2m_ping_req(uint32 u32DstIP, uint8 u8TTL, tpfPingCb fpPingCb)
}
return s8Ret;
}
/*********************************************************************
Function
sslSetActiveCipherSuites
Description
Send Ping request.
Return
Author
Ahmed Ezzat
Version
1.0
Date
4 June 2015
*********************************************************************/
sint8 sslSetActiveCipherSuites(uint32 u32SslCsBMP)
{
sint8 s8Ret = SOCK_ERR_INVALID_ARG;
if(u32SslCsBMP != 0)
{
tstrSslSetActiveCsList strCsList;
strCsList.u32CsBMP = u32SslCsBMP;
s8Ret = SOCKET_REQUEST(SOCKET_CMD_SSL_SET_CS_LIST, (uint8*)&strCsList, sizeof(tstrSslSetActiveCsList), NULL, 0, 0);
}
return s8Ret;
}