bsp_common.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. #ifndef __BSP_COMMON_H__
  22. #define __BSP_COMMON_H__
  23. #include <string.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <stdint.h>
  27. #include <stdarg.h>
  28. #include "cmsis_compiler.h"
  29. typedef struct
  30. {
  31. uint32_t MaigcNum; //升级包标识,标识不对直接抛弃
  32. uint32_t CRC32; //后续字节的CRC32校验,所有CRC32规则与ZIP压缩一致
  33. uint32_t Param1; //升级参数,其中byte0升级类型,byte1升级包存放位置,byte2外设总线序号,和platform_define里的外设序号一致
  34. uint32_t Param2; //额外的参数,需要和外置存储总线配合使用,一般是外置存储总线的PIN
  35. uint32_t DataStartAddress;//升级包在flash中的起始地址,外部和内部都可以用
  36. uint32_t DataLen;//升级包大小
  37. uint32_t DataCRC32;//升级包整包数据的CRC32
  38. char FilePath[100];//升级包在文件系统中的绝对路径,如果在flash中则随意填写
  39. }CoreUpgrade_HeadStruct;
  40. typedef struct
  41. {
  42. uint32_t MaigcNum; //升级包标识,标识不对直接抛弃
  43. uint32_t CRC32; //后续字节的CRC32校验
  44. uint32_t MainVersion;//目标的底层版本,升级成功的话就是这个版本号了
  45. uint32_t AppVersion;//整包的版本号
  46. uint32_t STDVersion;//允许升级的底层版本号
  47. uint32_t DataLen;//升级包大小
  48. uint32_t DataCRC32;//升级包整包数据的CRC32,这里验证传输的准确性
  49. }CoreUpgrade_FileHeadStruct;
  50. typedef struct
  51. {
  52. uint32_t MaigcNum; //升级包标识,标识不对直接抛弃
  53. uint32_t TotalLen; //解压前占据的空间
  54. uint32_t DataLen; //解压后占据的空间,如果和TotalLen一样,则表示未启用压缩,不需要解压,也没有压缩参数
  55. //如果是0,则表示是差分升级
  56. //其他表示是整包升级,数据包经过了lzma压缩
  57. uint32_t DataCRC32; //解压后的数据的CRC32,这里验证烧录的正确性
  58. uint32_t StartAddress; //烧写的起始地址
  59. }CoreUpgrade_SectorStruct;
  60. typedef struct
  61. {
  62. uint32_t param_max_num;
  63. uint32_t param_max_len;
  64. uint32_t param_num;
  65. int8_t *param_str;
  66. }CmdParam;
  67. typedef struct
  68. {
  69. uint8_t Sec;
  70. uint8_t Min;
  71. uint8_t Hour;
  72. uint8_t Week;//表示日期0~6,sun~sat,表示预约时,bit0~bit6,sun~sat
  73. }Time_UserDataStruct;
  74. typedef struct
  75. {
  76. uint16_t Year;
  77. uint8_t Mon;
  78. uint8_t Day;
  79. }Date_UserDataStruct;
  80. typedef union
  81. {
  82. uint32_t dwTime;
  83. Time_UserDataStruct Time;
  84. }Time_Union;
  85. typedef union
  86. {
  87. uint32_t dwDate;
  88. Date_UserDataStruct Date;
  89. }Date_Union;
  90. typedef struct
  91. {
  92. uint8_t *Data;
  93. uint32_t Len;
  94. uint32_t Offset;
  95. uint32_t MaxLength;
  96. uint32_t DataSize;
  97. }Loop_Buffer;
  98. typedef struct
  99. {
  100. uint8_t *Data;
  101. uint32_t Pos;
  102. uint32_t MaxLen;
  103. }Buffer_Struct;
  104. typedef struct
  105. {
  106. uint8_t *pCache[2];
  107. uint32_t pCacheLen[2];
  108. uint32_t MaxLen;
  109. uint8_t CurCacheSn;
  110. }DBuffer_Struct;
  111. typedef union
  112. {
  113. void *p;
  114. char *pc8;
  115. uint8_t *pu8;
  116. uint16_t *pu16;
  117. uint32_t *pu32;
  118. uint32_t u32;
  119. uint8_t u8[4];
  120. uint16_t u16[2];
  121. }PV_Union;
  122. enum
  123. {
  124. ERROR_NONE,
  125. ERROR_NO_SUCH_ID,
  126. ERROR_PERMISSION_DENIED,
  127. ERROR_PARAM_INVALID,
  128. ERROR_PARAM_OVERFLOW,
  129. ERROR_DEVICE_BUSY,
  130. ERROR_OPERATION_FAILED,
  131. ERROR_BUFFER_FULL,
  132. ERROR_NO_MEMORY,
  133. ERROR_CMD_NOT_SUPPORT,
  134. ERROR_NO_DATA,
  135. ERROR_NO_FLASH,
  136. ERROR_NO_TIMER,
  137. ERROR_TIMEOUT,
  138. ERROR_SSL_HANDSHAKE,
  139. ERROR_PROTOCL,
  140. ERROR_ID_INVALID,
  141. ERROR_MID_INVALID,
  142. ERROR_RETRY_TOO_MUCH,
  143. ERROR_CMD_BLOCK,
  144. LIST_FIND = 1,
  145. LIST_PASS = 0,
  146. LIST_DEL = -1,
  147. DMA_CB_DONE = 0,
  148. UART_CB_TX_BUFFER_DONE,
  149. UART_CB_TX_ALL_DONE,
  150. UART_CB_RX_NEW,
  151. UART_CB_RX_TIMEOUT,
  152. UART_CB_RX_BUFFER_FULL,
  153. UART_CB_ERROR,
  154. UART_CB_CONNECTED, //串口工具对方已经打开
  155. DMA_CB_ERROR = 0xffffffff,
  156. CORE_EVENT_ID_ANY = 0,
  157. CORE_EVENT_ID_START = 0xf0000000,
  158. CORE_EVENT_TIMEOUT,
  159. CORE_TIMER_TIMEOUT = 0xf0010000,
  160. SERVICE_EVENT_ID_START = 0xf0100000,
  161. DEV_EVENT_ID_START = 0xf0200000,
  162. DEV_SPIFLASH_SPI_DONE,
  163. DEV_SDHC_SPI_DONE,
  164. USB_APP_EVENT_ID_START = 0xf0300000,
  165. USER_EVENT_ID_START = 0xf1000000,
  166. INVALID_EVENT_ID = 0xffffffff,
  167. NW_EVENT_SENT = 0,
  168. NW_EVENT_RECV,
  169. NW_EVENT_ERR,
  170. NW_EVENT_CONNECTED,
  171. NW_EVENT_REMOTE_CLOSE,
  172. NW_EVENT_ACCEPT,
  173. NW_EVENT_CLOSE_OK,
  174. };
  175. #define INVALID_HANDLE_VALUE ((void *)0xffffffff)
  176. #define INVALID_PARAM (0xffffffff)
  177. #define CRC32_GEN (0x04C11DB7)
  178. #define CRC32_START (0xffffffff)
  179. #define CRC16_CCITT_GEN (0x1021)
  180. #define CRC16_MODBUS_GEN (0x8005)
  181. #define CRC16_START (0xffff)
  182. #define CRC16_IBM_SEED (0xffff)
  183. #define CRC16_CCITT_SEED (0x1D0F)
  184. #define HANDLE void *
  185. #ifndef BIT
  186. #define BIT(n) (1UL << (n))
  187. #endif
  188. #ifndef MIN
  189. #define MIN(X,Y) (((X) < (Y))?(X):(Y))
  190. #endif
  191. typedef void (*IrqHandler)(int32_t IrqLine, void *pData);
  192. typedef void (* TaskFun_t)( void * );
  193. typedef void (* CommonFun_t)(void);
  194. typedef void(* CBDataFun_t)(uint8_t *Data, uint32_t Len);
  195. typedef int32_t(*CBFuncEx_t)(void *pData, void *pParam);
  196. typedef uint64_t LongInt;
  197. #define INIT_FUN_EXPORT(fn, location, level) const CommonFun_t __ex_init_##fn __attribute__((section(location level))) = fn
  198. #define INIT_HW_EXPORT(fn, level) INIT_FUN_EXPORT(fn, ".preinit_fun_array.", level)
  199. #define INIT_DRV_EXPORT(fn, level) INIT_FUN_EXPORT(fn, ".init_fun_array.", level)
  200. #define INIT_TASK_EXPORT(fn, level) INIT_FUN_EXPORT(fn, ".task_fun_array.", level)
  201. /* board init routines will be called in board_init() function */
  202. #define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1")
  203. /* pre/device/component/env/app init routines will be called in init_thread */
  204. /* components pre-initialization (pure software initilization) */
  205. #define INIT_PREV_EXPORT(fn) INIT_EXPORT(fn, "2")
  206. /* device initialization */
  207. #define INIT_DEVICE_EXPORT(fn) INIT_EXPORT(fn, "3")
  208. /* components initialization (dfs, lwip, ...) */
  209. #define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "4")
  210. /* environment initialization (mount disk, ...) */
  211. #define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
  212. /* appliation initialization (rtgui application etc ...) */
  213. #define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6")
  214. typedef struct
  215. {
  216. uint32_t ID;
  217. uint32_t Param1;
  218. uint32_t Param2;
  219. uint32_t Param3;
  220. }OS_EVENT;
  221. typedef struct
  222. {
  223. CBFuncEx_t CB;
  224. union {
  225. void *pParam; //用户回调模式
  226. uint32_t MaxCnt; //设置捕获模式时的最大tick,捕获时的tick
  227. }uParam;
  228. union {
  229. struct {
  230. uint8_t Level; //IO输入输出电平,捕获模式下中断时IO电平
  231. uint8_t PullMode; //IO上下拉控制
  232. } IOArg;
  233. struct {
  234. uint8_t ExtiMode; //中断模式
  235. uint8_t PullMode; //IO上下拉控制
  236. } ExitArg;
  237. uint16_t Time; //delay时间,us
  238. } uArg;
  239. uint8_t Operation; //操作类型
  240. uint8_t PinOrDelay; //IO操作时为IOpin,delay操作时则为微调值,0~47,48为1us
  241. }OPQueue_CmdStruct;
  242. enum
  243. {
  244. UDATA_TYPE_UNDEFINED = 0,
  245. UDATA_MULTIPLE_RESOURCE,
  246. UDATA_TYPE_STRING,
  247. UDATA_TYPE_OPAQUE,
  248. UDATA_TYPE_INTEGER,
  249. UDATA_TYPE_DWORD,
  250. UDATA_TYPE_WORD,
  251. UDATA_TYPE_BYTE,
  252. UDATA_TYPE_FLOAT,
  253. UDATA_TYPE_BOOLEAN,
  254. UDATA_TYPE_UNSIGNED,
  255. UDATA_TYPE_UNUSD
  256. };
  257. typedef struct _u_data_t uData_t;
  258. struct _u_data_t
  259. {
  260. union
  261. {
  262. uint8_t asBoolean;
  263. uint64_t asUnsigned;
  264. int64_t asInteger;
  265. PV_Union asDword;
  266. double asFloat;
  267. struct
  268. {
  269. size_t length;
  270. uint8_t *buffer;
  271. } asBuffer;
  272. struct
  273. {
  274. size_t count;
  275. uData_t *array;
  276. } asChildren;
  277. } value;
  278. uint32_t ID;
  279. uint8_t Type;
  280. };
  281. __attribute__((weak)) uint8_t OS_CheckInIrq(void);
  282. #ifdef __BUILD_OS__
  283. HANDLE OS_MutexCreate(void);
  284. HANDLE OS_MutexCreateUnlock(void);
  285. void OS_MutexLock(HANDLE Sem);
  286. int32_t OS_MutexLockWtihTime(HANDLE Sem, uint32_t TimeoutMs);
  287. void OS_MutexRelease(HANDLE Sem);
  288. void OS_MutexDelete(HANDLE Sem);
  289. void OS_SuspendTask(HANDLE taskHandle);
  290. void OS_ResumeTask(HANDLE taskHandle);
  291. uint8_t OS_IsSchedulerRun(void);
  292. #endif
  293. uint32_t OS_EnterCritical(void);
  294. void OS_ExitCritical(uint32_t Critical);
  295. void OS_MemInfo(uint32_t *curalloc, uint32_t *totfree, uint32_t *maxfree);
  296. int32_t OS_InitBuffer(Buffer_Struct *Buf, uint32_t Size);
  297. void OS_DeInitBuffer(Buffer_Struct *Buf);
  298. int32_t OS_ReInitBuffer(Buffer_Struct *Buf, uint32_t Size);
  299. int32_t OS_ReSizeBuffer(Buffer_Struct *Buf, uint32_t Size);
  300. int32_t OS_BufferWrite(Buffer_Struct *Buf, void *Data, uint32_t Len);
  301. int32_t OS_BufferWriteLimit(Buffer_Struct *Buf, void *Data, uint32_t Len);
  302. void OS_BufferRemove(Buffer_Struct *Buf, uint32_t Len);
  303. void DBuffer_Init(DBuffer_Struct *DBuf, uint32_t Size);
  304. void DBuffer_ReInit(DBuffer_Struct *DBuf, uint32_t Size);
  305. void DBuffer_DeInit(DBuffer_Struct *DBuf);
  306. void *DBuffer_GetCache(DBuffer_Struct *DBuf, uint8_t IsCurrent);
  307. void DBuffer_SwapCache(DBuffer_Struct *DBuf);
  308. void DBuffer_SetDataLen(DBuffer_Struct *DBuf, uint32_t Len, uint8_t IsCurrent);
  309. uint32_t DBuffer_GetDataLen(DBuffer_Struct *DBuf, uint8_t IsCurrent);
  310. void Buffer_StaticInit(Buffer_Struct *Buf, void *Src, uint32_t MaxLen);
  311. int32_t Buffer_StaticWrite(Buffer_Struct *Buf, void *Data, uint32_t Len);
  312. void Buffer_Remove(Buffer_Struct *Buf, uint32_t Len);
  313. void LoopBuffer_Init(Loop_Buffer *Buf, void *Src, uint32_t MaxLen, uint32_t DataSize);
  314. uint32_t LoopBuffer_Query(Loop_Buffer *Buf, void *Src, uint32_t Len);
  315. uint32_t LoopBuffer_Read(Loop_Buffer *Buf, void *Src, uint32_t Len);
  316. void LoopBuffer_Del(Loop_Buffer *Buf, uint32_t Len);
  317. uint32_t LoopBuffer_Write(Loop_Buffer *Buf, void *Src, uint32_t Len);
  318. int32_t BSP_SetBit(uint8_t *Data, uint32_t Sn, uint8_t Value);
  319. int32_t BSP_GetBit(uint8_t *Data, uint32_t Sn, uint8_t *Value);
  320. uint8_t BSP_TestBit(uint8_t *Data, uint32_t Sn);
  321. uint8_t XorCheck(void *Src, uint32_t Len, uint8_t CheckStart);
  322. uint8_t SumCheck(uint8_t *Data, uint32_t Len);
  323. uint16_t CRC16Cal(void *Data, uint16_t Len, uint16_t CRC16Last, uint16_t CRCRoot, uint8_t IsReverse);
  324. uint32_t AsciiToU32(uint8_t *Src, uint32_t Len);
  325. void CRC32_CreateTable(uint32_t *Tab, uint32_t Gen);
  326. uint32_t CRC32_Cal(uint32_t * CRC32_Table, uint8_t *Buf, uint32_t Size, uint32_t CRC32Last);
  327. uint32_t CmdParseParam(int8_t* pStr, CmdParam *CmdParam, int8_t Cut);
  328. uint8_t IsLeapYear(uint32_t Year);
  329. LongInt UTC2Tamp(Date_UserDataStruct *Date, Time_UserDataStruct *Time);
  330. uint32_t Tamp2UTC(LongInt Sec, Date_UserDataStruct *Date, Time_UserDataStruct *Time, uint32_t LastDDay);
  331. /*
  332. * 转义解包
  333. * 标识Flag,即包头包尾加入Flag
  334. * 数据中遇到Code F1 -> Flag
  335. * 数据中遇到Code F2 -> Code
  336. * 数据中遇到Flag 出错返回0
  337. */
  338. uint32_t TransferUnpack(uint8_t Flag, uint8_t Code, uint8_t F1, uint8_t F2, uint8_t *InBuf, uint32_t Len, uint8_t *OutBuf);
  339. /*
  340. * llist相关代码,大部分来自linux内核
  341. */
  342. /**
  343. * container_of - cast a member of a structure out to the containing structure
  344. *
  345. * @ptr: the pointer to the member.
  346. * @type: the type of the container struct this is embedded in.
  347. * @member: the name of the member within the struct.
  348. *
  349. */
  350. #define container_of(ptr, type, member) ({ \
  351. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  352. (type *)( (char *)__mptr - offsetof(type,member) );})
  353. /*
  354. * These are non-NULL pointers that will result in page faults
  355. * under normal circumstances, used to verify that nobody uses
  356. * non-initialized llist entries.
  357. */
  358. #define LLIST_POISON1 (0)
  359. #define LLIST_POISON2 (0)
  360. /*
  361. * Simple doubly linked llist implementation.
  362. *
  363. * Some of the internal functions ("__xxx") are useful when
  364. * manipulating whole llists rather than single entries, as
  365. * sometimes we already know the next/prev entries and we can
  366. * generate better code by using them directly rather than
  367. * using the generic single-entry routines.
  368. */
  369. typedef struct llist_head_t{
  370. struct llist_head_t *next, *prev;
  371. }llist_head;
  372. #define LLIST_HEAD_INIT(name) { &(name), &(name) }
  373. #define LLIST_HEAD(name) \
  374. llist_head name = LLIST_HEAD_INIT(name)
  375. #define INIT_LLIST_HEAD(ptr) do { \
  376. (ptr)->next = (ptr); (ptr)->prev = (ptr); \
  377. } while (0)
  378. /*
  379. * Insert a new entry between two known consecutive entries.
  380. *
  381. * This is only for internal llist manipulation where we know
  382. * the prev/next entries already!
  383. */
  384. void __llist_add(llist_head *p,
  385. llist_head *prev,
  386. llist_head *next);
  387. /**
  388. * llist_add - add a new entry
  389. * @new: new entry to be added
  390. * @head: llist head to add it after
  391. *
  392. * Insert a new entry after the specified head.
  393. * This is good for implementing stacks.
  394. */
  395. void llist_add(llist_head *p, llist_head *head);
  396. /**
  397. * llist_add_tail - add a new entry
  398. * @new: new entry to be added
  399. * @head: llist head to add it before
  400. *
  401. * Insert a new entry before the specified head.
  402. * This is useful for implementing queues.
  403. */
  404. void llist_add_tail(llist_head *p, llist_head *head);
  405. /*
  406. * Delete a llist entry by making the prev/next entries
  407. * point to each other.
  408. *
  409. * This is only for internal llist manipulation where we know
  410. * the prev/next entries already!
  411. */
  412. void __llist_del(llist_head * prev, llist_head * next);
  413. /**
  414. * llist_del - deletes entry from llist.
  415. * @entry: the element to delete from the llist.
  416. * Note: llist_empty on entry does not return true after this, the entry is
  417. * in an undefined state.
  418. */
  419. void llist_del(llist_head *entry);
  420. /**
  421. * llist_del_init - deletes entry from llist and reinitialize it.
  422. * @entry: the element to delete from the llist.
  423. */
  424. void llist_del_init(llist_head *entry);
  425. /**
  426. * llist_move - delete from one llist and add as another's head
  427. * @llist: the entry to move
  428. * @head: the head that will precede our entry
  429. */
  430. void llist_move(llist_head *llist, llist_head *head);
  431. /**
  432. * llist_move_tail - delete from one llist and add as another's tail
  433. * @llist: the entry to move
  434. * @head: the head that will follow our entry
  435. */
  436. void llist_move_tail(llist_head *llist,
  437. llist_head *head);
  438. /**
  439. * llist_empty - tests whether a llist is empty
  440. * @head: the llist to test.
  441. */
  442. int llist_empty(const llist_head *head);
  443. uint32_t llist_num(const llist_head *head);
  444. void *llist_traversal(llist_head *head, CBFuncEx_t cb, void *pData);
  445. /**
  446. * llist_entry - get the struct for this entry
  447. * @ptr: the &llist_head pointer.
  448. * @type: the type of the struct this is embedded in.
  449. * @member: the name of the llist_struct within the struct.
  450. */
  451. #define llist_entry(ptr, type, member) \
  452. container_of(ptr, type, member)
  453. uint16_t BSP_Swap16(uint16_t n);
  454. uint32_t BSP_Swap32(uint32_t n);
  455. uint8_t BytesGet8(const void *ptr);
  456. void BytesPut8(void *ptr, uint8_t v);
  457. uint16_t BytesGetBe16(const void *ptr);
  458. void BytesPutBe16(void *ptr, uint16_t v);
  459. uint32_t BytesGetBe32(const void *ptr);
  460. void BytesPutBe32(void *ptr, uint32_t v);
  461. uint16_t BytesGetLe16(const void *ptr);
  462. void BytesPutLe16(void *ptr, uint16_t v);
  463. uint32_t BytesGetLe32(const void *ptr);
  464. void BytesPutLe32(void *ptr, uint32_t v);
  465. uint64_t BytesGetLe64(const void *ptr);
  466. void BytesPutLe64(void *ptr, uint64_t v);
  467. uint8_t BytesGet8FromBuf(Buffer_Struct *Buf);
  468. void BytesPut8ToBuf(Buffer_Struct *Buf, uint8_t v);
  469. uint16_t BytesGetBe16FromBuf(Buffer_Struct *Buf);
  470. void BytesPutBe16ToBuf(Buffer_Struct *Buf, uint16_t v);
  471. uint32_t BytesGetBe32FromBuf(Buffer_Struct *Buf);
  472. void BytesPutBe32ToBuf(Buffer_Struct *Buf, uint32_t v);
  473. uint16_t BytesGetLe16FromBuf(Buffer_Struct *Buf);
  474. void BytesPutLe16ToBuf(Buffer_Struct *Buf, uint16_t v);
  475. uint32_t BytesGetLe32FromBuf(Buffer_Struct *Buf);
  476. void BytesPutLe32ToBuf(Buffer_Struct *Buf, uint32_t v);
  477. uint64_t BytesGetLe64FromBuf(Buffer_Struct *Buf);
  478. void BytesPutLe64ToBuf(Buffer_Struct *Buf, uint64_t v);
  479. float BytesGetFloatFromBuf(Buffer_Struct *Buf);
  480. void BytesPutFloatToBuf(Buffer_Struct *Buf, float v);
  481. double BytesGetDoubleFromBuf(Buffer_Struct *Buf);
  482. void BytesPutDoubleToBuf(Buffer_Struct *Buf, double v);
  483. /*************************************************************************/
  484. extern uint64_t GetSysTickMS();
  485. //void *__wrap_malloc(size_t Size);
  486. //void *__wrap_zalloc(size_t Size);
  487. //void *__wrap_calloc(size_t count, size_t eltsize);
  488. //void *__wrap_realloc(void *buf, size_t size);
  489. //void __wrap_free(void *p);
  490. #ifndef ASSERT
  491. #if defined(__DEBUG__)
  492. #define ASSERT( x ) if( ( x ) == 0 ) { __disable_irq(); DBG_Trace("\r\nassert %s,%d", __FUNCTION__, __LINE__); for( ;; ); }
  493. #else
  494. #define ASSERT( x )
  495. #endif
  496. #endif
  497. #endif