初版
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#ifndef _DUBUG_H_
|
||||
#define _DUBUG_H_
|
||||
|
||||
void exception_analyze(u32 *p_sp);
|
||||
void debug_init(void);
|
||||
void debug_test();
|
||||
|
||||
#endif /* #ifndef _DUBUG_H_ */
|
||||
@@ -0,0 +1,111 @@
|
||||
#ifndef __ASS_Q32S_HWI__
|
||||
#define __ASS_Q32S_HWI__
|
||||
|
||||
//*********************************************************************************//
|
||||
// Module name : hwi.h //
|
||||
// Description : q32DSP interrupt head file //
|
||||
// By Designer : zequan_liu //
|
||||
// Dat changed : //
|
||||
//*********************************************************************************//
|
||||
|
||||
|
||||
#define IRQ_EXCEPTION_IDX 0
|
||||
#define IRQ_SOFT0_IDX 1
|
||||
#define IRQ_M2P_IDX 2
|
||||
#define IRQ_P33_IDX 3
|
||||
#define IRQ_WDT_IDX 4
|
||||
//#define IRQ_SPI_IDX 5
|
||||
#define IRQ_UART0_IDX 6
|
||||
//#define IRQ_UART1_IDX 7
|
||||
#define IRQ_IIC_IDX 8
|
||||
#define IRQ_LP_TMR0_IDX 9
|
||||
#define IRQ_LP_TMR1_IDX 10
|
||||
#define IRQ_P33_LPTMR0_IDX 11
|
||||
#define IRQ_P33_LPTMR1_IDX 12
|
||||
#define IRQ_GP_TMR0_IDX 13
|
||||
#define IRQ_GP_TMR1_IDX 14
|
||||
#define IRQ_LP_CTM_IDX 15
|
||||
//#define IRQ_LP_CTM1_IDX 16
|
||||
//#define IRQ_LP_VAD_IDX 17
|
||||
//#define IRQ_LP_NFC_IDX 18
|
||||
#define IRQ_PINR_IDX 19
|
||||
#define IRQ_GPCNT_IDX 20
|
||||
|
||||
//---------------------------------------------//
|
||||
// interrupt install
|
||||
//---------------------------------------------//
|
||||
|
||||
void reg_set_ip(unsigned char index, unsigned char dat);
|
||||
void bit_set_ie(unsigned char index);
|
||||
void bit_clr_ie(unsigned char index);
|
||||
void bit_set_swi(unsigned char index);
|
||||
void bit_clr_swi(unsigned char index);
|
||||
|
||||
void request_irq(u8 index, void (*handler)(void), u8 priority);
|
||||
|
||||
//---------------------------------------------//
|
||||
// core_num
|
||||
//---------------------------------------------//
|
||||
|
||||
static inline int core_num(void)
|
||||
{
|
||||
u32 num;
|
||||
asm volatile("%0 = cnum" : "=r"(num) :);
|
||||
return num;
|
||||
}
|
||||
|
||||
//---------------------------------------------//
|
||||
// interrupt enable
|
||||
//---------------------------------------------//
|
||||
|
||||
#define ENABLE_INT enable_int
|
||||
#define enable_int() local_irq_enable()
|
||||
|
||||
#define DISABLE_INT disable_int
|
||||
#define disable_int() local_irq_disable()
|
||||
|
||||
#define ___interrupt __attribute__((interrupt("")))
|
||||
|
||||
|
||||
void local_irq_disable();
|
||||
void local_irq_enable();
|
||||
|
||||
void irq_disable_core();
|
||||
void irq_enable_core();
|
||||
|
||||
#define P33_IE_ENABLE() \
|
||||
bit_set_ie(IRQ_P33_IDX)
|
||||
|
||||
#define P33_IE_DISABLE() \
|
||||
bit_clr_ie(IRQ_P33_IDX)
|
||||
|
||||
static inline int cpu_in_irq()
|
||||
{
|
||||
int flag;
|
||||
__asm__ volatile("%0 = icfg" : "=r"(flag));
|
||||
return flag & 0xff;
|
||||
}
|
||||
|
||||
static inline int cpu_irq_disable()
|
||||
{
|
||||
#if 0
|
||||
int flag;
|
||||
int ret;
|
||||
|
||||
__asm__ volatile("%0 = icfg" : "=r"(flag));
|
||||
ret = ((flag & 0x300) != 0x300);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
extern int __cpu_irq_disabled();
|
||||
return __cpu_irq_disabled();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//*********************************************************************************//
|
||||
// //
|
||||
// end of this module //
|
||||
// //
|
||||
//*********************************************************************************//
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef __INCLUDES__
|
||||
#define __INCLUDES__
|
||||
|
||||
#define PMU_SYSTEM 1
|
||||
|
||||
//utils
|
||||
#include "typedef.h"
|
||||
#include "typedef/assert.h"
|
||||
|
||||
#include "printf.h"
|
||||
#include "string.h"
|
||||
#include "delay.h"
|
||||
|
||||
//apps
|
||||
#include "lib_config.h"
|
||||
#include "sdk_config.h"
|
||||
|
||||
//driver
|
||||
#include "power_interface.h"
|
||||
#include "clock_interface.h"
|
||||
#include "uart.h"
|
||||
|
||||
//system
|
||||
#include "hwi.h"
|
||||
#include "interrupt_hw.h"
|
||||
#include "debug.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef __INTERRUPT_HW__
|
||||
#define __INTERRUPT_HW__
|
||||
|
||||
|
||||
/*
|
||||
gpcnt需要打断低功耗采样,优先即最高且不可屏蔽
|
||||
*/
|
||||
|
||||
#define IRQ_EXCEPTION_IP 0
|
||||
#define IRQ_M2P_IP 2
|
||||
#define IRQ_P33_IP 0
|
||||
#define IRQ_PINR_IP 0
|
||||
#define IRQ_SOFT0_IP 0
|
||||
#define IRQ_WDT_IP 0
|
||||
#define IRQ_SPI_IP 0
|
||||
#define IRQ_UART0_IP 0
|
||||
#define IRQ_UART1_IP 0
|
||||
#define IRQ_IIC_IP 0
|
||||
#define IRQ_LP_TMR0_IP 2
|
||||
#define IRQ_LP_TMR1_IP 0
|
||||
#define IRQ_LP_TMR2_IP 0
|
||||
#define IRQ_LP_TMR3_IP 0
|
||||
#define IRQ_GP_TMR0_IP 0
|
||||
#define IRQ_GP_TMR1_IP 0
|
||||
#define IRQ_LP_CTM_IP 1
|
||||
#define IRQ_LP_VAD_IP 0
|
||||
#define IRQ_GPCNT_IP 3
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef __DELAY_H__
|
||||
#define __DELAY_H__
|
||||
|
||||
void delay(u32 cnt);
|
||||
void udelay(u32 us);//不准
|
||||
void mdelay(u32 ms);//不准
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef __ASSERT_H__
|
||||
#define __ASSERT_H__
|
||||
|
||||
#define ASSERT(a,...) \
|
||||
do { \
|
||||
if(!(a)){ \
|
||||
printf("file:%s, line:%d", __FILE__, __LINE__); \
|
||||
printf("ASSERT-FAILD: "#a" "__VA_ARGS__); \
|
||||
while(1); \
|
||||
} \
|
||||
}while(0);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* #ifndef _COMMON_H_ */
|
||||
@@ -0,0 +1,90 @@
|
||||
//*********************************************************************************//
|
||||
// Module name : typedef.h //
|
||||
// Description : typedef head file //
|
||||
// By Designer : zequan_liu //
|
||||
// Dat changed : //
|
||||
//*********************************************************************************//
|
||||
|
||||
#ifndef __typedef_h__
|
||||
#define __typedef_h__
|
||||
|
||||
//------------------------------------------------------//
|
||||
// typedef
|
||||
//------------------------------------------------------//
|
||||
|
||||
//typedef bool _bit, bit;
|
||||
typedef float _f32, f32;
|
||||
typedef double _d64, d64;
|
||||
|
||||
typedef signed char _s08, s08, _s8, s8;
|
||||
typedef signed short _s16, s16;
|
||||
typedef signed int _s32, s32;
|
||||
typedef signed long long _s64, s64;
|
||||
|
||||
typedef unsigned char _u08, u08, _u8, u8, bool, BOOL;
|
||||
typedef unsigned short _u16, u16;
|
||||
typedef unsigned int _u32, u32;
|
||||
typedef unsigned long long _u64, u64;
|
||||
|
||||
|
||||
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
//------------------------------------------------------//
|
||||
// condition
|
||||
//------------------------------------------------------//
|
||||
|
||||
#define SIMEND asm ("trigger")
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#define false 0
|
||||
#define true 1
|
||||
#define NULL 0
|
||||
|
||||
#define AT(x) __attribute__ ((section(#x)))
|
||||
#define SEC_USED(x) __attribute__((section(#x),used))
|
||||
#define _INLINE_ __attribute__ ((always_inline))
|
||||
#define _NOINLINE_ __attribute__ ((noinline))
|
||||
#define __WEAK__ __attribute__((weak))
|
||||
#define __NO_INIT__
|
||||
#define ___interrupt __attribute__((interrupt("")))
|
||||
#define ALIGNED(x) __attribute__((aligned(x)))
|
||||
|
||||
//------------------------------------------------------//
|
||||
// common define
|
||||
//------------------------------------------------------//
|
||||
|
||||
#define hi(adr) ( (adr) >> 16 )
|
||||
#define lo(adr) ( (adr) & 0xffff )
|
||||
|
||||
#define LDR_W(ptr) *( (volatile _u32*)(ptr) )
|
||||
#define LDR_H(ptr) *( (volatile _u16*)(ptr) )
|
||||
#define LDR_B(ptr) *( (volatile _u08*)(ptr) )
|
||||
|
||||
#define STR_W(ptr,vld) *( (volatile _u32*)(ptr) ) = (_u32)(vld);
|
||||
#define STR_H(ptr,vld) *( (volatile _u16*)(ptr) ) = (_u16)(vld);
|
||||
#define STR_B(ptr,vld) *( (volatile _u08*)(ptr) ) = (_u08)(vld);
|
||||
|
||||
#define BIT(n) ( 1<<(n) )
|
||||
#define BITSET(r,n) ( r |= (1<<(n)) )
|
||||
#define BITCLR(r,n) ( r &= ~(1<<(n)) )
|
||||
#define BITXOR(r,n) ( r ^= (1<<(n)) )
|
||||
#define BITTST(r,n) ( r & (1<<(n)) )
|
||||
|
||||
#define BIT_CHK1(r,n) ( BITTST((r),(n)) == (1<<(n)) )
|
||||
#define BIT_CHK0(r,n) ( BITTST((r),(n)) == (0<<(n)) )
|
||||
|
||||
#define MIN(a,b) ( ((a)<(b)) ? (a) : (b) )
|
||||
#define MAX(a,b) ( ((a)>(b)) ? (a) : (b) )
|
||||
|
||||
#define SFR(sfr, start, len, dat) (sfr = sfr & ~((~(0xffffffff << (len))) << (start)) | (((dat) & (~(0xffffffff << (len)))) << (start)))
|
||||
|
||||
#define NOP() asm volatile ("nop")
|
||||
|
||||
#endif
|
||||
|
||||
//*********************************************************************************//
|
||||
// //
|
||||
// end of this module //
|
||||
// //
|
||||
//*********************************************************************************//
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef __USR_TIMER_H__
|
||||
#define __USR_TIMER_H__
|
||||
|
||||
#define time_after(a,b) ((long)(b) - (long)(a) <= 0)
|
||||
#define time_before(a,b) time_after(b,a)
|
||||
|
||||
#define TIMER_ID_0_ERROR 1 // ID号0错误
|
||||
|
||||
|
||||
u16 usr_timer_add(void *priv, void (*func)(void *priv), u32 msec, u8 priority);
|
||||
void usr_timer_del(u16 t);
|
||||
|
||||
u16 usr_timeout_add(void *priv, void (*func)(void *priv), u32 msec, u8 priority);
|
||||
void usr_timeout_del(u16 t);
|
||||
|
||||
int usr_timer_modify(u16 id, u32 msec);
|
||||
int usr_timeout_modify(u16 id, u32 msec);
|
||||
|
||||
void usr_timer_schedule();
|
||||
void usr_timer_dump(void);
|
||||
|
||||
void usr_timer_init();
|
||||
|
||||
u32 usr_timer_get_timeout();
|
||||
#endif
|
||||
Reference in New Issue
Block a user