| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #ifndef _Shark_OS_H__
- #define _Shark_OS_H__
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdint.h>
- #include <stdbool.h>
- #include <time.h>
- #ifndef TRUE
- #define TRUE 1
- #endif
- #ifndef FALSE
- #define FALSE 0
- #endif
- typedef uint8_t u8;
- typedef uint16_t u16;
- typedef uint32_t u24;
- typedef uint32_t u32;
- typedef uint64_t u64;
- typedef int8_t s8;
- typedef int16_t s16;
- typedef int32_t s24;
- typedef int32_t s32;
- typedef int64_t s64;
- /* These types must be 16-bit, 32-bit or larger integer */
- typedef signed int S32;
- typedef unsigned int U32;
- typedef unsigned long int U64;
- /* These types must be 8-bit integer */
- typedef signed char S8;
- typedef unsigned char U8;
- /* These types must be 16-bit integer */
- typedef signed short S16;
- typedef unsigned short U16;
- typedef signed char int8;
- typedef signed short int16;
- typedef signed int int32;
- typedef unsigned char uint8;
- typedef unsigned short uint16;
- typedef unsigned int uint32;
- typedef struct{
- uint16_t year; /*YYYY*/
- uint8_t month;
- uint8_t day;
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- }time_val;
- void task_delay(int ms);
- void os_udelay(u32 us);
- uint32_t calendar_to_utc(time_val *time);
- void set_utc_time(time_val *time);
- void get_local_time(time_val *out, int8_t tz);
- uint32_t get_timestamp(void);
- uint32_t get_timestamp_with_time_zone(int8_t tz);
- #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
- #define min(a,b) (a>b?b:a)
- #define delay_us os_udelay
- static __inline__ void delay_ms(u32 ms) {
- os_udelay(ms*1000);
- }
- static __inline__ u16 DECODE_U16(u8 *buff) {
- return (((U16)(buff[1]) << 8) | buff[0]);
- }
- static __inline__ u32 DECODE_U24(u8 *buff) {
- return ((U32)(buff[2]) << 16 | DECODE_U16(buff));
- }
- static __inline__ u16 DECODE_U32(u8 *buff) {
- return ((U32)(buff[3]) << 24 | DECODE_U24(buff));
- }
- #endif /* _Shark_OS_H__ */
|