nm_common.h
Go to the documentation of this file.
1 
38 #ifndef _NM_COMMON_H_
39 #define _NM_COMMON_H_
40 
41 #include "bsp/include/nm_bsp.h"
43 
48 #define M2M_TIME_OUT_DELAY 10000
49 
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 /*
67 Invalid argument
68 */
69 #define M2M_ERR_INVALID_ARG ((sint8)-15)
70 
71 /*i2c MAASTER ERR*/
72 #define I2C_ERR_LARGE_ADDRESS 0xE1UL
73 #define I2C_ERR_TX_ABRT 0xE2UL
74 #define I2C_ERR_OVER_SIZE 0xE3UL
75 #define ERR_PREFIX_NMIS 0xE4UL
76 #define ERR_FIRMEWARE_EXCEED_SIZE 0xE5UL
77 
78 #define PROGRAM_START 0x26961735UL
79 #define BOOT_SUCCESS 0x10add09eUL
80 #define BOOT_START 0x12345678UL
81 
82 
83 #define NBIT31 (0x80000000)
84 #define NBIT30 (0x40000000)
85 #define NBIT29 (0x20000000)
86 #define NBIT28 (0x10000000)
87 #define NBIT27 (0x08000000)
88 #define NBIT26 (0x04000000)
89 #define NBIT25 (0x02000000)
90 #define NBIT24 (0x01000000)
91 #define NBIT23 (0x00800000)
92 #define NBIT22 (0x00400000)
93 #define NBIT21 (0x00200000)
94 #define NBIT20 (0x00100000)
95 #define NBIT19 (0x00080000)
96 #define NBIT18 (0x00040000)
97 #define NBIT17 (0x00020000)
98 #define NBIT16 (0x00010000)
99 #define NBIT15 (0x00008000)
100 #define NBIT14 (0x00004000)
101 #define NBIT13 (0x00002000)
102 #define NBIT12 (0x00001000)
103 #define NBIT11 (0x00000800)
104 #define NBIT10 (0x00000400)
105 #define NBIT9 (0x00000200)
106 #define NBIT8 (0x00000100)
107 #define NBIT7 (0x00000080)
108 #define NBIT6 (0x00000040)
109 #define NBIT5 (0x00000020)
110 #define NBIT4 (0x00000010)
111 #define NBIT3 (0x00000008)
112 #define NBIT2 (0x00000004)
113 #define NBIT1 (0x00000002)
114 #define NBIT0 (0x00000001)
115 
117 #define M2M_MAX(A,B) ((A) > (B) ? (A) : (B))
118 
119 #define M2M_SEL(x,m1,m2,m3) ((x>1)?((x>2)?(m3):(m2)):(m1))
120 
121 #define WORD_ALIGN(val) (((val) & 0x03) ? ((val) + 4 - ((val) & 0x03)) : (val))
122 
123 
124 
125 #define DATA_PKT_OFFSET 4
126 
127 #ifndef BIG_ENDIAN
128 
129 #define BYTE_0(word) ((uint8)(((word) >> 0 ) & 0x000000FFUL))
130 
131 #define BYTE_1(word) ((uint8)(((word) >> 8 ) & 0x000000FFUL))
132 
133 #define BYTE_2(word) ((uint8)(((word) >> 16) & 0x000000FFUL))
134 
135 #define BYTE_3(word) ((uint8)(((word) >> 24) & 0x000000FFUL))
136 #else
137 
138 #define BYTE_0(word) ((uint8)(((word) >> 24) & 0x000000FFUL))
139 
140 #define BYTE_1(word) ((uint8)(((word) >> 16) & 0x000000FFUL))
141 
142 #define BYTE_2(word) ((uint8)(((word) >> 8 ) & 0x000000FFUL))
143 
144 #define BYTE_3(word) ((uint8)(((word) >> 0 ) & 0x000000FFUL))
145 #endif
146 
148 #ifdef __cplusplus
149  extern "C" {
150  #endif
151 
167 NMI_API void m2m_memcpy(uint8* pDst,uint8* pSrc,uint32 sz);
179 NMI_API void m2m_memset(uint8* pBuf,uint8 val,uint32 sz);
187 NMI_API uint16 m2m_strlen(uint8 * pcStr);
199 NMI_API sint8 m2m_memcmp(uint8 *pu8Buff1,uint8 *pu8Buff2 ,uint32 u32Size);
211 NMI_API uint8 m2m_strncmp(uint8 *pcS1, uint8 *pcS2, uint16 u16Len);
221 NMI_API uint8 * m2m_strstr(uint8 *pcIn, uint8 *pcStr);
231 NMI_API uint8 m2m_checksum(uint8* buf, int sz);
232 
237 NMI_API void (*at_sb_printf)(const char *_format, ...);
239 #ifdef __cplusplus
240 }
241  #endif
242 #endif /*_NM_COMMON_H_*/
NMI_API void m2m_memcpy(uint8 *pDst, uint8 *pSrc, uint32 sz)
Copy specified number of bytes from source buffer to destination buffer.
Definition: nm_common.c:36
signed char sint8
Range of values between -128 to 127.
Definition: nm_bsp.h:111
NMI_API sint8 m2m_memcmp(uint8 *pu8Buff1, uint8 *pu8Buff2, uint32 u32Size)
Compare specified number of data bytes in pu8Buff1 and pu8Buff2 and decide if they all match...
Definition: nm_common.c:116
NMI_API uint8 * m2m_strstr(uint8 *pcIn, uint8 *pcStr)
Find the occurrence of pcStr string in pcIn string.
Definition: nm_common.c:93
unsigned short uint16
Range of values between 0 to 65535.
Definition: nm_bsp.h:96
NMI_API void m2m_memset(uint8 *pBuf, uint8 val, uint32 sz)
Set specified number of data bytes in specified data buffer to specified value.
Definition: nm_common.c:58
NMI_API uint16 m2m_strlen(uint8 *pcStr)
Returns the string length of a null terminated string buffer.
Definition: nm_common.c:68
This module contains debug APIs declarations.
unsigned long uint32
Range of values between 0 to 4294967295.
Definition: nm_bsp.h:103
This module contains WINC3400 BSP APIs declarations.
unsigned char uint8
Range of values between 0 to 255.
Definition: nm_bsp.h:89
NMI_API uint8 m2m_checksum(uint8 *buf, int sz)
calculates checksum for the specified number of data bytes in specified data buffer ...
Definition: nm_common.c:46
NMI_API void(* at_sb_printf)(const char *_format,...)
chooses which function to use in order to output debug
Definition: nm_common.h:237
NMI_API uint8 m2m_strncmp(uint8 *pcS1, uint8 *pcS2, uint16 u16Len)
Compare specified number of data bytes in string buffers pcS1 and pcS2.
Definition: nm_common.c:79
#define NMI_API
Definition: nm_bsp.h:45


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