|
|
@ -25,12 +25,6 @@ using namespace std; |
|
|
|
#define ACTION_DUMP_RESULT 12 // 打印结果
|
|
|
|
#define ACTION_AUTO_ADJUST_DETECTOR_GAIN 13 // 自动调整增益倍数
|
|
|
|
|
|
|
|
#define UVLED_ON_DURATION_TIME 500 // 500us
|
|
|
|
#define UVLED_OFF_DURATION_TIME 100 // 100us
|
|
|
|
#define SCAN_DELAY_TIME 400 // 400us
|
|
|
|
#define SCAN_DURATION_TIME 1000 // 1000us
|
|
|
|
#define TIME_RESOLVING_DENSITY 100
|
|
|
|
|
|
|
|
void OpticalModuleV2::initialize(int32_t moduleid, hardware_config_t* hardwarecfg) { //
|
|
|
|
module_id = moduleid; |
|
|
|
m_hardwarecfg = *hardwarecfg; |
|
|
@ -103,6 +97,18 @@ void OpticalModuleV2::initialize(int32_t moduleid, hardware_config_t* hardwarecf |
|
|
|
m_reg.barcode_scan_tzerowait = 0; |
|
|
|
m_reg.barcode_scan_irun = 12; |
|
|
|
|
|
|
|
// #define UVLED_ON_DURATION_TIME 500 // 500us
|
|
|
|
// #define UVLED_OFF_DURATION_TIME 100 // 100us
|
|
|
|
// #define SCAN_DELAY_TIME 400 // 400us
|
|
|
|
// #define SCAN_DURATION_TIME 1000 // 1000us
|
|
|
|
// #define TIME_RESOLVING_DENSITY 100
|
|
|
|
|
|
|
|
m_reg.t_uvled_on_duration_time = 500; |
|
|
|
m_reg.t_uvled_off_duration_time = 100; |
|
|
|
m_reg.t_scan_delay_time = 400; |
|
|
|
m_reg.t_scan_duration_time = 1000; |
|
|
|
m_reg.t_time_resolving_density = 100; |
|
|
|
|
|
|
|
m_default_reg = m_reg; |
|
|
|
|
|
|
|
ZLOGI(TAG, "-----------------module info--------------"); |
|
|
@ -213,6 +219,13 @@ int32_t OpticalModuleV2::module_set_reg(int32_t regindex, int32_t val) { |
|
|
|
|
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_scan_step_interval, (m_reg.scan_step_interval)); |
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_scan_pointnum, (m_reg.scan_pointnum)); |
|
|
|
|
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_t_uvled_on_duration_time, (m_reg.t_uvled_on_duration_time)); |
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_t_uvled_off_duration_time, (m_reg.t_uvled_off_duration_time)); |
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_t_scan_delay_time, (m_reg.t_scan_delay_time)); |
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_t_scan_duration_time, (m_reg.t_scan_duration_time)); |
|
|
|
MODULE_REG_CASE__SET_REG_TO(kreg_a8k_opt_t_time_resolving_density, (m_reg.t_time_resolving_density)); |
|
|
|
|
|
|
|
default: |
|
|
|
return err::kmodule_not_find_reg; |
|
|
|
break; |
|
|
@ -248,6 +261,12 @@ int32_t OpticalModuleV2::module_get_reg(int32_t regindex, int32_t* val) { |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_scan_vstop, m_reg.t_scan_vstop); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_scan_tzerowait, m_reg.t_scan_tzerowait); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_scan_irun, m_reg.t_scan_irun); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_uvled_on_duration_time, (m_reg.t_uvled_on_duration_time)); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_uvled_off_duration_time, (m_reg.t_uvled_off_duration_time)); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_scan_delay_time, (m_reg.t_scan_delay_time)); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_scan_duration_time, (m_reg.t_scan_duration_time)); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_t_time_resolving_density, (m_reg.t_time_resolving_density)); |
|
|
|
|
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_barcode_scan_vdefault, m_reg.barcode_scan_vdefault); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_barcode_scan_vstart, m_reg.barcode_scan_vstart); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_barcode_scan_a1, m_reg.barcode_scan_a1); |
|
|
@ -261,6 +280,7 @@ int32_t OpticalModuleV2::module_get_reg(int32_t regindex, int32_t* val) { |
|
|
|
|
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_scan_step_interval, (m_reg.scan_step_interval)); |
|
|
|
MODULE_CFG_CASE__GET_REG_FROM(kreg_a8k_opt_scan_pointnum, (m_reg.scan_pointnum)); |
|
|
|
|
|
|
|
default: |
|
|
|
return err::kmodule_not_find_reg; |
|
|
|
break; |
|
|
@ -663,22 +683,22 @@ int32_t OpticalModuleV2::t_read_one_point(int32_t& adcval) { |
|
|
|
*/ |
|
|
|
chip_critical_enter(); |
|
|
|
tlaster_port->BSRR = closestate; |
|
|
|
zchip_clock_early_delayus2(UVLED_OFF_DURATION_TIME); |
|
|
|
zchip_clock_early_delayus2(m_reg.t_uvled_off_duration_time); |
|
|
|
tlaster_port->BSRR = openstate; |
|
|
|
zchip_clock_early_delayus2(UVLED_ON_DURATION_TIME); |
|
|
|
zchip_clock_early_delayus2(m_reg.t_uvled_on_duration_time); |
|
|
|
tlaster_port->BSRR = closestate; |
|
|
|
zchip_clock_early_delayus2(SCAN_DELAY_TIME); |
|
|
|
zchip_clock_early_delayus2(m_reg.t_scan_delay_time); |
|
|
|
zchip_clock_early_delayus_timer_start(); |
|
|
|
|
|
|
|
int32_t sumadcval = 0; |
|
|
|
int32_t currentadcval = 0; |
|
|
|
|
|
|
|
// t_laster_adc.get_adc_value(laster_fb_val);
|
|
|
|
for (int32_t i = 0; i < TIME_RESOLVING_DENSITY; i++) { |
|
|
|
for (int32_t i = 0; i < m_reg.t_time_resolving_density; i++) { |
|
|
|
t_result_adc.get_adc_value(currentadcval); |
|
|
|
sumadcval += currentadcval; |
|
|
|
} |
|
|
|
adcval = (sumadcval / TIME_RESOLVING_DENSITY); |
|
|
|
adcval = (sumadcval / m_reg.t_time_resolving_density); |
|
|
|
|
|
|
|
uint32_t haspassed = zchip_clock_early_delayus_timer_haspassed(); |
|
|
|
zchip_clock_early_delayus_timer_stop(); |
|
|
|