1 Star 1 Fork 1

music1273/bldc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
confgenerator.c 56.00 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
// This file is autogenerated by VESC Tool
#include <string.h>
#include "buffer.h"
#include "conf_general.h"
#include "confgenerator.h"
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf) {
int32_t ind = 0;
buffer_append_uint32(buffer, MCCONF_SIGNATURE, &ind);
buffer[ind++] = conf->pwm_mode;
buffer[ind++] = conf->comm_mode;
buffer[ind++] = conf->motor_type;
buffer[ind++] = conf->sensor_mode;
buffer_append_float32_auto(buffer, conf->l_current_max, &ind);
buffer_append_float32_auto(buffer, conf->l_current_min, &ind);
buffer_append_float32_auto(buffer, conf->l_in_current_max, &ind);
buffer_append_float32_auto(buffer, conf->l_in_current_min, &ind);
buffer_append_float16(buffer, conf->l_in_current_map_start, 10000, &ind);
buffer_append_float16(buffer, conf->l_in_current_map_filter, 10000, &ind);
buffer_append_float32_auto(buffer, conf->l_abs_current_max, &ind);
buffer_append_float32_auto(buffer, conf->l_min_erpm, &ind);
buffer_append_float32_auto(buffer, conf->l_max_erpm, &ind);
buffer_append_float16(buffer, conf->l_erpm_start, 10000, &ind);
buffer_append_float32_auto(buffer, conf->l_max_erpm_fbrake, &ind);
buffer_append_float32_auto(buffer, conf->l_max_erpm_fbrake_cc, &ind);
buffer_append_float16(buffer, conf->l_min_vin, 10, &ind);
buffer_append_float16(buffer, conf->l_max_vin, 10, &ind);
buffer_append_float16(buffer, conf->l_battery_cut_start, 10, &ind);
buffer_append_float16(buffer, conf->l_battery_cut_end, 10, &ind);
buffer_append_float16(buffer, conf->l_battery_regen_cut_start, 10, &ind);
buffer_append_float16(buffer, conf->l_battery_regen_cut_end, 10, &ind);
buffer[ind++] = conf->l_slow_abs_current;
buffer[ind++] = (uint8_t)conf->l_temp_fet_start;
buffer[ind++] = (uint8_t)conf->l_temp_fet_end;
buffer[ind++] = (uint8_t)conf->l_temp_motor_start;
buffer[ind++] = (uint8_t)conf->l_temp_motor_end;
buffer_append_float16(buffer, conf->l_temp_accel_dec, 10000, &ind);
buffer_append_float16(buffer, conf->l_min_duty, 10000, &ind);
buffer_append_float16(buffer, conf->l_max_duty, 10000, &ind);
buffer_append_float32_auto(buffer, conf->l_watt_max, &ind);
buffer_append_float32_auto(buffer, conf->l_watt_min, &ind);
buffer_append_float16(buffer, conf->l_current_max_scale, 10000, &ind);
buffer_append_float16(buffer, conf->l_current_min_scale, 10000, &ind);
buffer_append_float16(buffer, conf->l_duty_start, 10000, &ind);
buffer_append_float32_auto(buffer, conf->sl_min_erpm, &ind);
buffer_append_float32_auto(buffer, conf->sl_min_erpm_cycle_int_limit, &ind);
buffer_append_float32_auto(buffer, conf->sl_max_fullbreak_current_dir_change, &ind);
buffer_append_float16(buffer, conf->sl_cycle_int_limit, 10, &ind);
buffer_append_float16(buffer, conf->sl_phase_advance_at_br, 10000, &ind);
buffer_append_float32_auto(buffer, conf->sl_cycle_int_rpm_br, &ind);
buffer_append_float32_auto(buffer, conf->sl_bemf_coupling_k, &ind);
buffer[ind++] = (uint8_t)conf->hall_table[0];
buffer[ind++] = (uint8_t)conf->hall_table[1];
buffer[ind++] = (uint8_t)conf->hall_table[2];
buffer[ind++] = (uint8_t)conf->hall_table[3];
buffer[ind++] = (uint8_t)conf->hall_table[4];
buffer[ind++] = (uint8_t)conf->hall_table[5];
buffer[ind++] = (uint8_t)conf->hall_table[6];
buffer[ind++] = (uint8_t)conf->hall_table[7];
buffer_append_float32_auto(buffer, conf->hall_sl_erpm, &ind);
buffer_append_float32_auto(buffer, conf->foc_current_kp, &ind);
buffer_append_float32_auto(buffer, conf->foc_current_ki, &ind);
buffer_append_float32_auto(buffer, conf->foc_f_zv, &ind);
buffer_append_float32_auto(buffer, conf->foc_dt_us, &ind);
buffer[ind++] = conf->foc_encoder_inverted;
buffer_append_float32_auto(buffer, conf->foc_encoder_offset, &ind);
buffer_append_float32_auto(buffer, conf->foc_encoder_ratio, &ind);
buffer[ind++] = conf->foc_sensor_mode;
buffer_append_float32_auto(buffer, conf->foc_pll_kp, &ind);
buffer_append_float32_auto(buffer, conf->foc_pll_ki, &ind);
buffer_append_float32_auto(buffer, conf->foc_motor_l, &ind);
buffer_append_float32_auto(buffer, conf->foc_motor_ld_lq_diff, &ind);
buffer_append_float32_auto(buffer, conf->foc_motor_r, &ind);
buffer_append_float32_auto(buffer, conf->foc_motor_flux_linkage, &ind);
buffer_append_float32_auto(buffer, conf->foc_observer_gain, &ind);
buffer_append_float32_auto(buffer, conf->foc_observer_gain_slow, &ind);
buffer_append_float16(buffer, conf->foc_observer_offset, 1000, &ind);
buffer_append_float32_auto(buffer, conf->foc_duty_dowmramp_kp, &ind);
buffer_append_float32_auto(buffer, conf->foc_duty_dowmramp_ki, &ind);
buffer_append_float16(buffer, conf->foc_start_curr_dec, 10000, &ind);
buffer_append_float32_auto(buffer, conf->foc_start_curr_dec_rpm, &ind);
buffer_append_float32_auto(buffer, conf->foc_openloop_rpm, &ind);
buffer_append_float16(buffer, conf->foc_openloop_rpm_low, 1000, &ind);
buffer_append_float16(buffer, conf->foc_d_gain_scale_start, 1000, &ind);
buffer_append_float16(buffer, conf->foc_d_gain_scale_max_mod, 1000, &ind);
buffer_append_float16(buffer, conf->foc_sl_openloop_hyst, 100, &ind);
buffer_append_float16(buffer, conf->foc_sl_openloop_time_lock, 100, &ind);
buffer_append_float16(buffer, conf->foc_sl_openloop_time_ramp, 100, &ind);
buffer_append_float16(buffer, conf->foc_sl_openloop_time, 100, &ind);
buffer_append_float16(buffer, conf->foc_sl_openloop_boost_q, 100, &ind);
buffer_append_float16(buffer, conf->foc_sl_openloop_max_q, 100, &ind);
buffer[ind++] = (uint8_t)conf->foc_hall_table[0];
buffer[ind++] = (uint8_t)conf->foc_hall_table[1];
buffer[ind++] = (uint8_t)conf->foc_hall_table[2];
buffer[ind++] = (uint8_t)conf->foc_hall_table[3];
buffer[ind++] = (uint8_t)conf->foc_hall_table[4];
buffer[ind++] = (uint8_t)conf->foc_hall_table[5];
buffer[ind++] = (uint8_t)conf->foc_hall_table[6];
buffer[ind++] = (uint8_t)conf->foc_hall_table[7];
buffer_append_float32_auto(buffer, conf->foc_hall_interp_erpm, &ind);
buffer_append_float32_auto(buffer, conf->foc_sl_erpm_start, &ind);
buffer_append_float32_auto(buffer, conf->foc_sl_erpm, &ind);
buffer[ind++] = conf->foc_control_sample_mode;
buffer[ind++] = conf->foc_current_sample_mode;
buffer[ind++] = conf->foc_sat_comp_mode;
buffer_append_float16(buffer, conf->foc_sat_comp, 1000, &ind);
buffer[ind++] = conf->foc_temp_comp;
buffer_append_float16(buffer, conf->foc_temp_comp_base_temp, 100, &ind);
buffer_append_float16(buffer, conf->foc_current_filter_const, 10000, &ind);
buffer[ind++] = conf->foc_cc_decoupling;
buffer[ind++] = conf->foc_observer_type;
buffer[ind++] = conf->foc_hfi_amb_mode;
buffer_append_float16(buffer, conf->foc_hfi_amb_current, 10, &ind);
buffer[ind++] = (uint8_t)conf->foc_hfi_amb_tres;
buffer_append_float16(buffer, conf->foc_hfi_voltage_start, 10, &ind);
buffer_append_float16(buffer, conf->foc_hfi_voltage_run, 10, &ind);
buffer_append_float16(buffer, conf->foc_hfi_voltage_max, 10, &ind);
buffer_append_float16(buffer, conf->foc_hfi_gain, 1000, &ind);
buffer_append_float16(buffer, conf->foc_hfi_max_err, 1000, &ind);
buffer_append_float16(buffer, conf->foc_hfi_hyst, 100, &ind);
buffer_append_float32_auto(buffer, conf->foc_sl_erpm_hfi, &ind);
buffer_append_uint16(buffer, conf->foc_hfi_start_samples, &ind);
buffer_append_float32_auto(buffer, conf->foc_hfi_obs_ovr_sec, &ind);
buffer[ind++] = conf->foc_hfi_samples;
buffer[ind++] = conf->foc_offsets_cal_mode;
buffer_append_float32_auto(buffer, conf->foc_offsets_current[0], &ind);
buffer_append_float32_auto(buffer, conf->foc_offsets_current[1], &ind);
buffer_append_float32_auto(buffer, conf->foc_offsets_current[2], &ind);
buffer_append_float16(buffer, conf->foc_offsets_voltage[0], 10000, &ind);
buffer_append_float16(buffer, conf->foc_offsets_voltage[1], 10000, &ind);
buffer_append_float16(buffer, conf->foc_offsets_voltage[2], 10000, &ind);
buffer_append_float16(buffer, conf->foc_offsets_voltage_undriven[0], 10000, &ind);
buffer_append_float16(buffer, conf->foc_offsets_voltage_undriven[1], 10000, &ind);
buffer_append_float16(buffer, conf->foc_offsets_voltage_undriven[2], 10000, &ind);
buffer[ind++] = conf->foc_phase_filter_enable;
buffer[ind++] = conf->foc_phase_filter_disable_fault;
buffer_append_float32_auto(buffer, conf->foc_phase_filter_max_erpm, &ind);
buffer[ind++] = conf->foc_mtpa_mode;
buffer_append_float32_auto(buffer, conf->foc_fw_current_max, &ind);
buffer_append_float16(buffer, conf->foc_fw_duty_start, 10000, &ind);
buffer_append_float16(buffer, conf->foc_fw_ramp_time, 1000, &ind);
buffer_append_float16(buffer, conf->foc_fw_q_current_factor, 10000, &ind);
buffer[ind++] = conf->foc_speed_soure;
buffer[ind++] = conf->foc_short_ls_on_zero_duty;
buffer[ind++] = conf->sp_pid_loop_rate;
buffer_append_float32_auto(buffer, conf->s_pid_kp, &ind);
buffer_append_float32_auto(buffer, conf->s_pid_ki, &ind);
buffer_append_float32_auto(buffer, conf->s_pid_kd, &ind);
buffer_append_float16(buffer, conf->s_pid_kd_filter, 10000, &ind);
buffer_append_float32_auto(buffer, conf->s_pid_min_erpm, &ind);
buffer[ind++] = conf->s_pid_allow_braking;
buffer_append_float32_auto(buffer, conf->s_pid_ramp_erpms_s, &ind);
buffer[ind++] = conf->s_pid_speed_source;
buffer_append_float32_auto(buffer, conf->p_pid_kp, &ind);
buffer_append_float32_auto(buffer, conf->p_pid_ki, &ind);
buffer_append_float32_auto(buffer, conf->p_pid_kd, &ind);
buffer_append_float32_auto(buffer, conf->p_pid_kd_proc, &ind);
buffer_append_float16(buffer, conf->p_pid_kd_filter, 10000, &ind);
buffer_append_float32_auto(buffer, conf->p_pid_ang_div, &ind);
buffer_append_float16(buffer, conf->p_pid_gain_dec_angle, 10, &ind);
buffer_append_float32_auto(buffer, conf->p_pid_offset, &ind);
buffer_append_float16(buffer, conf->cc_startup_boost_duty, 10000, &ind);
buffer_append_float32_auto(buffer, conf->cc_min_current, &ind);
buffer_append_float32_auto(buffer, conf->cc_gain, &ind);
buffer_append_float16(buffer, conf->cc_ramp_step_max, 10000, &ind);
buffer_append_int32(buffer, conf->m_fault_stop_time_ms, &ind);
buffer_append_float16(buffer, conf->m_duty_ramp_step, 10000, &ind);
buffer_append_float32_auto(buffer, conf->m_current_backoff_gain, &ind);
buffer_append_uint32(buffer, conf->m_encoder_counts, &ind);
buffer_append_float16(buffer, conf->m_encoder_sin_amp, 1000, &ind);
buffer_append_float16(buffer, conf->m_encoder_cos_amp, 1000, &ind);
buffer_append_float16(buffer, conf->m_encoder_sin_offset, 1000, &ind);
buffer_append_float16(buffer, conf->m_encoder_cos_offset, 1000, &ind);
buffer_append_float16(buffer, conf->m_encoder_sincos_filter_constant, 1000, &ind);
buffer_append_float16(buffer, conf->m_encoder_sincos_phase_correction, 1000, &ind);
buffer[ind++] = conf->m_sensor_port_mode;
buffer[ind++] = conf->m_invert_direction;
buffer[ind++] = conf->m_drv8301_oc_mode;
buffer[ind++] = (uint8_t)conf->m_drv8301_oc_adj;
buffer_append_float32_auto(buffer, conf->m_bldc_f_sw_min, &ind);
buffer_append_float32_auto(buffer, conf->m_bldc_f_sw_max, &ind);
buffer_append_float32_auto(buffer, conf->m_dc_f_sw, &ind);
buffer_append_float32_auto(buffer, conf->m_ntc_motor_beta, &ind);
buffer[ind++] = conf->m_out_aux_mode;
buffer[ind++] = conf->m_motor_temp_sens_type;
buffer_append_float32_auto(buffer, conf->m_ptc_motor_coeff, &ind);
buffer_append_float16(buffer, conf->m_ntcx_ptcx_res, 0.1, &ind);
buffer_append_float16(buffer, conf->m_ntcx_ptcx_temp_base, 10, &ind);
buffer[ind++] = (uint8_t)conf->m_hall_extra_samples;
buffer[ind++] = (uint8_t)conf->m_batt_filter_const;
buffer[ind++] = (uint8_t)conf->si_motor_poles;
buffer_append_float32_auto(buffer, conf->si_gear_ratio, &ind);
buffer_append_float32_auto(buffer, conf->si_wheel_diameter, &ind);
buffer[ind++] = conf->si_battery_type;
buffer[ind++] = (uint8_t)conf->si_battery_cells;
buffer_append_float32_auto(buffer, conf->si_battery_ah, &ind);
buffer_append_float32_auto(buffer, conf->si_motor_nl_current, &ind);
buffer[ind++] = conf->bms.type;
buffer[ind++] = conf->bms.limit_mode;
buffer[ind++] = (uint8_t)conf->bms.t_limit_start;
buffer[ind++] = (uint8_t)conf->bms.t_limit_end;
buffer_append_float16(buffer, conf->bms.soc_limit_start, 1000, &ind);
buffer_append_float16(buffer, conf->bms.soc_limit_end, 1000, &ind);
buffer_append_float16(buffer, conf->bms.vmin_limit_start, 1000, &ind);
buffer_append_float16(buffer, conf->bms.vmin_limit_end, 1000, &ind);
buffer_append_float16(buffer, conf->bms.vmax_limit_start, 1000, &ind);
buffer_append_float16(buffer, conf->bms.vmax_limit_end, 1000, &ind);
buffer[ind++] = conf->bms.fwd_can_mode;
return ind;
}
int32_t confgenerator_serialize_appconf(uint8_t *buffer, const app_configuration *conf) {
int32_t ind = 0;
buffer_append_uint32(buffer, APPCONF_SIGNATURE, &ind);
buffer[ind++] = (uint8_t)conf->controller_id;
buffer_append_uint32(buffer, conf->timeout_msec, &ind);
buffer_append_float32_auto(buffer, conf->timeout_brake_current, &ind);
buffer_append_uint16(buffer, conf->can_status_rate_1, &ind);
buffer_append_uint16(buffer, conf->can_status_rate_2, &ind);
buffer[ind++] = conf->can_status_msgs_r1;
buffer[ind++] = conf->can_status_msgs_r2;
buffer[ind++] = conf->can_baud_rate;
buffer[ind++] = conf->pairing_done;
buffer[ind++] = conf->permanent_uart_enabled;
buffer[ind++] = conf->shutdown_mode;
buffer[ind++] = conf->can_mode;
buffer[ind++] = (uint8_t)conf->uavcan_esc_index;
buffer[ind++] = conf->uavcan_raw_mode;
buffer_append_float32_auto(buffer, conf->uavcan_raw_rpm_max, &ind);
buffer[ind++] = conf->uavcan_status_current_mode;
buffer[ind++] = conf->servo_out_enable;
buffer[ind++] = conf->kill_sw_mode;
buffer[ind++] = conf->app_to_use;
buffer[ind++] = conf->app_ppm_conf.ctrl_type;
buffer_append_float32_auto(buffer, conf->app_ppm_conf.pid_max_erpm, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.hyst, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.pulse_start, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.pulse_end, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.pulse_center, &ind);
buffer[ind++] = conf->app_ppm_conf.median_filter;
buffer[ind++] = conf->app_ppm_conf.safe_start;
buffer_append_float32_auto(buffer, conf->app_ppm_conf.throttle_exp, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.throttle_exp_brake, &ind);
buffer[ind++] = conf->app_ppm_conf.throttle_exp_mode;
buffer_append_float32_auto(buffer, conf->app_ppm_conf.ramp_time_pos, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.ramp_time_neg, &ind);
buffer[ind++] = conf->app_ppm_conf.multi_esc;
buffer[ind++] = conf->app_ppm_conf.tc;
buffer_append_float32_auto(buffer, conf->app_ppm_conf.tc_max_diff, &ind);
buffer_append_float16(buffer, conf->app_ppm_conf.max_erpm_for_dir, 1, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.smart_rev_max_duty, &ind);
buffer_append_float32_auto(buffer, conf->app_ppm_conf.smart_rev_ramp_time, &ind);
buffer[ind++] = conf->app_adc_conf.ctrl_type;
buffer_append_float32_auto(buffer, conf->app_adc_conf.hyst, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage_start, 1000, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage_end, 1000, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage_min, 1000, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage_max, 1000, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage_center, 1000, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage2_start, 1000, &ind);
buffer_append_float16(buffer, conf->app_adc_conf.voltage2_end, 1000, &ind);
buffer[ind++] = conf->app_adc_conf.use_filter;
buffer[ind++] = conf->app_adc_conf.safe_start;
buffer[ind++] = conf->app_adc_conf.buttons;
buffer[ind++] = conf->app_adc_conf.voltage_inverted;
buffer[ind++] = conf->app_adc_conf.voltage2_inverted;
buffer_append_float32_auto(buffer, conf->app_adc_conf.throttle_exp, &ind);
buffer_append_float32_auto(buffer, conf->app_adc_conf.throttle_exp_brake, &ind);
buffer[ind++] = conf->app_adc_conf.throttle_exp_mode;
buffer_append_float32_auto(buffer, conf->app_adc_conf.ramp_time_pos, &ind);
buffer_append_float32_auto(buffer, conf->app_adc_conf.ramp_time_neg, &ind);
buffer[ind++] = conf->app_adc_conf.multi_esc;
buffer[ind++] = conf->app_adc_conf.tc;
buffer_append_float32_auto(buffer, conf->app_adc_conf.tc_max_diff, &ind);
buffer_append_uint16(buffer, conf->app_adc_conf.update_rate_hz, &ind);
buffer_append_uint32(buffer, conf->app_uart_baudrate, &ind);
buffer[ind++] = conf->app_chuk_conf.ctrl_type;
buffer_append_float32_auto(buffer, conf->app_chuk_conf.hyst, &ind);
buffer_append_float32_auto(buffer, conf->app_chuk_conf.ramp_time_pos, &ind);
buffer_append_float32_auto(buffer, conf->app_chuk_conf.ramp_time_neg, &ind);
buffer_append_float32_auto(buffer, conf->app_chuk_conf.stick_erpm_per_s_in_cc, &ind);
buffer_append_float32_auto(buffer, conf->app_chuk_conf.throttle_exp, &ind);
buffer_append_float32_auto(buffer, conf->app_chuk_conf.throttle_exp_brake, &ind);
buffer[ind++] = conf->app_chuk_conf.throttle_exp_mode;
buffer[ind++] = conf->app_chuk_conf.multi_esc;
buffer[ind++] = conf->app_chuk_conf.tc;
buffer_append_float32_auto(buffer, conf->app_chuk_conf.tc_max_diff, &ind);
buffer[ind++] = conf->app_chuk_conf.use_smart_rev;
buffer_append_float32_auto(buffer, conf->app_chuk_conf.smart_rev_max_duty, &ind);
buffer_append_float32_auto(buffer, conf->app_chuk_conf.smart_rev_ramp_time, &ind);
buffer[ind++] = conf->app_nrf_conf.speed;
buffer[ind++] = conf->app_nrf_conf.power;
buffer[ind++] = conf->app_nrf_conf.crc_type;
buffer[ind++] = conf->app_nrf_conf.retry_delay;
buffer[ind++] = (uint8_t)conf->app_nrf_conf.retries;
buffer[ind++] = (uint8_t)conf->app_nrf_conf.channel;
buffer[ind++] = (uint8_t)conf->app_nrf_conf.address[0];
buffer[ind++] = (uint8_t)conf->app_nrf_conf.address[1];
buffer[ind++] = (uint8_t)conf->app_nrf_conf.address[2];
buffer[ind++] = conf->app_nrf_conf.send_crc_ack;
buffer[ind++] = conf->app_pas_conf.ctrl_type;
buffer[ind++] = conf->app_pas_conf.sensor_type;
buffer_append_float16(buffer, conf->app_pas_conf.current_scaling, 1000, &ind);
buffer_append_float16(buffer, conf->app_pas_conf.pedal_rpm_start, 10, &ind);
buffer_append_float16(buffer, conf->app_pas_conf.pedal_rpm_end, 10, &ind);
buffer[ind++] = conf->app_pas_conf.invert_pedal_direction;
buffer_append_uint16(buffer, conf->app_pas_conf.magnets, &ind);
buffer[ind++] = conf->app_pas_conf.use_filter;
buffer_append_float16(buffer, conf->app_pas_conf.ramp_time_pos, 100, &ind);
buffer_append_float16(buffer, conf->app_pas_conf.ramp_time_neg, 100, &ind);
buffer_append_uint16(buffer, conf->app_pas_conf.update_rate_hz, &ind);
buffer[ind++] = conf->imu_conf.type;
buffer[ind++] = conf->imu_conf.mode;
buffer[ind++] = conf->imu_conf.filter;
buffer_append_float16(buffer, conf->imu_conf.accel_lowpass_filter_x, 1, &ind);
buffer_append_float16(buffer, conf->imu_conf.accel_lowpass_filter_y, 1, &ind);
buffer_append_float16(buffer, conf->imu_conf.accel_lowpass_filter_z, 1, &ind);
buffer_append_float16(buffer, conf->imu_conf.gyro_lowpass_filter, 1, &ind);
buffer_append_uint16(buffer, conf->imu_conf.sample_rate_hz, &ind);
buffer[ind++] = conf->imu_conf.use_magnetometer;
buffer_append_float32_auto(buffer, conf->imu_conf.accel_confidence_decay, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.mahony_kp, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.mahony_ki, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.madgwick_beta, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.rot_roll, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.rot_pitch, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.rot_yaw, &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.accel_offsets[0], &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.accel_offsets[1], &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.accel_offsets[2], &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.gyro_offsets[0], &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.gyro_offsets[1], &ind);
buffer_append_float32_auto(buffer, conf->imu_conf.gyro_offsets[2], &ind);
return ind;
}
bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *conf) {
int32_t ind = 0;
uint32_t signature = buffer_get_uint32(buffer, &ind);
if (signature != MCCONF_SIGNATURE) {
return false;
}
conf->pwm_mode = buffer[ind++];
conf->comm_mode = buffer[ind++];
conf->motor_type = buffer[ind++];
conf->sensor_mode = buffer[ind++];
conf->l_current_max = buffer_get_float32_auto(buffer, &ind);
conf->l_current_min = buffer_get_float32_auto(buffer, &ind);
conf->l_in_current_max = buffer_get_float32_auto(buffer, &ind);
conf->l_in_current_min = buffer_get_float32_auto(buffer, &ind);
conf->l_in_current_map_start = buffer_get_float16(buffer, 10000, &ind);
conf->l_in_current_map_filter = buffer_get_float16(buffer, 10000, &ind);
conf->l_abs_current_max = buffer_get_float32_auto(buffer, &ind);
conf->l_min_erpm = buffer_get_float32_auto(buffer, &ind);
conf->l_max_erpm = buffer_get_float32_auto(buffer, &ind);
conf->l_erpm_start = buffer_get_float16(buffer, 10000, &ind);
conf->l_max_erpm_fbrake = buffer_get_float32_auto(buffer, &ind);
conf->l_max_erpm_fbrake_cc = buffer_get_float32_auto(buffer, &ind);
conf->l_min_vin = buffer_get_float16(buffer, 10, &ind);
conf->l_max_vin = buffer_get_float16(buffer, 10, &ind);
conf->l_battery_cut_start = buffer_get_float16(buffer, 10, &ind);
conf->l_battery_cut_end = buffer_get_float16(buffer, 10, &ind);
conf->l_battery_regen_cut_start = buffer_get_float16(buffer, 10, &ind);
conf->l_battery_regen_cut_end = buffer_get_float16(buffer, 10, &ind);
conf->l_slow_abs_current = buffer[ind++];
conf->l_temp_fet_start = buffer[ind++];
conf->l_temp_fet_end = buffer[ind++];
conf->l_temp_motor_start = buffer[ind++];
conf->l_temp_motor_end = buffer[ind++];
conf->l_temp_accel_dec = buffer_get_float16(buffer, 10000, &ind);
conf->l_min_duty = buffer_get_float16(buffer, 10000, &ind);
conf->l_max_duty = buffer_get_float16(buffer, 10000, &ind);
conf->l_watt_max = buffer_get_float32_auto(buffer, &ind);
conf->l_watt_min = buffer_get_float32_auto(buffer, &ind);
conf->l_current_max_scale = buffer_get_float16(buffer, 10000, &ind);
conf->l_current_min_scale = buffer_get_float16(buffer, 10000, &ind);
conf->l_duty_start = buffer_get_float16(buffer, 10000, &ind);
conf->sl_min_erpm = buffer_get_float32_auto(buffer, &ind);
conf->sl_min_erpm_cycle_int_limit = buffer_get_float32_auto(buffer, &ind);
conf->sl_max_fullbreak_current_dir_change = buffer_get_float32_auto(buffer, &ind);
conf->sl_cycle_int_limit = buffer_get_float16(buffer, 10, &ind);
conf->sl_phase_advance_at_br = buffer_get_float16(buffer, 10000, &ind);
conf->sl_cycle_int_rpm_br = buffer_get_float32_auto(buffer, &ind);
conf->sl_bemf_coupling_k = buffer_get_float32_auto(buffer, &ind);
conf->hall_table[0] = (int8_t)buffer[ind++];
conf->hall_table[1] = (int8_t)buffer[ind++];
conf->hall_table[2] = (int8_t)buffer[ind++];
conf->hall_table[3] = (int8_t)buffer[ind++];
conf->hall_table[4] = (int8_t)buffer[ind++];
conf->hall_table[5] = (int8_t)buffer[ind++];
conf->hall_table[6] = (int8_t)buffer[ind++];
conf->hall_table[7] = (int8_t)buffer[ind++];
conf->hall_sl_erpm = buffer_get_float32_auto(buffer, &ind);
conf->foc_current_kp = buffer_get_float32_auto(buffer, &ind);
conf->foc_current_ki = buffer_get_float32_auto(buffer, &ind);
conf->foc_f_zv = buffer_get_float32_auto(buffer, &ind);
conf->foc_dt_us = buffer_get_float32_auto(buffer, &ind);
conf->foc_encoder_inverted = buffer[ind++];
conf->foc_encoder_offset = buffer_get_float32_auto(buffer, &ind);
conf->foc_encoder_ratio = buffer_get_float32_auto(buffer, &ind);
conf->foc_sensor_mode = buffer[ind++];
conf->foc_pll_kp = buffer_get_float32_auto(buffer, &ind);
conf->foc_pll_ki = buffer_get_float32_auto(buffer, &ind);
conf->foc_motor_l = buffer_get_float32_auto(buffer, &ind);
conf->foc_motor_ld_lq_diff = buffer_get_float32_auto(buffer, &ind);
conf->foc_motor_r = buffer_get_float32_auto(buffer, &ind);
conf->foc_motor_flux_linkage = buffer_get_float32_auto(buffer, &ind);
conf->foc_observer_gain = buffer_get_float32_auto(buffer, &ind);
conf->foc_observer_gain_slow = buffer_get_float32_auto(buffer, &ind);
conf->foc_observer_offset = buffer_get_float16(buffer, 1000, &ind);
conf->foc_duty_dowmramp_kp = buffer_get_float32_auto(buffer, &ind);
conf->foc_duty_dowmramp_ki = buffer_get_float32_auto(buffer, &ind);
conf->foc_start_curr_dec = buffer_get_float16(buffer, 10000, &ind);
conf->foc_start_curr_dec_rpm = buffer_get_float32_auto(buffer, &ind);
conf->foc_openloop_rpm = buffer_get_float32_auto(buffer, &ind);
conf->foc_openloop_rpm_low = buffer_get_float16(buffer, 1000, &ind);
conf->foc_d_gain_scale_start = buffer_get_float16(buffer, 1000, &ind);
conf->foc_d_gain_scale_max_mod = buffer_get_float16(buffer, 1000, &ind);
conf->foc_sl_openloop_hyst = buffer_get_float16(buffer, 100, &ind);
conf->foc_sl_openloop_time_lock = buffer_get_float16(buffer, 100, &ind);
conf->foc_sl_openloop_time_ramp = buffer_get_float16(buffer, 100, &ind);
conf->foc_sl_openloop_time = buffer_get_float16(buffer, 100, &ind);
conf->foc_sl_openloop_boost_q = buffer_get_float16(buffer, 100, &ind);
conf->foc_sl_openloop_max_q = buffer_get_float16(buffer, 100, &ind);
conf->foc_hall_table[0] = buffer[ind++];
conf->foc_hall_table[1] = buffer[ind++];
conf->foc_hall_table[2] = buffer[ind++];
conf->foc_hall_table[3] = buffer[ind++];
conf->foc_hall_table[4] = buffer[ind++];
conf->foc_hall_table[5] = buffer[ind++];
conf->foc_hall_table[6] = buffer[ind++];
conf->foc_hall_table[7] = buffer[ind++];
conf->foc_hall_interp_erpm = buffer_get_float32_auto(buffer, &ind);
conf->foc_sl_erpm_start = buffer_get_float32_auto(buffer, &ind);
conf->foc_sl_erpm = buffer_get_float32_auto(buffer, &ind);
conf->foc_control_sample_mode = buffer[ind++];
conf->foc_current_sample_mode = buffer[ind++];
conf->foc_sat_comp_mode = buffer[ind++];
conf->foc_sat_comp = buffer_get_float16(buffer, 1000, &ind);
conf->foc_temp_comp = buffer[ind++];
conf->foc_temp_comp_base_temp = buffer_get_float16(buffer, 100, &ind);
conf->foc_current_filter_const = buffer_get_float16(buffer, 10000, &ind);
conf->foc_cc_decoupling = buffer[ind++];
conf->foc_observer_type = buffer[ind++];
conf->foc_hfi_amb_mode = buffer[ind++];
conf->foc_hfi_amb_current = buffer_get_float16(buffer, 10, &ind);
conf->foc_hfi_amb_tres = buffer[ind++];
conf->foc_hfi_voltage_start = buffer_get_float16(buffer, 10, &ind);
conf->foc_hfi_voltage_run = buffer_get_float16(buffer, 10, &ind);
conf->foc_hfi_voltage_max = buffer_get_float16(buffer, 10, &ind);
conf->foc_hfi_gain = buffer_get_float16(buffer, 1000, &ind);
conf->foc_hfi_max_err = buffer_get_float16(buffer, 1000, &ind);
conf->foc_hfi_hyst = buffer_get_float16(buffer, 100, &ind);
conf->foc_sl_erpm_hfi = buffer_get_float32_auto(buffer, &ind);
conf->foc_hfi_start_samples = buffer_get_uint16(buffer, &ind);
conf->foc_hfi_obs_ovr_sec = buffer_get_float32_auto(buffer, &ind);
conf->foc_hfi_samples = buffer[ind++];
conf->foc_offsets_cal_mode = buffer[ind++];
conf->foc_offsets_current[0] = buffer_get_float32_auto(buffer, &ind);
conf->foc_offsets_current[1] = buffer_get_float32_auto(buffer, &ind);
conf->foc_offsets_current[2] = buffer_get_float32_auto(buffer, &ind);
conf->foc_offsets_voltage[0] = buffer_get_float16(buffer, 10000, &ind);
conf->foc_offsets_voltage[1] = buffer_get_float16(buffer, 10000, &ind);
conf->foc_offsets_voltage[2] = buffer_get_float16(buffer, 10000, &ind);
conf->foc_offsets_voltage_undriven[0] = buffer_get_float16(buffer, 10000, &ind);
conf->foc_offsets_voltage_undriven[1] = buffer_get_float16(buffer, 10000, &ind);
conf->foc_offsets_voltage_undriven[2] = buffer_get_float16(buffer, 10000, &ind);
conf->foc_phase_filter_enable = buffer[ind++];
conf->foc_phase_filter_disable_fault = buffer[ind++];
conf->foc_phase_filter_max_erpm = buffer_get_float32_auto(buffer, &ind);
conf->foc_mtpa_mode = buffer[ind++];
conf->foc_fw_current_max = buffer_get_float32_auto(buffer, &ind);
conf->foc_fw_duty_start = buffer_get_float16(buffer, 10000, &ind);
conf->foc_fw_ramp_time = buffer_get_float16(buffer, 1000, &ind);
conf->foc_fw_q_current_factor = buffer_get_float16(buffer, 10000, &ind);
conf->foc_speed_soure = buffer[ind++];
conf->foc_short_ls_on_zero_duty = buffer[ind++];
conf->sp_pid_loop_rate = buffer[ind++];
conf->s_pid_kp = buffer_get_float32_auto(buffer, &ind);
conf->s_pid_ki = buffer_get_float32_auto(buffer, &ind);
conf->s_pid_kd = buffer_get_float32_auto(buffer, &ind);
conf->s_pid_kd_filter = buffer_get_float16(buffer, 10000, &ind);
conf->s_pid_min_erpm = buffer_get_float32_auto(buffer, &ind);
conf->s_pid_allow_braking = buffer[ind++];
conf->s_pid_ramp_erpms_s = buffer_get_float32_auto(buffer, &ind);
conf->s_pid_speed_source = buffer[ind++];
conf->p_pid_kp = buffer_get_float32_auto(buffer, &ind);
conf->p_pid_ki = buffer_get_float32_auto(buffer, &ind);
conf->p_pid_kd = buffer_get_float32_auto(buffer, &ind);
conf->p_pid_kd_proc = buffer_get_float32_auto(buffer, &ind);
conf->p_pid_kd_filter = buffer_get_float16(buffer, 10000, &ind);
conf->p_pid_ang_div = buffer_get_float32_auto(buffer, &ind);
conf->p_pid_gain_dec_angle = buffer_get_float16(buffer, 10, &ind);
conf->p_pid_offset = buffer_get_float32_auto(buffer, &ind);
conf->cc_startup_boost_duty = buffer_get_float16(buffer, 10000, &ind);
conf->cc_min_current = buffer_get_float32_auto(buffer, &ind);
conf->cc_gain = buffer_get_float32_auto(buffer, &ind);
conf->cc_ramp_step_max = buffer_get_float16(buffer, 10000, &ind);
conf->m_fault_stop_time_ms = buffer_get_int32(buffer, &ind);
conf->m_duty_ramp_step = buffer_get_float16(buffer, 10000, &ind);
conf->m_current_backoff_gain = buffer_get_float32_auto(buffer, &ind);
conf->m_encoder_counts = buffer_get_uint32(buffer, &ind);
conf->m_encoder_sin_amp = buffer_get_float16(buffer, 1000, &ind);
conf->m_encoder_cos_amp = buffer_get_float16(buffer, 1000, &ind);
conf->m_encoder_sin_offset = buffer_get_float16(buffer, 1000, &ind);
conf->m_encoder_cos_offset = buffer_get_float16(buffer, 1000, &ind);
conf->m_encoder_sincos_filter_constant = buffer_get_float16(buffer, 1000, &ind);
conf->m_encoder_sincos_phase_correction = buffer_get_float16(buffer, 1000, &ind);
conf->m_sensor_port_mode = buffer[ind++];
conf->m_invert_direction = buffer[ind++];
conf->m_drv8301_oc_mode = buffer[ind++];
conf->m_drv8301_oc_adj = buffer[ind++];
conf->m_bldc_f_sw_min = buffer_get_float32_auto(buffer, &ind);
conf->m_bldc_f_sw_max = buffer_get_float32_auto(buffer, &ind);
conf->m_dc_f_sw = buffer_get_float32_auto(buffer, &ind);
conf->m_ntc_motor_beta = buffer_get_float32_auto(buffer, &ind);
conf->m_out_aux_mode = buffer[ind++];
conf->m_motor_temp_sens_type = buffer[ind++];
conf->m_ptc_motor_coeff = buffer_get_float32_auto(buffer, &ind);
conf->m_ntcx_ptcx_res = buffer_get_float16(buffer, 0.1, &ind);
conf->m_ntcx_ptcx_temp_base = buffer_get_float16(buffer, 10, &ind);
conf->m_hall_extra_samples = buffer[ind++];
conf->m_batt_filter_const = buffer[ind++];
conf->si_motor_poles = buffer[ind++];
conf->si_gear_ratio = buffer_get_float32_auto(buffer, &ind);
conf->si_wheel_diameter = buffer_get_float32_auto(buffer, &ind);
conf->si_battery_type = buffer[ind++];
conf->si_battery_cells = buffer[ind++];
conf->si_battery_ah = buffer_get_float32_auto(buffer, &ind);
conf->si_motor_nl_current = buffer_get_float32_auto(buffer, &ind);
conf->bms.type = buffer[ind++];
conf->bms.limit_mode = buffer[ind++];
conf->bms.t_limit_start = buffer[ind++];
conf->bms.t_limit_end = buffer[ind++];
conf->bms.soc_limit_start = buffer_get_float16(buffer, 1000, &ind);
conf->bms.soc_limit_end = buffer_get_float16(buffer, 1000, &ind);
conf->bms.vmin_limit_start = buffer_get_float16(buffer, 1000, &ind);
conf->bms.vmin_limit_end = buffer_get_float16(buffer, 1000, &ind);
conf->bms.vmax_limit_start = buffer_get_float16(buffer, 1000, &ind);
conf->bms.vmax_limit_end = buffer_get_float16(buffer, 1000, &ind);
conf->bms.fwd_can_mode = buffer[ind++];
return true;
}
bool confgenerator_deserialize_appconf(const uint8_t *buffer, app_configuration *conf) {
int32_t ind = 0;
uint32_t signature = buffer_get_uint32(buffer, &ind);
if (signature != APPCONF_SIGNATURE) {
return false;
}
conf->controller_id = buffer[ind++];
conf->timeout_msec = buffer_get_uint32(buffer, &ind);
conf->timeout_brake_current = buffer_get_float32_auto(buffer, &ind);
conf->can_status_rate_1 = buffer_get_uint16(buffer, &ind);
conf->can_status_rate_2 = buffer_get_uint16(buffer, &ind);
conf->can_status_msgs_r1 = buffer[ind++];
conf->can_status_msgs_r2 = buffer[ind++];
conf->can_baud_rate = buffer[ind++];
conf->pairing_done = buffer[ind++];
conf->permanent_uart_enabled = buffer[ind++];
conf->shutdown_mode = buffer[ind++];
conf->can_mode = buffer[ind++];
conf->uavcan_esc_index = buffer[ind++];
conf->uavcan_raw_mode = buffer[ind++];
conf->uavcan_raw_rpm_max = buffer_get_float32_auto(buffer, &ind);
conf->uavcan_status_current_mode = buffer[ind++];
conf->servo_out_enable = buffer[ind++];
conf->kill_sw_mode = buffer[ind++];
conf->app_to_use = buffer[ind++];
conf->app_ppm_conf.ctrl_type = buffer[ind++];
conf->app_ppm_conf.pid_max_erpm = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.hyst = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.pulse_start = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.pulse_end = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.pulse_center = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.median_filter = buffer[ind++];
conf->app_ppm_conf.safe_start = buffer[ind++];
conf->app_ppm_conf.throttle_exp = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.throttle_exp_brake = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.throttle_exp_mode = buffer[ind++];
conf->app_ppm_conf.ramp_time_pos = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.ramp_time_neg = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.multi_esc = buffer[ind++];
conf->app_ppm_conf.tc = buffer[ind++];
conf->app_ppm_conf.tc_max_diff = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.max_erpm_for_dir = buffer_get_float16(buffer, 1, &ind);
conf->app_ppm_conf.smart_rev_max_duty = buffer_get_float32_auto(buffer, &ind);
conf->app_ppm_conf.smart_rev_ramp_time = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.ctrl_type = buffer[ind++];
conf->app_adc_conf.hyst = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.voltage_start = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.voltage_end = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.voltage_min = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.voltage_max = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.voltage_center = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.voltage2_start = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.voltage2_end = buffer_get_float16(buffer, 1000, &ind);
conf->app_adc_conf.use_filter = buffer[ind++];
conf->app_adc_conf.safe_start = buffer[ind++];
conf->app_adc_conf.buttons = buffer[ind++];
conf->app_adc_conf.voltage_inverted = buffer[ind++];
conf->app_adc_conf.voltage2_inverted = buffer[ind++];
conf->app_adc_conf.throttle_exp = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.throttle_exp_brake = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.throttle_exp_mode = buffer[ind++];
conf->app_adc_conf.ramp_time_pos = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.ramp_time_neg = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.multi_esc = buffer[ind++];
conf->app_adc_conf.tc = buffer[ind++];
conf->app_adc_conf.tc_max_diff = buffer_get_float32_auto(buffer, &ind);
conf->app_adc_conf.update_rate_hz = buffer_get_uint16(buffer, &ind);
conf->app_uart_baudrate = buffer_get_uint32(buffer, &ind);
conf->app_chuk_conf.ctrl_type = buffer[ind++];
conf->app_chuk_conf.hyst = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.ramp_time_pos = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.ramp_time_neg = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.stick_erpm_per_s_in_cc = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.throttle_exp = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.throttle_exp_brake = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.throttle_exp_mode = buffer[ind++];
conf->app_chuk_conf.multi_esc = buffer[ind++];
conf->app_chuk_conf.tc = buffer[ind++];
conf->app_chuk_conf.tc_max_diff = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.use_smart_rev = buffer[ind++];
conf->app_chuk_conf.smart_rev_max_duty = buffer_get_float32_auto(buffer, &ind);
conf->app_chuk_conf.smart_rev_ramp_time = buffer_get_float32_auto(buffer, &ind);
conf->app_nrf_conf.speed = buffer[ind++];
conf->app_nrf_conf.power = buffer[ind++];
conf->app_nrf_conf.crc_type = buffer[ind++];
conf->app_nrf_conf.retry_delay = buffer[ind++];
conf->app_nrf_conf.retries = (int8_t)buffer[ind++];
conf->app_nrf_conf.channel = (int8_t)buffer[ind++];
conf->app_nrf_conf.address[0] = buffer[ind++];
conf->app_nrf_conf.address[1] = buffer[ind++];
conf->app_nrf_conf.address[2] = buffer[ind++];
conf->app_nrf_conf.send_crc_ack = buffer[ind++];
conf->app_pas_conf.ctrl_type = buffer[ind++];
conf->app_pas_conf.sensor_type = buffer[ind++];
conf->app_pas_conf.current_scaling = buffer_get_float16(buffer, 1000, &ind);
conf->app_pas_conf.pedal_rpm_start = buffer_get_float16(buffer, 10, &ind);
conf->app_pas_conf.pedal_rpm_end = buffer_get_float16(buffer, 10, &ind);
conf->app_pas_conf.invert_pedal_direction = buffer[ind++];
conf->app_pas_conf.magnets = buffer_get_uint16(buffer, &ind);
conf->app_pas_conf.use_filter = buffer[ind++];
conf->app_pas_conf.ramp_time_pos = buffer_get_float16(buffer, 100, &ind);
conf->app_pas_conf.ramp_time_neg = buffer_get_float16(buffer, 100, &ind);
conf->app_pas_conf.update_rate_hz = buffer_get_uint16(buffer, &ind);
conf->imu_conf.type = buffer[ind++];
conf->imu_conf.mode = buffer[ind++];
conf->imu_conf.filter = buffer[ind++];
conf->imu_conf.accel_lowpass_filter_x = buffer_get_float16(buffer, 1, &ind);
conf->imu_conf.accel_lowpass_filter_y = buffer_get_float16(buffer, 1, &ind);
conf->imu_conf.accel_lowpass_filter_z = buffer_get_float16(buffer, 1, &ind);
conf->imu_conf.gyro_lowpass_filter = buffer_get_float16(buffer, 1, &ind);
conf->imu_conf.sample_rate_hz = buffer_get_uint16(buffer, &ind);
conf->imu_conf.use_magnetometer = buffer[ind++];
conf->imu_conf.accel_confidence_decay = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.mahony_kp = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.mahony_ki = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.madgwick_beta = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.rot_roll = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.rot_pitch = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.rot_yaw = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.accel_offsets[0] = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.accel_offsets[1] = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.accel_offsets[2] = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.gyro_offsets[0] = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.gyro_offsets[1] = buffer_get_float32_auto(buffer, &ind);
conf->imu_conf.gyro_offsets[2] = buffer_get_float32_auto(buffer, &ind);
return true;
}
void confgenerator_set_defaults_mcconf(mc_configuration *conf) {
conf->pwm_mode = MCCONF_PWM_MODE;
conf->comm_mode = MCCONF_COMM_MODE;
conf->motor_type = MCCONF_DEFAULT_MOTOR_TYPE;
conf->sensor_mode = MCCONF_SENSOR_MODE;
conf->l_current_max = MCCONF_L_CURRENT_MAX;
conf->l_current_min = MCCONF_L_CURRENT_MIN;
conf->l_in_current_max = MCCONF_L_IN_CURRENT_MAX;
conf->l_in_current_min = MCCONF_L_IN_CURRENT_MIN;
conf->l_in_current_map_start = MCCONF_L_IN_CURRENT_MAP_START;
conf->l_in_current_map_filter = MCCONF_L_IN_CURRENT_MAP_FILTER;
conf->l_abs_current_max = MCCONF_L_MAX_ABS_CURRENT;
conf->l_min_erpm = MCCONF_L_RPM_MIN;
conf->l_max_erpm = MCCONF_L_RPM_MAX;
conf->l_erpm_start = MCCONF_L_RPM_START;
conf->l_max_erpm_fbrake = MCCONF_L_CURR_MAX_RPM_FBRAKE;
conf->l_max_erpm_fbrake_cc = MCCONF_L_CURR_MAX_RPM_FBRAKE_CC;
conf->l_min_vin = MCCONF_L_MIN_VOLTAGE;
conf->l_max_vin = MCCONF_L_MAX_VOLTAGE;
conf->l_battery_cut_start = MCCONF_L_BATTERY_CUT_START;
conf->l_battery_cut_end = MCCONF_L_BATTERY_CUT_END;
conf->l_battery_regen_cut_start = MCCONF_L_BATTERY_REGEN_CUT_START;
conf->l_battery_regen_cut_end = MCCONF_L_BATTERY_REGEN_CUT_END;
conf->l_slow_abs_current = MCCONF_L_SLOW_ABS_OVERCURRENT;
conf->l_temp_fet_start = MCCONF_L_LIM_TEMP_FET_START;
conf->l_temp_fet_end = MCCONF_L_LIM_TEMP_FET_END;
conf->l_temp_motor_start = MCCONF_L_LIM_TEMP_MOTOR_START;
conf->l_temp_motor_end = MCCONF_L_LIM_TEMP_MOTOR_END;
conf->l_temp_accel_dec = MCCONF_L_LIM_TEMP_ACCEL_DEC;
conf->l_min_duty = MCCONF_L_MIN_DUTY;
conf->l_max_duty = MCCONF_L_MAX_DUTY;
conf->l_watt_max = MCCONF_L_WATT_MAX;
conf->l_watt_min = MCCONF_L_WATT_MIN;
conf->l_current_max_scale = MCCONF_L_CURRENT_MAX_SCALE;
conf->l_current_min_scale = MCCONF_L_CURRENT_MIN_SCALE;
conf->l_duty_start = MCCONF_L_DUTY_START;
conf->sl_min_erpm = MCCONF_SL_MIN_RPM;
conf->sl_min_erpm_cycle_int_limit = MCCONF_SL_MIN_ERPM_CYCLE_INT_LIMIT;
conf->sl_max_fullbreak_current_dir_change = MCCONF_SL_MAX_FB_CURR_DIR_CHANGE;
conf->sl_cycle_int_limit = MCCONF_SL_CYCLE_INT_LIMIT;
conf->sl_phase_advance_at_br = MCCONF_SL_PHASE_ADVANCE_AT_BR;
conf->sl_cycle_int_rpm_br = MCCONF_SL_CYCLE_INT_BR;
conf->sl_bemf_coupling_k = MCCONF_SL_BEMF_COUPLING_K;
conf->hall_table[0] = MCCONF_HALL_TAB_0;
conf->hall_table[1] = MCCONF_HALL_TAB_1;
conf->hall_table[2] = MCCONF_HALL_TAB_2;
conf->hall_table[3] = MCCONF_HALL_TAB_3;
conf->hall_table[4] = MCCONF_HALL_TAB_4;
conf->hall_table[5] = MCCONF_HALL_TAB_5;
conf->hall_table[6] = MCCONF_HALL_TAB_6;
conf->hall_table[7] = MCCONF_HALL_TAB_7;
conf->hall_sl_erpm = MCCONF_HALL_ERPM;
conf->foc_current_kp = MCCONF_FOC_CURRENT_KP;
conf->foc_current_ki = MCCONF_FOC_CURRENT_KI;
conf->foc_f_zv = MCCONF_FOC_F_ZV;
conf->foc_dt_us = MCCONF_FOC_DT_US;
conf->foc_encoder_inverted = MCCONF_FOC_ENCODER_INVERTED;
conf->foc_encoder_offset = MCCONF_FOC_ENCODER_OFFSET;
conf->foc_encoder_ratio = MCCONF_FOC_ENCODER_RATIO;
conf->foc_sensor_mode = MCCONF_FOC_SENSOR_MODE;
conf->foc_pll_kp = MCCONF_FOC_PLL_KP;
conf->foc_pll_ki = MCCONF_FOC_PLL_KI;
conf->foc_motor_l = MCCONF_FOC_MOTOR_L;
conf->foc_motor_ld_lq_diff = MCCONF_FOC_MOTOR_LD_LQ_DIFF;
conf->foc_motor_r = MCCONF_FOC_MOTOR_R;
conf->foc_motor_flux_linkage = MCCONF_FOC_MOTOR_FLUX_LINKAGE;
conf->foc_observer_gain = MCCONF_FOC_OBSERVER_GAIN;
conf->foc_observer_gain_slow = MCCONF_FOC_OBSERVER_GAIN_SLOW;
conf->foc_observer_offset = MCCONF_FOC_OBSERVER_OFFSET;
conf->foc_duty_dowmramp_kp = MCCONF_FOC_DUTY_DOWNRAMP_KP;
conf->foc_duty_dowmramp_ki = MCCONF_FOC_DUTY_DOWNRAMP_KI;
conf->foc_start_curr_dec = MCCONF_FOC_START_CURR_DEC;
conf->foc_start_curr_dec_rpm = MCCONF_FOC_START_CURR_DEC_RPM;
conf->foc_openloop_rpm = MCCONF_FOC_OPENLOOP_RPM;
conf->foc_openloop_rpm_low = MCCONF_FOC_OPENLOOP_RPM_LOW;
conf->foc_d_gain_scale_start = MCCONF_FOC_D_GAIN_SCALE_START;
conf->foc_d_gain_scale_max_mod = MCCONF_FOC_D_GAIN_SCALE_MAX_MOD;
conf->foc_sl_openloop_hyst = MCCONF_FOC_SL_OPENLOOP_HYST;
conf->foc_sl_openloop_time_lock = MCCONF_FOC_SL_OPENLOOP_T_LOCK;
conf->foc_sl_openloop_time_ramp = MCCONF_FOC_SL_OPENLOOP_T_RAMP;
conf->foc_sl_openloop_time = MCCONF_FOC_SL_OPENLOOP_TIME;
conf->foc_sl_openloop_boost_q = MCCONF_FOC_SL_OPENLOOP_BOOST_Q;
conf->foc_sl_openloop_max_q = MCCONF_FOC_SL_OPENLOOP_MAX_Q;
conf->foc_hall_table[0] = MCCONF_FOC_HALL_TAB_0;
conf->foc_hall_table[1] = MCCONF_FOC_HALL_TAB_1;
conf->foc_hall_table[2] = MCCONF_FOC_HALL_TAB_2;
conf->foc_hall_table[3] = MCCONF_FOC_HALL_TAB_3;
conf->foc_hall_table[4] = MCCONF_FOC_HALL_TAB_4;
conf->foc_hall_table[5] = MCCONF_FOC_HALL_TAB_5;
conf->foc_hall_table[6] = MCCONF_FOC_HALL_TAB_6;
conf->foc_hall_table[7] = MCCONF_FOC_HALL_TAB_7;
conf->foc_hall_interp_erpm = MCCONF_FOC_HALL_INTERP_ERPM;
conf->foc_sl_erpm_start = MCCONF_FOC_SL_ERPM_START;
conf->foc_sl_erpm = MCCONF_FOC_SL_ERPM;
conf->foc_control_sample_mode = MCCONF_FOC_CONTROL_SAMPLE_MODE;
conf->foc_current_sample_mode = MCCONF_FOC_CURRENT_SAMPLE_MODE;
conf->foc_sat_comp_mode = MCCONF_FOC_SAT_COMP_MODE;
conf->foc_sat_comp = MCCONF_FOC_SAT_COMP;
conf->foc_temp_comp = MCCONF_FOC_TEMP_COMP;
conf->foc_temp_comp_base_temp = MCCONF_FOC_TEMP_COMP_BASE_TEMP;
conf->foc_current_filter_const = MCCONF_FOC_CURRENT_FILTER_CONST;
conf->foc_cc_decoupling = MCCONF_FOC_CC_DECOUPLING;
conf->foc_observer_type = MCCONF_FOC_OBSERVER_TYPE;
conf->foc_hfi_amb_mode = MCCONF_FOC_HFI_AMB_MODE;
conf->foc_hfi_amb_current = MCCONF_FOC_HFI_AMB_CURRENT;
conf->foc_hfi_amb_tres = MCCONF_FOC_HFI_AMB_TRES;
conf->foc_hfi_voltage_start = MCCONF_FOC_HFI_VOLTAGE_START;
conf->foc_hfi_voltage_run = MCCONF_FOC_HFI_VOLTAGE_RUN;
conf->foc_hfi_voltage_max = MCCONF_FOC_HFI_VOLTAGE_MAX;
conf->foc_hfi_gain = MCCONF_FOC_HFI_GAIN;
conf->foc_hfi_max_err = MCCONF_FOC_HFI_MAX_ERR;
conf->foc_hfi_hyst = MCCONF_FOC_HFI_HYST;
conf->foc_sl_erpm_hfi = MCCONF_FOC_SL_ERPM_HFI;
conf->foc_hfi_start_samples = MCCONF_FOC_HFI_START_SAMPLES;
conf->foc_hfi_obs_ovr_sec = MCCONF_FOC_HFI_OBS_OVR_SEC;
conf->foc_hfi_samples = MCCONF_FOC_HFI_SAMPLES;
conf->foc_offsets_cal_mode = MCCONF_FOC_OFFSETS_CAL_MODE;
conf->foc_offsets_current[0] = MCCONF_FOC_OFFSETS_CURRENT_0;
conf->foc_offsets_current[1] = MCCONF_FOC_OFFSETS_CURRENT_1;
conf->foc_offsets_current[2] = MCCONF_FOC_OFFSETS_CURRENT_2;
conf->foc_offsets_voltage[0] = MCCONF_FOC_OFFSETS_VOLTAGE_0;
conf->foc_offsets_voltage[1] = MCCONF_FOC_OFFSETS_VOLTAGE_1;
conf->foc_offsets_voltage[2] = MCCONF_FOC_OFFSETS_VOLTAGE_2;
conf->foc_offsets_voltage_undriven[0] = MCCONF_FOC_OFFSETS_VOLTAGE_UNDRIVEN_0;
conf->foc_offsets_voltage_undriven[1] = MCCONF_FOC_OFFSETS_VOLTAGE_UNDRIVEN_1;
conf->foc_offsets_voltage_undriven[2] = MCCONF_FOC_OFFSETS_VOLTAGE_UNDRIVEN_2;
conf->foc_phase_filter_enable = MCCONF_FOC_PHASE_FILTER_ENABLE;
conf->foc_phase_filter_disable_fault = MCCONF_FOC_PHASE_FILTER_DISABLE_FAULT;
conf->foc_phase_filter_max_erpm = MCCONF_FOC_PHASE_FILTER_MAX_ERPM;
conf->foc_mtpa_mode = MCCONF_FOC_MTPA_MODE;
conf->foc_fw_current_max = MCCONF_FOC_FW_CURRENT_MAX;
conf->foc_fw_duty_start = MCCONF_FOC_FW_DUTY_START;
conf->foc_fw_ramp_time = MCCONF_FOC_FW_RAMP_TIME;
conf->foc_fw_q_current_factor = MCCONF_FOC_FW_Q_CURRENT_FACTOR;
conf->foc_speed_soure = MCCONF_FOC_SPEED_SOURCE;
conf->foc_short_ls_on_zero_duty = MCCONF_FOC_SHORT_LS_ON_ZERO_DUTY;
conf->sp_pid_loop_rate = MCCONF_SP_PID_LOOP_RATE;
conf->s_pid_kp = MCCONF_S_PID_KP;
conf->s_pid_ki = MCCONF_S_PID_KI;
conf->s_pid_kd = MCCONF_S_PID_KD;
conf->s_pid_kd_filter = MCCONF_S_PID_KD_FILTER;
conf->s_pid_min_erpm = MCCONF_S_PID_MIN_RPM;
conf->s_pid_allow_braking = MCCONF_S_PID_ALLOW_BRAKING;
conf->s_pid_ramp_erpms_s = MCCONF_S_PID_RAMP_ERPMS_S;
conf->s_pid_speed_source = MCCONF_S_PID_SPEED_SOURCE;
conf->p_pid_kp = MCCONF_P_PID_KP;
conf->p_pid_ki = MCCONF_P_PID_KI;
conf->p_pid_kd = MCCONF_P_PID_KD;
conf->p_pid_kd_proc = MCCONF_P_PID_KD_PROC;
conf->p_pid_kd_filter = MCCONF_P_PID_KD_FILTER;
conf->p_pid_ang_div = MCCONF_P_PID_ANG_DIV;
conf->p_pid_gain_dec_angle = MCCONF_P_PID_GAIN_DEC_ANGLE;
conf->p_pid_offset = MCCONF_P_PID_OFFSET;
conf->cc_startup_boost_duty = MCCONF_CC_STARTUP_BOOST_DUTY;
conf->cc_min_current = MCCONF_CC_MIN_CURRENT;
conf->cc_gain = MCCONF_CC_GAIN;
conf->cc_ramp_step_max = MCCONF_CC_RAMP_STEP;
conf->m_fault_stop_time_ms = MCCONF_M_FAULT_STOP_TIME;
conf->m_duty_ramp_step = MCCONF_M_RAMP_STEP;
conf->m_current_backoff_gain = MCCONF_M_CURRENT_BACKOFF_GAIN;
conf->m_encoder_counts = MCCONF_M_ENCODER_COUNTS;
conf->m_encoder_sin_amp = MCCONF_M_ENCODER_SIN_AMP;
conf->m_encoder_cos_amp = MCCONF_M_ENCODER_COS_AMP;
conf->m_encoder_sin_offset = MCCONF_M_ENCODER_SIN_OFFSET;
conf->m_encoder_cos_offset = MCCONF_M_ENCODER_COS_OFFSET;
conf->m_encoder_sincos_filter_constant = MCCONF_M_ENCODER_SINCOS_FILTER;
conf->m_encoder_sincos_phase_correction = MCCONF_M_ENCODER_SINCOS_PHASE;
conf->m_sensor_port_mode = MCCONF_M_SENSOR_PORT_MODE;
conf->m_invert_direction = MCCONF_M_INVERT_DIRECTION;
conf->m_drv8301_oc_mode = MCCONF_M_DRV8301_OC_MODE;
conf->m_drv8301_oc_adj = MCCONF_M_DRV8301_OC_ADJ;
conf->m_bldc_f_sw_min = MCCONF_M_BLDC_F_SW_MIN;
conf->m_bldc_f_sw_max = MCCONF_M_BLDC_F_SW_MAX;
conf->m_dc_f_sw = MCCONF_M_DC_F_SW;
conf->m_ntc_motor_beta = MCCONF_M_NTC_MOTOR_BETA;
conf->m_out_aux_mode = MCCONF_M_OUT_AUX_MODE;
conf->m_motor_temp_sens_type = MCCONF_M_MOTOR_TEMP_SENS_TYPE;
conf->m_ptc_motor_coeff = MCCONF_M_PTC_MOTOR_COEFF;
conf->m_ntcx_ptcx_res = MCCONF_M_NTCX_PTCX_RES;
conf->m_ntcx_ptcx_temp_base = MCCONF_M_NTCX_PTCX_BASE_TEMP;
conf->m_hall_extra_samples = MCCONF_M_HALL_EXTRA_SAMPLES;
conf->m_batt_filter_const = MCCONF_M_BATT_FILTER_CONST;
conf->si_motor_poles = MCCONF_SI_MOTOR_POLES;
conf->si_gear_ratio = MCCONF_SI_GEAR_RATIO;
conf->si_wheel_diameter = MCCONF_SI_WHEEL_DIAMETER;
conf->si_battery_type = MCCONF_SI_BATTERY_TYPE;
conf->si_battery_cells = MCCONF_SI_BATTERY_CELLS;
conf->si_battery_ah = MCCONF_SI_BATTERY_AH;
conf->si_motor_nl_current = MCCONF_SI_MOTOR_NL_CURRENT;
conf->bms.type = MCCONF_BMS_TYPE;
conf->bms.limit_mode = MCCONF_BMS_LIMIT_MODE;
conf->bms.t_limit_start = MCCONF_BMS_T_LIMIT_START;
conf->bms.t_limit_end = MCCONF_BMS_T_LIMIT_END;
conf->bms.soc_limit_start = MCCONF_BMS_SOC_LIMIT_START;
conf->bms.soc_limit_end = MCCONF_BMS_SOC_LIMIT_END;
conf->bms.vmin_limit_start = MCCONF_BMS_VMIN_LIMIT_START;
conf->bms.vmin_limit_end = MCCONF_BMS_VMIN_LIMIT_END;
conf->bms.vmax_limit_start = MCCONF_BMS_VMAX_LIMIT_START;
conf->bms.vmax_limit_end = MCCONF_BMS_VMAX_LIMIT_END;
conf->bms.fwd_can_mode = MCCONF_BMS_FWD_CAN_MODE;
}
void confgenerator_set_defaults_appconf(app_configuration *conf) {
conf->controller_id = HW_DEFAULT_ID;
conf->timeout_msec = APPCONF_TIMEOUT_MSEC;
conf->timeout_brake_current = APPCONF_TIMEOUT_BRAKE_CURRENT;
conf->can_status_rate_1 = APPCONF_CAN_STATUS_RATE_1;
conf->can_status_rate_2 = APPCONF_CAN_STATUS_RATE_2;
conf->can_status_msgs_r1 = APPCONF_CAN_STATUS_MSGS_R1;
conf->can_status_msgs_r2 = APPCONF_CAN_STATUS_MSGS_R2;
conf->can_baud_rate = APPCONF_CAN_BAUD_RATE;
conf->pairing_done = APPCONF_PAIRING_DONE;
conf->permanent_uart_enabled = APPCONF_PERMANENT_UART_ENABLED;
conf->shutdown_mode = APPCONF_SHUTDOWN_MODE;
conf->can_mode = APPCONF_CAN_MODE;
conf->uavcan_esc_index = APPCONF_UAVCAN_ESC_INDEX;
conf->uavcan_raw_mode = APPCONF_UAVCAN_RAW_MODE;
conf->uavcan_raw_rpm_max = APPCONF_UAVCAN_RAW_RPM_MAX;
conf->uavcan_status_current_mode = APPCONF_UAVCAN_STATUS_CURRENT_MODE;
conf->servo_out_enable = APPCONF_SERVO_OUT_ENABLE;
conf->kill_sw_mode = APPCONF_KILL_SW_MODE;
conf->app_to_use = APPCONF_APP_TO_USE;
conf->app_ppm_conf.ctrl_type = APPCONF_PPM_CTRL_TYPE;
conf->app_ppm_conf.pid_max_erpm = APPCONF_PPM_PID_MAX_ERPM;
conf->app_ppm_conf.hyst = APPCONF_PPM_HYST;
conf->app_ppm_conf.pulse_start = APPCONF_PPM_PULSE_START;
conf->app_ppm_conf.pulse_end = APPCONF_PPM_PULSE_END;
conf->app_ppm_conf.pulse_center = APPCONF_PPM_PULSE_CENTER;
conf->app_ppm_conf.median_filter = APPCONF_PPM_MEDIAN_FILTER;
conf->app_ppm_conf.safe_start = APPCONF_PPM_SAFE_START;
conf->app_ppm_conf.throttle_exp = APPCONF_PPM_THROTTLE_EXP;
conf->app_ppm_conf.throttle_exp_brake = APPCONF_PPM_THROTTLE_EXP_BRAKE;
conf->app_ppm_conf.throttle_exp_mode = APPCONF_PPM_THROTTLE_EXP_MODE;
conf->app_ppm_conf.ramp_time_pos = APPCONF_PPM_RAMP_TIME_POS;
conf->app_ppm_conf.ramp_time_neg = APPCONF_PPM_RAMP_TIME_NEG;
conf->app_ppm_conf.multi_esc = APPCONF_PPM_MULTI_ESC;
conf->app_ppm_conf.tc = APPCONF_PPM_TC;
conf->app_ppm_conf.tc_max_diff = APPCONF_PPM_TC_MAX_DIFF;
conf->app_ppm_conf.max_erpm_for_dir = APPCONF_PPM_MAX_ERPM_FOR_DIR;
conf->app_ppm_conf.smart_rev_max_duty = APPCONF_PPM_SMART_REV_MAX_DUTY;
conf->app_ppm_conf.smart_rev_ramp_time = APPCONF_PPM_SMART_REV_RAMP_TIME;
conf->app_adc_conf.ctrl_type = APPCONF_ADC_CTRL_TYPE;
conf->app_adc_conf.hyst = APPCONF_ADC_HYST;
conf->app_adc_conf.voltage_start = APPCONF_ADC_VOLTAGE_START;
conf->app_adc_conf.voltage_end = APPCONF_ADC_VOLTAGE_END;
conf->app_adc_conf.voltage_min = APPCONF_ADC_VOLTAGE_MIN;
conf->app_adc_conf.voltage_max = APPCONF_ADC_VOLTAGE_MAX;
conf->app_adc_conf.voltage_center = APPCONF_ADC_VOLTAGE_CENTER;
conf->app_adc_conf.voltage2_start = APPCONF_ADC_VOLTAGE2_START;
conf->app_adc_conf.voltage2_end = APPCONF_ADC_VOLTAGE2_END;
conf->app_adc_conf.use_filter = APPCONF_ADC_USE_FILTER;
conf->app_adc_conf.safe_start = APPCONF_ADC_SAFE_START;
conf->app_adc_conf.buttons = APPCONF_ADC_BUTTONS;
conf->app_adc_conf.voltage_inverted = APPCONF_ADC_VOLTAGE_INVERTED;
conf->app_adc_conf.voltage2_inverted = APPCONF_ADC_VOLTAGE2_INVERTED;
conf->app_adc_conf.throttle_exp = APPCONF_ADC_THROTTLE_EXP;
conf->app_adc_conf.throttle_exp_brake = APPCONF_ADC_THROTTLE_EXP_BRAKE;
conf->app_adc_conf.throttle_exp_mode = APPCONF_ADC_THROTTLE_EXP_MODE;
conf->app_adc_conf.ramp_time_pos = APPCONF_ADC_RAMP_TIME_POS;
conf->app_adc_conf.ramp_time_neg = APPCONF_ADC_RAMP_TIME_NEG;
conf->app_adc_conf.multi_esc = APPCONF_ADC_MULTI_ESC;
conf->app_adc_conf.tc = APPCONF_ADC_TC;
conf->app_adc_conf.tc_max_diff = APPCONF_ADC_TC_MAX_DIFF;
conf->app_adc_conf.update_rate_hz = APPCONF_ADC_UPDATE_RATE_HZ;
conf->app_uart_baudrate = APPCONF_UART_BAUDRATE;
conf->app_chuk_conf.ctrl_type = APPCONF_CHUK_CTRL_TYPE;
conf->app_chuk_conf.hyst = APPCONF_CHUK_HYST;
conf->app_chuk_conf.ramp_time_pos = APPCONF_CHUK_RAMP_TIME_POS;
conf->app_chuk_conf.ramp_time_neg = APPCONF_CHUK_RAMP_TIME_NEG;
conf->app_chuk_conf.stick_erpm_per_s_in_cc = APPCONF_STICK_ERPM_PER_S_IN_CC;
conf->app_chuk_conf.throttle_exp = APPCONF_CHUK_THROTTLE_EXP;
conf->app_chuk_conf.throttle_exp_brake = APPCONF_CHUK_THROTTLE_EXP_BRAKE;
conf->app_chuk_conf.throttle_exp_mode = APPCONF_CHUK_THROTTLE_EXP_MODE;
conf->app_chuk_conf.multi_esc = APPCONF_CHUK_MULTI_ESC;
conf->app_chuk_conf.tc = APPCONF_CHUK_TC;
conf->app_chuk_conf.tc_max_diff = APPCONF_CHUK_TC_MAX_DIFF;
conf->app_chuk_conf.use_smart_rev = APPCONF_CHUK_USE_SMART_REV;
conf->app_chuk_conf.smart_rev_max_duty = APPCONF_CHUK_SMART_REV_MAX_DUTY;
conf->app_chuk_conf.smart_rev_ramp_time = APPCONF_CHUK_SMART_REV_RAMP_TIME;
conf->app_nrf_conf.speed = APPCONF_NRF_SPEED;
conf->app_nrf_conf.power = APPCONF_NRF_POWER;
conf->app_nrf_conf.crc_type = APPCONF_NRF_CRC;
conf->app_nrf_conf.retry_delay = APPCONF_NRF_RETR_DELAY;
conf->app_nrf_conf.retries = APPCONF_NRF_RETRIES;
conf->app_nrf_conf.channel = APPCONF_NRF_CHANNEL;
conf->app_nrf_conf.address[0] = APPCONF_NRF_ADDR_B0;
conf->app_nrf_conf.address[1] = APPCONF_NRF_ADDR_B1;
conf->app_nrf_conf.address[2] = APPCONF_NRF_ADDR_B2;
conf->app_nrf_conf.send_crc_ack = APPCONF_NRF_SEND_CRC_ACK;
conf->app_pas_conf.ctrl_type = APPCONF_PAS_CTRL_TYPE;
conf->app_pas_conf.sensor_type = APPCONF_PAS_SENSOR_TYPE;
conf->app_pas_conf.current_scaling = APPCONF_PAS_CURRENT_SCALING;
conf->app_pas_conf.pedal_rpm_start = APPCONF_PAS_PEDAL_RPM_START;
conf->app_pas_conf.pedal_rpm_end = APPCONF_PAS_PEDAL_RPM_END;
conf->app_pas_conf.invert_pedal_direction = APPCONF_PAS_INVERT_PEDAL_DIRECTION;
conf->app_pas_conf.magnets = APPCONF_PAS_MAGNETS;
conf->app_pas_conf.use_filter = APPCONF_PAS_USE_FILTER;
conf->app_pas_conf.ramp_time_pos = APPCONF_PAS_RAMP_TIME_POS;
conf->app_pas_conf.ramp_time_neg = APPCONF_PAS_RAMP_TIME_NEG;
conf->app_pas_conf.update_rate_hz = APPCONF_PAS_UPDATE_RATE_HZ;
conf->imu_conf.type = APPCONF_IMU_TYPE;
conf->imu_conf.mode = APPCONF_IMU_AHRS_MODE;
conf->imu_conf.filter = APPCONF_IMU_FILTER;
conf->imu_conf.accel_lowpass_filter_x = APPCONF_IMU_ACCEL_LOWPASS_FILTER_X;
conf->imu_conf.accel_lowpass_filter_y = APPCONF_IMU_ACCEL_LOWPASS_FILTER_Y;
conf->imu_conf.accel_lowpass_filter_z = APPCONF_IMU_ACCEL_LOWPASS_FILTER_Z;
conf->imu_conf.gyro_lowpass_filter = APPCONF_IMU_GYRO_LOWPASS_FILTER;
conf->imu_conf.sample_rate_hz = APPCONF_IMU_SAMPLE_RATE_HZ;
conf->imu_conf.use_magnetometer = APPCONF_IMU_USE_MAGNETOMETER;
conf->imu_conf.accel_confidence_decay = APPCONF_IMU_ACCEL_CONFIDENCE_DECAY;
conf->imu_conf.mahony_kp = APPCONF_IMU_MAHONY_KP;
conf->imu_conf.mahony_ki = APPCONF_IMU_MAHONY_KI;
conf->imu_conf.madgwick_beta = APPCONF_IMU_MADGWICK_BETA;
conf->imu_conf.rot_roll = APPCONF_IMU_ROT_ROLL;
conf->imu_conf.rot_pitch = APPCONF_IMU_ROT_PITCH;
conf->imu_conf.rot_yaw = APPCONF_IMU_ROT_YAW;
conf->imu_conf.accel_offsets[0] = APPCONF_IMU_A_OFFSET_0;
conf->imu_conf.accel_offsets[1] = APPCONF_IMU_A_OFFSET_1;
conf->imu_conf.accel_offsets[2] = APPCONF_IMU_A_OFFSET_2;
conf->imu_conf.gyro_offsets[0] = APPCONF_IMU_G_OFFSET_0;
conf->imu_conf.gyro_offsets[1] = APPCONF_IMU_G_OFFSET_1;
conf->imu_conf.gyro_offsets[2] = APPCONF_IMU_G_OFFSET_2;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/music1273/bldc.git
git@gitee.com:music1273/bldc.git
music1273
bldc
bldc
master

搜索帮助