[$is_event_jimu] 2 [$group_e] 元件事件库.脉宽测量 [$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] line [$name] 脉宽测量器的初始化积木 [$引脚占用列表,用于提示冲突] 外部中断输入#replace( "[($_xgm$extline),type=num]" ,"extline" ,"")% |脉宽测量积木里已占用此外部中断 [$寄存器占用列表,用于提示冲突,但=>后的值没变则不提示冲突] [$中断函数号占用列表,用于提示冲突] [$interrupt_1] [$thread_do] [$cs] [$function_ref_define_in_headfile] @@file=pulwidth.h extern u8 is_geted_pul_end_ed_$rnd_varname_pre$; extern u8 is_geted_pul_start_ed_$rnd_varname_pre$; extern u32 pul_width_$rnd_varname_pre$; extern u8 dianpin_$rnd_varname_pre$; extern u32 Fpul_width_$rnd_varname_pre$; u32 get_pul_width_val_$rnd_varname_pre$(); void a_t_callback_$rnd_varname_pre$(); [$init_code_for_define_area_once] @@file=pulwidth.c [$init_code_for_define_area] @@file=pulwidth.c #include "protothread.h" #include "app_process.h" #include "sys/timer.h" #include "Extline_Lib.h" #include "Lib_base.h" //考虑PROCESS2_WAIT_UNTIL宏 u32 Fpul_width_$rnd_varname_pre$=0; u8 dianpin_$rnd_varname_pre$=0; u8 is_geted_pul_end_ed_$rnd_varname_pre$=0; u8 is_geted_pul_start_ed_$rnd_varname_pre$=0; u32 pul_width_$rnd_varname_pre$=0; u32 get_pul_width_val_$rnd_varname_pre$(){ if(is_geted_pul_end_ed_$rnd_varname_pre$==0){ // return 0; } return Fpul_width_$rnd_varname_pre$; } void a_t_callback_$rnd_varname_pre$(){ dianpin_$rnd_varname_pre$ = TT_get_extline_pin_value([($_xgm$extline),type=num] ,[($_xgm$port),type=num]); if(is_geted_pul_start_ed_$rnd_varname_pre$==0 && dianpin_$rnd_varname_pre$==1){ pul_width_$rnd_varname_pre$=0; is_geted_pul_end_ed_$rnd_varname_pre$=0; is_geted_pul_start_ed_$rnd_varname_pre$=1; }else if(is_geted_pul_start_ed_$rnd_varname_pre$==1 && dianpin_$rnd_varname_pre$==0){ if(pul_width_$rnd_varname_pre$>0){ Fpul_width_$rnd_varname_pre$=pul_width_$rnd_varname_pre$; } is_geted_pul_end_ed_$rnd_varname_pre$=1; is_geted_pul_start_ed_$rnd_varname_pre$=0; } } [$init_code_for_init_val] Fpul_width_$rnd_varname_pre$=0; is_geted_pul_start_ed_$rnd_varname_pre$=0; is_geted_pul_end_ed_$rnd_varname_pre$=0; pul_width_$rnd_varname_pre$=0; // IT0=0; // 设置成上升沿和下降沿均触发 TT_init_from_jimu( [($_xgm$extline),type=num] , [($_xgm$port),type=num] ,3 ); TT_reg_callback_for_extline_use_timer_enum( [($_xgm$extline),type=num] ,a_t_callback_$rnd_varname_pre$ ); [$timer0_1ms_code] [$timer0_100us_code] if(is_geted_pul_start_ed_$rnd_varname_pre$==1){ pul_width_$rnd_varname_pre$=pul_width_$rnd_varname_pre$+100; } [$toolbox_block_code] [$replace_map] $_xgm$dev_no = $field$dev_no,mytype|num, ptype|TIMES $_xgm$extline = $field$extline ,mytype|num, ptype|TIMES $_xgm$port = $field$port ,mytype|num, ptype|TIMES