Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

151 lignes
5.0 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief WINC Driver Common API Declarations.
  6. *
  7. * Copyright (c) 2015 - 2017 Atmel Corporation. All rights reserved.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. *
  23. * 3. The name of Atmel may not be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  27. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  29. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  30. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  34. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  35. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * \asf_license_stop
  39. *
  40. */
  41. #ifndef _NM_COMMON_H_
  42. #define _NM_COMMON_H_
  43. #include "bsp/include/nm_bsp.h"
  44. #include "common/include/nm_debug.h"
  45. /**@defgroup CommonDefines CommonDefines
  46. * @ingroup WlanDefines
  47. */
  48. /**@{*/
  49. #define M2M_TIME_OUT_DELAY 10000
  50. /*states*/
  51. #define M2M_SUCCESS ((sint8)0)
  52. #define M2M_ERR_SEND ((sint8)-1)
  53. #define M2M_ERR_RCV ((sint8)-2)
  54. #define M2M_ERR_MEM_ALLOC ((sint8)-3)
  55. #define M2M_ERR_TIME_OUT ((sint8)-4)
  56. #define M2M_ERR_INIT ((sint8)-5)
  57. #define M2M_ERR_BUS_FAIL ((sint8)-6)
  58. #define M2M_NOT_YET ((sint8)-7)
  59. #define M2M_ERR_FIRMWARE ((sint8)-8)
  60. #define M2M_SPI_FAIL ((sint8)-9)
  61. #define M2M_ERR_FIRMWARE_bURN ((sint8)-10)
  62. #define M2M_ACK ((sint8)-11)
  63. #define M2M_ERR_FAIL ((sint8)-12)
  64. #define M2M_ERR_FW_VER_MISMATCH ((sint8)-13)
  65. #define M2M_ERR_SCAN_IN_PROGRESS ((sint8)-14)
  66. #define M2M_ERR_INVALID_ARG ((sint8)-15)
  67. #define M2M_ERR_INVALID ((sint8)-16)
  68. /*i2c MAASTER ERR*/
  69. #define I2C_ERR_LARGE_ADDRESS 0xE1UL /*the address exceed the max addressing mode in i2c flash*/
  70. #define I2C_ERR_TX_ABRT 0xE2UL /*NO ACK from slave*/
  71. #define I2C_ERR_OVER_SIZE 0xE3UL /**/
  72. #define ERR_PREFIX_NMIS 0xE4UL /*wrong first four byte in flash NMIS*/
  73. #define ERR_FIRMEWARE_EXCEED_SIZE 0xE5UL /*Total size of firmware exceed the max size 256k*/
  74. /**/
  75. #define PROGRAM_START 0x26961735UL
  76. #define BOOT_SUCCESS 0x10add09eUL
  77. #define BOOT_START 0x12345678UL
  78. #define NBIT31 (0x80000000)
  79. #define NBIT30 (0x40000000)
  80. #define NBIT29 (0x20000000)
  81. #define NBIT28 (0x10000000)
  82. #define NBIT27 (0x08000000)
  83. #define NBIT26 (0x04000000)
  84. #define NBIT25 (0x02000000)
  85. #define NBIT24 (0x01000000)
  86. #define NBIT23 (0x00800000)
  87. #define NBIT22 (0x00400000)
  88. #define NBIT21 (0x00200000)
  89. #define NBIT20 (0x00100000)
  90. #define NBIT19 (0x00080000)
  91. #define NBIT18 (0x00040000)
  92. #define NBIT17 (0x00020000)
  93. #define NBIT16 (0x00010000)
  94. #define NBIT15 (0x00008000)
  95. #define NBIT14 (0x00004000)
  96. #define NBIT13 (0x00002000)
  97. #define NBIT12 (0x00001000)
  98. #define NBIT11 (0x00000800)
  99. #define NBIT10 (0x00000400)
  100. #define NBIT9 (0x00000200)
  101. #define NBIT8 (0x00000100)
  102. #define NBIT7 (0x00000080)
  103. #define NBIT6 (0x00000040)
  104. #define NBIT5 (0x00000020)
  105. #define NBIT4 (0x00000010)
  106. #define NBIT3 (0x00000008)
  107. #define NBIT2 (0x00000004)
  108. #define NBIT1 (0x00000002)
  109. #define NBIT0 (0x00000001)
  110. #define M2M_MAX(A, B) ((A) > (B) ? (A) : (B))
  111. #define M2M_SEL(x, m1, m2, m3) ((x > 1) ? ((x > 2) ? (m3) : (m2)) : (m1))
  112. #define WORD_ALIGN(val) (((val)&0x03) ? ((val) + 4 - ((val)&0x03)) : (val))
  113. #define DATA_PKT_OFFSET 4
  114. #ifndef BIG_ENDIAN
  115. #define BYTE_0(word) ((uint8)(((word) >> 0) & 0x000000FFUL))
  116. #define BYTE_1(word) ((uint8)(((word) >> 8) & 0x000000FFUL))
  117. #define BYTE_2(word) ((uint8)(((word) >> 16) & 0x000000FFUL))
  118. #define BYTE_3(word) ((uint8)(((word) >> 24) & 0x000000FFUL))
  119. #else
  120. #define BYTE_0(word) ((uint8)(((word) >> 24) & 0x000000FFUL))
  121. #define BYTE_1(word) ((uint8)(((word) >> 16) & 0x000000FFUL))
  122. #define BYTE_2(word) ((uint8)(((word) >> 8) & 0x000000FFUL))
  123. #define BYTE_3(word) ((uint8)(((word) >> 0) & 0x000000FFUL))
  124. #endif
  125. /**@}*/
  126. #ifdef __cplusplus
  127. extern "C" {
  128. #endif
  129. NMI_API void m2m_memcpy(uint8 *pDst, uint8 *pSrc, uint32 sz);
  130. NMI_API void m2m_memset(uint8 *pBuf, uint8 val, uint32 sz);
  131. NMI_API uint16 m2m_strlen(uint8 *pcStr);
  132. NMI_API sint8 m2m_memcmp(uint8 *pu8Buff1, uint8 *pu8Buff2, uint32 u32Size);
  133. NMI_API uint8 m2m_strncmp(uint8 *pcS1, uint8 *pcS2, uint16 u16Len);
  134. NMI_API uint8 *m2m_strstr(uint8 *pcIn, uint8 *pcStr);
  135. NMI_API uint8 m2m_checksum(uint8 *buf, int sz);
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. #endif /*_NM_COMMON_H_*/