;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.8.0 #10562 (MINGW64)
;--------------------------------------------------------
	.module motor
	.optsdcc -mstm8
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _TIM1_CAP_COM_IRQHandler
	.globl _ui16_adc_read_battery_voltage_10b
	.globl _ui16_adc_read_battery_current_10b
	.globl _get_configuration_variables
	.globl _GPIO_Init
	.globl _TIM1_CtrlPWMOutputs
	.globl _experimental_high_cadence_mode
	.globl _ui8_wheel_speed_sensor_change_counter
	.globl _ui16_wheel_speed_sensor_counter
	.globl _ui8_wheel_speed_sensor_state_old
	.globl _ui8_wheel_speed_sensor_state
	.globl _ui16_torque_sensor_throttle_max_value
	.globl _ui8_torque_sensor_pas_signal_change_counter
	.globl _ui16_torque_sensor_throttle_processed_value
	.globl _ui16_pas_counter
	.globl _ui8_pas_after_first_pulse
	.globl _ui8_current_controller_flag
	.globl _ui8_current_controller_counter
	.globl _ui16_foc_angle_accumulated
	.globl _ui16_adc_battery_current_accumulated
	.globl _ui16_adc_battery_voltage_accumulated
	.globl _ui8_adc_battery_voltage_cut_off
	.globl _ui8_first_time_run_flag
	.globl _ui8_controller_adc_battery_max_current
	.globl _ui16_counter_adc_battery_current_ramp_up
	.globl _ui16_counter_duty_cycle_ramp_down
	.globl _ui16_counter_duty_cycle_ramp_up
	.globl _ui8_duty_cycle
	.globl _ui8_half_erps_flag
	.globl _ui8_hall_sensors_state_last
	.globl _ui8_hall_sensors_state
	.globl _ui8_motor_controller_state
	.globl _ui8_motor_commutation_type
	.globl _ui8_interpolation_angle
	.globl _ui8_foc_angle
	.globl _ui8_svm_table_index
	.globl _ui8_motor_over_speed_erps_flag
	.globl _ui16_motor_speed_erps
	.globl _ui16_PWM_cycles_counter_total
	.globl _ui16_PWM_cycles_counter_6
	.globl _ui16_PWM_cycles_counter
	.globl _ui8_sin_table
	.globl _ui8_svm_table
	.globl _ui16_torque_sensor_throttle_value
	.globl _ui8_pas_state_old
	.globl _ui8_pas_state
	.globl _ui8_adc_motor_phase_current_offset
	.globl _ui8_adc_target_motor_phase_max_current
	.globl _ui8_adc_motor_phase_current
	.globl _ui8_adc_battery_current
	.globl _ui16_adc_battery_current_10b
	.globl _ui8_adc_battery_current_filtered_10b
	.globl _ui16_adc_battery_voltage_filtered_10b
	.globl _ui16_value
	.globl _ui8_phase_c_voltage
	.globl _ui8_phase_b_voltage
	.globl _ui8_phase_a_voltage
	.globl _ui16_duty_cycle_ramp_down_inverse_step
	.globl _ui16_duty_cycle_ramp_up_inverse_step
	.globl _ui8_duty_cycle_target
	.globl _ui8_motor_rotor_angle
	.globl _ui8_motor_rotor_absolute_angle
	.globl _motor_controller
	.globl _motor_disable_PWM
	.globl _motor_enable_PWM
	.globl _motor_controller_set_state
	.globl _motor_controller_reset_state
	.globl _motor_controller_state_is_set
	.globl _hall_sensor_init
	.globl _motor_init
	.globl _motor_set_pwm_duty_cycle_target
	.globl _motor_set_pwm_duty_cycle_ramp_up_inverse_step
	.globl _motor_set_pwm_duty_cycle_ramp_down_inverse_step
	.globl _motor_set_phase_current_max
	.globl _ui16_motor_get_motor_speed_erps
	.globl _read_battery_voltage
	.globl _read_battery_current
	.globl _calc_foc_angle
	.globl _asin_table
	.globl _motor_get_adc_battery_current_filtered_10b
	.globl _motor_get_adc_battery_voltage_filtered_10b
	.globl _motor_set_adc_battery_voltage_cut_off
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area DATA
G$ui8_motor_rotor_absolute_angle$0_0$0==.
_ui8_motor_rotor_absolute_angle::
	.ds 1
G$ui8_motor_rotor_angle$0_0$0==.
_ui8_motor_rotor_angle::
	.ds 1
G$ui8_duty_cycle_target$0_0$0==.
_ui8_duty_cycle_target::
	.ds 1
G$ui16_duty_cycle_ramp_up_inverse_step$0_0$0==.
_ui16_duty_cycle_ramp_up_inverse_step::
	.ds 2
G$ui16_duty_cycle_ramp_down_inverse_step$0_0$0==.
_ui16_duty_cycle_ramp_down_inverse_step::
	.ds 2
G$ui8_phase_a_voltage$0_0$0==.
_ui8_phase_a_voltage::
	.ds 1
G$ui8_phase_b_voltage$0_0$0==.
_ui8_phase_b_voltage::
	.ds 1
G$ui8_phase_c_voltage$0_0$0==.
_ui8_phase_c_voltage::
	.ds 1
G$ui16_value$0_0$0==.
_ui16_value::
	.ds 2
G$ui16_adc_battery_voltage_filtered_10b$0_0$0==.
_ui16_adc_battery_voltage_filtered_10b::
	.ds 2
G$ui8_adc_battery_current_filtered_10b$0_0$0==.
_ui8_adc_battery_current_filtered_10b::
	.ds 1
G$ui16_adc_battery_current_10b$0_0$0==.
_ui16_adc_battery_current_10b::
	.ds 2
G$ui8_adc_battery_current$0_0$0==.
_ui8_adc_battery_current::
	.ds 1
G$ui8_adc_motor_phase_current$0_0$0==.
_ui8_adc_motor_phase_current::
	.ds 1
G$ui8_adc_target_motor_phase_max_current$0_0$0==.
_ui8_adc_target_motor_phase_max_current::
	.ds 1
G$ui8_adc_motor_phase_current_offset$0_0$0==.
_ui8_adc_motor_phase_current_offset::
	.ds 1
G$ui8_pas_state$0_0$0==.
_ui8_pas_state::
	.ds 1
G$ui8_pas_state_old$0_0$0==.
_ui8_pas_state_old::
	.ds 1
G$ui16_torque_sensor_throttle_value$0_0$0==.
_ui16_torque_sensor_throttle_value::
	.ds 2
Lmotor.TIM1_CAP_COM_IRQHandler$ui8_temp$1_0$424==.
_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424:
	.ds 1
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area INITIALIZED
G$ui8_svm_table$0_0$0==.
_ui8_svm_table::
	.ds 256
G$ui8_sin_table$0_0$0==.
_ui8_sin_table::
	.ds 60
G$ui16_PWM_cycles_counter$0_0$0==.
_ui16_PWM_cycles_counter::
	.ds 2
G$ui16_PWM_cycles_counter_6$0_0$0==.
_ui16_PWM_cycles_counter_6::
	.ds 2
G$ui16_PWM_cycles_counter_total$0_0$0==.
_ui16_PWM_cycles_counter_total::
	.ds 2
G$ui16_motor_speed_erps$0_0$0==.
_ui16_motor_speed_erps::
	.ds 2
G$ui8_motor_over_speed_erps_flag$0_0$0==.
_ui8_motor_over_speed_erps_flag::
	.ds 1
G$ui8_svm_table_index$0_0$0==.
_ui8_svm_table_index::
	.ds 1
G$ui8_foc_angle$0_0$0==.
_ui8_foc_angle::
	.ds 1
G$ui8_interpolation_angle$0_0$0==.
_ui8_interpolation_angle::
	.ds 1
G$ui8_motor_commutation_type$0_0$0==.
_ui8_motor_commutation_type::
	.ds 1
G$ui8_motor_controller_state$0_0$0==.
_ui8_motor_controller_state::
	.ds 1
G$ui8_hall_sensors_state$0_0$0==.
_ui8_hall_sensors_state::
	.ds 1
G$ui8_hall_sensors_state_last$0_0$0==.
_ui8_hall_sensors_state_last::
	.ds 1
G$ui8_half_erps_flag$0_0$0==.
_ui8_half_erps_flag::
	.ds 1
G$ui8_duty_cycle$0_0$0==.
_ui8_duty_cycle::
	.ds 1
G$ui16_counter_duty_cycle_ramp_up$0_0$0==.
_ui16_counter_duty_cycle_ramp_up::
	.ds 2
G$ui16_counter_duty_cycle_ramp_down$0_0$0==.
_ui16_counter_duty_cycle_ramp_down::
	.ds 2
G$ui16_counter_adc_battery_current_ramp_up$0_0$0==.
_ui16_counter_adc_battery_current_ramp_up::
	.ds 2
G$ui8_controller_adc_battery_max_current$0_0$0==.
_ui8_controller_adc_battery_max_current::
	.ds 1
G$ui8_first_time_run_flag$0_0$0==.
_ui8_first_time_run_flag::
	.ds 1
G$ui8_adc_battery_voltage_cut_off$0_0$0==.
_ui8_adc_battery_voltage_cut_off::
	.ds 1
G$ui16_adc_battery_voltage_accumulated$0_0$0==.
_ui16_adc_battery_voltage_accumulated::
	.ds 2
G$ui16_adc_battery_current_accumulated$0_0$0==.
_ui16_adc_battery_current_accumulated::
	.ds 2
G$ui16_foc_angle_accumulated$0_0$0==.
_ui16_foc_angle_accumulated::
	.ds 2
G$ui8_current_controller_counter$0_0$0==.
_ui8_current_controller_counter::
	.ds 1
G$ui8_current_controller_flag$0_0$0==.
_ui8_current_controller_flag::
	.ds 1
G$ui8_pas_after_first_pulse$0_0$0==.
_ui8_pas_after_first_pulse::
	.ds 1
G$ui16_pas_counter$0_0$0==.
_ui16_pas_counter::
	.ds 2
G$ui16_torque_sensor_throttle_processed_value$0_0$0==.
_ui16_torque_sensor_throttle_processed_value::
	.ds 2
G$ui8_torque_sensor_pas_signal_change_counter$0_0$0==.
_ui8_torque_sensor_pas_signal_change_counter::
	.ds 1
G$ui16_torque_sensor_throttle_max_value$0_0$0==.
_ui16_torque_sensor_throttle_max_value::
	.ds 2
G$ui8_wheel_speed_sensor_state$0_0$0==.
_ui8_wheel_speed_sensor_state::
	.ds 1
G$ui8_wheel_speed_sensor_state_old$0_0$0==.
_ui8_wheel_speed_sensor_state_old::
	.ds 1
G$ui16_wheel_speed_sensor_counter$0_0$0==.
_ui16_wheel_speed_sensor_counter::
	.ds 2
G$ui8_wheel_speed_sensor_change_counter$0_0$0==.
_ui8_wheel_speed_sensor_change_counter::
	.ds 1
G$experimental_high_cadence_mode$0_0$0==.
_experimental_high_cadence_mode::
	.ds 1
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
	.area DABS (ABS)

; default segment ordering for linker
	.area HOME
	.area GSINIT
	.area GSFINAL
	.area CONST
	.area INITIALIZER
	.area CODE

;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area HOME
	.area GSINIT
	.area GSFINAL
	.area GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area HOME
	.area HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area CODE
	G$motor_controller$0$0 ==.
	C$motor.c$433$0_0$422 ==.
;	motor.c: 433: void motor_controller (void)
;	-----------------------------------------
;	 function motor_controller
;	-----------------------------------------
_motor_controller:
	C$motor.c$436$1_0$422 ==.
;	motor.c: 436: read_battery_voltage ();
	call	_read_battery_voltage
	C$motor.c$437$1_0$422 ==.
;	motor.c: 437: read_battery_current ();
	call	_read_battery_current
	C$motor.c$440$1_0$422 ==.
;	motor.c: 440: calc_foc_angle ();
	call	_calc_foc_angle
	C$motor.c$441$1_0$422 ==.
;	motor.c: 441: }
	C$motor.c$441$1_0$422 ==.
	XG$motor_controller$0$0 ==.
	ret
	G$TIM1_CAP_COM_IRQHandler$0$0 ==.
	C$motor.c$449$1_0$424 ==.
;	motor.c: 449: void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
;	-----------------------------------------
;	 function TIM1_CAP_COM_IRQHandler
;	-----------------------------------------
_TIM1_CAP_COM_IRQHandler:
	clr	a
	div	x, a
	sub	sp, #21
	C$motor.c$456$1_0$424 ==.
;	motor.c: 456: ADC1->CR2 &= (uint8_t)(~ADC1_CR2_SCAN);
	bres	21506, #1
	C$motor.c$458$1_0$424 ==.
;	motor.c: 458: ADC1->CSR = 0x05;
	mov	0x5400+0, #0x05
	C$motor.c$460$1_0$424 ==.
;	motor.c: 460: ADC1->CR1 |= ADC1_CR1_ADON;
	bset	21505, #0
	C$motor.c$461$1_0$424 ==.
;	motor.c: 461: while(!(ADC1->CSR & ADC1_FLAG_EOC)) ;
00101$:
	ld	a, 0x5400
	jrpl	00101$
	C$motor.c$462$1_0$424 ==.
;	motor.c: 462: ui16_adc_battery_current_10b = ui16_adc_read_battery_current_10b ();
	call	_ui16_adc_read_battery_current_10b
	ldw	_ui16_adc_battery_current_10b+0, x
	C$motor.c$463$1_0$424 ==.
;	motor.c: 463: ui8_adc_battery_current = ui16_adc_battery_current_10b >> 2;
	ldw	x, _ui16_adc_battery_current_10b+0
	srlw	x
	srlw	x
	ld	a, xl
	ld	_ui8_adc_battery_current+0, a
	C$motor.c$466$1_0$424 ==.
;	motor.c: 466: if(ui8_duty_cycle > 0)
	tnz	_ui8_duty_cycle+0
	jreq	00105$
	C$motor.c$468$2_0$425 ==.
;	motor.c: 468: ui8_adc_motor_phase_current = ((ui16_adc_battery_current_10b << 6) / ((uint16_t) ui8_duty_cycle));
	ldw	x, _ui16_adc_battery_current_10b+0
	sllw	x
	sllw	x
	sllw	x
	sllw	x
	sllw	x
	sllw	x
	clrw	y
	ld	a, _ui8_duty_cycle+0
	ld	yl, a
	divw	x, y
	ld	a, xl
	ld	_ui8_adc_motor_phase_current+0, a
	jra	00106$
00105$:
	C$motor.c$472$2_0$426 ==.
;	motor.c: 472: ui8_adc_motor_phase_current = 0;
	clr	_ui8_adc_motor_phase_current+0
00106$:
	C$motor.c$478$1_0$424 ==.
;	motor.c: 478: ADC1->CR2 |= ADC1_CR2_SCAN; // enable scan mode
	bset	21506, #1
	C$motor.c$479$1_0$424 ==.
;	motor.c: 479: ADC1->CSR = 0x07; // clear EOC flag first (selected also channel 7)
	mov	0x5400+0, #0x07
	C$motor.c$480$1_0$424 ==.
;	motor.c: 480: ADC1->CR1 |= ADC1_CR1_ADON; // start ADC1 conversion
	bset	21505, #0
	C$motor.c$490$1_0$424 ==.
;	motor.c: 490: ui8_hall_sensors_state = ((HALL_SENSOR_A__PORT->IDR & HALL_SENSOR_A__PIN) >> 5) |
	ld	a, 0x5015
	and	a, #0x20
	swap	a
	and	a, #0x0f
	srl	a
	ld	(0x14, sp), a
	C$motor.c$491$1_0$424 ==.
;	motor.c: 491: ((HALL_SENSOR_B__PORT->IDR & HALL_SENSOR_B__PIN) >> 1) |
	ld	a, 0x5010
	and	a, #0x04
	srl	a
	or	a, (0x14, sp)
	ld	(0x0b, sp), a
	C$motor.c$492$1_0$424 ==.
;	motor.c: 492: ((HALL_SENSOR_C__PORT->IDR & HALL_SENSOR_C__PIN) >> 3);
	ld	a, 0x500b
	and	a, #0x20
	srl	a
	srl	a
	srl	a
	or	a, (0x0b, sp)
	ld	_ui8_hall_sensors_state+0, a
	C$motor.c$494$1_0$424 ==.
;	motor.c: 494: if(ui8_hall_sensors_state != ui8_hall_sensors_state_last)
	ld	a, _ui8_hall_sensors_state_last+0
	cp	a, _ui8_hall_sensors_state+0
	jrne	00415$
	jp	00128$
00415$:
	C$motor.c$496$2_0$427 ==.
;	motor.c: 496: ui8_hall_sensors_state_last = ui8_hall_sensors_state;
	mov	_ui8_hall_sensors_state_last+0, _ui8_hall_sensors_state+0
	C$motor.c$498$2_0$427 ==.
;	motor.c: 498: switch(ui8_hall_sensors_state)
	ld	a, _ui8_hall_sensors_state+0
	cp	a, #0x06
	jrule	00417$
	jp	00125$
00417$:
	clrw	x
	ld	a, _ui8_hall_sensors_state+0
	ld	xl, a
	sllw	x
	ldw	x, (#00418$, x)
	jp	(x)
00418$:
	.dw	#00125$
	.dw	#00108$
	.dw	#00124$
	.dw	#00107$
	.dw	#00122$
	.dw	#00121$
	.dw	#00123$
	C$motor.c$500$3_0$428 ==.
;	motor.c: 500: case 3:
00107$:
	C$motor.c$501$3_0$428 ==.
;	motor.c: 501: ui8_motor_rotor_absolute_angle = (uint8_t) MOTOR_ROTOR_ANGLE_150;
	mov	_ui8_motor_rotor_absolute_angle+0, #0x74
	C$motor.c$502$3_0$428 ==.
;	motor.c: 502: break;
	jp	00126$
	C$motor.c$504$3_0$428 ==.
;	motor.c: 504: case 1:
00108$:
	C$motor.c$505$3_0$428 ==.
;	motor.c: 505: if(ui8_half_erps_flag == 1)
	ld	a, _ui8_half_erps_flag+0
	dec	a
	jreq	00421$
	jp	00120$
00421$:
	C$motor.c$507$4_0$429 ==.
;	motor.c: 507: ui8_half_erps_flag = 0;
	clr	_ui8_half_erps_flag+0
	C$motor.c$508$4_0$429 ==.
;	motor.c: 508: ui16_PWM_cycles_counter_total = ui16_PWM_cycles_counter;
	ldw	x, _ui16_PWM_cycles_counter+0
	ldw	_ui16_PWM_cycles_counter_total+0, x
	C$motor.c$509$4_0$429 ==.
;	motor.c: 509: ui16_PWM_cycles_counter = 1;
	ldw	x, #0x0001
	ldw	_ui16_PWM_cycles_counter+0, x
	C$motor.c$513$4_0$429 ==.
;	motor.c: 513: if(ui16_PWM_cycles_counter_total > 0)
	ldw	x, _ui16_PWM_cycles_counter_total+0
	jreq	00110$
	C$motor.c$515$5_0$430 ==.
;	motor.c: 515: ui16_motor_speed_erps = ((uint16_t) PWM_CYCLES_SECOND) / ui16_PWM_cycles_counter_total;
	ldw	x, #0x3d09
	ldw	y, _ui16_PWM_cycles_counter_total+0
	divw	x, y
	ldw	_ui16_motor_speed_erps+0, x
	jra	00111$
00110$:
	C$motor.c$519$5_0$431 ==.
;	motor.c: 519: ui16_motor_speed_erps = ((uint16_t) PWM_CYCLES_SECOND);
	ldw	x, #0x3d09
	ldw	_ui16_motor_speed_erps+0, x
00111$:
	C$motor.c$523$4_0$429 ==.
;	motor.c: 523: ui8_motor_over_speed_erps_flag = 0;
	clr	_ui8_motor_over_speed_erps_flag+0
	C$motor.c$526$4_0$429 ==.
;	motor.c: 526: if(ui16_motor_speed_erps > MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES)
	ldw	x, _ui16_motor_speed_erps+0
	cpw	x, #0x000a
	jrule	00117$
	C$motor.c$528$5_0$432 ==.
;	motor.c: 528: if(ui8_motor_commutation_type == BLOCK_COMMUTATION)
	ld	a, _ui8_motor_commutation_type+0
	dec	a
	jrne	00120$
	C$motor.c$530$6_0$433 ==.
;	motor.c: 530: ui8_motor_commutation_type = SINEWAVE_INTERPOLATION_60_DEGREES;
	mov	_ui8_motor_commutation_type+0, #0x02
	C$motor.c$531$6_0$433 ==.
;	motor.c: 531: ui8_ebike_app_state = EBIKE_APP_STATE_MOTOR_RUNNING;
	mov	_ui8_ebike_app_state+0, #0x04
	jra	00120$
00117$:
	C$motor.c$536$5_0$434 ==.
;	motor.c: 536: if(ui8_motor_commutation_type == SINEWAVE_INTERPOLATION_60_DEGREES)
	ld	a, _ui8_motor_commutation_type+0
	cp	a, #0x02
	jrne	00120$
	C$motor.c$538$6_0$435 ==.
;	motor.c: 538: ui8_motor_commutation_type = BLOCK_COMMUTATION;
	mov	_ui8_motor_commutation_type+0, #0x01
	C$motor.c$539$6_0$435 ==.
;	motor.c: 539: ui8_foc_angle = 0;
	clr	_ui8_foc_angle+0
00120$:
	C$motor.c$544$3_0$428 ==.
;	motor.c: 544: ui8_motor_rotor_absolute_angle = (uint8_t) MOTOR_ROTOR_ANGLE_210;
	mov	_ui8_motor_rotor_absolute_angle+0, #0x9e
	C$motor.c$545$3_0$428 ==.
;	motor.c: 545: break;
	jra	00126$
	C$motor.c$547$3_0$428 ==.
;	motor.c: 547: case 5:
00121$:
	C$motor.c$548$3_0$428 ==.
;	motor.c: 548: ui8_motor_rotor_absolute_angle = (uint8_t) MOTOR_ROTOR_ANGLE_270;
	mov	_ui8_motor_rotor_absolute_angle+0, #0xc9
	C$motor.c$549$3_0$428 ==.
;	motor.c: 549: break;
	jra	00126$
	C$motor.c$551$3_0$428 ==.
;	motor.c: 551: case 4:
00122$:
	C$motor.c$552$3_0$428 ==.
;	motor.c: 552: ui8_motor_rotor_absolute_angle = (uint8_t) MOTOR_ROTOR_ANGLE_330;
	mov	_ui8_motor_rotor_absolute_angle+0, #0xf3
	C$motor.c$553$3_0$428 ==.
;	motor.c: 553: break;
	jra	00126$
	C$motor.c$555$3_0$428 ==.
;	motor.c: 555: case 6:
00123$:
	C$motor.c$556$3_0$428 ==.
;	motor.c: 556: ui8_half_erps_flag = 1;
	mov	_ui8_half_erps_flag+0, #0x01
	C$motor.c$558$3_0$428 ==.
;	motor.c: 558: ui8_motor_rotor_absolute_angle = (uint8_t) MOTOR_ROTOR_ANGLE_30;
	mov	_ui8_motor_rotor_absolute_angle+0, #0x1e
	C$motor.c$559$3_0$428 ==.
;	motor.c: 559: break;
	jra	00126$
	C$motor.c$564$3_0$428 ==.
;	motor.c: 564: case 2:
00124$:
	C$motor.c$565$3_0$428 ==.
;	motor.c: 565: ui8_motor_rotor_absolute_angle = (uint8_t) MOTOR_ROTOR_ANGLE_90;
	mov	_ui8_motor_rotor_absolute_angle+0, #0x49
	C$motor.c$566$3_0$428 ==.
;	motor.c: 566: break;
	jra	00126$
	C$motor.c$568$3_0$428 ==.
;	motor.c: 568: default:
00125$:
	C$motor.c$569$3_0$428 ==.
;	motor.c: 569: return;
	jp	00222$
	C$motor.c$571$2_0$427 ==.
;	motor.c: 571: }
00126$:
	C$motor.c$573$2_0$427 ==.
;	motor.c: 573: ui16_PWM_cycles_counter_6 = 1;
	ldw	x, #0x0001
	ldw	_ui16_PWM_cycles_counter_6+0, x
00128$:
	C$motor.c$579$1_0$424 ==.
;	motor.c: 579: if(ui16_PWM_cycles_counter < ((uint16_t) PWM_CYCLES_COUNTER_MAX))
	ldw	x, _ui16_PWM_cycles_counter+0
	cpw	x, #0x0c35
	jrnc	00130$
	C$motor.c$581$2_0$436 ==.
;	motor.c: 581: ui16_PWM_cycles_counter++;
	ldw	x, _ui16_PWM_cycles_counter+0
	incw	x
	ldw	_ui16_PWM_cycles_counter+0, x
	C$motor.c$582$2_0$436 ==.
;	motor.c: 582: ui16_PWM_cycles_counter_6++;
	ldw	x, _ui16_PWM_cycles_counter_6+0
	incw	x
	ldw	_ui16_PWM_cycles_counter_6+0, x
	jra	00131$
00130$:
	C$motor.c$586$2_0$437 ==.
;	motor.c: 586: ui16_PWM_cycles_counter = 1; // don't put to 0 to avoid 0 divisions
	ldw	x, #0x0001
	ldw	_ui16_PWM_cycles_counter+0, x
	C$motor.c$587$2_0$437 ==.
;	motor.c: 587: ui16_PWM_cycles_counter_6 = 1;
	ldw	x, #0x0001
	ldw	_ui16_PWM_cycles_counter_6+0, x
	C$motor.c$588$2_0$437 ==.
;	motor.c: 588: ui8_half_erps_flag = 0;
	clr	_ui8_half_erps_flag+0
	C$motor.c$589$2_0$437 ==.
;	motor.c: 589: ui16_motor_speed_erps = 0;
	clrw	x
	ldw	_ui16_motor_speed_erps+0, x
	C$motor.c$590$2_0$437 ==.
;	motor.c: 590: ui16_PWM_cycles_counter_total = 0xffff;
	ldw	x, #0xffff
	ldw	_ui16_PWM_cycles_counter_total+0, x
	C$motor.c$591$2_0$437 ==.
;	motor.c: 591: ui8_foc_angle = 0;
	clr	_ui8_foc_angle+0
	C$motor.c$592$2_0$437 ==.
;	motor.c: 592: ui8_motor_commutation_type = BLOCK_COMMUTATION;
	mov	_ui8_motor_commutation_type+0, #0x01
	C$motor.c$593$2_0$437 ==.
;	motor.c: 593: ui8_hall_sensors_state_last = 0; // this way we force execution of hall sensors code next time
	clr	_ui8_hall_sensors_state_last+0
00131$:
	C$motor.c$604$1_0$424 ==.
;	motor.c: 604: if(ui8_motor_commutation_type == SINEWAVE_INTERPOLATION_60_DEGREES)
	ld	a, _ui8_motor_commutation_type+0
	cp	a, #0x02
	jrne	00133$
	C$motor.c$608$2_0$438 ==.
;	motor.c: 608: ui8_interpolation_angle = (ui16_PWM_cycles_counter_6 << 8) / ui16_PWM_cycles_counter_total; // this operations take 4.4us
	ld	a, _ui16_PWM_cycles_counter_6+1
	ld	xh, a
	clr	a
	ld	xl, a
	ldw	y, _ui16_PWM_cycles_counter_total+0
	divw	x, y
	ld	a, xl
	ld	_ui8_interpolation_angle+0, a
	C$motor.c$609$2_0$438 ==.
;	motor.c: 609: ui8_motor_rotor_angle = ui8_motor_rotor_absolute_angle + ui8_interpolation_angle;
	ld	a, _ui8_motor_rotor_absolute_angle+0
	add	a, _ui8_interpolation_angle+0
	ld	_ui8_motor_rotor_angle+0, a
	C$motor.c$610$2_0$438 ==.
;	motor.c: 610: ui8_svm_table_index = ui8_motor_rotor_angle + ui8_foc_angle;
	ld	a, _ui8_motor_rotor_angle+0
	add	a, _ui8_foc_angle+0
	ld	_ui8_svm_table_index+0, a
	jra	00134$
00133$:
	C$motor.c$615$2_0$439 ==.
;	motor.c: 615: ui8_svm_table_index = ui8_motor_rotor_absolute_angle + ui8_foc_angle;
	ld	a, _ui8_motor_rotor_absolute_angle+0
	add	a, _ui8_foc_angle+0
	ld	_ui8_svm_table_index+0, a
00134$:
	C$motor.c$619$1_0$424 ==.
;	motor.c: 619: ui8_svm_table_index -= 63;
	ld	a, _ui8_svm_table_index+0
	sub	a, #0x3f
	ld	_ui8_svm_table_index+0, a
	C$motor.c$631$1_0$424 ==.
;	motor.c: 631: ui8_current_controller_counter++;
	inc	_ui8_current_controller_counter+0
	C$motor.c$632$1_0$424 ==.
;	motor.c: 632: if(ui8_current_controller_counter > 12)
	ld	a, _ui8_current_controller_counter+0
	cp	a, #0x0c
	jrule	00141$
	C$motor.c$634$2_0$440 ==.
;	motor.c: 634: ui8_current_controller_counter = 0;
	clr	_ui8_current_controller_counter+0
	C$motor.c$635$2_0$440 ==.
;	motor.c: 635: if((ui8_adc_battery_current > ui8_controller_adc_battery_max_current)|| // battery max current, reduce duty_cycle
	ld	a, _ui8_controller_adc_battery_max_current+0
	cp	a, _ui8_adc_battery_current+0
	jrc	00137$
	C$motor.c$636$2_0$440 ==.
;	motor.c: 636: (ui8_adc_motor_phase_current > ui8_adc_target_motor_phase_max_current)) // motor max phase current, reduce duty_cycle
	ld	a, _ui8_adc_target_motor_phase_max_current+0
	cp	a, _ui8_adc_motor_phase_current+0
	jrnc	00141$
00137$:
	C$motor.c$638$3_0$441 ==.
;	motor.c: 638: ui8_current_controller_flag = 1;
	mov	_ui8_current_controller_flag+0, #0x01
	C$motor.c$640$3_0$441 ==.
;	motor.c: 640: if(ui8_duty_cycle > 0)
	tnz	_ui8_duty_cycle+0
	jreq	00141$
	C$motor.c$642$4_0$442 ==.
;	motor.c: 642: ui8_duty_cycle--;
	dec	_ui8_duty_cycle+0
00141$:
	C$motor.c$647$1_0$424 ==.
;	motor.c: 647: if(ui8_current_controller_flag) // when we control the current, don't execute next ifs otherwise ui8_duty_cycle would be decremented more than one time on each PWM cycle
	tnz	_ui8_current_controller_flag+0
	jreq	00168$
	C$motor.c$649$2_0$443 ==.
;	motor.c: 649: ui8_current_controller_flag = 0;
	clr	_ui8_current_controller_flag+0
	jp	00169$
00168$:
	C$motor.c$651$1_0$424 ==.
;	motor.c: 651: else if(UI8_ADC_BATTERY_VOLTAGE < ui8_adc_battery_voltage_cut_off) // battery voltage under min voltage, reduce duty_cycle
	ld	a, 0x53ec
	cp	a, _ui8_adc_battery_voltage_cut_off+0
	jrnc	00165$
	C$motor.c$653$2_0$444 ==.
;	motor.c: 653: if(ui8_duty_cycle > 0)
	tnz	_ui8_duty_cycle+0
	jrne	00440$
	jp	00169$
00440$:
	C$motor.c$655$3_0$445 ==.
;	motor.c: 655: ui8_duty_cycle--;
	dec	_ui8_duty_cycle+0
	jp	00169$
00165$:
	C$motor.c$658$1_0$424 ==.
;	motor.c: 658: else if((ui16_motor_speed_erps > MOTOR_OVER_SPEED_ERPS)&& // motor speed over max ERPS, reduce duty_cycle
	ldw	x, _ui16_motor_speed_erps+0
	cpw	x, #0x0208
	jrule	00161$
	C$motor.c$659$1_0$424 ==.
;	motor.c: 659: (ui8_motor_over_speed_erps_flag == 0))
	tnz	_ui8_motor_over_speed_erps_flag+0
	jrne	00161$
	C$motor.c$662$2_0$446 ==.
;	motor.c: 662: if(!experimental_high_cadence_mode || (ui16_motor_speed_erps > MOTOR_OVER_SPEED_ERPS_EXPERIMENTAL))
	tnz	_experimental_high_cadence_mode+0
	jreq	00146$
	ldw	x, _ui16_motor_speed_erps+0
	cpw	x, #0x02bc
	jrugt	00444$
	jp	00169$
00444$:
00146$:
	C$motor.c$664$3_0$447 ==.
;	motor.c: 664: ui8_motor_over_speed_erps_flag = 1;
	mov	_ui8_motor_over_speed_erps_flag+0, #0x01
	C$motor.c$666$3_0$447 ==.
;	motor.c: 666: if(ui8_duty_cycle > 0)
	tnz	_ui8_duty_cycle+0
	jrne	00445$
	jp	00169$
00445$:
	C$motor.c$668$4_0$448 ==.
;	motor.c: 668: ui8_duty_cycle--;
	dec	_ui8_duty_cycle+0
	jp	00169$
00161$:
	C$motor.c$674$2_0$449 ==.
;	motor.c: 674: if(ui8_duty_cycle_target > ui8_duty_cycle)
	ld	a, _ui8_duty_cycle+0
	cp	a, _ui8_duty_cycle_target+0
	jrnc	00158$
	C$motor.c$676$3_0$450 ==.
;	motor.c: 676: if(ui16_counter_duty_cycle_ramp_up++ >= ui16_duty_cycle_ramp_up_inverse_step)
	ldw	y, _ui16_counter_duty_cycle_ramp_up+0
	ldw	x, _ui16_counter_duty_cycle_ramp_up+0
	incw	x
	ldw	_ui16_counter_duty_cycle_ramp_up+0, x
	cpw	y, _ui16_duty_cycle_ramp_up_inverse_step+0
	jrc	00169$
	C$motor.c$678$4_0$451 ==.
;	motor.c: 678: ui16_counter_duty_cycle_ramp_up = 0;
	clrw	x
	ldw	_ui16_counter_duty_cycle_ramp_up+0, x
	C$motor.c$681$4_0$451 ==.
;	motor.c: 681: if(ui8_motor_over_speed_erps_flag == 0)
	tnz	_ui8_motor_over_speed_erps_flag+0
	jrne	00169$
	C$motor.c$683$5_0$452 ==.
;	motor.c: 683: ui8_duty_cycle++;
	inc	_ui8_duty_cycle+0
	jra	00169$
00158$:
	C$motor.c$687$2_0$449 ==.
;	motor.c: 687: else if(ui8_duty_cycle_target < ui8_duty_cycle)
	ld	a, _ui8_duty_cycle+0
	cp	a, _ui8_duty_cycle_target+0
	jrule	00169$
	C$motor.c$689$3_0$453 ==.
;	motor.c: 689: if(ui16_counter_duty_cycle_ramp_down++ >= ui16_duty_cycle_ramp_down_inverse_step)
	ldw	y, _ui16_counter_duty_cycle_ramp_down+0
	ldw	x, _ui16_counter_duty_cycle_ramp_down+0
	incw	x
	ldw	_ui16_counter_duty_cycle_ramp_down+0, x
	cpw	y, _ui16_duty_cycle_ramp_down_inverse_step+0
	jrc	00169$
	C$motor.c$691$4_0$454 ==.
;	motor.c: 691: ui16_counter_duty_cycle_ramp_down = 0;
	clrw	x
	ldw	_ui16_counter_duty_cycle_ramp_down+0, x
	C$motor.c$692$4_0$454 ==.
;	motor.c: 692: ui8_duty_cycle--;
	dec	_ui8_duty_cycle+0
00169$:
	C$motor.c$703$1_0$424 ==.
;	motor.c: 703: ui8_temp = ui8_svm_table [(uint8_t) (ui8_svm_table_index + 171 /* 240° */)];
	ld	a, _ui8_svm_table_index+0
	ld	(0x15, sp), a
	ld	a, (0x15, sp)
	add	a, #0xab
	clrw	x
	ld	xl, a
	addw	x, #_ui8_svm_table
	ld	a, (x)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$704$1_0$424 ==.
;	motor.c: 704: if(ui8_temp > MIDDLE_PWM_DUTY_CYCLE_MAX)
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	cp	a, #0x7f
	jrule	00171$
	C$motor.c$706$2_0$455 ==.
;	motor.c: 706: ui16_value = ((uint16_t) (ui8_temp - MIDDLE_PWM_DUTY_CYCLE_MAX)) * ui8_duty_cycle;
	clrw	x
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	xl, a
	subw	x, #0x007f
	exgw	x, y
	clrw	x
	ld	a, _ui8_duty_cycle+0
	ld	xl, a
	pushw	x
	pushw	y
	call	__mulint
	addw	sp, #4
	ldw	_ui16_value+0, x
	C$motor.c$707$2_0$455 ==.
;	motor.c: 707: ui8_temp = (uint8_t) (ui16_value >> 8);
	ld	a, _ui16_value+0
	clr	(0x03, sp)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$708$2_0$455 ==.
;	motor.c: 708: ui8_phase_a_voltage = MIDDLE_PWM_DUTY_CYCLE_MAX + ui8_temp;
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	add	a, #0x7f
	ld	_ui8_phase_a_voltage+0, a
	jra	00172$
00171$:
	C$motor.c$712$2_0$456 ==.
;	motor.c: 712: ui16_value = ((uint16_t) (MIDDLE_PWM_DUTY_CYCLE_MAX - ui8_temp)) * ui8_duty_cycle;
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	(0x08, sp), a
	clr	(0x07, sp)
	ldw	y, #0x007f
	subw	y, (0x07, sp)
	clrw	x
	ld	a, _ui8_duty_cycle+0
	ld	xl, a
	pushw	x
	pushw	y
	call	__mulint
	addw	sp, #4
	ldw	_ui16_value+0, x
	C$motor.c$713$2_0$456 ==.
;	motor.c: 713: ui8_temp = (uint8_t) (ui16_value >> 8);
	ld	a, _ui16_value+0
	clr	(0x12, sp)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$714$2_0$456 ==.
;	motor.c: 714: ui8_phase_a_voltage = MIDDLE_PWM_DUTY_CYCLE_MAX - ui8_temp;
	ld	a, #0x7f
	sub	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	_ui8_phase_a_voltage+0, a
00172$:
	C$motor.c$718$1_0$424 ==.
;	motor.c: 718: ui8_temp = ui8_svm_table [ui8_svm_table_index];
	clrw	x
	ld	a, _ui8_svm_table_index+0
	ld	xl, a
	addw	x, #_ui8_svm_table
	ld	a, (x)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$719$1_0$424 ==.
;	motor.c: 719: if(ui8_temp > MIDDLE_PWM_DUTY_CYCLE_MAX)
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	cp	a, #0x7f
	jrule	00174$
	C$motor.c$721$2_0$457 ==.
;	motor.c: 721: ui16_value = ((uint16_t) (ui8_temp - MIDDLE_PWM_DUTY_CYCLE_MAX)) * ui8_duty_cycle;
	clrw	x
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	xl, a
	subw	x, #0x007f
	exgw	x, y
	clrw	x
	ld	a, _ui8_duty_cycle+0
	ld	xl, a
	pushw	x
	pushw	y
	call	__mulint
	addw	sp, #4
	ldw	_ui16_value+0, x
	C$motor.c$722$2_0$457 ==.
;	motor.c: 722: ui8_temp = (uint8_t) (ui16_value >> 8);
	ld	a, _ui16_value+0
	clr	(0x10, sp)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$723$2_0$457 ==.
;	motor.c: 723: ui8_phase_b_voltage = MIDDLE_PWM_DUTY_CYCLE_MAX + ui8_temp;
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	add	a, #0x7f
	ld	_ui8_phase_b_voltage+0, a
	jra	00175$
00174$:
	C$motor.c$727$2_0$458 ==.
;	motor.c: 727: ui16_value = ((uint16_t) (MIDDLE_PWM_DUTY_CYCLE_MAX - ui8_temp)) * ui8_duty_cycle;
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	(0x0d, sp), a
	clr	(0x0c, sp)
	ldw	y, #0x007f
	subw	y, (0x0c, sp)
	clrw	x
	ld	a, _ui8_duty_cycle+0
	ld	xl, a
	pushw	x
	pushw	y
	call	__mulint
	addw	sp, #4
	ldw	_ui16_value+0, x
	C$motor.c$728$2_0$458 ==.
;	motor.c: 728: ui8_temp = (uint8_t) (ui16_value >> 8);
	ld	a, _ui16_value+0
	clr	(0x01, sp)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$729$2_0$458 ==.
;	motor.c: 729: ui8_phase_b_voltage = MIDDLE_PWM_DUTY_CYCLE_MAX - ui8_temp;
	ld	a, #0x7f
	sub	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	_ui8_phase_b_voltage+0, a
00175$:
	C$motor.c$733$1_0$424 ==.
;	motor.c: 733: ui8_temp = ui8_svm_table [(uint8_t) (ui8_svm_table_index + 85 /* 120° */)];
	ld	a, (0x15, sp)
	add	a, #0x55
	clrw	x
	ld	xl, a
	addw	x, #_ui8_svm_table
	ld	a, (x)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$734$1_0$424 ==.
;	motor.c: 734: if(ui8_temp > MIDDLE_PWM_DUTY_CYCLE_MAX)
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	cp	a, #0x7f
	jrule	00177$
	C$motor.c$736$2_0$459 ==.
;	motor.c: 736: ui16_value = ((uint16_t) (ui8_temp - MIDDLE_PWM_DUTY_CYCLE_MAX)) * ui8_duty_cycle;
	clrw	x
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	xl, a
	subw	x, #0x007f
	exgw	x, y
	clrw	x
	ld	a, _ui8_duty_cycle+0
	ld	xl, a
	pushw	x
	pushw	y
	call	__mulint
	addw	sp, #4
	ldw	_ui16_value+0, x
	C$motor.c$737$2_0$459 ==.
;	motor.c: 737: ui8_temp = (uint8_t) (ui16_value >> 8);
	ld	a, _ui16_value+0
	clr	(0x05, sp)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$738$2_0$459 ==.
;	motor.c: 738: ui8_phase_c_voltage = MIDDLE_PWM_DUTY_CYCLE_MAX + ui8_temp;
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	add	a, #0x7f
	ld	_ui8_phase_c_voltage+0, a
	jra	00178$
00177$:
	C$motor.c$742$2_0$460 ==.
;	motor.c: 742: ui16_value = ((uint16_t) (MIDDLE_PWM_DUTY_CYCLE_MAX - ui8_temp)) * ui8_duty_cycle;
	ld	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	(0x0f, sp), a
	clr	(0x0e, sp)
	ldw	y, #0x007f
	subw	y, (0x0e, sp)
	clrw	x
	ld	a, _ui8_duty_cycle+0
	ld	xl, a
	pushw	x
	pushw	y
	call	__mulint
	addw	sp, #4
	ldw	_ui16_value+0, x
	C$motor.c$743$2_0$460 ==.
;	motor.c: 743: ui8_temp = (uint8_t) (ui16_value >> 8);
	ld	a, _ui16_value+0
	clr	(0x09, sp)
	ld	_TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0, a
	C$motor.c$744$2_0$460 ==.
;	motor.c: 744: ui8_phase_c_voltage = MIDDLE_PWM_DUTY_CYCLE_MAX - ui8_temp;
	ld	a, #0x7f
	sub	a, _TIM1_CAP_COM_IRQHandler_ui8_temp_65536_424+0
	ld	_ui8_phase_c_voltage+0, a
00178$:
	C$motor.c$749$1_0$424 ==.
;	motor.c: 749: TIM1->CCR3H = (uint8_t) (ui8_phase_b_voltage >> 7);
	ld	a, _ui8_phase_b_voltage+0
	swap	a
	and	a, #0x0f
	srl	a
	srl	a
	srl	a
	ld	0x5269, a
	C$motor.c$750$1_0$424 ==.
;	motor.c: 750: TIM1->CCR3L = (uint8_t) (ui8_phase_b_voltage << 1);
	ld	a, _ui8_phase_b_voltage+0
	sll	a
	ld	0x526a, a
	C$motor.c$752$1_0$424 ==.
;	motor.c: 752: TIM1->CCR2H = (uint8_t) (ui8_phase_c_voltage >> 7);
	ld	a, _ui8_phase_c_voltage+0
	swap	a
	and	a, #0x0f
	srl	a
	srl	a
	srl	a
	ld	0x5267, a
	C$motor.c$753$1_0$424 ==.
;	motor.c: 753: TIM1->CCR2L = (uint8_t) (ui8_phase_c_voltage << 1);
	ld	a, _ui8_phase_c_voltage+0
	sll	a
	ld	0x5268, a
	C$motor.c$755$1_0$424 ==.
;	motor.c: 755: TIM1->CCR1H = (uint8_t) (ui8_phase_a_voltage >> 7);
	ld	a, _ui8_phase_a_voltage+0
	swap	a
	and	a, #0x0f
	srl	a
	srl	a
	srl	a
	ld	0x5265, a
	C$motor.c$756$1_0$424 ==.
;	motor.c: 756: TIM1->CCR1L = (uint8_t) (ui8_phase_a_voltage << 1);
	ld	a, _ui8_phase_a_voltage+0
	sll	a
	ld	0x5266, a
	C$motor.c$761$1_0$424 ==.
;	motor.c: 761: if(ui8_adc_target_battery_max_current > ui8_controller_adc_battery_max_current)
	ld	a, _ui8_controller_adc_battery_max_current+0
	cp	a, _ui8_adc_target_battery_max_current+0
	jrnc	00184$
	C$motor.c$763$2_0$461 ==.
;	motor.c: 763: if(ui16_counter_adc_battery_current_ramp_up++ >= ADC_BATTERY_CURRENT_RAMP_UP_INVERSE_STEP)
	ldw	y, _ui16_counter_adc_battery_current_ramp_up+0
	ldw	x, _ui16_counter_adc_battery_current_ramp_up+0
	incw	x
	ldw	_ui16_counter_adc_battery_current_ramp_up+0, x
	cpw	y, #0x07a1
	jrc	00185$
	C$motor.c$765$3_0$462 ==.
;	motor.c: 765: ui16_counter_adc_battery_current_ramp_up = 0;
	clrw	x
	ldw	_ui16_counter_adc_battery_current_ramp_up+0, x
	C$motor.c$766$3_0$462 ==.
;	motor.c: 766: ui8_controller_adc_battery_max_current++;
	inc	_ui8_controller_adc_battery_max_current+0
	jra	00185$
00184$:
	C$motor.c$769$1_0$424 ==.
;	motor.c: 769: else if(ui8_adc_target_battery_max_current < ui8_controller_adc_battery_max_current)
	ld	a, _ui8_controller_adc_battery_max_current+0
	cp	a, _ui8_adc_target_battery_max_current+0
	jrule	00185$
	C$motor.c$772$2_0$463 ==.
;	motor.c: 772: ui8_controller_adc_battery_max_current = ui8_adc_target_battery_max_current;
	mov	_ui8_controller_adc_battery_max_current+0, _ui8_adc_target_battery_max_current+0
00185$:
	C$motor.c$779$1_0$424 ==.
;	motor.c: 779: ui16_pas_counter++;
	ldw	x, _ui16_pas_counter+0
	incw	x
	ldw	_ui16_pas_counter+0, x
	C$motor.c$782$1_0$424 ==.
;	motor.c: 782: if((PAS1__PORT->IDR & PAS1__PIN) == 0)
	ld	a, 0x5015
	srl	a
	jrc	00187$
	C$motor.c$784$2_0$464 ==.
;	motor.c: 784: ui8_pas_state = 0;
	clr	_ui8_pas_state+0
	jra	00188$
00187$:
	C$motor.c$788$2_0$465 ==.
;	motor.c: 788: ui8_pas_state = 1;
	mov	_ui8_pas_state+0, #0x01
00188$:
	C$motor.c$792$1_0$424 ==.
;	motor.c: 792: if(ui8_pas_state != ui8_pas_state_old)
	ld	a, _ui8_pas_state_old+0
	cp	a, _ui8_pas_state+0
	jrne	00459$
	jp	00207$
00459$:
	C$motor.c$794$2_0$466 ==.
;	motor.c: 794: ui8_pas_state_old = ui8_pas_state;
	mov	_ui8_pas_state_old+0, _ui8_pas_state+0
	C$motor.c$797$2_0$466 ==.
;	motor.c: 797: if(ui8_pas_state == 1)
	ld	a, _ui8_pas_state+0
	dec	a
	jrne	00204$
	C$motor.c$800$3_0$467 ==.
;	motor.c: 800: if(!ui8_pas_after_first_pulse)
	tnz	_ui8_pas_after_first_pulse+0
	jrne	00196$
	C$motor.c$802$4_0$468 ==.
;	motor.c: 802: ui8_pas_after_first_pulse = 1;
	mov	_ui8_pas_after_first_pulse+0, #0x01
	C$motor.c$803$4_0$468 ==.
;	motor.c: 803: ui16_pas_pwm_cycles_ticks = (uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS;
	ldw	x, #0x124f
	ldw	_ui16_pas_pwm_cycles_ticks+0, x
	jra	00205$
00196$:
	C$motor.c$809$4_0$469 ==.
;	motor.c: 809: if (ui16_pas_counter < ((uint16_t) PAS_ABSOLUTE_MAX_CADENCE_PWM_CYCLE_TICKS))
	ldw	x, _ui16_pas_counter+0
	cpw	x, #0x0138
	jrnc	00190$
	C$motor.c$811$5_0$470 ==.
;	motor.c: 811: ui16_pas_pwm_cycles_ticks = (uint16_t) PAS_ABSOLUTE_MAX_CADENCE_PWM_CYCLE_TICKS;
	ldw	x, #0x0138
	ldw	_ui16_pas_pwm_cycles_ticks+0, x
	jra	00191$
00190$:
	C$motor.c$815$5_0$471 ==.
;	motor.c: 815: ui16_pas_pwm_cycles_ticks = ui16_pas_counter;
	ldw	x, _ui16_pas_counter+0
	ldw	_ui16_pas_pwm_cycles_ticks+0, x
00191$:
	C$motor.c$819$4_0$469 ==.
;	motor.c: 819: if ((PAS2__PORT->IDR & PAS2__PIN) == 0)
	ld	a, 0x5010
	jrmi	00193$
	C$motor.c$821$5_0$472 ==.
;	motor.c: 821: ui8_pedaling_forward = 0;
	clr	_ui8_pedaling_forward+0
	jra	00205$
00193$:
	C$motor.c$825$5_0$473 ==.
;	motor.c: 825: ui8_pedaling_forward = 1;
	mov	_ui8_pedaling_forward+0, #0x01
	jra	00205$
00204$:
	C$motor.c$832$3_0$474 ==.
;	motor.c: 832: if(ui8_pas_after_first_pulse)
	tnz	_ui8_pas_after_first_pulse+0
	jreq	00205$
	C$motor.c$835$4_0$475 ==.
;	motor.c: 835: if ((PAS2__PORT->IDR & PAS2__PIN) != 0)
	ld	a, 0x5010
	jrpl	00199$
	C$motor.c$837$5_0$476 ==.
;	motor.c: 837: ui8_pedaling_forward = 0;
	clr	_ui8_pedaling_forward+0
	jra	00205$
00199$:
	C$motor.c$841$5_0$477 ==.
;	motor.c: 841: ui8_pedaling_forward = 1;
	mov	_ui8_pedaling_forward+0, #0x01
00205$:
	C$motor.c$846$2_0$466 ==.
;	motor.c: 846: ui16_pas_counter = 0;
	clrw	x
	ldw	_ui16_pas_counter+0, x
00207$:
	C$motor.c$874$1_0$424 ==.
;	motor.c: 874: if(ui16_pas_counter > ((uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS))
	ldw	x, _ui16_pas_counter+0
	cpw	x, #0x124f
	jrule	00209$
	C$motor.c$876$2_0$478 ==.
;	motor.c: 876: ui16_pas_pwm_cycles_ticks = (uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS;
	ldw	x, #0x124f
	ldw	_ui16_pas_pwm_cycles_ticks+0, x
	C$motor.c$877$2_0$478 ==.
;	motor.c: 877: ui16_pas_counter = 0;
	clrw	x
	ldw	_ui16_pas_counter+0, x
	C$motor.c$878$2_0$478 ==.
;	motor.c: 878: ui8_pas_after_first_pulse = 0;
	clr	_ui8_pas_after_first_pulse+0
	C$motor.c$879$2_0$478 ==.
;	motor.c: 879: ui8_pedaling_forward = 1;
	mov	_ui8_pedaling_forward+0, #0x01
	C$motor.c$881$2_0$478 ==.
;	motor.c: 881: ui16_torque_sensor_throttle_processed_value = 0;
	clrw	x
	ldw	_ui16_torque_sensor_throttle_processed_value+0, x
00209$:
	C$motor.c$887$1_0$424 ==.
;	motor.c: 887: ui16_wheel_speed_sensor_counter++;
	ldw	x, _ui16_wheel_speed_sensor_counter+0
	incw	x
	ldw	_ui16_wheel_speed_sensor_counter+0, x
	C$motor.c$890$1_0$424 ==.
;	motor.c: 890: if(ui16_wheel_speed_sensor_counter > ((uint16_t) WHEEL_SPEED_SENSOR_MIN_PWM_CYCLE_TICKS))
	ldw	x, _ui16_wheel_speed_sensor_counter+0
	cpw	x, #0xfffe
	jrule	00220$
	C$motor.c$892$2_0$479 ==.
;	motor.c: 892: ui16_wheel_speed_sensor_pwm_cycles_ticks = (uint16_t) WHEEL_SPEED_SENSOR_MIN_PWM_CYCLE_TICKS;
	ldw	x, #0xfffe
	ldw	_ui16_wheel_speed_sensor_pwm_cycles_ticks+0, x
	C$motor.c$893$2_0$479 ==.
;	motor.c: 893: ui16_wheel_speed_sensor_counter = 0;
	clrw	x
	ldw	_ui16_wheel_speed_sensor_counter+0, x
	C$motor.c$894$2_0$479 ==.
;	motor.c: 894: ui8_wheel_speed_sensor_change_counter = 0;
	clr	_ui8_wheel_speed_sensor_change_counter+0
	jp	00221$
00220$:
	C$motor.c$900$2_0$480 ==.
;	motor.c: 900: if(WHEEL_SPEED_SENSOR__PORT->IDR & WHEEL_SPEED_SENSOR__PIN)
	ld	a, 0x5001
	bcp	a, #0x02
	jreq	00211$
	C$motor.c$902$3_0$481 ==.
;	motor.c: 902: ui8_wheel_speed_sensor_state = 1;
	mov	_ui8_wheel_speed_sensor_state+0, #0x01
	jra	00212$
00211$:
	C$motor.c$906$3_0$482 ==.
;	motor.c: 906: ui8_wheel_speed_sensor_state = 0;
	clr	_ui8_wheel_speed_sensor_state+0
00212$:
	C$motor.c$909$2_0$480 ==.
;	motor.c: 909: if(ui8_wheel_speed_sensor_state != ui8_wheel_speed_sensor_state_old) // wheel speed sensor signal did change
	ld	a, _ui8_wheel_speed_sensor_state_old+0
	cp	a, _ui8_wheel_speed_sensor_state+0
	jreq	00221$
	C$motor.c$911$3_0$483 ==.
;	motor.c: 911: ui8_wheel_speed_sensor_state_old = ui8_wheel_speed_sensor_state;
	mov	_ui8_wheel_speed_sensor_state_old+0, _ui8_wheel_speed_sensor_state+0
	C$motor.c$913$3_0$483 ==.
;	motor.c: 913: if(ui8_wheel_speed_sensor_state == 1) // consider only when wheel speed sensor signal transition from 0 to 1
	ld	a, _ui8_wheel_speed_sensor_state+0
	dec	a
	jrne	00221$
	C$motor.c$917$4_0$484 ==.
;	motor.c: 917: ui8_wheel_speed_sensor_change_counter++;
	inc	_ui8_wheel_speed_sensor_change_counter+0
	C$motor.c$919$4_0$484 ==.
;	motor.c: 919: if(ui8_wheel_speed_sensor_change_counter >= 2)
	ld	a, _ui8_wheel_speed_sensor_change_counter+0
	cp	a, #0x02
	jrc	00221$
	C$motor.c$921$5_0$485 ==.
;	motor.c: 921: ui16_wheel_speed_sensor_pwm_cycles_ticks = ui16_wheel_speed_sensor_counter;
	ldw	x, _ui16_wheel_speed_sensor_counter+0
	ldw	_ui16_wheel_speed_sensor_pwm_cycles_ticks+0, x
	C$motor.c$922$5_0$485 ==.
;	motor.c: 922: ui16_wheel_speed_sensor_counter = 0;
	clrw	x
	ldw	_ui16_wheel_speed_sensor_counter+0, x
	C$motor.c$923$5_0$485 ==.
;	motor.c: 923: ui32_wheel_speed_sensor_tick_counter++;
	ldw	x, _ui32_wheel_speed_sensor_tick_counter+2
	addw	x, #0x0001
	ld	a, _ui32_wheel_speed_sensor_tick_counter+1
	adc	a, #0x00
	ld	yl, a
	ld	a, _ui32_wheel_speed_sensor_tick_counter+0
	adc	a, #0x00
	ld	yh, a
	ldw	_ui32_wheel_speed_sensor_tick_counter+2, x
	ldw	_ui32_wheel_speed_sensor_tick_counter+0, y
	C$motor.c$924$5_0$485 ==.
;	motor.c: 924: ui8_wheel_speed_sensor_change_counter = 1; // keep this counter as 1, meaning we just counted one previous change
	mov	_ui8_wheel_speed_sensor_change_counter+0, #0x01
00221$:
	C$motor.c$947$1_0$424 ==.
;	motor.c: 947: TIM1->SR1 = (uint8_t)(~(uint8_t)TIM1_IT_CC4);
	mov	0x5255+0, #0xef
00222$:
	C$motor.c$949$1_0$424 ==.
;	motor.c: 949: }
	addw	sp, #21
	C$motor.c$949$1_0$424 ==.
	XG$TIM1_CAP_COM_IRQHandler$0$0 ==.
	iret
	G$motor_disable_PWM$0$0 ==.
	C$motor.c$951$1_0$487 ==.
;	motor.c: 951: void motor_disable_PWM (void)
;	-----------------------------------------
;	 function motor_disable_PWM
;	-----------------------------------------
_motor_disable_PWM:
	C$motor.c$953$1_0$487 ==.
;	motor.c: 953: TIM1_CtrlPWMOutputs(DISABLE);
	push	#0x00
	call	_TIM1_CtrlPWMOutputs
	pop	a
	C$motor.c$954$1_0$487 ==.
;	motor.c: 954: }
	C$motor.c$954$1_0$487 ==.
	XG$motor_disable_PWM$0$0 ==.
	ret
	G$motor_enable_PWM$0$0 ==.
	C$motor.c$956$1_0$489 ==.
;	motor.c: 956: void motor_enable_PWM (void)
;	-----------------------------------------
;	 function motor_enable_PWM
;	-----------------------------------------
_motor_enable_PWM:
	C$motor.c$958$1_0$489 ==.
;	motor.c: 958: TIM1_CtrlPWMOutputs(ENABLE);
	push	#0x01
	call	_TIM1_CtrlPWMOutputs
	pop	a
	C$motor.c$959$1_0$489 ==.
;	motor.c: 959: }
	C$motor.c$959$1_0$489 ==.
	XG$motor_enable_PWM$0$0 ==.
	ret
	G$motor_controller_set_state$0$0 ==.
	C$motor.c$961$1_0$491 ==.
;	motor.c: 961: void motor_controller_set_state (uint8_t ui8_state)
;	-----------------------------------------
;	 function motor_controller_set_state
;	-----------------------------------------
_motor_controller_set_state:
	C$motor.c$963$1_0$491 ==.
;	motor.c: 963: ui8_motor_controller_state |= ui8_state;
	ld	a, (0x03, sp)
	or	a, _ui8_motor_controller_state+0
	ld	_ui8_motor_controller_state+0, a
	C$motor.c$964$1_0$491 ==.
;	motor.c: 964: }
	C$motor.c$964$1_0$491 ==.
	XG$motor_controller_set_state$0$0 ==.
	ret
	G$motor_controller_reset_state$0$0 ==.
	C$motor.c$966$1_0$493 ==.
;	motor.c: 966: void motor_controller_reset_state (uint8_t ui8_state)
;	-----------------------------------------
;	 function motor_controller_reset_state
;	-----------------------------------------
_motor_controller_reset_state:
	C$motor.c$968$1_0$493 ==.
;	motor.c: 968: ui8_motor_controller_state &= ~ui8_state;
	ld	a, (0x03, sp)
	cpl	a
	and	a, _ui8_motor_controller_state+0
	ld	_ui8_motor_controller_state+0, a
	C$motor.c$969$1_0$493 ==.
;	motor.c: 969: }
	C$motor.c$969$1_0$493 ==.
	XG$motor_controller_reset_state$0$0 ==.
	ret
	G$motor_controller_state_is_set$0$0 ==.
	C$motor.c$971$1_0$495 ==.
;	motor.c: 971: uint8_t motor_controller_state_is_set (uint8_t ui8_state)
;	-----------------------------------------
;	 function motor_controller_state_is_set
;	-----------------------------------------
_motor_controller_state_is_set:
	C$motor.c$973$1_0$495 ==.
;	motor.c: 973: return ui8_motor_controller_state & ui8_state;
	ld	a, (0x03, sp)
	and	a, _ui8_motor_controller_state+0
	C$motor.c$974$1_0$495 ==.
;	motor.c: 974: }
	C$motor.c$974$1_0$495 ==.
	XG$motor_controller_state_is_set$0$0 ==.
	ret
	G$hall_sensor_init$0$0 ==.
	C$motor.c$976$1_0$497 ==.
;	motor.c: 976: void hall_sensor_init (void)
;	-----------------------------------------
;	 function hall_sensor_init
;	-----------------------------------------
_hall_sensor_init:
	C$motor.c$978$1_0$497 ==.
;	motor.c: 978: GPIO_Init (HALL_SENSOR_A__PORT, (GPIO_Pin_TypeDef) HALL_SENSOR_A__PIN, GPIO_MODE_IN_FL_NO_IT);
	push	#0x00
	push	#0x20
	push	#0x14
	push	#0x50
	call	_GPIO_Init
	addw	sp, #4
	C$motor.c$979$1_0$497 ==.
;	motor.c: 979: GPIO_Init (HALL_SENSOR_B__PORT, (GPIO_Pin_TypeDef) HALL_SENSOR_B__PIN, GPIO_MODE_IN_FL_NO_IT);
	push	#0x00
	push	#0x04
	push	#0x0f
	push	#0x50
	call	_GPIO_Init
	addw	sp, #4
	C$motor.c$980$1_0$497 ==.
;	motor.c: 980: GPIO_Init (HALL_SENSOR_C__PORT, (GPIO_Pin_TypeDef) HALL_SENSOR_C__PIN, GPIO_MODE_IN_FL_NO_IT);
	push	#0x00
	push	#0x20
	push	#0x0a
	push	#0x50
	call	_GPIO_Init
	addw	sp, #4
	C$motor.c$981$1_0$497 ==.
;	motor.c: 981: }
	C$motor.c$981$1_0$497 ==.
	XG$hall_sensor_init$0$0 ==.
	ret
	G$motor_init$0$0 ==.
	C$motor.c$983$1_0$499 ==.
;	motor.c: 983: void motor_init (void)
;	-----------------------------------------
;	 function motor_init
;	-----------------------------------------
_motor_init:
	C$motor.c$985$1_0$499 ==.
;	motor.c: 985: motor_set_pwm_duty_cycle_ramp_up_inverse_step (PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP); // each step = 64us
	push	#0x14
	push	#0x00
	call	_motor_set_pwm_duty_cycle_ramp_up_inverse_step
	addw	sp, #2
	C$motor.c$986$1_0$499 ==.
;	motor.c: 986: motor_set_pwm_duty_cycle_ramp_down_inverse_step (PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP); // each step = 64us
	push	#0x14
	push	#0x00
	call	_motor_set_pwm_duty_cycle_ramp_down_inverse_step
	addw	sp, #2
	C$motor.c$987$1_0$499 ==.
;	motor.c: 987: motor_set_phase_current_max (ADC_MOTOR_PHASE_CURRENT_MAX);
	push	#0x30
	call	_motor_set_phase_current_max
	pop	a
	C$motor.c$988$1_0$499 ==.
;	motor.c: 988: }
	C$motor.c$988$1_0$499 ==.
	XG$motor_init$0$0 ==.
	ret
	G$motor_set_pwm_duty_cycle_target$0$0 ==.
	C$motor.c$990$1_0$501 ==.
;	motor.c: 990: void motor_set_pwm_duty_cycle_target (uint8_t ui8_value)
;	-----------------------------------------
;	 function motor_set_pwm_duty_cycle_target
;	-----------------------------------------
_motor_set_pwm_duty_cycle_target:
	C$motor.c$992$1_0$501 ==.
;	motor.c: 992: if(ui8_value > PWM_DUTY_CYCLE_MAX) { ui8_value = PWM_DUTY_CYCLE_MAX; }
	ld	a, (0x03, sp)
	cp	a, #0xfe
	jrule	00102$
	ld	a, #0xfe
	ld	(0x03, sp), a
00102$:
	C$motor.c$995$1_0$501 ==.
;	motor.c: 995: if(ui8_motor_controller_state & MOTOR_CONTROLLER_STATE_BRAKE) { ui8_value = 0; }
	ld	a, _ui8_motor_controller_state+0
	bcp	a, #0x02
	jreq	00104$
	clr	(0x03, sp)
00104$:
	C$motor.c$997$1_0$501 ==.
;	motor.c: 997: ui8_duty_cycle_target = ui8_value;
	ld	a, (0x03, sp)
	ld	_ui8_duty_cycle_target+0, a
	C$motor.c$998$1_0$501 ==.
;	motor.c: 998: }
	C$motor.c$998$1_0$501 ==.
	XG$motor_set_pwm_duty_cycle_target$0$0 ==.
	ret
	G$motor_set_pwm_duty_cycle_ramp_up_inverse_step$0$0 ==.
	C$motor.c$1000$1_0$505 ==.
;	motor.c: 1000: void motor_set_pwm_duty_cycle_ramp_up_inverse_step (uint16_t ui16_value)
;	-----------------------------------------
;	 function motor_set_pwm_duty_cycle_ramp_up_inverse_step
;	-----------------------------------------
_motor_set_pwm_duty_cycle_ramp_up_inverse_step:
	C$motor.c$1002$1_0$505 ==.
;	motor.c: 1002: ui16_duty_cycle_ramp_up_inverse_step = ui16_value;
	ldw	x, (0x03, sp)
	ldw	_ui16_duty_cycle_ramp_up_inverse_step+0, x
	C$motor.c$1003$1_0$505 ==.
;	motor.c: 1003: }
	C$motor.c$1003$1_0$505 ==.
	XG$motor_set_pwm_duty_cycle_ramp_up_inverse_step$0$0 ==.
	ret
	G$motor_set_pwm_duty_cycle_ramp_down_inverse_step$0$0 ==.
	C$motor.c$1005$1_0$507 ==.
;	motor.c: 1005: void motor_set_pwm_duty_cycle_ramp_down_inverse_step (uint16_t ui16_value)
;	-----------------------------------------
;	 function motor_set_pwm_duty_cycle_ramp_down_inverse_step
;	-----------------------------------------
_motor_set_pwm_duty_cycle_ramp_down_inverse_step:
	C$motor.c$1007$1_0$507 ==.
;	motor.c: 1007: ui16_duty_cycle_ramp_down_inverse_step = ui16_value;
	ldw	x, (0x03, sp)
	ldw	_ui16_duty_cycle_ramp_down_inverse_step+0, x
	C$motor.c$1008$1_0$507 ==.
;	motor.c: 1008: }
	C$motor.c$1008$1_0$507 ==.
	XG$motor_set_pwm_duty_cycle_ramp_down_inverse_step$0$0 ==.
	ret
	G$motor_set_phase_current_max$0$0 ==.
	C$motor.c$1010$1_0$509 ==.
;	motor.c: 1010: void motor_set_phase_current_max (uint8_t ui8_value)
;	-----------------------------------------
;	 function motor_set_phase_current_max
;	-----------------------------------------
_motor_set_phase_current_max:
	C$motor.c$1012$1_0$509 ==.
;	motor.c: 1012: ui8_adc_target_motor_phase_max_current = ui8_adc_motor_phase_current_offset + ui8_value;
	ld	a, _ui8_adc_motor_phase_current_offset+0
	add	a, (0x03, sp)
	ld	_ui8_adc_target_motor_phase_max_current+0, a
	C$motor.c$1013$1_0$509 ==.
;	motor.c: 1013: }
	C$motor.c$1013$1_0$509 ==.
	XG$motor_set_phase_current_max$0$0 ==.
	ret
	G$ui16_motor_get_motor_speed_erps$0$0 ==.
	C$motor.c$1015$1_0$511 ==.
;	motor.c: 1015: uint16_t ui16_motor_get_motor_speed_erps (void)
;	-----------------------------------------
;	 function ui16_motor_get_motor_speed_erps
;	-----------------------------------------
_ui16_motor_get_motor_speed_erps:
	C$motor.c$1017$1_0$511 ==.
;	motor.c: 1017: return ui16_motor_speed_erps;
	ldw	x, _ui16_motor_speed_erps+0
	C$motor.c$1018$1_0$511 ==.
;	motor.c: 1018: }
	C$motor.c$1018$1_0$511 ==.
	XG$ui16_motor_get_motor_speed_erps$0$0 ==.
	ret
	G$read_battery_voltage$0$0 ==.
	C$motor.c$1020$1_0$513 ==.
;	motor.c: 1020: void read_battery_voltage (void)
;	-----------------------------------------
;	 function read_battery_voltage
;	-----------------------------------------
_read_battery_voltage:
	C$motor.c$1023$1_0$513 ==.
;	motor.c: 1023: ui16_adc_battery_voltage_accumulated -= ui16_adc_battery_voltage_accumulated >> READ_BATTERY_VOLTAGE_FILTER_COEFFICIENT;
	ldw	x, _ui16_adc_battery_voltage_accumulated+0
	srlw	x
	srlw	x
	negw	x
	addw	x, _ui16_adc_battery_voltage_accumulated+0
	ldw	_ui16_adc_battery_voltage_accumulated+0, x
	C$motor.c$1024$1_0$513 ==.
;	motor.c: 1024: ui16_adc_battery_voltage_accumulated += ui16_adc_read_battery_voltage_10b ();
	call	_ui16_adc_read_battery_voltage_10b
	addw	x, _ui16_adc_battery_voltage_accumulated+0
	ldw	_ui16_adc_battery_voltage_accumulated+0, x
	C$motor.c$1025$1_0$513 ==.
;	motor.c: 1025: ui16_adc_battery_voltage_filtered_10b = ui16_adc_battery_voltage_accumulated >> READ_BATTERY_VOLTAGE_FILTER_COEFFICIENT;
	ldw	x, _ui16_adc_battery_voltage_accumulated+0
	srlw	x
	srlw	x
	ldw	_ui16_adc_battery_voltage_filtered_10b+0, x
	C$motor.c$1026$1_0$513 ==.
;	motor.c: 1026: }
	C$motor.c$1026$1_0$513 ==.
	XG$read_battery_voltage$0$0 ==.
	ret
	G$read_battery_current$0$0 ==.
	C$motor.c$1028$1_0$515 ==.
;	motor.c: 1028: void read_battery_current (void)
;	-----------------------------------------
;	 function read_battery_current
;	-----------------------------------------
_read_battery_current:
	C$motor.c$1031$1_0$515 ==.
;	motor.c: 1031: ui16_adc_battery_current_accumulated -= ui16_adc_battery_current_accumulated >> READ_BATTERY_CURRENT_FILTER_COEFFICIENT;
	ldw	x, _ui16_adc_battery_current_accumulated+0
	srlw	x
	srlw	x
	negw	x
	addw	x, _ui16_adc_battery_current_accumulated+0
	ldw	_ui16_adc_battery_current_accumulated+0, x
	C$motor.c$1032$1_0$515 ==.
;	motor.c: 1032: ui16_adc_battery_current_accumulated += ui16_adc_battery_current_10b;
	ldw	x, _ui16_adc_battery_current_accumulated+0
	addw	x, _ui16_adc_battery_current_10b+0
	ldw	_ui16_adc_battery_current_accumulated+0, x
	C$motor.c$1033$1_0$515 ==.
;	motor.c: 1033: ui8_adc_battery_current_filtered_10b = ui16_adc_battery_current_accumulated >> READ_BATTERY_CURRENT_FILTER_COEFFICIENT;
	ldw	x, _ui16_adc_battery_current_accumulated+0
	srlw	x
	srlw	x
	ld	a, xl
	ld	_ui8_adc_battery_current_filtered_10b+0, a
	C$motor.c$1034$1_0$515 ==.
;	motor.c: 1034: }
	C$motor.c$1034$1_0$515 ==.
	XG$read_battery_current$0$0 ==.
	ret
	G$calc_foc_angle$0$0 ==.
	C$motor.c$1036$1_0$517 ==.
;	motor.c: 1036: void calc_foc_angle (void)
;	-----------------------------------------
;	 function calc_foc_angle
;	-----------------------------------------
_calc_foc_angle:
	sub	sp, #22
	C$motor.c$1047$1_0$517 ==.
;	motor.c: 1047: p_configuration_variables = get_configuration_variables ();
	call	_get_configuration_variables
	ldw	(0x11, sp), x
	C$motor.c$1057$1_0$517 ==.
;	motor.c: 1057: ui16_temp = ui16_adc_battery_voltage_filtered_10b * ADC10BITS_BATTERY_VOLTAGE_PER_ADC_STEP_X512;
	push	_ui16_adc_battery_voltage_filtered_10b+1
	push	_ui16_adc_battery_voltage_filtered_10b+0
	push	#0x2c
	push	#0x00
	call	__mulint
	addw	sp, #4
	ld	a, xh
	C$motor.c$1058$1_0$517 ==.
;	motor.c: 1058: ui16_temp = (ui16_temp >> 8) * ui8_duty_cycle;
	clrw	x
	ld	xl, a
	ld	a, _ui8_duty_cycle+0
	clr	(0x01, sp)
	push	a
	ld	a, (0x02, sp)
	push	a
	pushw	x
	call	__mulint
	addw	sp, #4
	ld	a, xh
	C$motor.c$1059$1_0$517 ==.
;	motor.c: 1059: ui16_e_phase_voltage = ui16_temp >> 9;
	clrw	x
	ld	xl, a
	srlw	x
	ldw	(0x07, sp), x
	C$motor.c$1062$1_0$517 ==.
;	motor.c: 1062: if(ui8_duty_cycle > 10)
	ld	a, _ui8_duty_cycle+0
	cp	a, #0x0a
	jrule	00102$
	C$motor.c$1064$2_0$518 ==.
;	motor.c: 1064: ui16_temp = ((uint16_t) ui8_adc_battery_current_filtered_10b) * ADC_BATTERY_CURRENT_PER_ADC_STEP_X512;
	clrw	x
	ld	a, _ui8_adc_battery_current_filtered_10b+0
	ld	xl, a
	pushw	x
	push	#0x66
	push	#0x00
	call	__mulint
	addw	sp, #4
	C$motor.c$1065$2_0$518 ==.
;	motor.c: 1065: ui32_i_phase_current_x2 = ui16_temp / ui8_duty_cycle;
	clrw	y
	ld	a, _ui8_duty_cycle+0
	ld	yl, a
	divw	x, y
	clrw	y
	ldw	(0x0f, sp), x
	ldw	(0x0d, sp), y
	C$motor.c$1068$2_0$518 ==.
;	motor.c: 1068: p_configuration_variables->ui8_working_status |= 0x40; // bit6 = 1 (motor working)
	ldw	x, (0x11, sp)
	addw	x, #0x0023
	ld	a, (x)
	or	a, #0x40
	ld	(x), a
	jra	00103$
00102$:
	C$motor.c$1073$2_0$519 ==.
;	motor.c: 1073: ui32_i_phase_current_x2 = 0;
	clrw	x
	ldw	(0x0f, sp), x
	ldw	(0x0d, sp), x
	C$motor.c$1076$2_0$519 ==.
;	motor.c: 1076: p_configuration_variables->ui8_working_status &= 0xBF; // bit6 = 0 (motor not working)
	ldw	x, (0x11, sp)
	addw	x, #0x0023
	ld	a, (x)
	and	a, #0xbf
	ld	(x), a
00103$:
	C$motor.c$1081$1_0$517 ==.
;	motor.c: 1081: ui32_w_angular_velocity_x16 = ui16_motor_speed_erps * 101;
	push	_ui16_motor_speed_erps+1
	push	_ui16_motor_speed_erps+0
	push	#0x65
	push	#0x00
	call	__mulint
	addw	sp, #4
	clrw	y
	ldw	(0x15, sp), x
	ldw	(0x13, sp), y
	C$motor.c$1101$1_0$517 ==.
;	motor.c: 1101: switch(p_configuration_variables->ui8_motor_type)
	ldw	x, (0x11, sp)
	ld	a, (0xb, x)
	cp	a, #0x00
	jreq	00104$
	cp	a, #0x01
	jreq	00105$
	cp	a, #0x02
	jreq	00106$
	jra	00107$
	C$motor.c$1103$2_0$520 ==.
;	motor.c: 1103: case 0:
00104$:
	C$motor.c$1104$2_0$520 ==.
;	motor.c: 1104: ui32_l_x1048576 = 142; // 48V motor
	ld	a, #0x8e
	clrw	x
	clr	(0x09, sp)
	C$motor.c$1105$2_0$520 ==.
;	motor.c: 1105: experimental_high_cadence_mode = 0;
	clr	_experimental_high_cadence_mode+0
	C$motor.c$1106$2_0$520 ==.
;	motor.c: 1106: break;
	jra	00108$
	C$motor.c$1108$2_0$520 ==.
;	motor.c: 1108: case 1:
00105$:
	C$motor.c$1109$2_0$520 ==.
;	motor.c: 1109: ui32_l_x1048576 = 80; // 36V motor
	ld	a, #0x50
	clrw	x
	clr	(0x09, sp)
	C$motor.c$1110$2_0$520 ==.
;	motor.c: 1110: experimental_high_cadence_mode = 0;
	clr	_experimental_high_cadence_mode+0
	C$motor.c$1111$2_0$520 ==.
;	motor.c: 1111: break;
	jra	00108$
	C$motor.c$1113$2_0$520 ==.
;	motor.c: 1113: case 2: // experimental high cadence mode
00106$:
	C$motor.c$1114$2_0$520 ==.
;	motor.c: 1114: ui32_l_x1048576 = 115; // confirmed working with the 36V motor (only) by jbalat so far
	ld	a, #0x73
	clrw	x
	clr	(0x09, sp)
	C$motor.c$1115$2_0$520 ==.
;	motor.c: 1115: experimental_high_cadence_mode = 1;
	mov	_experimental_high_cadence_mode+0, #0x01
	C$motor.c$1116$2_0$520 ==.
;	motor.c: 1116: break;
	jra	00108$
	C$motor.c$1118$2_0$520 ==.
;	motor.c: 1118: default:
00107$:
	C$motor.c$1119$2_0$520 ==.
;	motor.c: 1119: ui32_l_x1048576 = 142; // 48V motor
	ld	a, #0x8e
	clrw	x
	clr	(0x09, sp)
	C$motor.c$1120$2_0$520 ==.
;	motor.c: 1120: experimental_high_cadence_mode = 0;
	clr	_experimental_high_cadence_mode+0
	C$motor.c$1122$1_0$517 ==.
;	motor.c: 1122: }
00108$:
	C$motor.c$1125$1_0$517 ==.
;	motor.c: 1125: ui32_temp = ui32_i_phase_current_x2 * ui32_l_x1048576;
	push	a
	pushw	x
	ld	a, (0x0c, sp)
	push	a
	ldw	x, (0x13, sp)
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	call	__mullong
	addw	sp, #8
	ldw	(0x05, sp), x
	C$motor.c$1126$1_0$517 ==.
;	motor.c: 1126: ui32_temp *= ui32_w_angular_velocity_x16;
	ldw	x, (0x15, sp)
	pushw	x
	ldw	x, (0x15, sp)
	pushw	x
	ldw	x, (0x09, sp)
	pushw	x
	pushw	y
	call	__mullong
	addw	sp, #8
	exgw	x, y
	C$motor.c$1127$1_0$517 ==.
;	motor.c: 1127: ui16_iwl_128 = ui32_temp >> 18;
	srlw	x
	srlw	x
	C$motor.c$1130$1_0$517 ==.
;	motor.c: 1130: ui8_foc_angle = asin_table (ui16_iwl_128 / ui16_e_phase_voltage);
	ldw	y, (0x07, sp)
	divw	x, y
	ld	a, xl
	push	a
	call	_asin_table
	addw	sp, #1
	ld	_ui8_foc_angle+0, a
	C$motor.c$1133$1_0$517 ==.
;	motor.c: 1133: ui16_foc_angle_accumulated -= ui16_foc_angle_accumulated >> 4;
	ldw	x, _ui16_foc_angle_accumulated+0
	ld	a, #0x10
	div	x, a
	negw	x
	addw	x, _ui16_foc_angle_accumulated+0
	ldw	_ui16_foc_angle_accumulated+0, x
	C$motor.c$1134$1_0$517 ==.
;	motor.c: 1134: ui16_foc_angle_accumulated += ui8_foc_angle;
	clrw	x
	ld	a, _ui8_foc_angle+0
	ld	xl, a
	addw	x, _ui16_foc_angle_accumulated+0
	ldw	_ui16_foc_angle_accumulated+0, x
	C$motor.c$1135$1_0$517 ==.
;	motor.c: 1135: ui8_foc_angle = ui16_foc_angle_accumulated >> 4;
	ldw	x, _ui16_foc_angle_accumulated+0
	ld	a, #0x10
	div	x, a
	ld	a, xl
	ld	_ui8_foc_angle+0, a
	C$motor.c$1136$1_0$517 ==.
;	motor.c: 1136: }
	addw	sp, #22
	C$motor.c$1136$1_0$517 ==.
	XG$calc_foc_angle$0$0 ==.
	ret
	G$asin_table$0$0 ==.
	C$motor.c$1139$1_0$522 ==.
;	motor.c: 1139: uint8_t asin_table (uint8_t ui8_inverted_angle_x128)
;	-----------------------------------------
;	 function asin_table
;	-----------------------------------------
_asin_table:
	push	a
	C$motor.c$1143$2_0$523 ==.
;	motor.c: 1143: while(ui8_index < SIN_TABLE_LEN)
	clr	(0x01, sp)
00103$:
	ld	a, (0x01, sp)
	cp	a, #0x3c
	jrnc	00105$
	C$motor.c$1145$2_0$523 ==.
;	motor.c: 1145: if(ui8_inverted_angle_x128 < ui8_sin_table [ui8_index])
	clrw	x
	ld	a, (0x01, sp)
	ld	xl, a
	addw	x, #_ui8_sin_table
	ld	a, (x)
	cp	a, (0x04, sp)
	jrugt	00105$
	C$motor.c$1150$2_0$523 ==.
;	motor.c: 1150: ui8_index++;
	inc	(0x01, sp)
	jra	00103$
00105$:
	C$motor.c$1154$1_0$522 ==.
;	motor.c: 1154: return ui8_index--;
	ld	a, (0x01, sp)
	C$motor.c$1155$1_0$522 ==.
;	motor.c: 1155: }
	addw	sp, #1
	C$motor.c$1155$1_0$522 ==.
	XG$asin_table$0$0 ==.
	ret
	G$motor_get_adc_battery_current_filtered_10b$0$0 ==.
	C$motor.c$1157$1_0$526 ==.
;	motor.c: 1157: uint8_t motor_get_adc_battery_current_filtered_10b (void)
;	-----------------------------------------
;	 function motor_get_adc_battery_current_filtered_10b
;	-----------------------------------------
_motor_get_adc_battery_current_filtered_10b:
	C$motor.c$1159$1_0$526 ==.
;	motor.c: 1159: return ui8_adc_battery_current_filtered_10b;
	ld	a, _ui8_adc_battery_current_filtered_10b+0
	C$motor.c$1160$1_0$526 ==.
;	motor.c: 1160: }
	C$motor.c$1160$1_0$526 ==.
	XG$motor_get_adc_battery_current_filtered_10b$0$0 ==.
	ret
	G$motor_get_adc_battery_voltage_filtered_10b$0$0 ==.
	C$motor.c$1162$1_0$528 ==.
;	motor.c: 1162: uint16_t motor_get_adc_battery_voltage_filtered_10b (void)
;	-----------------------------------------
;	 function motor_get_adc_battery_voltage_filtered_10b
;	-----------------------------------------
_motor_get_adc_battery_voltage_filtered_10b:
	C$motor.c$1164$1_0$528 ==.
;	motor.c: 1164: return ui16_adc_battery_voltage_filtered_10b;
	ldw	x, _ui16_adc_battery_voltage_filtered_10b+0
	C$motor.c$1165$1_0$528 ==.
;	motor.c: 1165: }
	C$motor.c$1165$1_0$528 ==.
	XG$motor_get_adc_battery_voltage_filtered_10b$0$0 ==.
	ret
	G$motor_set_adc_battery_voltage_cut_off$0$0 ==.
	C$motor.c$1167$1_0$530 ==.
;	motor.c: 1167: void motor_set_adc_battery_voltage_cut_off (uint8_t ui8_value)
;	-----------------------------------------
;	 function motor_set_adc_battery_voltage_cut_off
;	-----------------------------------------
_motor_set_adc_battery_voltage_cut_off:
	C$motor.c$1169$1_0$530 ==.
;	motor.c: 1169: ui8_adc_battery_voltage_cut_off = ui8_value;
	ld	a, (0x03, sp)
	ld	_ui8_adc_battery_voltage_cut_off+0, a
	C$motor.c$1170$1_0$530 ==.
;	motor.c: 1170: }
	C$motor.c$1170$1_0$530 ==.
	XG$motor_set_adc_battery_voltage_cut_off$0$0 ==.
	ret
	.area CODE
	.area CONST
	.area INITIALIZER
Fmotor$__xinit_ui8_svm_table$0_0$0 == .
__xinit__ui8_svm_table:
	.db #0xef	; 239
	.db #0xf1	; 241
	.db #0xf2	; 242
	.db #0xf3	; 243
	.db #0xf5	; 245
	.db #0xf6	; 246
	.db #0xf7	; 247
	.db #0xf8	; 248
	.db #0xf9	; 249
	.db #0xfa	; 250
	.db #0xfb	; 251
	.db #0xfb	; 251
	.db #0xfc	; 252
	.db #0xfd	; 253
	.db #0xfd	; 253
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xfd	; 253
	.db #0xfd	; 253
	.db #0xfc	; 252
	.db #0xfb	; 251
	.db #0xfa	; 250
	.db #0xfa	; 250
	.db #0xf9	; 249
	.db #0xf8	; 248
	.db #0xf7	; 247
	.db #0xf5	; 245
	.db #0xf4	; 244
	.db #0xf3	; 243
	.db #0xf2	; 242
	.db #0xf0	; 240
	.db #0xef	; 239
	.db #0xec	; 236
	.db #0xe7	; 231
	.db #0xe3	; 227
	.db #0xde	; 222
	.db #0xd9	; 217
	.db #0xd4	; 212
	.db #0xcf	; 207
	.db #0xca	; 202
	.db #0xc5	; 197
	.db #0xbf	; 191
	.db #0xba	; 186
	.db #0xb5	; 181
	.db #0xb0	; 176
	.db #0xaa	; 170
	.db #0xa5	; 165
	.db #0xa0	; 160
	.db #0x9a	; 154
	.db #0x95	; 149
	.db #0x90	; 144
	.db #0x8a	; 138
	.db #0x85	; 133
	.db #0x7f	; 127
	.db #0x7a	; 122	'z'
	.db #0x74	; 116	't'
	.db #0x6f	; 111	'o'
	.db #0x6a	; 106	'j'
	.db #0x64	; 100	'd'
	.db #0x5f	; 95
	.db #0x59	; 89	'Y'
	.db #0x54	; 84	'T'
	.db #0x4f	; 79	'O'
	.db #0x4a	; 74	'J'
	.db #0x44	; 68	'D'
	.db #0x3f	; 63
	.db #0x3a	; 58
	.db #0x35	; 53	'5'
	.db #0x30	; 48	'0'
	.db #0x2b	; 43
	.db #0x26	; 38
	.db #0x21	; 33
	.db #0x1c	; 28
	.db #0x17	; 23
	.db #0x12	; 18
	.db #0x10	; 16
	.db #0x0e	; 14
	.db #0x0d	; 13
	.db #0x0c	; 12
	.db #0x0a	; 10
	.db #0x09	; 9
	.db #0x08	; 8
	.db #0x07	; 7
	.db #0x06	; 6
	.db #0x05	; 5
	.db #0x04	; 4
	.db #0x03	; 3
	.db #0x03	; 3
	.db #0x02	; 2
	.db #0x01	; 1
	.db #0x01	; 1
	.db #0x01	; 1
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x01	; 1
	.db #0x01	; 1
	.db #0x02	; 2
	.db #0x02	; 2
	.db #0x03	; 3
	.db #0x04	; 4
	.db #0x05	; 5
	.db #0x06	; 6
	.db #0x06	; 6
	.db #0x08	; 8
	.db #0x09	; 9
	.db #0x0a	; 10
	.db #0x0b	; 11
	.db #0x0c	; 12
	.db #0x0e	; 14
	.db #0x0f	; 15
	.db #0x11	; 17
	.db #0x0f	; 15
	.db #0x0e	; 14
	.db #0x0c	; 12
	.db #0x0b	; 11
	.db #0x0a	; 10
	.db #0x09	; 9
	.db #0x08	; 8
	.db #0x06	; 6
	.db #0x06	; 6
	.db #0x05	; 5
	.db #0x04	; 4
	.db #0x03	; 3
	.db #0x02	; 2
	.db #0x02	; 2
	.db #0x01	; 1
	.db #0x01	; 1
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x00	; 0
	.db #0x01	; 1
	.db #0x01	; 1
	.db #0x01	; 1
	.db #0x02	; 2
	.db #0x03	; 3
	.db #0x03	; 3
	.db #0x04	; 4
	.db #0x05	; 5
	.db #0x06	; 6
	.db #0x07	; 7
	.db #0x08	; 8
	.db #0x09	; 9
	.db #0x0a	; 10
	.db #0x0c	; 12
	.db #0x0d	; 13
	.db #0x0e	; 14
	.db #0x10	; 16
	.db #0x12	; 18
	.db #0x17	; 23
	.db #0x1c	; 28
	.db #0x21	; 33
	.db #0x26	; 38
	.db #0x2b	; 43
	.db #0x30	; 48	'0'
	.db #0x35	; 53	'5'
	.db #0x3a	; 58
	.db #0x3f	; 63
	.db #0x44	; 68	'D'
	.db #0x4a	; 74	'J'
	.db #0x4f	; 79	'O'
	.db #0x54	; 84	'T'
	.db #0x59	; 89	'Y'
	.db #0x5f	; 95
	.db #0x64	; 100	'd'
	.db #0x6a	; 106	'j'
	.db #0x6f	; 111	'o'
	.db #0x74	; 116	't'
	.db #0x7a	; 122	'z'
	.db #0x7f	; 127
	.db #0x85	; 133
	.db #0x8a	; 138
	.db #0x90	; 144
	.db #0x95	; 149
	.db #0x9a	; 154
	.db #0xa0	; 160
	.db #0xa5	; 165
	.db #0xaa	; 170
	.db #0xb0	; 176
	.db #0xb5	; 181
	.db #0xba	; 186
	.db #0xbf	; 191
	.db #0xc5	; 197
	.db #0xca	; 202
	.db #0xcf	; 207
	.db #0xd4	; 212
	.db #0xd9	; 217
	.db #0xde	; 222
	.db #0xe3	; 227
	.db #0xe7	; 231
	.db #0xec	; 236
	.db #0xef	; 239
	.db #0xf0	; 240
	.db #0xf2	; 242
	.db #0xf3	; 243
	.db #0xf4	; 244
	.db #0xf5	; 245
	.db #0xf7	; 247
	.db #0xf8	; 248
	.db #0xf9	; 249
	.db #0xfa	; 250
	.db #0xfa	; 250
	.db #0xfb	; 251
	.db #0xfc	; 252
	.db #0xfd	; 253
	.db #0xfd	; 253
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xff	; 255
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xfe	; 254
	.db #0xfd	; 253
	.db #0xfd	; 253
	.db #0xfc	; 252
	.db #0xfb	; 251
	.db #0xfb	; 251
	.db #0xfa	; 250
	.db #0xf9	; 249
	.db #0xf8	; 248
	.db #0xf7	; 247
	.db #0xf6	; 246
	.db #0xf5	; 245
	.db #0xf3	; 243
	.db #0xf2	; 242
	.db #0xf1	; 241
	.db #0xef	; 239
	.db #0xee	; 238
Fmotor$__xinit_ui8_sin_table$0_0$0 == .
__xinit__ui8_sin_table:
	.db #0x00	; 0
	.db #0x03	; 3
	.db #0x06	; 6
	.db #0x09	; 9
	.db #0x0c	; 12
	.db #0x10	; 16
	.db #0x13	; 19
	.db #0x16	; 22
	.db #0x19	; 25
	.db #0x1c	; 28
	.db #0x1f	; 31
	.db #0x22	; 34
	.db #0x25	; 37
	.db #0x28	; 40
	.db #0x2b	; 43
	.db #0x2e	; 46
	.db #0x31	; 49	'1'
	.db #0x34	; 52	'4'
	.db #0x36	; 54	'6'
	.db #0x39	; 57	'9'
	.db #0x3c	; 60
	.db #0x3f	; 63
	.db #0x42	; 66	'B'
	.db #0x44	; 68	'D'
	.db #0x47	; 71	'G'
	.db #0x49	; 73	'I'
	.db #0x4c	; 76	'L'
	.db #0x4e	; 78	'N'
	.db #0x51	; 81	'Q'
	.db #0x53	; 83	'S'
	.db #0x56	; 86	'V'
	.db #0x58	; 88	'X'
	.db #0x5a	; 90	'Z'
	.db #0x5c	; 92
	.db #0x5f	; 95
	.db #0x61	; 97	'a'
	.db #0x63	; 99	'c'
	.db #0x65	; 101	'e'
	.db #0x66	; 102	'f'
	.db #0x68	; 104	'h'
	.db #0x6a	; 106	'j'
	.db #0x6c	; 108	'l'
	.db #0x6d	; 109	'm'
	.db #0x6f	; 111	'o'
	.db #0x71	; 113	'q'
	.db #0x72	; 114	'r'
	.db #0x73	; 115	's'
	.db #0x75	; 117	'u'
	.db #0x76	; 118	'v'
	.db #0x77	; 119	'w'
	.db #0x78	; 120	'x'
	.db #0x79	; 121	'y'
	.db #0x7a	; 122	'z'
	.db #0x7b	; 123
	.db #0x7c	; 124
	.db #0x7d	; 125
	.db #0x7d	; 125
	.db #0x7e	; 126
	.db #0x7e	; 126
	.db #0x7f	; 127
Fmotor$__xinit_ui16_PWM_cycles_counter$0_0$0 == .
__xinit__ui16_PWM_cycles_counter:
	.dw #0x0001
Fmotor$__xinit_ui16_PWM_cycles_counter_6$0_0$0 == .
__xinit__ui16_PWM_cycles_counter_6:
	.dw #0x0001
Fmotor$__xinit_ui16_PWM_cycles_counter_total$0_0$0 == .
__xinit__ui16_PWM_cycles_counter_total:
	.dw #0xffff
Fmotor$__xinit_ui16_motor_speed_erps$0_0$0 == .
__xinit__ui16_motor_speed_erps:
	.dw #0x0000
Fmotor$__xinit_ui8_motor_over_speed_erps_flag$0_0$0 == .
__xinit__ui8_motor_over_speed_erps_flag:
	.db #0x00	; 0
Fmotor$__xinit_ui8_svm_table_index$0_0$0 == .
__xinit__ui8_svm_table_index:
	.db #0x00	; 0
Fmotor$__xinit_ui8_foc_angle$0_0$0 == .
__xinit__ui8_foc_angle:
	.db #0x00	; 0
Fmotor$__xinit_ui8_interpolation_angle$0_0$0 == .
__xinit__ui8_interpolation_angle:
	.db #0x00	; 0
Fmotor$__xinit_ui8_motor_commutation_type$0_0$0 == .
__xinit__ui8_motor_commutation_type:
	.db #0x01	; 1
Fmotor$__xinit_ui8_motor_controller_state$0_0$0 == .
__xinit__ui8_motor_controller_state:
	.db #0x01	; 1
Fmotor$__xinit_ui8_hall_sensors_state$0_0$0 == .
__xinit__ui8_hall_sensors_state:
	.db #0x00	; 0
Fmotor$__xinit_ui8_hall_sensors_state_last$0_0$0 == .
__xinit__ui8_hall_sensors_state_last:
	.db #0x00	; 0
Fmotor$__xinit_ui8_half_erps_flag$0_0$0 == .
__xinit__ui8_half_erps_flag:
	.db #0x00	; 0
Fmotor$__xinit_ui8_duty_cycle$0_0$0 == .
__xinit__ui8_duty_cycle:
	.db #0x00	; 0
Fmotor$__xinit_ui16_counter_duty_cycle_ramp_up$0_0$0 == .
__xinit__ui16_counter_duty_cycle_ramp_up:
	.dw #0x0000
Fmotor$__xinit_ui16_counter_duty_cycle_ramp_down$0_0$0 == .
__xinit__ui16_counter_duty_cycle_ramp_down:
	.dw #0x0000
Fmotor$__xinit_ui16_counter_adc_battery_current_ramp_up$0_0$0 == .
__xinit__ui16_counter_adc_battery_current_ramp_up:
	.dw #0x0000
Fmotor$__xinit_ui8_controller_adc_battery_max_current$0_0$0 == .
__xinit__ui8_controller_adc_battery_max_current:
	.db #0x00	; 0
Fmotor$__xinit_ui8_first_time_run_flag$0_0$0 == .
__xinit__ui8_first_time_run_flag:
	.db #0x01	; 1
Fmotor$__xinit_ui8_adc_battery_voltage_cut_off$0_0$0 == .
__xinit__ui8_adc_battery_voltage_cut_off:
	.db #0xff	; 255
Fmotor$__xinit_ui16_adc_battery_voltage_accumulated$0_0$0 == .
__xinit__ui16_adc_battery_voltage_accumulated:
	.dw #0x0000
Fmotor$__xinit_ui16_adc_battery_current_accumulated$0_0$0 == .
__xinit__ui16_adc_battery_current_accumulated:
	.dw #0x0000
Fmotor$__xinit_ui16_foc_angle_accumulated$0_0$0 == .
__xinit__ui16_foc_angle_accumulated:
	.dw #0x0000
Fmotor$__xinit_ui8_current_controller_counter$0_0$0 == .
__xinit__ui8_current_controller_counter:
	.db #0x00	; 0
Fmotor$__xinit_ui8_current_controller_flag$0_0$0 == .
__xinit__ui8_current_controller_flag:
	.db #0x00	; 0
Fmotor$__xinit_ui8_pas_after_first_pulse$0_0$0 == .
__xinit__ui8_pas_after_first_pulse:
	.db #0x00	; 0
Fmotor$__xinit_ui16_pas_counter$0_0$0 == .
__xinit__ui16_pas_counter:
	.dw #0x124f
Fmotor$__xinit_ui16_torque_sensor_throttle_processed_value$0_0$0 == .
__xinit__ui16_torque_sensor_throttle_processed_value:
	.dw #0x0000
Fmotor$__xinit_ui8_torque_sensor_pas_signal_change_counter$0_0$0 == .
__xinit__ui8_torque_sensor_pas_signal_change_counter:
	.db #0x00	; 0
Fmotor$__xinit_ui16_torque_sensor_throttle_max_value$0_0$0 == .
__xinit__ui16_torque_sensor_throttle_max_value:
	.dw #0x0000
Fmotor$__xinit_ui8_wheel_speed_sensor_state$0_0$0 == .
__xinit__ui8_wheel_speed_sensor_state:
	.db #0x01	; 1
Fmotor$__xinit_ui8_wheel_speed_sensor_state_old$0_0$0 == .
__xinit__ui8_wheel_speed_sensor_state_old:
	.db #0x01	; 1
Fmotor$__xinit_ui16_wheel_speed_sensor_counter$0_0$0 == .
__xinit__ui16_wheel_speed_sensor_counter:
	.dw #0x0000
Fmotor$__xinit_ui8_wheel_speed_sensor_change_counter$0_0$0 == .
__xinit__ui8_wheel_speed_sensor_change_counter:
	.db #0x00	; 0
Fmotor$__xinit_experimental_high_cadence_mode$0_0$0 == .
__xinit__experimental_high_cadence_mode:
	.db #0x00	; 0
	.area CABS (ABS)
