[$group] 元件库-执行器.$pname$ [$last_ver_update_time] 2021-04-03 [$min_need_ver] 1.23 [$p_list] [$short_show_UIname] [$code_area_type] codes,exe_per_1ms,init_code [$blocks_type] [$name] 舵机的初始化积木 [$引脚占用列表,用于提示冲突] [($_xgm$dat),type=pin]|舵机积木里已占用此引脚 [$寄存器占用列表,用于提示冲突,但=>后的值没变则不提示冲突] [($_xgm$timer),type=num]|舵机积木里已占用此定时器号:[($_xgm$timer),type=num] [$中断函数号占用列表,用于提示冲突] [$thread_do] [$cs] [$shared_func_In_main_c] [$function_ref_define_in_headfile] @@file=duoji1.h #define pre_t u8 #define pre2_t u8 extern u8 pin_st_$rnd_varname_pre$; extern u8 inset_$rnd_varname_pre$; extern pre2_t pul_width_10us_$rnd_varname_pre$; extern pre2_t cur_pul_width_10us_$rnd_varname_pre$; extern pre_t pwn_t2_$rnd_varname_pre$; extern pre_t pwn_t_$rnd_varname_pre$; void call_back_from_10us_timer_$rnd_varname_pre$(); [$replace_map] $_xgm$timer = $field$timer,mytype|num, ptype|TIMES $_xgm$dat = $field$dat,mytype|pin, ptype|TIMES $_xgm$hz = $field$hz ,mytype|num, ptype|TIMES $_xgm$value11 =$dev_no_for_complie_include_code$$field$timer $_xgm$dev_no2 = $field$timer,mytype|num, ptype|TIMES [$init_code_for_define_area] @@file=duoji1.c #define pre2_t u8 #define pre_t u8 u8 pin_st_$rnd_varname_pre$; u8 inset_$rnd_varname_pre$; pre_t pwn_t2_$rnd_varname_pre$; pre_t pwn_t_$rnd_varname_pre$; pre2_t pul_width_10us_$rnd_varname_pre$; pre2_t cur_pul_width_10us_$rnd_varname_pre$; //#define _nop_() __asm NOP __endasm #include "protothread.h" #include "sys/timer.h" //#include "Extline_Lib.h" #include "timer_Lib.h" #include "Lib_base.h" //考虑PROCESS2_WAIT_UNTIL宏 void call_back_from_10us_timer_$rnd_varname_pre$(){ if(pin_st_$rnd_varname_pre$==1){ cur_pul_width_10us_$rnd_varname_pre$++; if(cur_pul_width_10us_$rnd_varname_pre$>=pul_width_10us_$rnd_varname_pre$){ cur_pul_width_10us_$rnd_varname_pre$=0; pwn_t_$rnd_varname_pre$=0; IO_Write([($_xgm$dat),type=pin] ,0) ; pin_st_$rnd_varname_pre$=0; } } } [$init_code_for_define_area_once] @@file=duoji1.c [$init_code_for_init_val] #get_P口_to_PxM1_PxM0_set_code(group_xml,rand1,block_name,ref_complier,extinfo,"[($_xgm$dat),type=pin]","1","舵机的信号输入")% IO_Write([($_xgm$dat),type=pin] ,0) ; pin_st_$rnd_varname_pre$=0; pwn_t_$rnd_varname_pre$=0; pul_width_10us_$rnd_varname_pre$=150/2;//150*10us=1.5ms,舵机中间角度位置 cur_pul_width_10us_$rnd_varname_pre$=0; pwn_t2_$rnd_varname_pre$=(u8) (200- 2*pul_width_10us_$rnd_varname_pre$/10);//2000*10us=20ms,就是50Hz //20us per callback: TT_init_timer_from_jimu([($_xgm$timer),type=num], #get_stm32_arr_value_at_guding_psc_Input_time_us(ref_complier,"71","72","20")%-1 ,72-1 ,1,0,0,0,0,0,0,0,0); TT_reg_callback_for_timer_use_timer_enum([($_xgm$timer),type=num],call_back_from_10us_timer_$rnd_varname_pre$); [$timer0_1ms_code] [$timer0_100us_code] if(pin_st_$rnd_varname_pre$==0){ pwn_t_$rnd_varname_pre$++; if(pwn_t_$rnd_varname_pre$>=pwn_t2_$rnd_varname_pre$){ IO_Write([($_xgm$dat),type=pin] ,1) ; pin_st_$rnd_varname_pre$=1; pwn_t_$rnd_varname_pre$=0; cur_pul_width_10us_$rnd_varname_pre$=0; } } [$interrupt_1] [$run] [$toolbox_block_code]