使用定时器来精确控制数据发送的时间间隙,保证和其他小板不冲突
This commit is contained in:
@@ -58,6 +58,18 @@ typedef struct __gpioout_def{
|
||||
|
||||
|
||||
|
||||
typedef struct __timer_def{
|
||||
const char *name;
|
||||
int (*init)(struct __timer_def *u);
|
||||
int (*deinit)(struct __timer_def *u);
|
||||
uint32_t (*read)(struct __timer_def *u);
|
||||
int (*write)(struct __timer_def *u,const uint32_t value);
|
||||
void *private_data;
|
||||
}timer_def;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define CHECK_DO(s,to) if(s) {to(s);}
|
||||
|
||||
@@ -136,7 +148,26 @@ typedef struct __gpioout_def{
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define timer_init_export(name_,init_,deinit_,read_,write_,priv_) \
|
||||
const static char __dev_##name_##_name[] SECTION(".rodata.devstr") = #name_; \
|
||||
RT_USED static timer_def _timer_##name_={\
|
||||
.name=__dev_##name_##_name,\
|
||||
.init=init_,\
|
||||
.deinit=deinit_,\
|
||||
.read=read_,\
|
||||
.write=write_,\
|
||||
.private_data=priv_,\
|
||||
};\
|
||||
RT_USED static const struct dev_struct __dev_##name_ SECTION("devstruct")= \
|
||||
{ \
|
||||
__dev_##name_##_name, \
|
||||
&_timer_##name_, \
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct init_struct{
|
||||
int (*init_fun)(void);
|
||||
|
Reference in New Issue
Block a user