123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- #ifndef __COMMON__H__
- #define __COMMON__H__
- #include "types.h"
- #define CLAER_RTC_COUNT *(volatile unsigned int *)0x4000f024 |= BIT(1)
- #define RUN_RTC *(volatile unsigned int *)0x4000f024 |= BIT(0)
- #define STOP_RTC *(volatile unsigned int *)0x4000f024 &= ~BIT(0)
-
- #define TIME_BASE (1000000)
- #define TIME_DELTA(x,y) ( (x>=y) ? x-y : TIME_BASE-y+x )
- void hal_setMem(uint8_t *buf, uint8_t value, uint32_t length);
- void hal_cpyMem(uint8_t *dst, uint8_t *src, uint32_t length);
- void hal_cpyMem32(uint32_t *dst, uint32_t *src, uint32_t length);
- int hal_my_strcmp( const uint8_t *str, const uint8_t *ptr);
- void hal_copy_bin_from_flash_to_sram( int toAddr, int fromAddr, int length);
- int hal_my_sizeof(const uint8_t *str);
- int hal_my_strlen(const uint8_t *str);
- void hal_convert_hex_to_char(unsigned char *ch, unsigned int data);
- void hal_convert_hex_to_char_wo_x(unsigned char *ch, unsigned int data);
- uint32_t hal_convert_char_to_hex(const unsigned char *ch);
- uint32_t hal_convert_char_to_dec(const unsigned char *ch);
- int hal_is_an_valid_number(uint8_t ch);
- extern uint32_t clock_time_rtc(void);
- void subWriteReg(uint32_t addr,uint8_t hOff,uint8_t lOff,uint32_t value);
- void WaitMs(uint32_t msecond);
- #define WR_REG(a,b) *(volatile unsigned int *)a=b
- #define RD_REG(a) *(volatile unsigned int *)a
- #define ADD_IDX(a,b) (a==b)? a=0:a++;
- #define ENABLE_XTAL_TRIGGER *(volatile unsigned int *)0x4000f040 |= BIT(16)
- #define ENABLE_XTAL_OUTPUT *(volatile unsigned int *)0x4000f040 |= BIT(18)
- #define ENABLE_DLL *(volatile unsigned int *)0x4000f044 |= BIT(7)
- #define DLL32M_CLOCK_ENABLE *(volatile unsigned int *)0x4000f044 |= BIT(13)
- #define DLLn_CLOCK_ENABLE(n) *(volatile unsigned int *)0x4000f044 |= BIT(n+11)
- #define DBLE_CLOCK_DISABLE *(volatile unsigned int *)0x4000f044 &= ~BIT(21)
- #define CLK_1P28M_ENABLE *(volatile unsigned int *)0x4000f03c |= BIT(6)
- #define HCLK_DIV2_ENABLE *(volatile unsigned int *)0x4000f03c |= BIT(15)
- #define PCLK_DIV_ENABLE *(volatile unsigned int *)0x4000001c & 0x02
- enum H_SYSCLK_SEL {
- SYS_CLK_RC_32M = 0,
- SYS_CLK_DLL_32M = 1,
- SYS_CLK_XTAL_16M = 2,
- SYS_CLK_DLL_48M = 3,
- SYS_CLK_DLL_64M = 4,
- SYS_CLK_DLL_96M = 5,
- SYS_CLK_DBL_32M = 6
- };
- enum LOWCLK_SEL{
- RC_32K,
- XTAL_32K
- };
- static inline void wdt_clk_sel(enum LOWCLK_SEL clk){
- if(clk){
- BM_SET((volatile unsigned int *)0x4000f03c,BIT(16));
- }else{
- BM_CLR((volatile unsigned int *)0x4000f03c,BIT(16));
- }
- }
- void hal_system_init(uint8_t h_system_clk_sel);
- void WaitUs(uint32_t wtTime);
- void WaitRTCCount(uint32_t rtcDelyCnt);
- uint8 char_array_cmp(uint8 *s1, uint8 *s2, uint8 len);
- void hal_system_soft_reset(void);
- uint32_t osal_memory_statics(void) ;
- #endif
|