;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.8.0 #10562 (MINGW64)
;--------------------------------------------------------
	.module ebike_app
	.optsdcc -mstm8
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _UART2_IRQHandler
	.globl _lights_set_state
	.globl _eeprom_init_variables
	.globl _brake_is_set
	.globl _putchar
	.globl _motor_set_adc_battery_voltage_cut_off
	.globl _motor_get_adc_battery_voltage_filtered_10b
	.globl _motor_get_adc_battery_current_filtered_10b
	.globl _motor_set_pwm_duty_cycle_target
	.globl _ui8_limit_max
	.globl _ui8_min
	.globl _ui8_max
	.globl _map
	.globl _ui16_adc_read_throttle_10b
	.globl _UART2_GetFlagStatus
	.globl _UART2_ReceiveData8
	.globl _ui8_pwm_stopped
	.globl _ui8_pwm_started
	.globl _ui8_boost_flag
	.globl _ui8_mode_flag
	.globl _ui8_lights_flag
	.globl _ui8_default_flag
	.globl _ui8_walk_assist_pwm_step
	.globl _ui8_walk_assist_pwm
	.globl _ui8_walk_assist_start
	.globl _ui8_walk_assist_current_per_cent
	.globl _ui8_walk_assist
	.globl _ui8_walk_assist_flag
	.globl _ui8_enable_walk_assist
	.globl _ui8_display_ready_flag
	.globl _ui8_walk_assist_delay_off_flag
	.globl _ui16_walk_assist_delay_off
	.globl _ui8_lights_counter
	.globl _ui8_startup_counter
	.globl _ui8_timer_counter
	.globl _ui8_battery_state_of_charge
	.globl _ui16_battery_current_accumulated_x5
	.globl _ui32_battery_voltage_accumulated_x10000
	.globl _safe_tests_state_machine_counter
	.globl _safe_tests_state_machine
	.globl _ui16_adc_motor_temperatured_accumulated
	.globl _ui8_rtst_counter
	.globl _ui8_tstr_state_machine
	.globl _ui8_uart_received_first_package
	.globl _ui8_state_machine
	.globl _ui8_tx_counter
	.globl _ui8_rx_counter
	.globl _ui8_received_package_flag
	.globl _ui32_wheel_speed_sensor_tick_counter
	.globl _ui8_wheel_speed_max
	.globl _ui16_wheel_speed_sensor_pwm_cycles_ticks
	.globl _ui8_startup_boost_fade_steps
	.globl _ui8_startup_boost_timer
	.globl _ui8_startup_boost_no_torque
	.globl _ui8_startup_boost_state_machine
	.globl _ui8_startup_boost_fade_enable
	.globl _ui8_startup_boost_enable
	.globl _ui8_pedal_human_power
	.globl _ui8_pas_cadence_rpm
	.globl _ui8_pedaling_forward
	.globl _ui16_pas_pwm_cycles_ticks
	.globl _ui8_ebike_app_state
	.globl _ui8_torque_sensor_raw
	.globl _ui8_torque_sensor
	.globl _ui8_torque_sensor_value1
	.globl _ui8_throttle
	.globl _ui8_target_battery_max_power_x10
	.globl _ui8_adc_battery_max_current
	.globl _ui8_adc_battery_target_current
	.globl _ui8_byte_received
	.globl _ui8_checksum
	.globl _ui8_i
	.globl _ui8_tx_buffer
	.globl _ui8_rx_buffer
	.globl _configuration_variables
	.globl _ui16_oem_wheel_speed
	.globl _f_oem_wheel_speed
	.globl _ui16_wheel_speed_x10
	.globl _f_wheel_speed_x10
	.globl _ui16_startup_boost_fade_variable_step_amount_x256
	.globl _ui16_startup_boost_fade_variable_x256
	.globl _ui16_pedal_power_x10
	.globl _ui16_pedal_torque_x10
	.globl _ui8_adc_battery_current_max
	.globl _ui8_adc_target_battery_max_current
	.globl _ui8_adc_battery_current_offset
	.globl _ui8_adc_torque_sensor_max_value
	.globl _ui8_adc_torque_sensor_min_value
	.globl _ebike_app_init
	.globl _ebike_app_controller
	.globl _get_configuration_variables
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area DATA
G$ui8_adc_torque_sensor_min_value$0_0$0==.
_ui8_adc_torque_sensor_min_value::
	.ds 1
G$ui8_adc_torque_sensor_max_value$0_0$0==.
_ui8_adc_torque_sensor_max_value::
	.ds 1
G$ui8_adc_battery_current_offset$0_0$0==.
_ui8_adc_battery_current_offset::
	.ds 1
G$ui8_adc_target_battery_max_current$0_0$0==.
_ui8_adc_target_battery_max_current::
	.ds 1
G$ui8_adc_battery_current_max$0_0$0==.
_ui8_adc_battery_current_max::
	.ds 1
G$ui16_pedal_torque_x10$0_0$0==.
_ui16_pedal_torque_x10::
	.ds 2
G$ui16_pedal_power_x10$0_0$0==.
_ui16_pedal_power_x10::
	.ds 2
G$ui16_startup_boost_fade_variable_x256$0_0$0==.
_ui16_startup_boost_fade_variable_x256::
	.ds 2
G$ui16_startup_boost_fade_variable_step_amount_x256$0_0$0==.
_ui16_startup_boost_fade_variable_step_amount_x256::
	.ds 2
G$f_wheel_speed_x10$0_0$0==.
_f_wheel_speed_x10::
	.ds 4
G$ui16_wheel_speed_x10$0_0$0==.
_ui16_wheel_speed_x10::
	.ds 2
G$f_oem_wheel_speed$0_0$0==.
_f_oem_wheel_speed::
	.ds 4
G$ui16_oem_wheel_speed$0_0$0==.
_ui16_oem_wheel_speed::
	.ds 2
G$configuration_variables$0_0$0==.
_configuration_variables::
	.ds 63
G$ui8_rx_buffer$0_0$0==.
_ui8_rx_buffer::
	.ds 7
G$ui8_tx_buffer$0_0$0==.
_ui8_tx_buffer::
	.ds 9
G$ui8_i$0_0$0==.
_ui8_i::
	.ds 1
G$ui8_checksum$0_0$0==.
_ui8_checksum::
	.ds 1
G$ui8_byte_received$0_0$0==.
_ui8_byte_received::
	.ds 1
Febike_app$ui16_crc_rx$0_0$0==.
_ui16_crc_rx:
	.ds 2
Febike_app$ui16_crc_tx$0_0$0==.
_ui16_crc_tx:
	.ds 2
G$ui8_adc_battery_target_current$0_0$0==.
_ui8_adc_battery_target_current::
	.ds 1
Lebike_app.ebike_control_motor$ui32_temp$1_0$424==.
_ebike_control_motor_ui32_temp_65536_424:
	.ds 4
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area INITIALIZED
G$ui8_adc_battery_max_current$0_0$0==.
_ui8_adc_battery_max_current::
	.ds 1
G$ui8_target_battery_max_power_x10$0_0$0==.
_ui8_target_battery_max_power_x10::
	.ds 1
G$ui8_throttle$0_0$0==.
_ui8_throttle::
	.ds 1
G$ui8_torque_sensor_value1$0_0$0==.
_ui8_torque_sensor_value1::
	.ds 1
G$ui8_torque_sensor$0_0$0==.
_ui8_torque_sensor::
	.ds 1
G$ui8_torque_sensor_raw$0_0$0==.
_ui8_torque_sensor_raw::
	.ds 1
G$ui8_ebike_app_state$0_0$0==.
_ui8_ebike_app_state::
	.ds 1
G$ui16_pas_pwm_cycles_ticks$0_0$0==.
_ui16_pas_pwm_cycles_ticks::
	.ds 2
G$ui8_pedaling_forward$0_0$0==.
_ui8_pedaling_forward::
	.ds 1
G$ui8_pas_cadence_rpm$0_0$0==.
_ui8_pas_cadence_rpm::
	.ds 1
G$ui8_pedal_human_power$0_0$0==.
_ui8_pedal_human_power::
	.ds 1
G$ui8_startup_boost_enable$0_0$0==.
_ui8_startup_boost_enable::
	.ds 1
G$ui8_startup_boost_fade_enable$0_0$0==.
_ui8_startup_boost_fade_enable::
	.ds 1
G$ui8_startup_boost_state_machine$0_0$0==.
_ui8_startup_boost_state_machine::
	.ds 1
G$ui8_startup_boost_no_torque$0_0$0==.
_ui8_startup_boost_no_torque::
	.ds 1
G$ui8_startup_boost_timer$0_0$0==.
_ui8_startup_boost_timer::
	.ds 1
G$ui8_startup_boost_fade_steps$0_0$0==.
_ui8_startup_boost_fade_steps::
	.ds 1
G$ui16_wheel_speed_sensor_pwm_cycles_ticks$0_0$0==.
_ui16_wheel_speed_sensor_pwm_cycles_ticks::
	.ds 2
G$ui8_wheel_speed_max$0_0$0==.
_ui8_wheel_speed_max::
	.ds 1
G$ui32_wheel_speed_sensor_tick_counter$0_0$0==.
_ui32_wheel_speed_sensor_tick_counter::
	.ds 4
G$ui8_received_package_flag$0_0$0==.
_ui8_received_package_flag::
	.ds 1
G$ui8_rx_counter$0_0$0==.
_ui8_rx_counter::
	.ds 1
G$ui8_tx_counter$0_0$0==.
_ui8_tx_counter::
	.ds 1
G$ui8_state_machine$0_0$0==.
_ui8_state_machine::
	.ds 1
G$ui8_uart_received_first_package$0_0$0==.
_ui8_uart_received_first_package::
	.ds 1
Febike_app$ui8_master_comm_package_id$0_0$0==.
_ui8_master_comm_package_id:
	.ds 1
Febike_app$ui8_slave_comm_package_id$0_0$0==.
_ui8_slave_comm_package_id:
	.ds 1
G$ui8_tstr_state_machine$0_0$0==.
_ui8_tstr_state_machine::
	.ds 1
G$ui8_rtst_counter$0_0$0==.
_ui8_rtst_counter::
	.ds 1
G$ui16_adc_motor_temperatured_accumulated$0_0$0==.
_ui16_adc_motor_temperatured_accumulated::
	.ds 2
G$safe_tests_state_machine$0_0$0==.
_safe_tests_state_machine::
	.ds 1
G$safe_tests_state_machine_counter$0_0$0==.
_safe_tests_state_machine_counter::
	.ds 1
G$ui32_battery_voltage_accumulated_x10000$0_0$0==.
_ui32_battery_voltage_accumulated_x10000::
	.ds 4
G$ui16_battery_current_accumulated_x5$0_0$0==.
_ui16_battery_current_accumulated_x5::
	.ds 2
G$ui8_battery_state_of_charge$0_0$0==.
_ui8_battery_state_of_charge::
	.ds 1
G$ui8_timer_counter$0_0$0==.
_ui8_timer_counter::
	.ds 1
G$ui8_startup_counter$0_0$0==.
_ui8_startup_counter::
	.ds 1
G$ui8_lights_counter$0_0$0==.
_ui8_lights_counter::
	.ds 1
G$ui16_walk_assist_delay_off$0_0$0==.
_ui16_walk_assist_delay_off::
	.ds 2
G$ui8_walk_assist_delay_off_flag$0_0$0==.
_ui8_walk_assist_delay_off_flag::
	.ds 1
G$ui8_display_ready_flag$0_0$0==.
_ui8_display_ready_flag::
	.ds 1
G$ui8_enable_walk_assist$0_0$0==.
_ui8_enable_walk_assist::
	.ds 1
G$ui8_walk_assist_flag$0_0$0==.
_ui8_walk_assist_flag::
	.ds 1
G$ui8_walk_assist$0_0$0==.
_ui8_walk_assist::
	.ds 1
G$ui8_walk_assist_current_per_cent$0_0$0==.
_ui8_walk_assist_current_per_cent::
	.ds 1
G$ui8_walk_assist_start$0_0$0==.
_ui8_walk_assist_start::
	.ds 1
G$ui8_walk_assist_pwm$0_0$0==.
_ui8_walk_assist_pwm::
	.ds 1
G$ui8_walk_assist_pwm_step$0_0$0==.
_ui8_walk_assist_pwm_step::
	.ds 1
G$ui8_default_flag$0_0$0==.
_ui8_default_flag::
	.ds 1
G$ui8_lights_flag$0_0$0==.
_ui8_lights_flag::
	.ds 1
G$ui8_mode_flag$0_0$0==.
_ui8_mode_flag::
	.ds 1
G$ui8_boost_flag$0_0$0==.
_ui8_boost_flag::
	.ds 1
G$ui8_pwm_started$0_0$0==.
_ui8_pwm_started::
	.ds 1
G$ui8_pwm_stopped$0_0$0==.
_ui8_pwm_stopped::
	.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$ebike_app_init$0$0 ==.
	C$ebike_app.c$155$0_0$420 ==.
;	ebike_app.c: 155: void ebike_app_init (void)
;	-----------------------------------------
;	 function ebike_app_init
;	-----------------------------------------
_ebike_app_init:
	C$ebike_app.c$158$1_0$420 ==.
;	ebike_app.c: 158: eeprom_init_variables ();
	call	_eeprom_init_variables
	C$ebike_app.c$159$1_0$420 ==.
;	ebike_app.c: 159: ebike_app_set_battery_max_current (ADC_BATTERY_CURRENT_MAX);
	push	#0x1c
	call	_ebike_app_set_battery_max_current
	pop	a
	C$ebike_app.c$162$1_0$420 ==.
;	ebike_app.c: 162: configuration_variables.ui8_function_code = NO_FUNCTION;
	ldw	x, #_configuration_variables+36
	clr	(x)
	C$ebike_app.c$164$1_0$420 ==.
;	ebike_app.c: 164: if(configuration_variables.ui8_street_enabled_on_startup)
	ldw	x, #_configuration_variables+30
	ld	a, (x)
	jreq	00102$
	C$ebike_app.c$166$1_0$420 ==.
;	ebike_app.c: 166: configuration_variables.ui8_offroad_mode = 0;
	ldw	x, #_configuration_variables+9
	clr	(x)
	jra	00104$
00102$:
	C$ebike_app.c$169$1_0$420 ==.
;	ebike_app.c: 169: configuration_variables.ui8_offroad_mode = 1;
	ldw	x, #_configuration_variables+9
	ld	a, #0x01
	ld	(x), a
00104$:
	C$ebike_app.c$170$1_0$420 ==.
;	ebike_app.c: 170: }
	C$ebike_app.c$170$1_0$420 ==.
	XG$ebike_app_init$0$0 ==.
	ret
	G$ebike_app_controller$0$0 ==.
	C$ebike_app.c$172$1_0$422 ==.
;	ebike_app.c: 172: void ebike_app_controller (void)
;	-----------------------------------------
;	 function ebike_app_controller
;	-----------------------------------------
_ebike_app_controller:
	C$ebike_app.c$174$1_0$422 ==.
;	ebike_app.c: 174: check_battery_soc();
	call	_check_battery_soc
	C$ebike_app.c$175$1_0$422 ==.
;	ebike_app.c: 175: walk_assist_read();
	call	_walk_assist_read
	C$ebike_app.c$176$1_0$422 ==.
;	ebike_app.c: 176: throttle_read();
	call	_throttle_read
	C$ebike_app.c$177$1_0$422 ==.
;	ebike_app.c: 177: torque_sensor_read();
	call	_torque_sensor_read
	C$ebike_app.c$178$1_0$422 ==.
;	ebike_app.c: 178: read_pas_cadence();
	call	_read_pas_cadence
	C$ebike_app.c$179$1_0$422 ==.
;	ebike_app.c: 179: calc_pedal_force_and_torque();
	call	_calc_pedal_force_and_torque
	C$ebike_app.c$180$1_0$422 ==.
;	ebike_app.c: 180: calc_wheel_speed();
	call	_calc_wheel_speed
	C$ebike_app.c$181$1_0$422 ==.
;	ebike_app.c: 181: calc_motor_temperature();
	call	_calc_motor_temperature
	C$ebike_app.c$182$1_0$422 ==.
;	ebike_app.c: 182: ebike_control_motor();
	call	_ebike_control_motor
	C$ebike_app.c$183$1_0$422 ==.
;	ebike_app.c: 183: communications_controller();
	call	_communications_controller
	C$ebike_app.c$231$1_0$422 ==.
;	ebike_app.c: 231: }
	C$ebike_app.c$231$1_0$422 ==.
	XG$ebike_app_controller$0$0 ==.
	ret
	Febike_app$ebike_control_motor$0$0 ==.
	C$ebike_app.c$277$1_0$424 ==.
;	ebike_app.c: 277: static void ebike_control_motor (void)
;	-----------------------------------------
;	 function ebike_control_motor
;	-----------------------------------------
_ebike_control_motor:
	sub	sp, #45
	C$ebike_app.c$282$2_0$424 ==.
;	ebike_app.c: 282: uint8_t ui8_adc_max_battery_current = 0;
	clr	(0x01, sp)
	C$ebike_app.c$283$2_0$424 ==.
;	ebike_app.c: 283: uint8_t ui8_adc_max_battery_power_current = 0;
	clr	(0x26, sp)
	C$ebike_app.c$285$2_0$424 ==.
;	ebike_app.c: 285: uint8_t ui8_boost_enabled_and_applied = 0;
	clr	(0x25, sp)
	C$ebike_app.c$288$1_0$424 ==.
;	ebike_app.c: 288: uint16_t ui16_battery_voltage_filtered = calc_filtered_battery_voltage ();
	call	_calc_filtered_battery_voltage
	ldw	(0x2b, sp), x
	C$ebike_app.c$293$1_0$424 ==.
;	ebike_app.c: 293: uint8_t ui8_adc_max_battery_current_boost_state = 0;
	clr	(0x02, sp)
	C$ebike_app.c$295$1_0$424 ==.
;	ebike_app.c: 295: if(ui16_battery_voltage_filtered > 15)
	ldw	x, (0x2b, sp)
	cpw	x, #0x000f
	jrugt	00268$
	jp	00112$
00268$:
	C$ebike_app.c$300$2_0$425 ==.
;	ebike_app.c: 300: if(configuration_variables.ui8_startup_motor_power_boost_assist_level > 0)
	ldw	x, #_configuration_variables+17
	ld	a, (x)
	jrne	00269$
	jp	00102$
00269$:
	C$ebike_app.c$302$3_0$426 ==.
;	ebike_app.c: 302: ui32_temp = (uint32_t) ui16_pedal_torque_x10 * (uint32_t) configuration_variables.ui8_startup_motor_power_boost_assist_level;
	ldw	x, _ui16_pedal_torque_x10+0
	ldw	(0x23, sp), x
	clrw	y
	ldw	x, #_configuration_variables+17
	ld	a, (x)
	clrw	x
	ld	xl, a
	clr	(0x16, sp)
	clr	(0x15, sp)
	pushw	x
	ldw	x, (0x17, sp)
	pushw	x
	ldw	x, (0x27, sp)
	pushw	x
	pushw	y
	call	__mullong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	C$ebike_app.c$303$1_0$424 ==.
;	ebike_app.c: 303: ui32_temp /= 10;
	push	#0x0a
	clrw	x
	pushw	x
	push	#0x00
	push	_ebike_control_motor_ui32_temp_65536_424+3
	push	_ebike_control_motor_ui32_temp_65536_424+2
	push	_ebike_control_motor_ui32_temp_65536_424+1
	push	_ebike_control_motor_ui32_temp_65536_424+0
	call	__divulong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	C$ebike_app.c$307$1_0$424 ==.
;	ebike_app.c: 307: ui32_temp = (ui32_temp * 13) / ((uint32_t) ui16_battery_voltage_filtered);
	push	_ebike_control_motor_ui32_temp_65536_424+3
	push	_ebike_control_motor_ui32_temp_65536_424+2
	push	_ebike_control_motor_ui32_temp_65536_424+1
	push	_ebike_control_motor_ui32_temp_65536_424+0
	push	#0x0d
	clrw	x
	pushw	x
	push	#0x00
	call	__mullong
	addw	sp, #8
	ldw	(0x13, sp), x
	ldw	(0x11, sp), y
	ldw	y, (0x2b, sp)
	clrw	x
	pushw	y
	pushw	x
	ldw	x, (0x17, sp)
	pushw	x
	ldw	x, (0x17, sp)
	pushw	x
	call	__divulong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	C$ebike_app.c$308$1_0$424 ==.
;	ebike_app.c: 308: ui8_adc_max_battery_current_boost_state = ui32_temp >> 3;
	ldw	x, _ebike_control_motor_ui32_temp_65536_424+2
	srlw	x
	srlw	x
	srlw	x
	exg	a, xl
	ld	(0x02, sp), a
	exg	a, xl
	C$ebike_app.c$309$3_0$426 ==.
;	ebike_app.c: 309: ui8_limit_max(&ui8_adc_max_battery_current_boost_state, 255);
	ldw	x, sp
	incw	x
	incw	x
	push	#0xff
	pushw	x
	call	_ui8_limit_max
	addw	sp, #3
00102$:
	C$ebike_app.c$312$2_0$425 ==.
;	ebike_app.c: 312: if(configuration_variables.ui8_assist_level_factor_x10 > 0)
	ld	a, _configuration_variables
	jrne	00270$
	jp	00108$
00270$:
	C$ebike_app.c$315$3_0$427 ==.
;	ebike_app.c: 315: if((!configuration_variables.ui8_motor_assistance_startup_without_pedal_rotation)||
	ldw	x, #_configuration_variables+12
	ld	a, (x)
	jreq	00103$
	C$ebike_app.c$316$3_0$427 ==.
;	ebike_app.c: 316: (ui8_pas_cadence_rpm > 0))
	tnz	_ui8_pas_cadence_rpm+0
	jreq	00104$
00103$:
	C$ebike_app.c$318$4_0$428 ==.
;	ebike_app.c: 318: ui32_temp = (uint32_t) ui16_pedal_power_x10 * (uint32_t) configuration_variables.ui8_assist_level_factor_x10;
	ldw	x, _ui16_pedal_power_x10+0
	ldw	(0x0f, sp), x
	clr	(0x0e, sp)
	clr	(0x0d, sp)
	ld	a, _configuration_variables
	clrw	x
	ld	xl, a
	clrw	y
	pushw	x
	pushw	y
	ldw	x, (0x13, sp)
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	call	__mullong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	C$ebike_app.c$319$1_0$424 ==.
;	ebike_app.c: 319: ui32_temp /= 100;
	push	#0x64
	clrw	x
	pushw	x
	push	#0x00
	push	_ebike_control_motor_ui32_temp_65536_424+3
	push	_ebike_control_motor_ui32_temp_65536_424+2
	push	_ebike_control_motor_ui32_temp_65536_424+1
	push	_ebike_control_motor_ui32_temp_65536_424+0
	call	__divulong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	jra	00105$
00104$:
	C$ebike_app.c$323$4_0$429 ==.
;	ebike_app.c: 323: ui32_temp = (uint32_t) ui16_pedal_torque_x10 * (uint32_t) configuration_variables.ui8_assist_level_factor_x10;
	ldw	x, _ui16_pedal_torque_x10+0
	ldw	(0x1f, sp), x
	clr	(0x1e, sp)
	clr	(0x1d, sp)
	ld	a, _configuration_variables
	clrw	x
	ld	xl, a
	clrw	y
	pushw	x
	pushw	y
	ldw	x, (0x23, sp)
	pushw	x
	ldw	x, (0x23, sp)
	pushw	x
	call	__mullong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	C$ebike_app.c$324$1_0$424 ==.
;	ebike_app.c: 324: ui32_temp /= 100;
	push	#0x64
	clrw	x
	pushw	x
	push	#0x00
	push	_ebike_control_motor_ui32_temp_65536_424+3
	push	_ebike_control_motor_ui32_temp_65536_424+2
	push	_ebike_control_motor_ui32_temp_65536_424+1
	push	_ebike_control_motor_ui32_temp_65536_424+0
	call	__divulong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
00105$:
	C$ebike_app.c$329$1_0$424 ==.
;	ebike_app.c: 329: ui32_temp = (ui32_temp * 13) / ((uint32_t) ui16_battery_voltage_filtered);
	push	_ebike_control_motor_ui32_temp_65536_424+3
	push	_ebike_control_motor_ui32_temp_65536_424+2
	push	_ebike_control_motor_ui32_temp_65536_424+1
	push	_ebike_control_motor_ui32_temp_65536_424+0
	push	#0x0d
	clrw	x
	pushw	x
	push	#0x00
	call	__mullong
	addw	sp, #8
	ldw	(0x1b, sp), x
	ldw	x, (0x2b, sp)
	clr	(0x28, sp)
	clr	(0x27, sp)
	pushw	x
	ldw	x, (0x29, sp)
	pushw	x
	ldw	x, (0x1f, sp)
	pushw	x
	pushw	y
	call	__divulong
	addw	sp, #8
	ldw	_ebike_control_motor_ui32_temp_65536_424+2, x
	ldw	_ebike_control_motor_ui32_temp_65536_424+0, y
	C$ebike_app.c$330$1_0$424 ==.
;	ebike_app.c: 330: ui8_adc_max_battery_current = ui32_temp >> 3;
	ldw	x, _ebike_control_motor_ui32_temp_65536_424+2
	srlw	x
	srlw	x
	srlw	x
	exg	a, xl
	ld	(0x01, sp), a
	exg	a, xl
	C$ebike_app.c$331$3_0$427 ==.
;	ebike_app.c: 331: ui8_limit_max(&ui8_adc_max_battery_current, 255);
	ldw	x, sp
	incw	x
	push	#0xff
	pushw	x
	call	_ui8_limit_max
	addw	sp, #3
	C$ebike_app.c$332$3_0$427 ==.
;	ebike_app.c: 332: ui8_adc_battery_target_current = ui8_adc_max_battery_current;
	ld	a, (0x01, sp)
	ld	_ui8_adc_battery_target_current+0, a
00108$:
	C$ebike_app.c$335$2_0$425 ==.
;	ebike_app.c: 335: if(configuration_variables.ui8_target_battery_max_power_div25 > 0) //TODO: add real feature toggle for max power feature
	ldw	x, #_configuration_variables+13
	ld	a, (x)
	jreq	00112$
	C$ebike_app.c$337$3_0$430 ==.
;	ebike_app.c: 337: ui32_adc_max_battery_current_x4 = (((uint32_t) configuration_variables.ui8_target_battery_max_power_div25) * 160) / ((uint32_t) ui16_battery_voltage_filtered);
	ldw	x, #_configuration_variables+13
	ld	a, (x)
	clrw	x
	ld	xl, a
	clrw	y
	pushw	x
	pushw	y
	push	#0xa0
	clrw	x
	pushw	x
	push	#0x00
	call	__mullong
	addw	sp, #8
	ldw	(0x0b, sp), x
	ldw	(0x09, sp), y
	ldw	y, (0x2b, sp)
	clrw	x
	pushw	y
	pushw	x
	ldw	x, (0x0f, sp)
	pushw	x
	ldw	x, (0x0f, sp)
	pushw	x
	call	__divulong
	addw	sp, #8
	C$ebike_app.c$338$1_0$424 ==.
;	ebike_app.c: 338: ui8_adc_max_battery_power_current = ui32_adc_max_battery_current_x4 >> 2;
	srlw	x
	srlw	x
	exg	a, xl
	ld	(0x26, sp), a
	exg	a, xl
00112$:
	C$ebike_app.c$343$1_0$424 ==.
;	ebike_app.c: 343: ui8_startup_enable = configuration_variables.ui8_assist_level_factor_x10 && ui8_torque_sensor ? 1 : 0;
	ld	a, _configuration_variables
	jreq	00156$
	tnz	_ui8_torque_sensor+0
	jreq	00156$
	clrw	x
	incw	x
	.byte 0x21
00156$:
	clrw	x
00157$:
	exg	a, xl
	ld	(0x04, sp), a
	exg	a, xl
	C$ebike_app.c$345$1_0$424 ==.
;	ebike_app.c: 345: ui8_tmp_pas_cadence_rpm = ui8_pas_cadence_rpm;
	ld	a, _ui8_pas_cadence_rpm+0
	ld	(0x2d, sp), a
	C$ebike_app.c$347$1_0$424 ==.
;	ebike_app.c: 347: if(configuration_variables.ui8_motor_assistance_startup_without_pedal_rotation)
	ldw	x, #_configuration_variables+12
	ld	a, (x)
	jreq	00116$
	C$ebike_app.c$349$2_0$431 ==.
;	ebike_app.c: 349: if(ui8_pas_cadence_rpm < 10)
	ld	a, _ui8_pas_cadence_rpm+0
	cp	a, #0x0a
	jrnc	00116$
	C$ebike_app.c$351$3_0$432 ==.
;	ebike_app.c: 351: ui8_tmp_pas_cadence_rpm = 10;
	ld	a, #0x0a
	ld	(0x2d, sp), a
00116$:
	C$ebike_app.c$355$1_0$424 ==.
;	ebike_app.c: 355: if(configuration_variables.ui8_startup_motor_power_boost_feature_enabled)
	ldw	x, #_configuration_variables+16
	ld	a, (x)
	jreq	00118$
	C$ebike_app.c$357$2_0$433 ==.
;	ebike_app.c: 357: boost_run_statemachine ();  
	call	_boost_run_statemachine
	C$ebike_app.c$358$2_0$433 ==.
;	ebike_app.c: 358: ui8_boost_enabled_and_applied = apply_boost (ui8_tmp_pas_cadence_rpm, ui8_adc_max_battery_current_boost_state, &ui8_adc_battery_target_current);
	push	#<_ui8_adc_battery_target_current
	push	#(_ui8_adc_battery_target_current >> 8)
	ld	a, (0x04, sp)
	push	a
	ld	a, (0x30, sp)
	push	a
	call	_apply_boost
	addw	sp, #4
	ld	(0x25, sp), a
00118$:
	C$ebike_app.c$362$1_0$424 ==.
;	ebike_app.c: 362: if(configuration_variables.ui8_startup_motor_power_boost_feature_enabled)
	ldw	x, #_configuration_variables+16
	ld	a, (x)
	jreq	00120$
	C$ebike_app.c$364$2_0$434 ==.
;	ebike_app.c: 364: apply_boost_fade_out (&ui8_adc_battery_target_current);
	push	#<_ui8_adc_battery_target_current
	push	#(_ui8_adc_battery_target_current >> 8)
	call	_apply_boost_fade_out
	addw	sp, #2
00120$:
	C$ebike_app.c$372$1_0$424 ==.
;	ebike_app.c: 372: ui8_tmp_max_speed = configuration_variables.ui8_wheel_max_speed;
	ldw	x, #_configuration_variables+10
	ld	a, (x)
	ld	(0x03, sp), a
	C$ebike_app.c$375$1_0$424 ==.
;	ebike_app.c: 375: if(configuration_variables.ui8_street_feature_enabled)
	ldw	x, #_configuration_variables+29
	ld	a, (x)
	jreq	00122$
	C$ebike_app.c$377$2_0$435 ==.
;	ebike_app.c: 377: apply_street_mode (ui16_battery_voltage_filtered, &ui8_tmp_max_speed, &ui8_adc_battery_target_current);
	ldw	x, sp
	addw	x, #3
	push	#<_ui8_adc_battery_target_current
	push	#(_ui8_adc_battery_target_current >> 8)
	pushw	x
	ldw	x, (0x2f, sp)
	pushw	x
	call	_apply_street_mode
	addw	sp, #6
00122$:
	C$ebike_app.c$381$1_0$424 ==.
;	ebike_app.c: 381: apply_speed_limit (ui16_wheel_speed_x10, ui8_tmp_max_speed, &ui8_adc_battery_target_current);
	push	#<_ui8_adc_battery_target_current
	push	#(_ui8_adc_battery_target_current >> 8)
	ld	a, (0x05, sp)
	push	a
	push	_ui16_wheel_speed_x10+1
	push	_ui16_wheel_speed_x10+0
	call	_apply_speed_limit
	addw	sp, #5
	C$ebike_app.c$384$1_0$424 ==.
;	ebike_app.c: 384: if(configuration_variables.ui8_target_battery_max_power_div25 > 0) //TODO: add real feature toggle for max power feature
	ldw	x, #_configuration_variables+13
	ld	a, (x)
	jreq	00128$
	C$ebike_app.c$389$2_0$436 ==.
;	ebike_app.c: 389: if((configuration_variables.ui8_startup_motor_power_boost_limit_to_max_power == 1)||
	ldw	x, #_configuration_variables+19
	ld	a, (x)
	dec	a
	jreq	00123$
	C$ebike_app.c$390$2_0$436 ==.
;	ebike_app.c: 390: (!((ui8_boost_enabled_and_applied == 1)||
	ld	a, (0x25, sp)
	dec	a
	jreq	00128$
	C$ebike_app.c$391$2_0$436 ==.
;	ebike_app.c: 391: (ui8_startup_boost_fade_enable == 1))))
	ld	a, _ui8_startup_boost_fade_enable+0
	dec	a
	jreq	00128$
00123$:
	C$ebike_app.c$394$3_0$437 ==.
;	ebike_app.c: 394: ui8_adc_battery_target_current = ui8_min (ui8_adc_battery_target_current, ui8_adc_max_battery_power_current);
	ld	a, (0x26, sp)
	push	a
	push	_ui8_adc_battery_target_current+0
	call	_ui8_min
	addw	sp, #2
	ld	_ui8_adc_battery_target_current+0, a
00128$:
	C$ebike_app.c$399$1_0$424 ==.
;	ebike_app.c: 399: if(configuration_variables.ui8_temperature_limit_feature_enabled)
	ldw	x, #_configuration_variables+22
	ld	a, (x)
	jreq	00130$
	C$ebike_app.c$401$2_0$438 ==.
;	ebike_app.c: 401: apply_temperature_limiting (&ui8_adc_battery_target_current);
	push	#<_ui8_adc_battery_target_current
	push	#(_ui8_adc_battery_target_current >> 8)
	call	_apply_temperature_limiting
	addw	sp, #2
	jra	00131$
00130$:
	C$ebike_app.c$407$2_0$439 ==.
;	ebike_app.c: 407: configuration_variables.ui8_temperature_current_limiting_value = 255;
	ldw	x, #_configuration_variables+25
	ld	a, #0xff
	ld	(x), a
00131$:
	C$ebike_app.c$411$1_0$424 ==.
;	ebike_app.c: 411: ebike_app_set_target_adc_battery_max_current (ui8_adc_battery_target_current);
	push	_ui8_adc_battery_target_current+0
	call	_ebike_app_set_target_adc_battery_max_current
	pop	a
	C$ebike_app.c$414$1_0$424 ==.
;	ebike_app.c: 414: safe_tests ();
	call	_safe_tests
	C$ebike_app.c$417$1_0$424 ==.
;	ebike_app.c: 417: if(ui8_walk_assist_flag)
	tnz	_ui8_walk_assist_flag+0
	jreq	00133$
	C$ebike_app.c$419$2_0$440 ==.
;	ebike_app.c: 419: ui8_adc_battery_target_current = (ui8_adc_battery_current_max	* ui8_walk_assist_current_per_cent) / 100;
	ld	a, _ui8_adc_battery_current_max+0
	ld	xl, a
	ld	a, _ui8_walk_assist_current_per_cent+0
	mul	x, a
	push	#0x64
	push	#0x00
	pushw	x
	call	__divsint
	addw	sp, #4
	ld	a, xl
	ld	_ui8_adc_battery_target_current+0, a
	C$ebike_app.c$420$2_0$440 ==.
;	ebike_app.c: 420: apply_walk_assist (ui8_walk_assist, &ui8_startup_enable, &ui8_adc_battery_target_current);
	ldw	x, sp
	addw	x, #4
	push	#<_ui8_adc_battery_target_current
	push	#(_ui8_adc_battery_target_current >> 8)
	pushw	x
	push	_ui8_walk_assist+0
	call	_apply_walk_assist
	addw	sp, #5
00133$:
	C$ebike_app.c$423$1_0$424 ==.
;	ebike_app.c: 423: if((ui8_adc_battery_target_current)&& // we must have a target positive current
	tnz	_ui8_adc_battery_target_current+0
	jrne	00293$
	jp	00148$
00293$:
	C$ebike_app.c$424$1_0$424 ==.
;	ebike_app.c: 424: (ui8_startup_enable)&& // startup enabled
	tnz	(0x04, sp)
	jrne	00294$
	jp	00148$
00294$:
	C$ebike_app.c$425$1_0$424 ==.
;	ebike_app.c: 425: (!brake_is_set())&& // brakes must not be pressed
	call	_brake_is_set
	tnz	a
	jreq	00295$
	jp	00148$
00295$:
	C$ebike_app.c$426$1_0$424 ==.
;	ebike_app.c: 426: (ui8_pedaling_forward)&& // we must not be pedaling backwards
	tnz	_ui8_pedaling_forward+0
	jrne	00296$
	jp	00148$
00296$:
	C$ebike_app.c$427$1_0$424 ==.
;	ebike_app.c: 427: (configuration_variables.ui8_error_states == ERROR_STATE_NO_ERRORS)) // we must have no errors
	ldw	x, #_configuration_variables+34
	ld	a, (x)
	jreq	00297$
	jp	00148$
00297$:
	C$ebike_app.c$442$2_0$441 ==.
;	ebike_app.c: 442: ui8_pwm_started = 1;			
	mov	_ui8_pwm_started+0, #0x01
	C$ebike_app.c$446$2_0$441 ==.
;	ebike_app.c: 446: if(ui8_pwm_started)
	tnz	_ui8_pwm_started+0
	jrne	00298$
	jp	00154$
00298$:
	C$ebike_app.c$449$3_0$442 ==.
;	ebike_app.c: 449: if(ui8_walk_assist_flag)
	tnz	_ui8_walk_assist_flag+0
	jrne	00299$
	jp	00143$
00299$:
	C$ebike_app.c$452$4_0$443 ==.
;	ebike_app.c: 452: if(ui8_walk_assist_start == 0)
	tnz	_ui8_walk_assist_start+0
	jrne	00138$
	C$ebike_app.c$455$5_0$444 ==.
;	ebike_app.c: 455: ui8_walk_assist_start = 1;
	mov	_ui8_walk_assist_start+0, #0x01
	C$ebike_app.c$458$5_0$444 ==.
;	ebike_app.c: 458: ui8_walk_assist_pwm = 0;
	clr	_ui8_walk_assist_pwm+0
	C$ebike_app.c$461$5_0$444 ==.
;	ebike_app.c: 461: if(ui8_walk_assist_pwm < configuration_variables.ui8_walk_assist_ramp_time)
	ldw	x, #_configuration_variables+58
	ld	a, (x)
	cp	a, _ui8_walk_assist_pwm+0
	jrule	00135$
	C$ebike_app.c$462$5_0$444 ==.
;	ebike_app.c: 462: ui8_walk_assist_pwm_step = 1;
	mov	_ui8_walk_assist_pwm_step+0, #0x01
	jra	00138$
00135$:
	C$ebike_app.c$464$5_0$444 ==.
;	ebike_app.c: 464: ui8_walk_assist_pwm_step = configuration_variables.ui8_walk_assist_pwm_duty_cycle / configuration_variables.ui8_walk_assist_ramp_time;
	ldw	x, #_configuration_variables+52
	ld	a, (x)
	ld	xl, a
	ldw	y, #_configuration_variables+58
	ld	a, (y)
	rlwa	x
	clr	a
	rrwa	x
	div	x, a
	ld	a, xl
	ld	_ui8_walk_assist_pwm_step+0, a
00138$:
	C$ebike_app.c$468$4_0$443 ==.
;	ebike_app.c: 468: if((ui8_walk_assist_pwm + ui8_walk_assist_pwm_step) <= configuration_variables.ui8_walk_assist_pwm_duty_cycle)
	ld	a, _ui8_walk_assist_pwm+0
	ld	(0x08, sp), a
	clr	(0x07, sp)
	clrw	x
	ld	a, _ui8_walk_assist_pwm_step+0
	ld	xl, a
	addw	x, (0x07, sp)
	ldw	(0x05, sp), x
	ldw	x, #_configuration_variables+52
	ld	a, (x)
	clrw	x
	ld	xl, a
	cpw	x, (0x05, sp)
	jrslt	00140$
	C$ebike_app.c$469$4_0$443 ==.
;	ebike_app.c: 469: ui8_walk_assist_pwm += ui8_walk_assist_pwm_step;
	ld	a, _ui8_walk_assist_pwm+0
	add	a, _ui8_walk_assist_pwm_step+0
	ld	_ui8_walk_assist_pwm+0, a
	jra	00141$
00140$:
	C$ebike_app.c$471$4_0$443 ==.
;	ebike_app.c: 471: ui8_walk_assist_pwm = configuration_variables.ui8_walk_assist_pwm_duty_cycle;
	ldw	x, #_configuration_variables+52
	ld	a, (x)
	ld	_ui8_walk_assist_pwm+0, a
00141$:
	C$ebike_app.c$474$4_0$443 ==.
;	ebike_app.c: 474: motor_set_pwm_duty_cycle_target(ui8_walk_assist_pwm);
	push	_ui8_walk_assist_pwm+0
	call	_motor_set_pwm_duty_cycle_target
	pop	a
	jra	00154$
00143$:
	C$ebike_app.c$478$4_0$445 ==.
;	ebike_app.c: 478: motor_set_pwm_duty_cycle_target(255);
	push	#0xff
	call	_motor_set_pwm_duty_cycle_target
	pop	a
	jra	00154$
00148$:
	C$ebike_app.c$484$2_0$446 ==.
;	ebike_app.c: 484: motor_set_pwm_duty_cycle_target(0);
	push	#0x00
	call	_motor_set_pwm_duty_cycle_target
	pop	a
	C$ebike_app.c$518$2_0$446 ==.
;	ebike_app.c: 518: ui8_walk_assist_flag = 0;
	clr	_ui8_walk_assist_flag+0
	C$ebike_app.c$519$2_0$446 ==.
;	ebike_app.c: 519: ui8_walk_assist_start = 0;
	clr	_ui8_walk_assist_start+0
	C$ebike_app.c$520$2_0$446 ==.
;	ebike_app.c: 520: ui8_walk_assist_delay_off_flag = 0;
	clr	_ui8_walk_assist_delay_off_flag+0
	C$ebike_app.c$521$2_0$446 ==.
;	ebike_app.c: 521: ui8_walk_assist_current_per_cent = 0;
	clr	_ui8_walk_assist_current_per_cent+0
00154$:
	C$ebike_app.c$524$1_0$424 ==.
;	ebike_app.c: 524: }
	addw	sp, #45
	C$ebike_app.c$524$1_0$424 ==.
	XFebike_app$ebike_control_motor$0$0 ==.
	ret
	Febike_app$check_battery_soc$0$0 ==.
	C$ebike_app.c$526$1_0$448 ==.
;	ebike_app.c: 526: static void check_battery_soc (void)
;	-----------------------------------------
;	 function check_battery_soc
;	-----------------------------------------
_check_battery_soc:
	sub	sp, #14
	C$ebike_app.c$537$1_0$448 ==.
;	ebike_app.c: 537: ui16_adc_battery_voltage = motor_get_adc_battery_voltage_filtered_10b();
	call	_motor_get_adc_battery_voltage_filtered_10b
	ldw	(0x0b, sp), x
	C$ebike_app.c$540$1_0$448 ==.
;	ebike_app.c: 540: ui32_battery_voltage_accumulated_x10000 -= ui32_battery_voltage_accumulated_x10000 >> SOC_BATTERY_VOLTAGE_FILTER_COEFFICIENT;
	ldw	x, _ui32_battery_voltage_accumulated_x10000+2
	ldw	(0x07, sp), x
	ldw	x, _ui32_battery_voltage_accumulated_x10000+0
	srlw	x
	rrc	(0x07, sp)
	rrc	(0x08, sp)
	srlw	x
	rrc	(0x07, sp)
	rrc	(0x08, sp)
	srlw	x
	rrc	(0x07, sp)
	rrc	(0x08, sp)
	srlw	x
	rrc	(0x07, sp)
	rrc	(0x08, sp)
	ldw	y, _ui32_battery_voltage_accumulated_x10000+2
	subw	y, (0x07, sp)
	ld	a, _ui32_battery_voltage_accumulated_x10000+1
	pushw	x
	sbc	a, (#2, sp)
	popw	x
	ld	xl, a
	ld	a, _ui32_battery_voltage_accumulated_x10000+0
	pushw	x
	sbc	a, (#1, sp)
	popw	x
	ld	xh, a
	ldw	_ui32_battery_voltage_accumulated_x10000+2, y
	ldw	_ui32_battery_voltage_accumulated_x10000+0, x
	C$ebike_app.c$541$1_0$448 ==.
;	ebike_app.c: 541: ui32_battery_voltage_accumulated_x10000 += (uint32_t) ui16_adc_battery_voltage * SOC_ADC_BATTERY_VOLTAGE_PER_ADC_STEP_X10000;
	ldw	x, (0x0b, sp)
	pushw	x
	push	#0x62
	push	#0x03
	call	___muluint2ulong
	addw	sp, #4
	ld	a, yl
	addw	x, _ui32_battery_voltage_accumulated_x10000+2
	adc	a, _ui32_battery_voltage_accumulated_x10000+1
	ld	yl, a
	ld	a, yh
	adc	a, _ui32_battery_voltage_accumulated_x10000+0
	ld	yh, a
	ldw	_ui32_battery_voltage_accumulated_x10000+2, x
	ldw	_ui32_battery_voltage_accumulated_x10000+0, y
	C$ebike_app.c$542$1_0$448 ==.
;	ebike_app.c: 542: ui16_battery_voltage_filtered_x10 = ((uint32_t) (ui32_battery_voltage_accumulated_x10000 >> SOC_BATTERY_VOLTAGE_FILTER_COEFFICIENT)) / 1000;
	ldw	x, _ui32_battery_voltage_accumulated_x10000+2
	ldw	y, _ui32_battery_voltage_accumulated_x10000+0
	srlw	y
	rrcw	x
	srlw	y
	rrcw	x
	srlw	y
	rrcw	x
	srlw	y
	rrcw	x
	push	#0xe8
	push	#0x03
	push	#0x00
	push	#0x00
	pushw	x
	pushw	y
	call	__divulong
	addw	sp, #8
	ldw	(0x0d, sp), x
	C$ebike_app.c$545$1_0$448 ==.
;	ebike_app.c: 545: ui8_battery_current_x5 = (uint8_t) ((float) motor_get_adc_battery_current_filtered_10b() * 0.826);
	call	_motor_get_adc_battery_current_filtered_10b
	push	a
	call	___uchar2fs
	pop	a
	pushw	x
	pushw	y
	push	#0xbc
	push	#0x74
	push	#0x53
	push	#0x3f
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uchar
	addw	sp, #4
	C$ebike_app.c$548$1_0$448 ==.
;	ebike_app.c: 548: ui16_battery_current_accumulated_x5 -= ui16_battery_current_accumulated_x5 >> SOC_BATTERY_CURRENT_FILTER_COEFFICIENT;
	ldw	x, _ui16_battery_current_accumulated_x5+0
	srlw	x
	srlw	x
	srlw	x
	srlw	x
	negw	x
	addw	x, _ui16_battery_current_accumulated_x5+0
	ldw	_ui16_battery_current_accumulated_x5+0, x
	C$ebike_app.c$549$1_0$448 ==.
;	ebike_app.c: 549: ui16_battery_current_accumulated_x5 += (uint16_t) ui8_battery_current_x5;
	clrw	x
	ld	xl, a
	addw	x, _ui16_battery_current_accumulated_x5+0
	ldw	_ui16_battery_current_accumulated_x5+0, x
	C$ebike_app.c$550$1_0$448 ==.
;	ebike_app.c: 550: ui16_battery_current_filtered_x5 = ui16_battery_current_accumulated_x5 >> SOC_BATTERY_CURRENT_FILTER_COEFFICIENT;
	ldw	x, _ui16_battery_current_accumulated_x5+0
	ld	a, #0x10
	div	x, a
	exgw	x, y
	C$ebike_app.c$553$1_0$448 ==.
;	ebike_app.c: 553: ui16_fluctuate_battery_voltage_x10 = (uint16_t) ((((uint32_t) configuration_variables.ui16_battery_pack_resistance_x1000) * ((uint32_t) ui16_battery_current_filtered_x5)) / ((uint32_t) 500));
	ldw	x, #_configuration_variables+39
	ldw	x, (x)
	pushw	y
	pushw	x
	call	___muluint2ulong
	addw	sp, #4
	push	#0xf4
	push	#0x01
	push	#0x00
	push	#0x00
	pushw	x
	pushw	y
	call	__divulong
	addw	sp, #8
	C$ebike_app.c$555$1_0$448 ==.
;	ebike_app.c: 555: ui16_battery_voltage_soc_x10 = ui16_battery_voltage_filtered_x10 + ui16_fluctuate_battery_voltage_x10;
	addw	x, (0x0d, sp)
	ldw	(0x09, sp), x
	C$ebike_app.c$558$1_0$448 ==.
;	ebike_app.c: 558: ui8_battery_cells_number_x10 = configuration_variables.ui8_battery_cells_number * 10;
	ldw	x, #_configuration_variables+38
	ld	a, (x)
	ld	xl, a
	ld	a, #0x0a
	mul	x, a
	C$ebike_app.c$561$1_0$448 ==.
;	ebike_app.c: 561: if(ui8_timer_counter++ >= 1)
	ld	a, _ui8_timer_counter+0
	inc	_ui8_timer_counter+0
	cp	a, #0x01
	jrnc	00151$
	jp	00121$
00151$:
	C$ebike_app.c$563$2_0$449 ==.
;	ebike_app.c: 563: ui8_timer_counter = 0;
	clr	_ui8_timer_counter+0
	C$ebike_app.c$566$1_0$448 ==.
;	ebike_app.c: 566: if(ui16_battery_voltage_soc_x10 > ((uint16_t) ((float) ui8_battery_cells_number_x10 * LI_ION_CELL_VOLTS_5))) {ui8_battery_state_of_charge = 6;}				// 4 bars --> full + overvoltage
	ld	a, xl
	push	a
	call	___uchar2fs
	pop	a
	ldw	(0x03, sp), x
	ldw	(0x01, sp), y
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	clrw	x
	pushw	x
	push	#0x88
	push	#0x40
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	cpw	x, (0x09, sp)
	jrnc	00117$
	mov	_ui8_battery_state_of_charge+0, #0x06
	jp	00121$
00117$:
	C$ebike_app.c$567$1_0$448 ==.
;	ebike_app.c: 567: else if(ui16_battery_voltage_soc_x10 > ((uint16_t) ((float) ui8_battery_cells_number_x10 * LI_ION_CELL_VOLTS_4))) {ui8_battery_state_of_charge = 5;}	// 4 bars --> full
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	push	#0xa4
	push	#0x70
	push	#0x7d
	push	#0x40
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	cpw	x, (0x09, sp)
	jrnc	00114$
	mov	_ui8_battery_state_of_charge+0, #0x05
	jp	00121$
00114$:
	C$ebike_app.c$568$1_0$448 ==.
;	ebike_app.c: 568: else if(ui16_battery_voltage_soc_x10 > ((uint16_t) ((float) ui8_battery_cells_number_x10 * LI_ION_CELL_VOLTS_3))) {ui8_battery_state_of_charge = 4;}	// 3 bars
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	push	#0xcd
	push	#0xcc
	push	#0x6c
	push	#0x40
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	cpw	x, (0x09, sp)
	jrnc	00111$
	mov	_ui8_battery_state_of_charge+0, #0x04
	jp	00121$
00111$:
	C$ebike_app.c$569$1_0$448 ==.
;	ebike_app.c: 569: else if(ui16_battery_voltage_soc_x10 > ((uint16_t) ((float) ui8_battery_cells_number_x10 * LI_ION_CELL_VOLTS_2))) {ui8_battery_state_of_charge = 3;}	// 2 bars
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	push	#0xf6
	push	#0x28
	push	#0x5c
	push	#0x40
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	cpw	x, (0x09, sp)
	jrnc	00108$
	mov	_ui8_battery_state_of_charge+0, #0x03
	jra	00121$
00108$:
	C$ebike_app.c$570$1_0$448 ==.
;	ebike_app.c: 570: else if(ui16_battery_voltage_soc_x10 > ((uint16_t) ((float) ui8_battery_cells_number_x10 * LI_ION_CELL_VOLTS_1))) {ui8_battery_state_of_charge = 2;}	// 1 bar
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	push	#0x33
	push	#0x33
	push	#0x53
	push	#0x40
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	cpw	x, (0x09, sp)
	jrnc	00105$
	mov	_ui8_battery_state_of_charge+0, #0x02
	jra	00121$
00105$:
	C$ebike_app.c$571$1_0$448 ==.
;	ebike_app.c: 571: else if(ui16_battery_voltage_soc_x10 > ((uint16_t) ((float) ui8_battery_cells_number_x10 * LI_ION_CELL_VOLTS_0))) {ui8_battery_state_of_charge = 1;}	// blink --> empty
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	clrw	x
	pushw	x
	push	#0x40
	push	#0x40
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	cpw	x, (0x09, sp)
	jrnc	00102$
	mov	_ui8_battery_state_of_charge+0, #0x01
	jra	00121$
00102$:
	C$ebike_app.c$572$3_0$456 ==.
;	ebike_app.c: 572: else{ui8_battery_state_of_charge = 0;} // undervoltage
	clr	_ui8_battery_state_of_charge+0
00121$:
	C$ebike_app.c$587$1_0$448 ==.
;	ebike_app.c: 587: }
	addw	sp, #14
	C$ebike_app.c$587$1_0$448 ==.
	XFebike_app$check_battery_soc$0$0 ==.
	ret
	Febike_app$communications_controller$0$0 ==.
	C$ebike_app.c$589$1_0$458 ==.
;	ebike_app.c: 589: static void communications_controller (void)
;	-----------------------------------------
;	 function communications_controller
;	-----------------------------------------
_communications_controller:
	sub	sp, #4
	C$ebike_app.c$597$1_0$458 ==.
;	ebike_app.c: 597: ui16_walk_assist_delay_off++;
	ldw	x, _ui16_walk_assist_delay_off+0
	incw	x
	ldw	_ui16_walk_assist_delay_off+0, x
	C$ebike_app.c$600$1_0$458 ==.
;	ebike_app.c: 600: ui8_lights_counter++;
	inc	_ui8_lights_counter+0
	C$ebike_app.c$602$1_0$458 ==.
;	ebike_app.c: 602: if(ui8_received_package_flag)
	tnz	_ui8_received_package_flag+0
	jrne	00419$
	jp	00198$
00419$:
	C$ebike_app.c$605$2_0$459 ==.
;	ebike_app.c: 605: ui8_rx_check_code = 0x00;
	clr	(0x03, sp)
	C$ebike_app.c$606$3_0$460 ==.
;	ebike_app.c: 606: for(ui8_i = 0; ui8_i < 6; ui8_i++)
	clr	_ui8_i+0
00200$:
	ld	a, _ui8_i+0
	cp	a, #0x06
	jrnc	00101$
	C$ebike_app.c$608$4_0$461 ==.
;	ebike_app.c: 608: ui8_rx_check_code += ui8_rx_buffer[ui8_i];
	clrw	x
	ld	a, _ui8_i+0
	ld	xl, a
	addw	x, #_ui8_rx_buffer
	ld	a, (x)
	add	a, (0x03, sp)
	ld	(0x03, sp), a
	C$ebike_app.c$606$3_0$460 ==.
;	ebike_app.c: 606: for(ui8_i = 0; ui8_i < 6; ui8_i++)
	inc	_ui8_i+0
	jra	00200$
00101$:
	C$ebike_app.c$612$2_0$459 ==.
;	ebike_app.c: 612: if(ui8_rx_check_code == ui8_rx_buffer[6])
	ldw	x, #_ui8_rx_buffer+6
	ld	a, (x)
	ld	(0x01, sp), a
	ld	a, (0x03, sp)
	cp	a, (0x01, sp)
	jreq	00423$
	jp	00196$
00423$:
	C$ebike_app.c$615$3_0$462 ==.
;	ebike_app.c: 615: ui8_enable_walk_assist = 1;
	mov	_ui8_enable_walk_assist+0, #0x01
	C$ebike_app.c$618$3_0$462 ==.
;	ebike_app.c: 618: ui8_assist_level = ui8_rx_buffer[1] & 0x5E; // mask: 01011110
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	and	a, #0x5e
	ld	(0x04, sp), a
	C$ebike_app.c$620$3_0$462 ==.
;	ebike_app.c: 620: switch(ui8_assist_level)
	ld	a, (0x04, sp)
	sub	a, #0x02
	jrne	00425$
	inc	a
	ld	(0x02, sp), a
	.byte 0xc1
00425$:
	clr	(0x02, sp)
00426$:
	tnz	(0x02, sp)
	jreq	00427$
	jp	00104$
00427$:
	ld	a, (0x04, sp)
	cp	a, #0x04
	jrne	00429$
	jp	00105$
00429$:
	ld	a, (0x04, sp)
	cp	a, #0x08
	jrne	00432$
	jp	00106$
00432$:
	ld	a, (0x04, sp)
	cp	a, #0x10
	jreq	00102$
	ld	a, (0x04, sp)
	cp	a, #0x40
	jreq	00103$
	jp	00108$
	C$ebike_app.c$622$4_0$463 ==.
;	ebike_app.c: 622: case ASSIST_PEDAL_LEVEL0:
00102$:
	C$ebike_app.c$624$4_0$463 ==.
;	ebike_app.c: 624: configuration_variables.ui8_assist_level_factor_x10 = 0;
	mov	_configuration_variables+0, #0x00
	C$ebike_app.c$627$4_0$463 ==.
;	ebike_app.c: 627: configuration_variables.ui8_startup_motor_power_boost_assist_level = 0;
	ldw	x, #_configuration_variables+17
	clr	(x)
	C$ebike_app.c$630$4_0$463 ==.
;	ebike_app.c: 630: configuration_variables.ui8_walk_assist_pwm_duty_cycle = configuration_variables.ui8_walk_assist_pwm_duty_cycle_level[0];
	ldw	y, #_configuration_variables+52
	ldw	x, #_configuration_variables+53
	ld	a, (x)
	ld	(y), a
	C$ebike_app.c$636$4_0$463 ==.
;	ebike_app.c: 636: break;
	jp	00108$
	C$ebike_app.c$638$4_0$463 ==.
;	ebike_app.c: 638: case ASSIST_PEDAL_LEVEL1:
00103$:
	C$ebike_app.c$640$4_0$463 ==.
;	ebike_app.c: 640: configuration_variables.ui8_assist_level_factor_x10 = configuration_variables.ui8_assist_level_power[0];
	ldw	x, #_configuration_variables+43
	ld	a, (x)
	ld	_configuration_variables, a
	C$ebike_app.c$643$4_0$463 ==.
;	ebike_app.c: 643: configuration_variables.ui8_startup_motor_power_boost_assist_level = configuration_variables.ui8_startup_motor_power_boost[0];
	ldw	x, #_configuration_variables+17
	ldw	y, #_configuration_variables+47
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$650$4_0$463 ==.
;	ebike_app.c: 650: configuration_variables.ui8_walk_assist_pwm_duty_cycle = configuration_variables.ui8_walk_assist_pwm_duty_cycle_level[1];
	ldw	x, #_configuration_variables+52
	ldw	y, #_configuration_variables+54
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$652$4_0$463 ==.
;	ebike_app.c: 652: break;
	jp	00108$
	C$ebike_app.c$654$4_0$463 ==.
;	ebike_app.c: 654: case ASSIST_PEDAL_LEVEL2:
00104$:
	C$ebike_app.c$656$4_0$463 ==.
;	ebike_app.c: 656: configuration_variables.ui8_assist_level_factor_x10 = configuration_variables.ui8_assist_level_power[1];
	ldw	x, #_configuration_variables+44
	ld	a, (x)
	ld	_configuration_variables, a
	C$ebike_app.c$659$4_0$463 ==.
;	ebike_app.c: 659: configuration_variables.ui8_startup_motor_power_boost_assist_level = configuration_variables.ui8_startup_motor_power_boost[1];
	ldw	y, #_configuration_variables+17
	ldw	x, #_configuration_variables+48
	ld	a, (x)
	ld	(y), a
	C$ebike_app.c$662$4_0$463 ==.
;	ebike_app.c: 662: configuration_variables.ui8_walk_assist_pwm_duty_cycle = configuration_variables.ui8_walk_assist_pwm_duty_cycle_level[2];
	ldw	x, #_configuration_variables+52
	ldw	y, #_configuration_variables+55
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$668$4_0$463 ==.
;	ebike_app.c: 668: break;
	jra	00108$
	C$ebike_app.c$670$4_0$463 ==.
;	ebike_app.c: 670: case ASSIST_PEDAL_LEVEL3:
00105$:
	C$ebike_app.c$672$4_0$463 ==.
;	ebike_app.c: 672: configuration_variables.ui8_assist_level_factor_x10 = configuration_variables.ui8_assist_level_power[2];
	ldw	x, #_configuration_variables+45
	ld	a, (x)
	ld	_configuration_variables, a
	C$ebike_app.c$675$4_0$463 ==.
;	ebike_app.c: 675: configuration_variables.ui8_startup_motor_power_boost_assist_level = configuration_variables.ui8_startup_motor_power_boost[2];
	ldw	x, #_configuration_variables+17
	ldw	y, #_configuration_variables+49
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$678$4_0$463 ==.
;	ebike_app.c: 678: configuration_variables.ui8_walk_assist_pwm_duty_cycle = configuration_variables.ui8_walk_assist_pwm_duty_cycle_level[3];
	ldw	x, #_configuration_variables+52
	ldw	y, #_configuration_variables+56
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$679$4_0$463 ==.
;	ebike_app.c: 679: break;
	jra	00108$
	C$ebike_app.c$681$4_0$463 ==.
;	ebike_app.c: 681: case ASSIST_PEDAL_LEVEL4:
00106$:
	C$ebike_app.c$683$4_0$463 ==.
;	ebike_app.c: 683: configuration_variables.ui8_assist_level_factor_x10 = configuration_variables.ui8_assist_level_power[3];
	ldw	x, #_configuration_variables+46
	ld	a, (x)
	ld	_configuration_variables, a
	C$ebike_app.c$686$4_0$463 ==.
;	ebike_app.c: 686: configuration_variables.ui8_startup_motor_power_boost_assist_level = configuration_variables.ui8_startup_motor_power_boost[3];
	ldw	x, #_configuration_variables+17
	ldw	y, #_configuration_variables+50
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$689$4_0$463 ==.
;	ebike_app.c: 689: configuration_variables.ui8_walk_assist_pwm_duty_cycle = configuration_variables.ui8_walk_assist_pwm_duty_cycle_level[4];
	ldw	x, #_configuration_variables+52
	ldw	y, #_configuration_variables+57
	ld	a, (y)
	ld	(x), a
	C$ebike_app.c$695$3_0$462 ==.
;	ebike_app.c: 695: }
00108$:
	C$ebike_app.c$701$3_0$462 ==.
;	ebike_app.c: 701: if(ui8_assist_level == ASSIST_PEDAL_LEVEL0)
	ld	a, (0x04, sp)
	cp	a, #0x10
	jreq	00442$
	jp	00127$
00442$:
	C$ebike_app.c$704$4_0$464 ==.
;	ebike_app.c: 704: if((ui8_rx_buffer[1]) & (1 << 0) ? 1: 0)
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	srl	a
	jrnc	00124$
	C$ebike_app.c$707$5_0$465 ==.
;	ebike_app.c: 707: if(!ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jreq	00444$
	jp	00128$
00444$:
	C$ebike_app.c$710$6_0$466 ==.
;	ebike_app.c: 710: if(!ui8_default_flag)
	tnz	_ui8_default_flag+0
	jrne	00110$
	C$ebike_app.c$713$7_0$467 ==.
;	ebike_app.c: 713: ui8_default_flag = 1;
	mov	_ui8_default_flag+0, #0x01
	C$ebike_app.c$716$7_0$467 ==.
;	ebike_app.c: 716: configuration_variables.ui8_function_code = DEFAULT_ENABLED_ON_OEM;
	ldw	x, #_configuration_variables+36
	ld	a, #0x02
	ld	(x), a
	C$ebike_app.c$719$7_0$467 ==.
;	ebike_app.c: 719: ui8_lights_counter = 0;
	clr	_ui8_lights_counter+0
00110$:
	C$ebike_app.c$723$6_0$466 ==.
;	ebike_app.c: 723: if(ui8_lights_counter >= DELAY_LIGHTS_ON)
	ld	a, _ui8_lights_counter+0
	cp	a, #0x32
	jrnc	00446$
	jp	00128$
00446$:
	C$ebike_app.c$727$7_0$468 ==.
;	ebike_app.c: 727: ui8_lights_flag = 1;
	mov	_ui8_lights_flag+0, #0x01
	C$ebike_app.c$731$7_0$468 ==.
;	ebike_app.c: 731: ui8_default_flag = 0;
	clr	_ui8_default_flag+0
	jra	00128$
00124$:
	C$ebike_app.c$738$5_0$469 ==.
;	ebike_app.c: 738: if(!ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jrne	00121$
	C$ebike_app.c$741$6_0$470 ==.
;	ebike_app.c: 741: if(ui8_default_flag)
	tnz	_ui8_default_flag+0
	jreq	00128$
	C$ebike_app.c$744$7_0$471 ==.
;	ebike_app.c: 744: ui8_default_flag = 0;
	clr	_ui8_default_flag+0
	C$ebike_app.c$746$7_0$471 ==.
;	ebike_app.c: 746: if(configuration_variables.ui8_street_enabled_on_startup)
	ldw	x, #_configuration_variables+30
	ld	a, (x)
	jreq	00116$
	C$ebike_app.c$748$7_0$471 ==.
;	ebike_app.c: 748: configuration_variables.ui8_offroad_mode = 0;
	ldw	x, #_configuration_variables+9
	clr	(x)
	jra	00117$
00116$:
	C$ebike_app.c$751$7_0$471 ==.
;	ebike_app.c: 751: configuration_variables.ui8_offroad_mode = 1;
	ldw	x, #_configuration_variables+9
	ld	a, #0x01
	ld	(x), a
00117$:
	C$ebike_app.c$754$7_0$471 ==.
;	ebike_app.c: 754: configuration_variables.ui8_startup_motor_power_boost_feature_enabled = 0;
	ldw	x, #_configuration_variables+16
	clr	(x)
	C$ebike_app.c$757$7_0$471 ==.
;	ebike_app.c: 757: configuration_variables.ui8_function_code = DEFAULT_FUNCTION_ENABLED;
	ldw	x, #_configuration_variables+36
	clr	(x)
	jra	00128$
00121$:
	C$ebike_app.c$764$6_0$472 ==.
;	ebike_app.c: 764: ui8_lights_flag = 0;
	clr	_ui8_lights_flag+0
	jra	00128$
00127$:
	C$ebike_app.c$771$4_0$473 ==.
;	ebike_app.c: 771: ui8_default_flag = 0;
	clr	_ui8_default_flag+0
00128$:
	C$ebike_app.c$778$3_0$462 ==.
;	ebike_app.c: 778: if(ui8_assist_level == ASSIST_PEDAL_LEVEL1)
	ld	a, (0x04, sp)
	cp	a, #0x40
	jreq	00452$
	jp	00150$
00452$:
	C$ebike_app.c$781$4_0$474 ==.
;	ebike_app.c: 781: if((ui8_rx_buffer[1]) & (1 << 0) ? 1: 0)
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	srl	a
	jrnc	00147$
	C$ebike_app.c$784$5_0$475 ==.
;	ebike_app.c: 784: if(!ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jreq	00454$
	jp	00151$
00454$:
	C$ebike_app.c$787$6_0$476 ==.
;	ebike_app.c: 787: if(!ui8_mode_flag)
	tnz	_ui8_mode_flag+0
	jrne	00133$
	C$ebike_app.c$790$7_0$477 ==.
;	ebike_app.c: 790: ui8_mode_flag = 1;
	mov	_ui8_mode_flag+0, #0x01
	C$ebike_app.c$792$7_0$477 ==.
;	ebike_app.c: 792: if(configuration_variables.ui8_offroad_mode == 1)
	ldw	x, #_configuration_variables+9
	ld	a, (x)
	dec	a
	jrne	00130$
	C$ebike_app.c$794$7_0$477 ==.
;	ebike_app.c: 794: configuration_variables.ui8_function_code = STREET_ENABLED_ON_OEM;
	ldw	x, #_configuration_variables+36
	ld	a, #0x03
	ld	(x), a
	jra	00131$
00130$:
	C$ebike_app.c$797$7_0$477 ==.
;	ebike_app.c: 797: configuration_variables.ui8_function_code = OFFROAD_ENABLED_ON_OEM;
	ldw	x, #_configuration_variables+36
	ld	a, #0x04
	ld	(x), a
00131$:
	C$ebike_app.c$800$7_0$477 ==.
;	ebike_app.c: 800: ui8_lights_counter = 0;
	clr	_ui8_lights_counter+0
00133$:
	C$ebike_app.c$804$6_0$476 ==.
;	ebike_app.c: 804: if(ui8_lights_counter >= DELAY_LIGHTS_ON)
	ld	a, _ui8_lights_counter+0
	cp	a, #0x32
	jrnc	00459$
	jp	00151$
00459$:
	C$ebike_app.c$808$7_0$478 ==.
;	ebike_app.c: 808: ui8_lights_flag = 1;
	mov	_ui8_lights_flag+0, #0x01
	C$ebike_app.c$812$7_0$478 ==.
;	ebike_app.c: 812: ui8_mode_flag = 0;
	clr	_ui8_mode_flag+0
	jra	00151$
00147$:
	C$ebike_app.c$819$5_0$479 ==.
;	ebike_app.c: 819: if(!ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jrne	00144$
	C$ebike_app.c$822$6_0$480 ==.
;	ebike_app.c: 822: if(ui8_mode_flag)
	tnz	_ui8_mode_flag+0
	jreq	00151$
	C$ebike_app.c$825$7_0$481 ==.
;	ebike_app.c: 825: ui8_mode_flag = 0;
	clr	_ui8_mode_flag+0
	C$ebike_app.c$827$7_0$481 ==.
;	ebike_app.c: 827: if(configuration_variables.ui8_offroad_mode == 1)
	ldw	x, #_configuration_variables+9
	ld	a, (x)
	dec	a
	jrne	00139$
	C$ebike_app.c$830$8_0$482 ==.
;	ebike_app.c: 830: configuration_variables.ui8_offroad_mode = 0;
	ldw	x, #_configuration_variables+9
	clr	(x)
	C$ebike_app.c$833$8_0$482 ==.
;	ebike_app.c: 833: configuration_variables.ui8_function_code = STREET_FUNCTION_ENABLED;
	ldw	x, #_configuration_variables+36
	clr	(x)
	jra	00151$
00139$:
	C$ebike_app.c$838$8_0$483 ==.
;	ebike_app.c: 838: configuration_variables.ui8_offroad_mode = 1;
	ldw	x, #_configuration_variables+9
	ld	a, #0x01
	ld	(x), a
	C$ebike_app.c$841$8_0$483 ==.
;	ebike_app.c: 841: configuration_variables.ui8_function_code = OFFROAD_FUNCTION_ENABLED;
	ldw	x, #_configuration_variables+36
	clr	(x)
	jra	00151$
00144$:
	C$ebike_app.c$849$6_0$484 ==.
;	ebike_app.c: 849: ui8_lights_flag = 0;
	clr	_ui8_lights_flag+0
	jra	00151$
00150$:
	C$ebike_app.c$856$4_0$485 ==.
;	ebike_app.c: 856: ui8_mode_flag = 0;
	clr	_ui8_mode_flag+0
00151$:
	C$ebike_app.c$863$3_0$462 ==.
;	ebike_app.c: 863: if(ui8_assist_level == ASSIST_PEDAL_LEVEL2)
	tnz	(0x02, sp)
	jrne	00465$
	jp	00173$
00465$:
	C$ebike_app.c$866$4_0$486 ==.
;	ebike_app.c: 866: if((ui8_rx_buffer[1]) & (1 << 0) ? 1: 0)
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	srl	a
	jrnc	00170$
	C$ebike_app.c$869$5_0$487 ==.
;	ebike_app.c: 869: if(!ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jreq	00467$
	jp	00174$
00467$:
	C$ebike_app.c$872$6_0$488 ==.
;	ebike_app.c: 872: if(!ui8_boost_flag)
	tnz	_ui8_boost_flag+0
	jrne	00156$
	C$ebike_app.c$875$7_0$489 ==.
;	ebike_app.c: 875: ui8_boost_flag = 1;
	mov	_ui8_boost_flag+0, #0x01
	C$ebike_app.c$877$7_0$489 ==.
;	ebike_app.c: 877: if(configuration_variables.ui8_startup_motor_power_boost_feature_enabled == 0)
	ldw	x, #_configuration_variables+16
	ld	a, (x)
	jrne	00153$
	C$ebike_app.c$879$7_0$489 ==.
;	ebike_app.c: 879: configuration_variables.ui8_function_code = BOOST_ENABLED_ON_OEM;
	ldw	x, #_configuration_variables+36
	ld	a, #0x05
	ld	(x), a
	jra	00154$
00153$:
	C$ebike_app.c$882$7_0$489 ==.
;	ebike_app.c: 882: configuration_variables.ui8_function_code = BOOST_DISABLED_ON_OEM;
	ldw	x, #_configuration_variables+36
	ld	a, #0x01
	ld	(x), a
00154$:
	C$ebike_app.c$885$7_0$489 ==.
;	ebike_app.c: 885: ui8_lights_counter = 0;
	clr	_ui8_lights_counter+0
00156$:
	C$ebike_app.c$889$6_0$488 ==.
;	ebike_app.c: 889: if(ui8_lights_counter >= DELAY_LIGHTS_ON)
	ld	a, _ui8_lights_counter+0
	cp	a, #0x32
	jrnc	00470$
	jp	00174$
00470$:
	C$ebike_app.c$893$7_0$490 ==.
;	ebike_app.c: 893: ui8_lights_flag = 1;
	mov	_ui8_lights_flag+0, #0x01
	C$ebike_app.c$897$7_0$490 ==.
;	ebike_app.c: 897: ui8_boost_flag = 0;
	clr	_ui8_boost_flag+0
	jra	00174$
00170$:
	C$ebike_app.c$904$5_0$491 ==.
;	ebike_app.c: 904: if(!ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jrne	00167$
	C$ebike_app.c$907$6_0$492 ==.
;	ebike_app.c: 907: if(ui8_boost_flag)
	tnz	_ui8_boost_flag+0
	jreq	00174$
	C$ebike_app.c$910$7_0$493 ==.
;	ebike_app.c: 910: ui8_boost_flag = 0;
	clr	_ui8_boost_flag+0
	C$ebike_app.c$912$7_0$493 ==.
;	ebike_app.c: 912: if(configuration_variables.ui8_startup_motor_power_boost_feature_enabled == 0)
	ldw	x, #_configuration_variables+16
	ld	a, (x)
	jrne	00162$
	C$ebike_app.c$915$8_0$494 ==.
;	ebike_app.c: 915: configuration_variables.ui8_startup_motor_power_boost_feature_enabled = 1;
	ldw	x, #_configuration_variables+16
	ld	a, #0x01
	ld	(x), a
	C$ebike_app.c$918$8_0$494 ==.
;	ebike_app.c: 918: configuration_variables.ui8_function_code = BOOST_FUNCTION_ENABLED;
	ldw	x, #_configuration_variables+36
	clr	(x)
	jra	00174$
00162$:
	C$ebike_app.c$923$8_0$495 ==.
;	ebike_app.c: 923: configuration_variables.ui8_startup_motor_power_boost_feature_enabled = 0;
	ldw	x, #_configuration_variables+16
	clr	(x)
	C$ebike_app.c$926$8_0$495 ==.
;	ebike_app.c: 926: configuration_variables.ui8_function_code = BOOST_FUNCTION_DISABLED;
	ldw	x, #_configuration_variables+36
	clr	(x)
	jra	00174$
00167$:
	C$ebike_app.c$934$6_0$496 ==.
;	ebike_app.c: 934: ui8_lights_flag = 0;
	clr	_ui8_lights_flag+0
	jra	00174$
00173$:
	C$ebike_app.c$941$4_0$497 ==.
;	ebike_app.c: 941: ui8_boost_flag = 0;
	clr	_ui8_boost_flag+0
00174$:
	C$ebike_app.c$948$3_0$462 ==.
;	ebike_app.c: 948: if(ui8_assist_level == ASSIST_PEDAL_LEVEL3)
	ld	a, (0x04, sp)
	cp	a, #0x04
	jrne	00179$
	C$ebike_app.c$951$4_0$498 ==.
;	ebike_app.c: 951: if((ui8_rx_buffer[1]) & (1 << 0) ? 1: 0)
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	srl	a
	jrnc	00176$
	C$ebike_app.c$953$4_0$498 ==.
;	ebike_app.c: 953: ui8_lights_flag = 1;
	mov	_ui8_lights_flag+0, #0x01
	jra	00179$
00176$:
	C$ebike_app.c$956$4_0$498 ==.
;	ebike_app.c: 956: ui8_lights_flag = 0;
	clr	_ui8_lights_flag+0
00179$:
	C$ebike_app.c$964$3_0$462 ==.
;	ebike_app.c: 964: if(ui8_assist_level == ASSIST_PEDAL_LEVEL4)
	ld	a, (0x04, sp)
	cp	a, #0x08
	jrne	00184$
	C$ebike_app.c$967$4_0$499 ==.
;	ebike_app.c: 967: if((ui8_rx_buffer[1]) & (1 << 0) ? 1: 0)
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	srl	a
	jrnc	00181$
	C$ebike_app.c$969$4_0$499 ==.
;	ebike_app.c: 969: ui8_lights_flag = 1;
	mov	_ui8_lights_flag+0, #0x01
	jra	00184$
00181$:
	C$ebike_app.c$972$4_0$499 ==.
;	ebike_app.c: 972: ui8_lights_flag = 0;
	clr	_ui8_lights_flag+0
00184$:
	C$ebike_app.c$978$3_0$462 ==.
;	ebike_app.c: 978: if(ui8_lights_flag)
	tnz	_ui8_lights_flag+0
	jreq	00186$
	C$ebike_app.c$979$3_0$462 ==.
;	ebike_app.c: 979: configuration_variables.ui8_function_code = PENDING_FUNCTION_ABORTED;
	ldw	x, #_configuration_variables+36
	clr	(x)
00186$:
	C$ebike_app.c$982$3_0$462 ==.
;	ebike_app.c: 982: configuration_variables.ui8_lights = ui8_lights_flag;
	ldw	x, #_configuration_variables+7
	ld	a, _ui8_lights_flag+0
	ld	(x), a
	C$ebike_app.c$983$3_0$462 ==.
;	ebike_app.c: 983: lights_set_state (configuration_variables.ui8_lights);
	ldw	x, #_configuration_variables+7
	ld	a, (x)
	push	a
	call	_lights_set_state
	pop	a
	C$ebike_app.c$991$3_0$462 ==.
;	ebike_app.c: 991: if(ui8_enable_walk_assist)
	tnz	_ui8_enable_walk_assist+0
	jreq	00191$
	C$ebike_app.c$994$4_0$500 ==.
;	ebike_app.c: 994: if((ui8_rx_buffer[1] & (1 << 5)) ? 1: 0)
	ldw	x, #_ui8_rx_buffer+1
	ld	a, (x)
	bcp	a, #0x20
	jreq	00188$
	C$ebike_app.c$997$5_0$501 ==.
;	ebike_app.c: 997: ui8_walk_assist_flag = 1;
	mov	_ui8_walk_assist_flag+0, #0x01
	C$ebike_app.c$1000$5_0$501 ==.
;	ebike_app.c: 1000: ui16_walk_assist_delay_off = 0;
	clrw	x
	ldw	_ui16_walk_assist_delay_off+0, x
	C$ebike_app.c$1003$5_0$501 ==.
;	ebike_app.c: 1003: ui8_walk_assist_current_per_cent = configuration_variables.ui8_walk_assist_percentage_current;
	ldw	x, #_configuration_variables+51
	ld	a, (x)
	ld	_ui8_walk_assist_current_per_cent+0, a
	jra	00192$
00188$:
	C$ebike_app.c$1029$5_0$502 ==.
;	ebike_app.c: 1029: ui8_walk_assist_current_per_cent = 0;
	clr	_ui8_walk_assist_current_per_cent+0
	jra	00192$
00191$:
	C$ebike_app.c$1035$4_0$503 ==.
;	ebike_app.c: 1035: ui8_walk_assist_current_per_cent = 0;
	clr	_ui8_walk_assist_current_per_cent+0
00192$:
	C$ebike_app.c$1042$3_0$462 ==.
;	ebike_app.c: 1042: ebike_app_set_battery_max_current (configuration_variables.ui8_battery_max_current);
	ldw	x, #_configuration_variables+1
	ld	a, (x)
	push	a
	call	_ebike_app_set_battery_max_current
	pop	a
	C$ebike_app.c$1045$3_0$462 ==.
;	ebike_app.c: 1045: ui32_temp = ((uint32_t) configuration_variables.ui16_battery_low_voltage_cut_off_x10 << 8) / ((uint32_t) ADC8BITS_BATTERY_VOLTAGE_PER_ADC_STEP_INVERSE_X256);
	ldw	x, #_configuration_variables+3
	ld	a, (0x1, x)
	ld	yh, a
	ld	a, (x)
	clrw	x
	ld	xl, a
	clr	a
	ld	yl, a
	push	#0x58
	push	#0x00
	push	#0x00
	push	#0x00
	pushw	y
	pushw	x
	call	__divulong
	addw	sp, #8
	C$ebike_app.c$1046$1_0$458 ==.
;	ebike_app.c: 1046: ui32_temp /= 10;
	push	#0x0a
	push	#0x00
	push	#0x00
	push	#0x00
	pushw	x
	pushw	y
	call	__divulong
	addw	sp, #8
	ld	a, xl
	C$ebike_app.c$1047$3_0$462 ==.
;	ebike_app.c: 1047: motor_set_adc_battery_voltage_cut_off((uint8_t) ui32_temp);
	push	a
	call	_motor_set_adc_battery_voltage_cut_off
	pop	a
	C$ebike_app.c$1051$3_0$462 ==.
;	ebike_app.c: 1051: configuration_variables.ui16_wheel_perimeter = ui8_rx_buffer[3] * 80; // wheel diameter (inch) * 3.14 * 2.54 * 10
	ldw	y, #_configuration_variables+5
	ldw	x, #_ui8_rx_buffer+3
	ld	a, (x)
	clrw	x
	ld	xl, a
	pushw	x
	sllw	x
	sllw	x
	addw	x, (1, sp)
	sllw	x
	sllw	x
	sllw	x
	sllw	x
	addw	sp, #2
	ldw	(y), x
	C$ebike_app.c$1072$3_0$462 ==.
;	ebike_app.c: 1072: if(configuration_variables.ui8_offroad_mode)
	ldw	x, #_configuration_variables+9
	ld	a, (x)
	jreq	00194$
	C$ebike_app.c$1073$3_0$462 ==.
;	ebike_app.c: 1073: configuration_variables.ui8_wheel_max_speed = ui8_rx_buffer[5];
	ldw	x, #_configuration_variables+10
	ldw	y, #_ui8_rx_buffer+5
	ld	a, (y)
	ld	(x), a
00194$:
	C$ebike_app.c$1086$3_0$462 ==.
;	ebike_app.c: 1086: ui8_received_package_flag = 0;
	clr	_ui8_received_package_flag+0
	C$ebike_app.c$1088$3_0$462 ==.
;	ebike_app.c: 1088: ui8_uart_received_first_package = 1;
	mov	_ui8_uart_received_first_package+0, #0x01
00196$:
	C$ebike_app.c$1092$2_0$459 ==.
;	ebike_app.c: 1092: UART2->CR2 |= (1 << 5);
	bset	21061, #5
00198$:
	C$ebike_app.c$1096$1_0$458 ==.
;	ebike_app.c: 1096: uart_send_package();
	call	_uart_send_package
	C$ebike_app.c$1098$1_0$458 ==.
;	ebike_app.c: 1098: }
	addw	sp, #4
	C$ebike_app.c$1098$1_0$458 ==.
	XFebike_app$communications_controller$0$0 ==.
	ret
	Febike_app$uart_send_package$0$0 ==.
	C$ebike_app.c$1100$1_0$505 ==.
;	ebike_app.c: 1100: static void uart_send_package (void)
;	-----------------------------------------
;	 function uart_send_package
;	-----------------------------------------
_uart_send_package:
	sub	sp, #7
	C$ebike_app.c$1107$1_0$505 ==.
;	ebike_app.c: 1107: ui8_tx_buffer[0] = 0x43;
	mov	_ui8_tx_buffer+0, #0x43
	C$ebike_app.c$1110$1_0$505 ==.
;	ebike_app.c: 1110: configuration_variables.ui8_fault_code = NO_FAULT;
	ldw	x, #_configuration_variables+37
	clr	(x)
	C$ebike_app.c$1113$1_0$505 ==.
;	ebike_app.c: 1113: configuration_variables.ui8_working_status &= 0xFE; // bit0 = 0 (battery normal)
	ldw	x, #_configuration_variables+35
	ldw	y, #_configuration_variables+35
	ld	a, (y)
	and	a, #0xfe
	ld	(x), a
	C$ebike_app.c$1116$1_0$505 ==.
;	ebike_app.c: 1116: switch(ui8_battery_state_of_charge)
	ld	a, _ui8_battery_state_of_charge+0
	cp	a, #0x06
	jrule	00172$
	jp	00108$
00172$:
	clrw	x
	ld	xl, a
	sllw	x
	ldw	x, (#00173$, x)
	jp	(x)
00173$:
	.dw	#00101$
	.dw	#00102$
	.dw	#00103$
	.dw	#00104$
	.dw	#00105$
	.dw	#00106$
	.dw	#00107$
	C$ebike_app.c$1118$2_0$506 ==.
;	ebike_app.c: 1118: case 0:
00101$:
	C$ebike_app.c$1119$2_0$506 ==.
;	ebike_app.c: 1119: configuration_variables.ui8_working_status |= 0x01; // bit0 = 1 (battery undervoltage)
	ldw	x, #_configuration_variables+35
	ldw	y, #_configuration_variables+35
	ld	a, (y)
	or	a, #0x01
	ld	(x), a
	C$ebike_app.c$1120$2_0$506 ==.
;	ebike_app.c: 1120: ui8_tx_buffer[1] = 0x00;
	ldw	x, #_ui8_tx_buffer+1
	clr	(x)
	C$ebike_app.c$1121$2_0$506 ==.
;	ebike_app.c: 1121: break;
	jp	00108$
	C$ebike_app.c$1123$2_0$506 ==.
;	ebike_app.c: 1123: case 1:
00102$:
	C$ebike_app.c$1124$2_0$506 ==.
;	ebike_app.c: 1124: ui8_tx_buffer[1] = 0x00; // Battery 0/4 (empty and blinking)
	ldw	x, #_ui8_tx_buffer+1
	clr	(x)
	C$ebike_app.c$1125$2_0$506 ==.
;	ebike_app.c: 1125: break;
	jp	00108$
	C$ebike_app.c$1127$2_0$506 ==.
;	ebike_app.c: 1127: case 2:
00103$:
	C$ebike_app.c$1128$2_0$506 ==.
;	ebike_app.c: 1128: ui8_tx_buffer[1] = 0x02; // Battery 1/4
	ldw	x, #_ui8_tx_buffer+1
	ld	a, #0x02
	ld	(x), a
	C$ebike_app.c$1129$2_0$506 ==.
;	ebike_app.c: 1129: break;
	jra	00108$
	C$ebike_app.c$1131$2_0$506 ==.
;	ebike_app.c: 1131: case 3:
00104$:
	C$ebike_app.c$1132$2_0$506 ==.
;	ebike_app.c: 1132: ui8_tx_buffer[1] = 0x06; // Battery 2/4
	ldw	x, #_ui8_tx_buffer+1
	ld	a, #0x06
	ld	(x), a
	C$ebike_app.c$1133$2_0$506 ==.
;	ebike_app.c: 1133: break;
	jra	00108$
	C$ebike_app.c$1135$2_0$506 ==.
;	ebike_app.c: 1135: case 4:
00105$:
	C$ebike_app.c$1136$2_0$506 ==.
;	ebike_app.c: 1136: ui8_tx_buffer[1] = 0x09; // Battery 3/4
	ldw	x, #_ui8_tx_buffer+1
	ld	a, #0x09
	ld	(x), a
	C$ebike_app.c$1137$2_0$506 ==.
;	ebike_app.c: 1137: break;
	jra	00108$
	C$ebike_app.c$1139$2_0$506 ==.
;	ebike_app.c: 1139: case 5:
00106$:
	C$ebike_app.c$1140$2_0$506 ==.
;	ebike_app.c: 1140: ui8_tx_buffer[1] = 0x0C; // Battery 4/4 (full)
	ldw	x, #_ui8_tx_buffer+1
	ld	a, #0x0c
	ld	(x), a
	C$ebike_app.c$1141$2_0$506 ==.
;	ebike_app.c: 1141: break;
	jra	00108$
	C$ebike_app.c$1143$2_0$506 ==.
;	ebike_app.c: 1143: case 6:
00107$:
	C$ebike_app.c$1144$2_0$506 ==.
;	ebike_app.c: 1144: ui8_tx_buffer[1] = 0x0C; // Battery 4/4 (full)
	ldw	x, #_ui8_tx_buffer+1
	ld	a, #0x0c
	ld	(x), a
	C$ebike_app.c$1145$2_0$506 ==.
;	ebike_app.c: 1145: configuration_variables.ui8_fault_code = OVERVOLTAGE; // Fault overvoltage
	ldw	x, #_configuration_variables+37
	ld	a, #0x08
	ld	(x), a
	C$ebike_app.c$1147$1_0$505 ==.
;	ebike_app.c: 1147: }
00108$:
	C$ebike_app.c$1194$1_0$505 ==.
;	ebike_app.c: 1194: ui8_tx_buffer[3] = 0x46;
	ldw	x, #_ui8_tx_buffer+3
	ld	a, #0x46
	ld	(x), a
	C$ebike_app.c$1195$1_0$505 ==.
;	ebike_app.c: 1195: ui8_tx_buffer[4] = 0x46;
	ldw	x, #_ui8_tx_buffer+4
	ld	a, #0x46
	ld	(x), a
	C$ebike_app.c$1198$1_0$505 ==.
;	ebike_app.c: 1198: if(configuration_variables.ui8_fault_code == NO_FAULT)
	ldw	x, #_configuration_variables+37
	ld	a, (x)
	jrne	00112$
	C$ebike_app.c$1200$2_0$507 ==.
;	ebike_app.c: 1200: if(configuration_variables.ui8_error_states & ERROR_STATE_EBIKE_WHEEL_BLOCKED)
	ldw	x, #_configuration_variables+34
	ld	a, (x)
	srl	a
	jrnc	00112$
	C$ebike_app.c$1201$2_0$507 ==.
;	ebike_app.c: 1201: configuration_variables.ui8_fault_code = EBIKE_WHEEL_BLOCKED;
	ldw	x, #_configuration_variables+37
	ld	a, #0x07
	ld	(x), a
00112$:
	C$ebike_app.c$1205$1_0$505 ==.
;	ebike_app.c: 1205: if(configuration_variables.ui8_function_code != NO_FUNCTION)
	ldw	x, #_configuration_variables+36
	ld	a, (x)
	jreq	00114$
	C$ebike_app.c$1208$2_0$508 ==.
;	ebike_app.c: 1208: ui8_tx_buffer[5] = configuration_variables.ui8_function_code;
	ldw	x, #_ui8_tx_buffer+5
	ldw	y, #_configuration_variables+36
	ld	a, (y)
	ld	(x), a
	jra	00115$
00114$:
	C$ebike_app.c$1213$2_0$509 ==.
;	ebike_app.c: 1213: ui8_tx_buffer[5] = configuration_variables.ui8_fault_code;
	ldw	x, #_ui8_tx_buffer+5
	ldw	y, #_configuration_variables+37
	ld	a, (y)
	ld	(x), a
00115$:
	C$ebike_app.c$1217$1_0$505 ==.
;	ebike_app.c: 1217: if(ui16_oem_wheel_speed == 0)
	ldw	x, _ui16_oem_wheel_speed+0
	jrne	00117$
	C$ebike_app.c$1219$2_0$510 ==.
;	ebike_app.c: 1219: ui8_tx_buffer[6] = 0x07;
	ldw	x, #_ui8_tx_buffer+6
	ld	a, #0x07
	ld	(x), a
	C$ebike_app.c$1220$2_0$510 ==.
;	ebike_app.c: 1220: ui8_tx_buffer[7] = 0x07;
	ldw	x, #_ui8_tx_buffer+7
	ld	a, #0x07
	ld	(x), a
	C$ebike_app.c$1224$2_0$510 ==.
;	ebike_app.c: 1224: configuration_variables.ui8_working_status &= 0x7F;
	ldw	x, #_configuration_variables+35
	ldw	y, #_configuration_variables+35
	ld	a, (y)
	and	a, #0x7f
	ld	(x), a
	jra	00118$
00117$:
	C$ebike_app.c$1229$2_0$511 ==.
;	ebike_app.c: 1229: ui8_tx_buffer[6] = (uint8_t) (ui16_oem_wheel_speed & 0xff);
	ldw	x, #_ui8_tx_buffer+6
	ld	a, _ui16_oem_wheel_speed+1
	ld	(x), a
	C$ebike_app.c$1230$2_0$511 ==.
;	ebike_app.c: 1230: ui8_tx_buffer[7] = (uint8_t) (ui16_oem_wheel_speed >> 8);
	ldw	x, #_ui8_tx_buffer+7
	ld	a, _ui16_oem_wheel_speed+0
	clr	(0x03, sp)
	ld	(x), a
	C$ebike_app.c$1234$2_0$511 ==.
;	ebike_app.c: 1234: configuration_variables.ui8_working_status |= 0x80;
	ldw	x, #_configuration_variables+35
	ldw	(0x05, sp), x
	ldw	x, #_configuration_variables+35
	ld	a, (x)
	or	a, #0x80
	ldw	x, (0x05, sp)
	ld	(x), a
00118$:
	C$ebike_app.c$1243$1_0$505 ==.
;	ebike_app.c: 1243: configuration_variables.ui8_working_status &= 0x3B;
	ldw	x, #_configuration_variables+35
	ldw	y, #_configuration_variables+35
	ld	a, (y)
	and	a, #0x3b
	ld	(x), a
	C$ebike_app.c$1246$1_0$505 ==.
;	ebike_app.c: 1246: if(configuration_variables.ui8_working_status & 0xC0)
	ldw	x, #_configuration_variables+35
	ld	a, (x)
	bcp	a, #0xc0
	jreq	00120$
	C$ebike_app.c$1249$2_0$512 ==.
;	ebike_app.c: 1249: configuration_variables.ui8_working_status |= 0x04;
	ldw	x, #_configuration_variables+35
	ldw	y, #_configuration_variables+35
	ld	a, (y)
	or	a, #0x04
	ld	(x), a
	jra	00121$
00120$:
	C$ebike_app.c$1254$2_0$513 ==.
;	ebike_app.c: 1254: configuration_variables.ui8_working_status &= 0xFB;
	ldw	x, #_configuration_variables+35
	ldw	(0x01, sp), x
	ldw	x, #_configuration_variables+35
	ld	a, (x)
	and	a, #0xfb
	ldw	x, (0x01, sp)
	ld	(x), a
00121$:
	C$ebike_app.c$1259$1_0$505 ==.
;	ebike_app.c: 1259: ui8_tx_buffer[2] = (configuration_variables.ui8_working_status & 0x1F);
	ldw	x, #_ui8_tx_buffer+2
	ldw	y, #_configuration_variables+35
	ld	a, (y)
	and	a, #0x1f
	ld	(x), a
	C$ebike_app.c$1262$1_0$505 ==.
;	ebike_app.c: 1262: ui8_tx_check_code = 0x00;
	clr	(0x07, sp)
	C$ebike_app.c$1263$2_0$514 ==.
;	ebike_app.c: 1263: for(ui8_i = 0; ui8_i < 8; ui8_i++)
	clr	_ui8_i+0
00125$:
	ld	a, _ui8_i+0
	cp	a, #0x08
	jrnc	00122$
	C$ebike_app.c$1265$3_0$515 ==.
;	ebike_app.c: 1265: ui8_tx_check_code += ui8_tx_buffer[ui8_i];
	clrw	x
	ld	a, _ui8_i+0
	ld	xl, a
	addw	x, #_ui8_tx_buffer
	ld	a, (x)
	add	a, (0x07, sp)
	ld	(0x07, sp), a
	C$ebike_app.c$1263$2_0$514 ==.
;	ebike_app.c: 1263: for(ui8_i = 0; ui8_i < 8; ui8_i++)
	inc	_ui8_i+0
	jra	00125$
00122$:
	C$ebike_app.c$1267$1_0$505 ==.
;	ebike_app.c: 1267: ui8_tx_buffer[8] = ui8_tx_check_code;
	ldw	x, #_ui8_tx_buffer+8
	ld	a, (0x07, sp)
	ld	(x), a
	C$ebike_app.c$1270$2_0$516 ==.
;	ebike_app.c: 1270: for(ui8_i = 0; ui8_i <= 8; ui8_i++)
	clr	_ui8_i+0
00128$:
	ld	a, _ui8_i+0
	cp	a, #0x08
	jrugt	00130$
	C$ebike_app.c$1272$3_0$517 ==.
;	ebike_app.c: 1272: putchar (ui8_tx_buffer[ui8_i]);
	clrw	x
	ld	a, _ui8_i+0
	ld	xl, a
	addw	x, #_ui8_tx_buffer
	ld	a, (x)
	clrw	x
	ld	xl, a
	pushw	x
	call	_putchar
	addw	sp, #2
	C$ebike_app.c$1270$2_0$516 ==.
;	ebike_app.c: 1270: for(ui8_i = 0; ui8_i <= 8; ui8_i++)
	inc	_ui8_i+0
	jra	00128$
00130$:
	C$ebike_app.c$1275$2_0$505 ==.
;	ebike_app.c: 1275: }
	addw	sp, #7
	C$ebike_app.c$1275$2_0$505 ==.
	XFebike_app$uart_send_package$0$0 ==.
	ret
	Febike_app$ebike_app_set_target_adc_battery_max_current$0$0 ==.
	C$ebike_app.c$1278$2_0$519 ==.
;	ebike_app.c: 1278: static void ebike_app_set_target_adc_battery_max_current (uint8_t ui8_value)
;	-----------------------------------------
;	 function ebike_app_set_target_adc_battery_max_current
;	-----------------------------------------
_ebike_app_set_target_adc_battery_max_current:
	C$ebike_app.c$1281$1_0$519 ==.
;	ebike_app.c: 1281: if(ui8_value > ui8_adc_battery_current_max)
	ld	a, (0x03, sp)
	cp	a, _ui8_adc_battery_current_max+0
	jrule	00102$
	C$ebike_app.c$1282$1_0$519 ==.
;	ebike_app.c: 1282: ui8_value = ui8_adc_battery_current_max;
	ld	a, _ui8_adc_battery_current_max+0
	ld	(0x03, sp), a
00102$:
	C$ebike_app.c$1284$1_0$519 ==.
;	ebike_app.c: 1284: ui8_adc_target_battery_max_current = ui8_adc_battery_current_offset + ui8_value;
	ld	a, _ui8_adc_battery_current_offset+0
	add	a, (0x03, sp)
	ld	_ui8_adc_target_battery_max_current+0, a
	C$ebike_app.c$1285$1_0$519 ==.
;	ebike_app.c: 1285: }
	C$ebike_app.c$1285$1_0$519 ==.
	XFebike_app$ebike_app_set_target_adc_battery_max_current$0$0 ==.
	ret
	Febike_app$ebike_app_set_battery_max_current$0$0 ==.
	C$ebike_app.c$1288$1_0$521 ==.
;	ebike_app.c: 1288: static void ebike_app_set_battery_max_current (uint8_t ui8_value)
;	-----------------------------------------
;	 function ebike_app_set_battery_max_current
;	-----------------------------------------
_ebike_app_set_battery_max_current:
	C$ebike_app.c$1291$1_0$521 ==.
;	ebike_app.c: 1291: ui8_adc_battery_current_max = ((((uint16_t) ui8_value) << 8) / 160);
	ld	a, (0x03, sp)
	ld	xh, a
	clr	a
	ld	xl, a
	ldw	y, #0x00a0
	divw	x, y
	ld	a, xl
	ld	_ui8_adc_battery_current_max+0, a
	C$ebike_app.c$1293$1_0$521 ==.
;	ebike_app.c: 1293: if(ui8_adc_battery_current_max > ADC_BATTERY_CURRENT_MAX)
	ld	a, _ui8_adc_battery_current_max+0
	cp	a, #0x1c
	jrule	00103$
	C$ebike_app.c$1294$1_0$521 ==.
;	ebike_app.c: 1294: ui8_adc_battery_current_max = ADC_BATTERY_CURRENT_MAX;
	mov	_ui8_adc_battery_current_max+0, #0x1c
00103$:
	C$ebike_app.c$1295$1_0$521 ==.
;	ebike_app.c: 1295: }
	C$ebike_app.c$1295$1_0$521 ==.
	XFebike_app$ebike_app_set_battery_max_current$0$0 ==.
	ret
	Febike_app$calc_pedal_force_and_torque$0$0 ==.
	C$ebike_app.c$1297$1_0$523 ==.
;	ebike_app.c: 1297: static void calc_pedal_force_and_torque(void)
;	-----------------------------------------
;	 function calc_pedal_force_and_torque
;	-----------------------------------------
_calc_pedal_force_and_torque:
	sub	sp, #8
	C$ebike_app.c$1302$1_0$523 ==.
;	ebike_app.c: 1302: ui16_temp = (uint16_t) ui8_torque_sensor * (uint16_t) PEDAL_TORQUE_X100;
	clrw	x
	ld	a, _ui8_torque_sensor+0
	ld	xl, a
	pushw	x
	push	#0x37
	push	#0x00
	call	__mulint
	addw	sp, #4
	C$ebike_app.c$1303$1_0$523 ==.
;	ebike_app.c: 1303: ui16_pedal_torque_x10 = ui16_temp / 10;
	pushw	x
	ldw	y, #0x000a
	divw	x, y
	exgw	x, y
	popw	x
	ldw	_ui16_pedal_torque_x10+0, y
	C$ebike_app.c$1319$1_0$523 ==.
;	ebike_app.c: 1319: ui16_pedal_power_x10 = (uint16_t) ((((uint32_t) ui16_temp * (uint32_t) ui8_pas_cadence_rpm)) / PEDAL_POWER_DIVISOR);
	ldw	(0x07, sp), x
	clrw	y
	clrw	x
	ld	a, _ui8_pas_cadence_rpm+0
	ld	xl, a
	clr	(0x02, sp)
	clr	(0x01, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x0b, sp)
	pushw	x
	pushw	y
	call	__mullong
	addw	sp, #8
	push	#0xa4
	push	#0x00
	push	#0x00
	push	#0x00
	pushw	x
	pushw	y
	call	__divulong
	addw	sp, #8
	ldw	_ui16_pedal_power_x10+0, x
	C$ebike_app.c$1320$1_0$523 ==.
;	ebike_app.c: 1320: }
	addw	sp, #8
	C$ebike_app.c$1320$1_0$523 ==.
	XFebike_app$calc_pedal_force_and_torque$0$0 ==.
	ret
	Febike_app$calc_wheel_speed$0$0 ==.
	C$ebike_app.c$1322$1_0$525 ==.
;	ebike_app.c: 1322: static void calc_wheel_speed (void)
;	-----------------------------------------
;	 function calc_wheel_speed
;	-----------------------------------------
_calc_wheel_speed:
	sub	sp, #4
	C$ebike_app.c$1325$1_0$525 ==.
;	ebike_app.c: 1325: if(ui16_wheel_speed_sensor_pwm_cycles_ticks < WHEEL_SPEED_SENSOR_MIN_PWM_CYCLE_TICKS)
	ldw	x, _ui16_wheel_speed_sensor_pwm_cycles_ticks+0
	cpw	x, #0xfffe
	jrc	00123$
	jp	00107$
00123$:
	C$ebike_app.c$1345$1_0$525 ==.
;	ebike_app.c: 1345: f_wheel_speed_x10 = ((float) PWM_CYCLES_SECOND) / ((float) ui16_wheel_speed_sensor_pwm_cycles_ticks); // rps
	push	_ui16_wheel_speed_sensor_pwm_cycles_ticks+1
	push	_ui16_wheel_speed_sensor_pwm_cycles_ticks+0
	call	___uint2fs
	addw	sp, #2
	pushw	x
	pushw	y
	push	#0x00
	push	#0x24
	push	#0x74
	push	#0x46
	call	___fsdiv
	addw	sp, #8
	ldw	_f_wheel_speed_x10+2, x
	ldw	_f_wheel_speed_x10+0, y
	C$ebike_app.c$1346$2_0$526 ==.
;	ebike_app.c: 1346: f_wheel_speed_x10 *= configuration_variables.ui16_wheel_perimeter; // millimeters per second
	ldw	x, #_configuration_variables+5
	ldw	x, (x)
	pushw	x
	call	___uint2fs
	addw	sp, #2
	pushw	x
	pushw	y
	push	_f_wheel_speed_x10+3
	push	_f_wheel_speed_x10+2
	push	_f_wheel_speed_x10+1
	push	_f_wheel_speed_x10+0
	call	___fsmul
	addw	sp, #8
	ldw	_f_wheel_speed_x10+2, x
	ldw	_f_wheel_speed_x10+0, y
	C$ebike_app.c$1347$1_0$525 ==.
;	ebike_app.c: 1347: f_wheel_speed_x10 *= 0.036; // ((3600 / (1000 * 1000)) * 10) kms per hour * 10
	push	_f_wheel_speed_x10+3
	push	_f_wheel_speed_x10+2
	push	_f_wheel_speed_x10+1
	push	_f_wheel_speed_x10+0
	push	#0xbc
	push	#0x74
	push	#0x13
	push	#0x3d
	call	___fsmul
	addw	sp, #8
	ldw	_f_wheel_speed_x10+2, x
	ldw	_f_wheel_speed_x10+0, y
	C$ebike_app.c$1348$1_0$525 ==.
;	ebike_app.c: 1348: ui16_wheel_speed_x10 = (uint16_t) f_wheel_speed_x10;
	push	_f_wheel_speed_x10+3
	push	_f_wheel_speed_x10+2
	push	_f_wheel_speed_x10+1
	push	_f_wheel_speed_x10+0
	call	___fs2uint
	addw	sp, #4
	ldw	_ui16_wheel_speed_x10+0, x
	C$ebike_app.c$1351$2_0$526 ==.
;	ebike_app.c: 1351: if(ui8_display_ready_flag)
	tnz	_ui8_display_ready_flag+0
	jreq	00104$
	C$ebike_app.c$1353$1_0$525 ==.
;	ebike_app.c: 1353: f_oem_wheel_speed = (((float) ui16_wheel_speed_sensor_pwm_cycles_ticks) * 10.0) / ((float) configuration_variables.ui16_oem_wheel_speed_factor);
	push	_ui16_wheel_speed_sensor_pwm_cycles_ticks+1
	push	_ui16_wheel_speed_sensor_pwm_cycles_ticks+0
	call	___uint2fs
	addw	sp, #2
	pushw	x
	pushw	y
	clrw	x
	pushw	x
	push	#0x20
	push	#0x41
	call	___fsmul
	addw	sp, #8
	ldw	(0x03, sp), x
	ldw	(0x01, sp), y
	ldw	x, #_configuration_variables+41
	ldw	x, (x)
	pushw	x
	call	___uint2fs
	addw	sp, #2
	pushw	x
	pushw	y
	ldw	x, (0x07, sp)
	pushw	x
	ldw	x, (0x07, sp)
	pushw	x
	call	___fsdiv
	addw	sp, #8
	ldw	_f_oem_wheel_speed+2, x
	ldw	_f_oem_wheel_speed+0, y
	C$ebike_app.c$1354$1_0$525 ==.
;	ebike_app.c: 1354: ui16_oem_wheel_speed = (uint16_t) f_oem_wheel_speed;
	push	_f_oem_wheel_speed+3
	push	_f_oem_wheel_speed+2
	push	_f_oem_wheel_speed+1
	push	_f_oem_wheel_speed+0
	call	___fs2uint
	addw	sp, #4
	ldw	_ui16_oem_wheel_speed+0, x
	jra	00109$
00104$:
	C$ebike_app.c$1360$3_0$528 ==.
;	ebike_app.c: 1360: ui16_oem_wheel_speed = 0;
	clrw	x
	ldw	_ui16_oem_wheel_speed+0, x
	C$ebike_app.c$1363$3_0$528 ==.
;	ebike_app.c: 1363: if(ui8_startup_counter++ >= 40)
	ld	a, _ui8_startup_counter+0
	inc	_ui8_startup_counter+0
	cp	a, #0x28
	jrc	00109$
	C$ebike_app.c$1366$4_0$529 ==.
;	ebike_app.c: 1366: ui8_display_ready_flag = 1;
	mov	_ui8_display_ready_flag+0, #0x01
	jra	00109$
00107$:
	C$ebike_app.c$1372$2_0$530 ==.
;	ebike_app.c: 1372: ui16_wheel_speed_x10 = 0;
	clrw	x
	ldw	_ui16_wheel_speed_x10+0, x
	C$ebike_app.c$1373$2_0$530 ==.
;	ebike_app.c: 1373: ui16_oem_wheel_speed = 0;
	clrw	x
	ldw	_ui16_oem_wheel_speed+0, x
00109$:
	C$ebike_app.c$1375$1_0$525 ==.
;	ebike_app.c: 1375: }
	addw	sp, #4
	C$ebike_app.c$1375$1_0$525 ==.
	XFebike_app$calc_wheel_speed$0$0 ==.
	ret
	Febike_app$calc_motor_temperature$0$0 ==.
	C$ebike_app.c$1377$1_0$532 ==.
;	ebike_app.c: 1377: static void calc_motor_temperature (void)
;	-----------------------------------------
;	 function calc_motor_temperature
;	-----------------------------------------
_calc_motor_temperature:
	sub	sp, #2
	C$ebike_app.c$1382$1_0$532 ==.
;	ebike_app.c: 1382: ui16_adc_motor_temperatured_accumulated -= ui16_adc_motor_temperatured_accumulated >> READ_MOTOR_TEMPERATURE_FILTER_COEFFICIENT;
	ldw	x, _ui16_adc_motor_temperatured_accumulated+0
	ld	a, #0x10
	div	x, a
	negw	x
	addw	x, _ui16_adc_motor_temperatured_accumulated+0
	ldw	_ui16_adc_motor_temperatured_accumulated+0, x
	C$ebike_app.c$1383$1_0$532 ==.
;	ebike_app.c: 1383: ui16_adc_motor_temperatured_accumulated += ui16_adc_read_throttle_10b ();
	call	_ui16_adc_read_throttle_10b
	addw	x, _ui16_adc_motor_temperatured_accumulated+0
	ldw	_ui16_adc_motor_temperatured_accumulated+0, x
	C$ebike_app.c$1384$1_0$532 ==.
;	ebike_app.c: 1384: ui16_adc_motor_temperatured_filtered_10b = ui16_adc_motor_temperatured_accumulated >> READ_MOTOR_TEMPERATURE_FILTER_COEFFICIENT;
	ldw	x, _ui16_adc_motor_temperatured_accumulated+0
	ld	a, #0x10
	div	x, a
	C$ebike_app.c$1386$1_0$532 ==.
;	ebike_app.c: 1386: configuration_variables.ui16_motor_temperature_x2 = (uint16_t) ((float) ui16_adc_motor_temperatured_filtered_10b / 1.024);
	ldw	y, #_configuration_variables+26
	ldw	(0x01, sp), y
	pushw	x
	call	___uint2fs
	addw	sp, #2
	push	#0x6f
	push	#0x12
	push	#0x83
	push	#0x3f
	pushw	x
	pushw	y
	call	___fsdiv
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uint
	addw	sp, #4
	ldw	y, (0x01, sp)
	ldw	(y), x
	C$ebike_app.c$1387$1_0$532 ==.
;	ebike_app.c: 1387: configuration_variables.ui8_motor_temperature = (uint8_t) (configuration_variables.ui16_motor_temperature_x2 >> 1);
	ldw	y, #_configuration_variables+28
	ldw	x, #_configuration_variables+26
	ldw	x, (x)
	srlw	x
	ld	a, xl
	ld	(y), a
	C$ebike_app.c$1388$1_0$532 ==.
;	ebike_app.c: 1388: }
	addw	sp, #2
	C$ebike_app.c$1388$1_0$532 ==.
	XFebike_app$calc_motor_temperature$0$0 ==.
	ret
	Febike_app$calc_filtered_battery_voltage$0$0 ==.
	C$ebike_app.c$1390$1_0$534 ==.
;	ebike_app.c: 1390: static uint16_t calc_filtered_battery_voltage (void)
;	-----------------------------------------
;	 function calc_filtered_battery_voltage
;	-----------------------------------------
_calc_filtered_battery_voltage:
	C$ebike_app.c$1392$1_0$534 ==.
;	ebike_app.c: 1392: uint16_t ui16_batt_voltage_filtered = (uint16_t) motor_get_adc_battery_voltage_filtered_10b () * ADC10BITS_BATTERY_VOLTAGE_PER_ADC_STEP_X512;
	call	_motor_get_adc_battery_voltage_filtered_10b
	pushw	x
	push	#0x2c
	push	#0x00
	call	__mulint
	addw	sp, #4
	ld	a, xh
	C$ebike_app.c$1393$1_0$534 ==.
;	ebike_app.c: 1393: return (ui16_batt_voltage_filtered >> 9);
	clrw	x
	ld	xl, a
	srlw	x
	C$ebike_app.c$1394$1_0$534 ==.
;	ebike_app.c: 1394: }
	C$ebike_app.c$1394$1_0$534 ==.
	XFebike_app$calc_filtered_battery_voltage$0$0 ==.
	ret
	Febike_app$apply_street_mode$0$0 ==.
	C$ebike_app.c$1396$1_0$536 ==.
;	ebike_app.c: 1396: static void apply_street_mode (uint16_t ui16_battery_voltage, uint8_t *ui8_max_speed, uint8_t *ui8_target_current)
;	-----------------------------------------
;	 function apply_street_mode
;	-----------------------------------------
_apply_street_mode:
	sub	sp, #8
	C$ebike_app.c$1398$1_0$536 ==.
;	ebike_app.c: 1398: if(!configuration_variables.ui8_offroad_mode)
	ldw	x, #_configuration_variables+9
	ld	a, (x)
	jrne	00106$
	C$ebike_app.c$1401$2_0$537 ==.
;	ebike_app.c: 1401: *ui8_max_speed = configuration_variables.ui8_street_speed_limit;
	ldw	y, (0x0d, sp)
	ldw	x, #_configuration_variables+31
	ld	a, (x)
	ld	(y), a
	C$ebike_app.c$1403$2_0$537 ==.
;	ebike_app.c: 1403: if(configuration_variables.ui8_street_power_limit_enabled && configuration_variables.ui8_street_power_limit_div25 > 0)
	ldw	x, #_configuration_variables+32
	ld	a, (x)
	jreq	00106$
	ldw	x, #_configuration_variables+33
	ld	a, (x)
	jreq	00106$
	C$ebike_app.c$1405$3_0$538 ==.
;	ebike_app.c: 1405: uint8_t ui8_street_mode_max_current = (uint8_t) (((((uint32_t) configuration_variables.ui8_street_power_limit_div25) * 160) / ((uint32_t) ui16_battery_voltage)) >> 2);
	ldw	x, #_configuration_variables+33
	ld	a, (x)
	clrw	x
	ld	xl, a
	clrw	y
	pushw	x
	pushw	y
	push	#0xa0
	clrw	x
	pushw	x
	push	#0x00
	call	__mullong
	addw	sp, #8
	ldw	(0x07, sp), x
	ldw	x, (0x0b, sp)
	clr	(0x02, sp)
	clr	(0x01, sp)
	pushw	x
	ldw	x, (0x03, sp)
	pushw	x
	ldw	x, (0x0b, sp)
	pushw	x
	pushw	y
	call	__divulong
	addw	sp, #8
	srlw	x
	srlw	x
	exgw	x, y
	C$ebike_app.c$1406$3_0$538 ==.
;	ebike_app.c: 1406: *ui8_target_current = ui8_min (ui8_street_mode_max_current, *ui8_target_current);
	ldw	x, (0x0f, sp)
	ld	a, (x)
	pushw	x
	push	a
	ld	a, yl
	push	a
	call	_ui8_min
	addw	sp, #2
	popw	x
	ld	(x), a
00106$:
	C$ebike_app.c$1409$1_0$536 ==.
;	ebike_app.c: 1409: }
	addw	sp, #8
	C$ebike_app.c$1409$1_0$536 ==.
	XFebike_app$apply_street_mode$0$0 ==.
	ret
	Febike_app$apply_speed_limit$0$0 ==.
	C$ebike_app.c$1411$1_0$540 ==.
;	ebike_app.c: 1411: static void apply_speed_limit (uint16_t ui16_speed_x10, uint8_t ui8_max_speed, uint8_t *ui8_target_current)
;	-----------------------------------------
;	 function apply_speed_limit
;	-----------------------------------------
_apply_speed_limit:
	sub	sp, #22
	C$ebike_app.c$1413$1_0$540 ==.
;	ebike_app.c: 1413: *ui8_target_current = (uint8_t) (map ((uint32_t) ui16_speed_x10,
	ldw	y, (0x1c, sp)
	C$ebike_app.c$1416$1_0$540 ==.
;	ebike_app.c: 1416: (uint32_t) *ui8_target_current,
	ld	a, (y)
	ld	(0x10, sp), a
	clr	(0x0f, sp)
	clr	(0x0e, sp)
	clr	(0x0d, sp)
	C$ebike_app.c$1415$1_0$540 ==.
;	ebike_app.c: 1415: (uint32_t) ((ui8_max_speed * 10) + 20),
	clrw	x
	ld	a, (0x1b, sp)
	ld	xl, a
	pushw	x
	sllw	x
	sllw	x
	addw	x, (1, sp)
	sllw	x
	addw	sp, #2
	ldw	(0x11, sp), x
	addw	x, #0x0014
	ldw	(0x03, sp), x
	ld	a, (0x03, sp)
	rlc	a
	clr	a
	sbc	a, #0x00
	ld	(0x02, sp), a
	ld	(0x01, sp), a
	C$ebike_app.c$1414$1_0$540 ==.
;	ebike_app.c: 1414: (uint32_t) ((ui8_max_speed * 10) - 20),
	ldw	x, (0x11, sp)
	subw	x, #0x0014
	ldw	(0x15, sp), x
	ld	a, (0x15, sp)
	rlc	a
	clr	a
	sbc	a, #0x00
	ld	(0x14, sp), a
	ld	(0x13, sp), a
	C$ebike_app.c$1413$1_0$540 ==.
;	ebike_app.c: 1413: *ui8_target_current = (uint8_t) (map ((uint32_t) ui16_speed_x10,
	ldw	x, (0x19, sp)
	ldw	(0x0b, sp), x
	clr	a
	clr	(0x09, sp)
	pushw	y
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	ldw	x, (0x15, sp)
	pushw	x
	ldw	x, (0x15, sp)
	pushw	x
	ldw	x, (0x0d, sp)
	pushw	x
	ldw	x, (0x0d, sp)
	pushw	x
	ldw	x, (0x23, sp)
	pushw	x
	ldw	x, (0x23, sp)
	pushw	x
	ldw	x, (0x1d, sp)
	pushw	x
	push	a
	ld	a, (0x1e, sp)
	push	a
	call	_map
	addw	sp, #20
	ldw	(0x07, sp), y
	ld	a, xl
	popw	y
	ld	(y), a
	C$ebike_app.c$1418$1_0$540 ==.
;	ebike_app.c: 1418: }
	addw	sp, #22
	C$ebike_app.c$1418$1_0$540 ==.
	XFebike_app$apply_speed_limit$0$0 ==.
	ret
	Febike_app$apply_walk_assist$0$0 ==.
	C$ebike_app.c$1440$1_0$542 ==.
;	ebike_app.c: 1440: static void apply_walk_assist (uint8_t ui8_walk_assist_value, uint8_t *ui8_motor_enable, uint8_t *ui8_target_current)
;	-----------------------------------------
;	 function apply_walk_assist
;	-----------------------------------------
_apply_walk_assist:
	sub	sp, #8
	C$ebike_app.c$1442$1_0$542 ==.
;	ebike_app.c: 1442: uint8_t ui8_temp = (uint8_t) (map ((uint32_t) ui8_walk_assist_value,
	clrw	x
	ld	a, _ui8_adc_battery_current_max+0
	ld	xl, a
	clr	(0x06, sp)
	clr	(0x05, sp)
	ld	a, (0x0b, sp)
	ld	(0x04, sp), a
	clr	(0x03, sp)
	clrw	y
	pushw	x
	ldw	x, (0x07, sp)
	pushw	x
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	push	#0xff
	clrw	x
	pushw	x
	push	#0x00
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	pushw	y
	call	_map
	addw	sp, #20
	C$ebike_app.c$1448$1_0$542 ==.
;	ebike_app.c: 1448: *ui8_target_current = ui8_max (*ui8_target_current, ui8_temp);
	ldw	y, (0x0e, sp)
	ld	a, (y)
	ld	xh, a
	pushw	y
	ld	a, xl
	push	a
	ld	a, xh
	push	a
	call	_ui8_max
	addw	sp, #2
	popw	y
	ld	(y), a
	C$ebike_app.c$1451$1_0$542 ==.
;	ebike_app.c: 1451: if(*ui8_target_current)
	tnz	a
	jreq	00103$
	C$ebike_app.c$1453$2_0$543 ==.
;	ebike_app.c: 1453: *ui8_motor_enable = 1;
	ldw	x, (0x0c, sp)
	ld	a, #0x01
	ld	(x), a
00103$:
	C$ebike_app.c$1455$1_0$542 ==.
;	ebike_app.c: 1455: }
	addw	sp, #8
	C$ebike_app.c$1455$1_0$542 ==.
	XFebike_app$apply_walk_assist$0$0 ==.
	ret
	Febike_app$apply_temperature_limiting$0$0 ==.
	C$ebike_app.c$1457$1_0$545 ==.
;	ebike_app.c: 1457: static void apply_temperature_limiting (uint8_t *ui8_target_current)
;	-----------------------------------------
;	 function apply_temperature_limiting
;	-----------------------------------------
_apply_temperature_limiting:
	sub	sp, #35
	C$ebike_app.c$1460$1_0$545 ==.
;	ebike_app.c: 1460: if(configuration_variables.ui8_motor_temperature_min_value_to_limit >= configuration_variables.ui8_motor_temperature_max_value_to_limit)
	ldw	x, #_configuration_variables+23
	ld	a, (x)
	ld	(0x0f, sp), a
	ldw	x, #_configuration_variables+24
	ld	a, (x)
	cp	a, (0x0f, sp)
	jrugt	00102$
	C$ebike_app.c$1462$2_0$546 ==.
;	ebike_app.c: 1462: *ui8_target_current = 0;
	ldw	x, (0x26, sp)
	clr	(x)
	C$ebike_app.c$1463$2_0$546 ==.
;	ebike_app.c: 1463: configuration_variables.ui8_temperature_current_limiting_value = 0;
	ldw	x, #_configuration_variables+25
	clr	(x)
	jp	00104$
00102$:
	C$ebike_app.c$1468$2_0$547 ==.
;	ebike_app.c: 1468: *ui8_target_current = 
	ldw	y, (0x26, sp)
	C$ebike_app.c$1472$2_0$547 ==.
;	ebike_app.c: 1472: (uint32_t) *ui8_target_current,
	ld	a, (y)
	ld	(0x1b, sp), a
	clr	(0x1a, sp)
	clr	(0x19, sp)
	clr	(0x18, sp)
	C$ebike_app.c$1471$2_0$547 ==.
;	ebike_app.c: 1471: (uint32_t) (((uint16_t) configuration_variables.ui8_motor_temperature_max_value_to_limit) << 1),
	ldw	x, #_configuration_variables+24
	ld	a, (x)
	clrw	x
	ld	xl, a
	sllw	x
	ldw	(0x1e, sp), x
	clr	(0x1d, sp)
	clr	(0x1c, sp)
	C$ebike_app.c$1470$2_0$547 ==.
;	ebike_app.c: 1470: (uint32_t) (((uint16_t) configuration_variables.ui8_motor_temperature_min_value_to_limit) << 1),
	ldw	x, #_configuration_variables+23
	ld	a, (x)
	clrw	x
	ld	xl, a
	sllw	x
	ldw	(0x16, sp), x
	clr	a
	clr	(0x14, sp)
	C$ebike_app.c$1469$2_0$547 ==.
;	ebike_app.c: 1469: (uint8_t) (map ((uint32_t) configuration_variables.ui16_motor_temperature_x2,
	ldw	x, #_configuration_variables+26
	ldw	x, (x)
	ldw	(0x12, sp), x
	clr	(0x11, sp)
	clr	(0x10, sp)
	pushw	y
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	ldw	x, (0x20, sp)
	pushw	x
	ldw	x, (0x20, sp)
	pushw	x
	ldw	x, (0x28, sp)
	pushw	x
	ldw	x, (0x28, sp)
	pushw	x
	ldw	x, (0x24, sp)
	pushw	x
	push	a
	ld	a, (0x25, sp)
	push	a
	ldw	x, (0x24, sp)
	pushw	x
	ldw	x, (0x24, sp)
	pushw	x
	call	_map
	addw	sp, #20
	ldw	(0x07, sp), y
	ld	a, xl
	popw	y
	ld	(y), a
	C$ebike_app.c$1476$2_0$547 ==.
;	ebike_app.c: 1476: configuration_variables.ui8_temperature_current_limiting_value = 
	ldw	x, #_configuration_variables+25
	ldw	(0x0d, sp), x
	C$ebike_app.c$1479$2_0$547 ==.
;	ebike_app.c: 1479: (uint32_t) (((uint16_t) configuration_variables.ui8_motor_temperature_max_value_to_limit) << 1),
	ldw	x, #_configuration_variables+24
	ld	a, (x)
	clrw	x
	ld	xl, a
	sllw	x
	ldw	(0x22, sp), x
	clrw	y
	C$ebike_app.c$1478$2_0$547 ==.
;	ebike_app.c: 1478: (uint32_t) (((uint16_t) configuration_variables.ui8_motor_temperature_min_value_to_limit) << 1),
	ldw	x, #_configuration_variables+23
	ld	a, (x)
	clrw	x
	ld	xl, a
	sllw	x
	ldw	(0x0b, sp), x
	clr	a
	clr	(0x09, sp)
	C$ebike_app.c$1477$2_0$547 ==.
;	ebike_app.c: 1477: (uint8_t) (map ((uint32_t) configuration_variables.ui16_motor_temperature_x2,
	ldw	x, #_configuration_variables+26
	ldw	x, (x)
	ldw	(0x03, sp), x
	clr	(0x02, sp)
	clr	(0x01, sp)
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	push	#0xff
	clrw	x
	pushw	x
	push	#0x00
	ldw	x, (0x2a, sp)
	pushw	x
	pushw	y
	ldw	x, (0x17, sp)
	pushw	x
	push	a
	ld	a, (0x18, sp)
	push	a
	ldw	x, (0x13, sp)
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	call	_map
	addw	sp, #20
	ld	a, xl
	ldw	x, (0x0d, sp)
	ld	(x), a
00104$:
	C$ebike_app.c$1483$1_0$545 ==.
;	ebike_app.c: 1483: }
	addw	sp, #35
	C$ebike_app.c$1483$1_0$545 ==.
	XFebike_app$apply_temperature_limiting$0$0 ==.
	ret
	Febike_app$boost_run_statemachine$0$0 ==.
	C$ebike_app.c$1485$1_0$549 ==.
;	ebike_app.c: 1485: static void boost_run_statemachine (void)
;	-----------------------------------------
;	 function boost_run_statemachine
;	-----------------------------------------
_boost_run_statemachine:
	sub	sp, #3
	C$ebike_app.c$1487$1_0$549 ==.
;	ebike_app.c: 1487: if(configuration_variables.ui8_startup_motor_power_boost_time > 0)
	ldw	x, #_configuration_variables+20
	ld	a, (x)
	ld	(0x03, sp), a
	jrne	00193$
	jp	00135$
00193$:
	C$ebike_app.c$1489$2_0$550 ==.
;	ebike_app.c: 1489: switch(ui8_startup_boost_state_machine)
	ld	a, _ui8_startup_boost_state_machine+0
	cp	a, #0x05
	jrule	00194$
	jp	00135$
00194$:
	clrw	x
	ld	a, _ui8_startup_boost_state_machine+0
	ld	xl, a
	sllw	x
	ldw	x, (#00195$, x)
	jp	(x)
00195$:
	.dw	#00101$
	.dw	#00105$
	.dw	#00106$
	.dw	#00112$
	.dw	#00113$
	.dw	#00120$
	C$ebike_app.c$1492$3_0$551 ==.
;	ebike_app.c: 1492: case BOOST_STATE_BOOST_DISABLED:
00101$:
	C$ebike_app.c$1493$3_0$551 ==.
;	ebike_app.c: 1493: if((ui8_torque_sensor > 0)&&
	tnz	_ui8_torque_sensor+0
	jrne	00196$
	jp	00135$
00196$:
	C$ebike_app.c$1494$3_0$551 ==.
;	ebike_app.c: 1494: (!brake_is_set()))
	call	_brake_is_set
	tnz	a
	jreq	00197$
	jp	00135$
00197$:
	C$ebike_app.c$1496$4_0$552 ==.
;	ebike_app.c: 1496: ui8_startup_boost_state_machine = BOOST_STATE_START_BOOST;
	mov	_ui8_startup_boost_state_machine+0, #0x01
	C$ebike_app.c$1498$3_0$551 ==.
;	ebike_app.c: 1498: break;
	jp	00135$
	C$ebike_app.c$1500$3_0$551 ==.
;	ebike_app.c: 1500: case BOOST_STATE_START_BOOST:
00105$:
	C$ebike_app.c$1501$3_0$551 ==.
;	ebike_app.c: 1501: ui8_startup_boost_enable = 1;
	mov	_ui8_startup_boost_enable+0, #0x01
	C$ebike_app.c$1502$3_0$551 ==.
;	ebike_app.c: 1502: ui8_startup_boost_timer = configuration_variables.ui8_startup_motor_power_boost_time;
	ldw	x, #_configuration_variables+20
	ld	a, (x)
	ld	_ui8_startup_boost_timer+0, a
	C$ebike_app.c$1503$3_0$551 ==.
;	ebike_app.c: 1503: ui8_startup_boost_state_machine = BOOST_STATE_BOOST;
	mov	_ui8_startup_boost_state_machine+0, #0x02
	C$ebike_app.c$1504$3_0$551 ==.
;	ebike_app.c: 1504: break;
	jp	00135$
	C$ebike_app.c$1506$3_0$551 ==.
;	ebike_app.c: 1506: case BOOST_STATE_BOOST:
00106$:
	C$ebike_app.c$1508$3_0$551 ==.
;	ebike_app.c: 1508: if(ui8_startup_boost_timer > 0)
	tnz	_ui8_startup_boost_timer+0
	jreq	00108$
	C$ebike_app.c$1510$4_0$553 ==.
;	ebike_app.c: 1510: ui8_startup_boost_timer--;
	dec	_ui8_startup_boost_timer+0
00108$:
	C$ebike_app.c$1514$3_0$551 ==.
;	ebike_app.c: 1514: if((ui8_torque_sensor == 0)||
	tnz	_ui8_torque_sensor+0
	jreq	00109$
	C$ebike_app.c$1515$3_0$551 ==.
;	ebike_app.c: 1515: (ui8_startup_boost_timer == 0))
	tnz	_ui8_startup_boost_timer+0
	jreq	00200$
	jp	00135$
00200$:
00109$:
	C$ebike_app.c$1517$4_0$554 ==.
;	ebike_app.c: 1517: ui8_startup_boost_state_machine = BOOST_STATE_END_BOOST;
	mov	_ui8_startup_boost_state_machine+0, #0x03
	C$ebike_app.c$1519$3_0$551 ==.
;	ebike_app.c: 1519: break;
	jp	00135$
	C$ebike_app.c$1521$3_0$551 ==.
;	ebike_app.c: 1521: case BOOST_STATE_END_BOOST:
00112$:
	C$ebike_app.c$1522$3_0$551 ==.
;	ebike_app.c: 1522: ui8_startup_boost_enable = 0;
	clr	_ui8_startup_boost_enable+0
	C$ebike_app.c$1525$3_0$551 ==.
;	ebike_app.c: 1525: ui8_startup_boost_fade_steps = configuration_variables.ui8_startup_motor_power_boost_fade_time;
	ldw	x, #_configuration_variables+21
	ld	a, (x)
	ld	_ui8_startup_boost_fade_steps+0, a
	C$ebike_app.c$1526$3_0$551 ==.
;	ebike_app.c: 1526: ui16_startup_boost_fade_variable_x256 = ((uint16_t) ui8_adc_battery_target_current << 8);
	ld	a, _ui8_adc_battery_target_current+0
	ld	xl, a
	clr	a
	rlwa	x
	ldw	_ui16_startup_boost_fade_variable_x256+0, x
	C$ebike_app.c$1527$3_0$551 ==.
;	ebike_app.c: 1527: ui16_startup_boost_fade_variable_step_amount_x256 = (ui16_startup_boost_fade_variable_x256 / ((uint16_t) ui8_startup_boost_fade_steps));
	clrw	x
	ld	a, _ui8_startup_boost_fade_steps+0
	ld	xl, a
	exgw	x, y
	ldw	x, _ui16_startup_boost_fade_variable_x256+0
	divw	x, y
	ldw	_ui16_startup_boost_fade_variable_step_amount_x256+0, x
	C$ebike_app.c$1528$3_0$551 ==.
;	ebike_app.c: 1528: ui8_startup_boost_fade_enable = 1;
	mov	_ui8_startup_boost_fade_enable+0, #0x01
	C$ebike_app.c$1530$3_0$551 ==.
;	ebike_app.c: 1530: ui8_startup_boost_state_machine = BOOST_STATE_FADE;
	mov	_ui8_startup_boost_state_machine+0, #0x04
	C$ebike_app.c$1531$3_0$551 ==.
;	ebike_app.c: 1531: break;
	jp	00135$
	C$ebike_app.c$1533$3_0$551 ==.
;	ebike_app.c: 1533: case BOOST_STATE_FADE:
00113$:
	C$ebike_app.c$1534$3_0$551 ==.
;	ebike_app.c: 1534: if(ui8_startup_boost_fade_steps > 0)
	tnz	_ui8_startup_boost_fade_steps+0
	jreq	00115$
	C$ebike_app.c$1536$4_0$555 ==.
;	ebike_app.c: 1536: ui8_startup_boost_fade_steps--;
	dec	_ui8_startup_boost_fade_steps+0
00115$:
	C$ebike_app.c$1540$3_0$551 ==.
;	ebike_app.c: 1540: if((ui8_torque_sensor_raw == 0)||
	tnz	_ui8_torque_sensor_raw+0
	jreq	00116$
	C$ebike_app.c$1541$3_0$551 ==.
;	ebike_app.c: 1541: (ui8_pas_cadence_rpm == 0)||
	tnz	_ui8_pas_cadence_rpm+0
	jreq	00116$
	C$ebike_app.c$1542$3_0$551 ==.
;	ebike_app.c: 1542: (ui8_startup_boost_fade_steps == 0))
	tnz	_ui8_startup_boost_fade_steps+0
	jreq	00204$
	jp	00135$
00204$:
00116$:
	C$ebike_app.c$1544$4_0$556 ==.
;	ebike_app.c: 1544: ui8_startup_boost_fade_enable = 0;
	clr	_ui8_startup_boost_fade_enable+0
	C$ebike_app.c$1545$4_0$556 ==.
;	ebike_app.c: 1545: ui8_startup_boost_fade_steps = 0;
	clr	_ui8_startup_boost_fade_steps+0
	C$ebike_app.c$1546$4_0$556 ==.
;	ebike_app.c: 1546: ui8_startup_boost_state_machine = BOOST_STATE_BOOST_WAIT_TO_RESTART;
	mov	_ui8_startup_boost_state_machine+0, #0x05
	C$ebike_app.c$1548$3_0$551 ==.
;	ebike_app.c: 1548: break;
	jra	00135$
	C$ebike_app.c$1551$3_0$551 ==.
;	ebike_app.c: 1551: case BOOST_STATE_BOOST_WAIT_TO_RESTART:
00120$:
	C$ebike_app.c$1553$3_0$551 ==.
;	ebike_app.c: 1553: if((configuration_variables.ui8_startup_motor_power_boost_state & 1) == 0)
	ldw	x, #_configuration_variables+18
	ld	a, (x)
	srl	a
	jrc	00125$
	C$ebike_app.c$1555$4_0$557 ==.
;	ebike_app.c: 1555: if((ui16_wheel_speed_x10 == 0)&&(ui8_torque_sensor_raw == 0))
	ldw	x, _ui16_wheel_speed_x10+0
	jrne	00125$
	tnz	_ui8_torque_sensor_raw+0
	jrne	00125$
	C$ebike_app.c$1557$5_0$558 ==.
;	ebike_app.c: 1557: ui8_startup_boost_state_machine = BOOST_STATE_BOOST_DISABLED;
	clr	_ui8_startup_boost_state_machine+0
00125$:
	C$ebike_app.c$1561$3_0$551 ==.
;	ebike_app.c: 1561: if((configuration_variables.ui8_startup_motor_power_boost_state & 1) > 0)
	ldw	x, #_configuration_variables+18
	ld	a, (x)
	clr	(0x01, sp)
	and	a, #0x01
	ld	xl, a
	clr	a
	ld	xh, a
	cpw	x, #0x0000
	jrsle	00135$
	C$ebike_app.c$1563$4_0$559 ==.
;	ebike_app.c: 1563: if((ui8_torque_sensor_raw == 0)||(ui8_pas_cadence_rpm == 0))
	tnz	_ui8_torque_sensor_raw+0
	jreq	00126$
	tnz	_ui8_pas_cadence_rpm+0
	jrne	00135$
00126$:
	C$ebike_app.c$1565$5_0$560 ==.
;	ebike_app.c: 1565: ui8_startup_boost_state_machine = BOOST_STATE_BOOST_DISABLED;
	clr	_ui8_startup_boost_state_machine+0
	C$ebike_app.c$1572$1_0$549 ==.
;	ebike_app.c: 1572: }
00135$:
	C$ebike_app.c$1574$1_0$549 ==.
;	ebike_app.c: 1574: }
	addw	sp, #3
	C$ebike_app.c$1574$1_0$549 ==.
	XFebike_app$boost_run_statemachine$0$0 ==.
	ret
	Febike_app$apply_boost$0$0 ==.
	C$ebike_app.c$1576$1_0$562 ==.
;	ebike_app.c: 1576: static uint8_t apply_boost (uint8_t ui8_pas_cadence, uint8_t ui8_max_current_boost_state, uint8_t *ui8_target_current)
;	-----------------------------------------
;	 function apply_boost
;	-----------------------------------------
_apply_boost:
	C$ebike_app.c$1578$1_0$562 ==.
;	ebike_app.c: 1578: uint8_t ui8_boost_enable = ui8_startup_boost_enable && configuration_variables.ui8_assist_level_factor_x10 && ui8_pas_cadence > 0 ? 1 : 0;
	tnz	_ui8_startup_boost_enable+0
	jreq	00105$
	ld	a, _configuration_variables
	jreq	00105$
	tnz	(0x03, sp)
	jreq	00105$
	clrw	x
	incw	x
	.byte 0x21
00105$:
	clrw	x
00106$:
	ld	a, xl
	C$ebike_app.c$1580$1_0$562 ==.
;	ebike_app.c: 1580: if(ui8_boost_enable)
	tnz	a
	jreq	00102$
	C$ebike_app.c$1582$2_0$563 ==.
;	ebike_app.c: 1582: *ui8_target_current = ui8_max_current_boost_state;
	ldw	y, (0x05, sp)
	ld	a, (0x04, sp)
	ld	(y), a
00102$:
	C$ebike_app.c$1585$1_0$562 ==.
;	ebike_app.c: 1585: return ui8_boost_enable;
	ld	a, xl
	C$ebike_app.c$1586$1_0$562 ==.
;	ebike_app.c: 1586: }
	C$ebike_app.c$1586$1_0$562 ==.
	XFebike_app$apply_boost$0$0 ==.
	ret
	Febike_app$apply_boost_fade_out$0$0 ==.
	C$ebike_app.c$1588$1_0$565 ==.
;	ebike_app.c: 1588: static void apply_boost_fade_out (uint8_t *ui8_target_current)
;	-----------------------------------------
;	 function apply_boost_fade_out
;	-----------------------------------------
_apply_boost_fade_out:
	sub	sp, #4
	C$ebike_app.c$1590$1_0$565 ==.
;	ebike_app.c: 1590: if(ui8_startup_boost_fade_enable)
	tnz	_ui8_startup_boost_fade_enable+0
	jreq	00108$
	C$ebike_app.c$1593$2_0$566 ==.
;	ebike_app.c: 1593: uint16_t ui16_adc_battery_target_current_x256 = ((uint16_t) ui8_adc_battery_target_current) << 8;
	ld	a, _ui8_adc_battery_target_current+0
	ld	xl, a
	clr	a
	rlwa	x
	ldw	(0x03, sp), x
	C$ebike_app.c$1594$2_0$566 ==.
;	ebike_app.c: 1594: if(ui16_startup_boost_fade_variable_x256 > ui16_adc_battery_target_current_x256)
	ldw	x, (0x03, sp)
	cpw	x, _ui16_startup_boost_fade_variable_x256+0
	jrnc	00104$
	C$ebike_app.c$1596$3_0$567 ==.
;	ebike_app.c: 1596: ui16_startup_boost_fade_variable_x256 -= ui16_startup_boost_fade_variable_step_amount_x256;
	ldw	x, _ui16_startup_boost_fade_variable_x256+0
	subw	x, _ui16_startup_boost_fade_variable_step_amount_x256+0
	ldw	_ui16_startup_boost_fade_variable_x256+0, x
	jra	00105$
00104$:
	C$ebike_app.c$1598$2_0$566 ==.
;	ebike_app.c: 1598: else if(ui16_startup_boost_fade_variable_x256 < ui16_adc_battery_target_current_x256)
	ldw	x, (0x03, sp)
	cpw	x, _ui16_startup_boost_fade_variable_x256+0
	jrule	00105$
	C$ebike_app.c$1600$3_0$568 ==.
;	ebike_app.c: 1600: ui16_startup_boost_fade_variable_x256 += ui16_startup_boost_fade_variable_step_amount_x256;
	ldw	x, _ui16_startup_boost_fade_variable_x256+0
	addw	x, _ui16_startup_boost_fade_variable_step_amount_x256+0
	ldw	_ui16_startup_boost_fade_variable_x256+0, x
00105$:
	C$ebike_app.c$1603$2_0$566 ==.
;	ebike_app.c: 1603: *ui8_target_current = (uint8_t) (ui16_startup_boost_fade_variable_x256 >> 8);
	ldw	x, (0x07, sp)
	ld	a, _ui16_startup_boost_fade_variable_x256+0
	clr	(0x01, sp)
	ld	(x), a
00108$:
	C$ebike_app.c$1605$1_0$565 ==.
;	ebike_app.c: 1605: }
	addw	sp, #4
	C$ebike_app.c$1605$1_0$565 ==.
	XFebike_app$apply_boost_fade_out$0$0 ==.
	ret
	Febike_app$read_pas_cadence$0$0 ==.
	C$ebike_app.c$1607$1_0$570 ==.
;	ebike_app.c: 1607: static void read_pas_cadence (void)
;	-----------------------------------------
;	 function read_pas_cadence
;	-----------------------------------------
_read_pas_cadence:
	C$ebike_app.c$1610$1_0$570 ==.
;	ebike_app.c: 1610: if(ui16_pas_pwm_cycles_ticks >= ((uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS))
	ldw	x, _ui16_pas_pwm_cycles_ticks+0
	cpw	x, #0x124f
	jrc	00102$
	C$ebike_app.c$1612$2_0$571 ==.
;	ebike_app.c: 1612: ui8_pas_cadence_rpm = 0;
	clr	_ui8_pas_cadence_rpm+0
	jra	00104$
00102$:
	C$ebike_app.c$1616$1_0$570 ==.
;	ebike_app.c: 1616: ui8_pas_cadence_rpm = (uint8_t) (60 / (((float) ui16_pas_pwm_cycles_ticks) * ((float) PAS_NUMBER_MAGNETS) * 0.000064));
	push	_ui16_pas_pwm_cycles_ticks+1
	push	_ui16_pas_pwm_cycles_ticks+0
	call	___uint2fs
	addw	sp, #2
	pushw	x
	pushw	y
	push	#0xac
	push	#0xc5
	push	#0xa7
	push	#0x3a
	call	___fsmul
	addw	sp, #8
	pushw	x
	pushw	y
	clrw	x
	pushw	x
	push	#0x70
	push	#0x42
	call	___fsdiv
	addw	sp, #8
	pushw	x
	pushw	y
	call	___fs2uchar
	addw	sp, #4
	ld	_ui8_pas_cadence_rpm+0, a
00104$:
	C$ebike_app.c$1618$1_0$570 ==.
;	ebike_app.c: 1618: }
	C$ebike_app.c$1618$1_0$570 ==.
	XFebike_app$read_pas_cadence$0$0 ==.
	ret
	Febike_app$torque_sensor_read$0$0 ==.
	C$ebike_app.c$1620$1_0$574 ==.
;	ebike_app.c: 1620: static void torque_sensor_read (void)
;	-----------------------------------------
;	 function torque_sensor_read
;	-----------------------------------------
_torque_sensor_read:
	sub	sp, #12
	C$ebike_app.c$1626$1_0$574 ==.
;	ebike_app.c: 1626: (uint8_t) ui8_adc_torque_sensor_max_value,
	ld	a, _ui8_adc_torque_sensor_max_value+0
	ld	(0x0c, sp), a
	clr	(0x0b, sp)
	clr	(0x0a, sp)
	clr	(0x09, sp)
	C$ebike_app.c$1625$1_0$574 ==.
;	ebike_app.c: 1625: (uint8_t) ui8_adc_torque_sensor_min_value,
	ld	a, _ui8_adc_torque_sensor_min_value+0
	ld	(0x08, sp), a
	clr	(0x07, sp)
	clr	(0x06, sp)
	clr	(0x05, sp)
	C$ebike_app.c$1624$1_0$574 ==.
;	ebike_app.c: 1624: UI8_ADC_TORQUE_SENSOR,
	ld	a, 0x53e8
	clrw	y
	clr	(0x01, sp)
	push	#0xff
	clrw	x
	pushw	x
	push	#0x00
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	ldw	x, (0x13, sp)
	pushw	x
	push	a
	pushw	y
	ld	a, (0x14, sp)
	push	a
	call	_map
	addw	sp, #20
	ld	a, xl
	ld	_ui8_torque_sensor_raw+0, a
	C$ebike_app.c$1630$1_0$574 ==.
;	ebike_app.c: 1630: switch(ui8_tstr_state_machine)
	ld	a, _ui8_tstr_state_machine+0
	cp	a, #0x00
	jreq	00101$
	ld	a, _ui8_tstr_state_machine+0
	dec	a
	jreq	00105$
	ld	a, _ui8_tstr_state_machine+0
	cp	a, #0x02
	jrne	00173$
	jp	00110$
00173$:
	jp	00115$
	C$ebike_app.c$1633$2_0$575 ==.
;	ebike_app.c: 1633: case STATE_NO_PEDALLING:
00101$:
	C$ebike_app.c$1634$2_0$575 ==.
;	ebike_app.c: 1634: if((ui8_torque_sensor_raw > 0)&&
	tnz	_ui8_torque_sensor_raw+0
	jrne	00175$
	jp	00115$
00175$:
	C$ebike_app.c$1635$2_0$575 ==.
;	ebike_app.c: 1635: (!brake_is_set()))
	call	_brake_is_set
	tnz	a
	jreq	00176$
	jp	00115$
00176$:
	C$ebike_app.c$1637$3_0$576 ==.
;	ebike_app.c: 1637: ui8_tstr_state_machine = STATE_STARTUP_PEDALLING;
	mov	_ui8_tstr_state_machine+0, #0x01
	C$ebike_app.c$1639$2_0$575 ==.
;	ebike_app.c: 1639: break;
	jra	00115$
	C$ebike_app.c$1642$2_0$575 ==.
;	ebike_app.c: 1642: case STATE_STARTUP_PEDALLING:
00105$:
	C$ebike_app.c$1643$2_0$575 ==.
;	ebike_app.c: 1643: if(ui8_rtst_counter++ > 20) // 2 seconds
	ld	a, _ui8_rtst_counter+0
	inc	_ui8_rtst_counter+0
	cp	a, #0x14
	jrule	00107$
	C$ebike_app.c$1645$3_0$577 ==.
;	ebike_app.c: 1645: ui8_rtst_counter = 0;
	clr	_ui8_rtst_counter+0
	C$ebike_app.c$1646$3_0$577 ==.
;	ebike_app.c: 1646: ui8_tstr_state_machine = STATE_PEDALLING;
	mov	_ui8_tstr_state_machine+0, #0x02
00107$:
	C$ebike_app.c$1650$2_0$575 ==.
;	ebike_app.c: 1650: if(ui16_wheel_speed_x10 == 0)
	ldw	x, _ui16_wheel_speed_x10+0
	jrne	00115$
	C$ebike_app.c$1652$3_0$578 ==.
;	ebike_app.c: 1652: ui8_rtst_counter = 0;
	clr	_ui8_rtst_counter+0
	C$ebike_app.c$1653$3_0$578 ==.
;	ebike_app.c: 1653: ui8_tstr_state_machine = STATE_NO_PEDALLING;
	clr	_ui8_tstr_state_machine+0
	C$ebike_app.c$1655$2_0$575 ==.
;	ebike_app.c: 1655: break;
	jra	00115$
	C$ebike_app.c$1658$2_0$575 ==.
;	ebike_app.c: 1658: case STATE_PEDALLING:
00110$:
	C$ebike_app.c$1659$2_0$575 ==.
;	ebike_app.c: 1659: if((ui16_wheel_speed_x10 == 0)&&(ui8_torque_sensor_raw == 0))
	ldw	x, _ui16_wheel_speed_x10+0
	jrne	00115$
	tnz	_ui8_torque_sensor_raw+0
	jrne	00115$
	C$ebike_app.c$1661$3_0$579 ==.
;	ebike_app.c: 1661: ui8_tstr_state_machine = STATE_NO_PEDALLING;
	clr	_ui8_tstr_state_machine+0
	C$ebike_app.c$1667$1_0$574 ==.
;	ebike_app.c: 1667: }
00115$:
	C$ebike_app.c$1670$1_0$574 ==.
;	ebike_app.c: 1670: if((ui8_tstr_state_machine == STATE_PEDALLING)&&(ui8_pas_cadence_rpm == 0))
	ld	a, _ui8_tstr_state_machine+0
	cp	a, #0x02
	jrne	00117$
	tnz	_ui8_pas_cadence_rpm+0
	jrne	00117$
	C$ebike_app.c$1672$2_0$580 ==.
;	ebike_app.c: 1672: ui8_torque_sensor = 0;
	clr	_ui8_torque_sensor+0
	jra	00120$
00117$:
	C$ebike_app.c$1676$2_0$581 ==.
;	ebike_app.c: 1676: ui8_torque_sensor = ui8_torque_sensor_raw;
	mov	_ui8_torque_sensor+0, _ui8_torque_sensor_raw+0
00120$:
	C$ebike_app.c$1678$1_0$574 ==.
;	ebike_app.c: 1678: }
	addw	sp, #12
	C$ebike_app.c$1678$1_0$574 ==.
	XFebike_app$torque_sensor_read$0$0 ==.
	ret
	Febike_app$throttle_read$0$0 ==.
	C$ebike_app.c$1680$1_0$583 ==.
;	ebike_app.c: 1680: static void throttle_read (void)
;	-----------------------------------------
;	 function throttle_read
;	-----------------------------------------
_throttle_read:
	C$ebike_app.c$1691$1_0$583 ==.
;	ebike_app.c: 1691: ui8_throttle = 0;
	clr	_ui8_throttle+0
	C$ebike_app.c$1693$1_0$583 ==.
;	ebike_app.c: 1693: }
	C$ebike_app.c$1693$1_0$583 ==.
	XFebike_app$throttle_read$0$0 ==.
	ret
	Febike_app$walk_assist_read$0$0 ==.
	C$ebike_app.c$1695$1_0$585 ==.
;	ebike_app.c: 1695: static void walk_assist_read (void)
;	-----------------------------------------
;	 function walk_assist_read
;	-----------------------------------------
_walk_assist_read:
	sub	sp, #4
	C$ebike_app.c$1699$1_0$585 ==.
;	ebike_app.c: 1699: ui8_walk_assist_current_per_cent,
	ld	a, _ui8_walk_assist_current_per_cent+0
	clrw	y
	clr	(0x01, sp)
	push	#0xff
	clrw	x
	pushw	x
	push	#0x00
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	push	#0x64
	clrw	x
	pushw	x
	push	#0x00
	clrw	x
	pushw	x
	clrw	x
	pushw	x
	push	a
	pushw	y
	ld	a, (0x14, sp)
	push	a
	call	_map
	addw	sp, #20
	ld	a, xl
	ld	_ui8_walk_assist+0, a
	C$ebike_app.c$1704$1_0$585 ==.
;	ebike_app.c: 1704: }
	addw	sp, #4
	C$ebike_app.c$1704$1_0$585 ==.
	XFebike_app$walk_assist_read$0$0 ==.
	ret
	G$UART2_IRQHandler$0$0 ==.
	C$ebike_app.c$1709$1_0$587 ==.
;	ebike_app.c: 1709: void UART2_IRQHandler(void) __interrupt(UART2_IRQHANDLER)
;	-----------------------------------------
;	 function UART2_IRQHandler
;	-----------------------------------------
_UART2_IRQHandler:
	clr	a
	div	x, a
	C$ebike_app.c$1711$1_0$587 ==.
;	ebike_app.c: 1711: if(UART2_GetFlagStatus(UART2_FLAG_RXNE) == SET)
	push	#0x20
	push	#0x00
	call	_UART2_GetFlagStatus
	addw	sp, #2
	dec	a
	jreq	00136$
	jp	00112$
00136$:
	C$ebike_app.c$1713$2_0$588 ==.
;	ebike_app.c: 1713: UART2->SR &= (uint8_t)~(UART2_FLAG_RXNE); // this may be redundant
	ld	a, 0x5240
	and	a, #0xdf
	ld	0x5240, a
	C$ebike_app.c$1715$2_0$588 ==.
;	ebike_app.c: 1715: ui8_byte_received = UART2_ReceiveData8 ();
	call	_UART2_ReceiveData8
	ld	_ui8_byte_received+0, a
	C$ebike_app.c$1717$2_0$588 ==.
;	ebike_app.c: 1717: switch(ui8_state_machine)
	ld	a, _ui8_state_machine+0
	cp	a, #0x00
	jreq	00101$
	dec	a
	jreq	00105$
	jp	00112$
	C$ebike_app.c$1719$3_0$589 ==.
;	ebike_app.c: 1719: case 0:
00101$:
	C$ebike_app.c$1720$3_0$589 ==.
;	ebike_app.c: 1720: if(ui8_byte_received == 0x59) // see if we get start package byte
	ld	a, _ui8_byte_received+0
	cp	a, #0x59
	jrne	00103$
	C$ebike_app.c$1722$4_0$590 ==.
;	ebike_app.c: 1722: ui8_rx_buffer [ui8_rx_counter] = ui8_byte_received;
	clrw	x
	ld	a, _ui8_rx_counter+0
	ld	xl, a
	ld	a, _ui8_byte_received+0
	ld	(_ui8_rx_buffer, x), a
	C$ebike_app.c$1723$4_0$590 ==.
;	ebike_app.c: 1723: ui8_rx_counter++;
	inc	_ui8_rx_counter+0
	C$ebike_app.c$1724$4_0$590 ==.
;	ebike_app.c: 1724: ui8_state_machine = 1;
	mov	_ui8_state_machine+0, #0x01
	jra	00112$
00103$:
	C$ebike_app.c$1728$4_0$591 ==.
;	ebike_app.c: 1728: ui8_rx_counter = 0;
	clr	_ui8_rx_counter+0
	C$ebike_app.c$1729$4_0$591 ==.
;	ebike_app.c: 1729: ui8_state_machine = 0;
	clr	_ui8_state_machine+0
	C$ebike_app.c$1731$3_0$589 ==.
;	ebike_app.c: 1731: break;
	jra	00112$
	C$ebike_app.c$1733$3_0$589 ==.
;	ebike_app.c: 1733: case 1:
00105$:
	C$ebike_app.c$1734$3_0$589 ==.
;	ebike_app.c: 1734: ui8_rx_buffer [ui8_rx_counter] = ui8_byte_received;
	clrw	x
	ld	a, _ui8_rx_counter+0
	ld	xl, a
	addw	x, #_ui8_rx_buffer
	ld	a, _ui8_byte_received+0
	ld	(x), a
	C$ebike_app.c$1735$3_0$589 ==.
;	ebike_app.c: 1735: ui8_rx_counter++;
	inc	_ui8_rx_counter+0
	C$ebike_app.c$1738$3_0$589 ==.
;	ebike_app.c: 1738: if(ui8_rx_counter > 8)
	ld	a, _ui8_rx_counter+0
	cp	a, #0x08
	jrule	00112$
	C$ebike_app.c$1740$4_0$592 ==.
;	ebike_app.c: 1740: ui8_rx_counter = 0;
	clr	_ui8_rx_counter+0
	C$ebike_app.c$1741$4_0$592 ==.
;	ebike_app.c: 1741: ui8_state_machine = 0;
	clr	_ui8_state_machine+0
	C$ebike_app.c$1742$4_0$592 ==.
;	ebike_app.c: 1742: ui8_received_package_flag = 1; // signal that we have a full package to be processed
	mov	_ui8_received_package_flag+0, #0x01
	C$ebike_app.c$1743$4_0$592 ==.
;	ebike_app.c: 1743: UART2->CR2 &= ~(1 << 5); // disable UART2 receive interrupt
	bres	21061, #5
	C$ebike_app.c$1749$1_0$587 ==.
;	ebike_app.c: 1749: }
00112$:
	C$ebike_app.c$1751$1_0$587 ==.
;	ebike_app.c: 1751: }
	C$ebike_app.c$1751$1_0$587 ==.
	XG$UART2_IRQHandler$0$0 ==.
	iret
	G$get_configuration_variables$0$0 ==.
	C$ebike_app.c$1753$1_0$594 ==.
;	ebike_app.c: 1753: struct_configuration_variables* get_configuration_variables (void)
;	-----------------------------------------
;	 function get_configuration_variables
;	-----------------------------------------
_get_configuration_variables:
	C$ebike_app.c$1755$1_0$594 ==.
;	ebike_app.c: 1755: return &configuration_variables;
	ldw	x, #_configuration_variables
	C$ebike_app.c$1756$1_0$594 ==.
;	ebike_app.c: 1756: }
	C$ebike_app.c$1756$1_0$594 ==.
	XG$get_configuration_variables$0$0 ==.
	ret
	Febike_app$safe_tests$0$0 ==.
	C$ebike_app.c$1758$1_0$596 ==.
;	ebike_app.c: 1758: static void safe_tests (void)
;	-----------------------------------------
;	 function safe_tests
;	-----------------------------------------
_safe_tests:
	C$ebike_app.c$1761$1_0$596 ==.
;	ebike_app.c: 1761: if(configuration_variables.ui8_motor_assistance_startup_without_pedal_rotation)
	ldw	x, #_configuration_variables+12
	ld	a, (x)
	jrne	00208$
	jp	00132$
00208$:
	C$ebike_app.c$1764$2_0$597 ==.
;	ebike_app.c: 1764: if((brake_is_set())|| // we hit brakes
	call	_brake_is_set
	tnz	a
	jrne	00101$
	C$ebike_app.c$1765$2_0$597 ==.
;	ebike_app.c: 1765: (configuration_variables.ui8_assist_level_factor_x10 == 0)) // we choose assist power assist level = 0
	ld	a, _configuration_variables
	jrne	00102$
00101$:
	C$ebike_app.c$1767$3_0$598 ==.
;	ebike_app.c: 1767: configuration_variables.ui8_error_states &= ~ERROR_STATE_EBIKE_WHEEL_BLOCKED; // disable error state in case it was enable
	ldw	x, #_configuration_variables+34
	ldw	y, #_configuration_variables+34
	ld	a, (y)
	and	a, #0xfe
	ld	(x), a
	C$ebike_app.c$1768$3_0$598 ==.
;	ebike_app.c: 1768: safe_tests_state_machine = 0;
	clr	_safe_tests_state_machine+0
00102$:
	C$ebike_app.c$1771$2_0$597 ==.
;	ebike_app.c: 1771: switch(safe_tests_state_machine)
	ld	a, _safe_tests_state_machine+0
	cp	a, #0x00
	jreq	00104$
	ld	a, _safe_tests_state_machine+0
	dec	a
	jreq	00109$
	ld	a, _safe_tests_state_machine+0
	cp	a, #0x02
	jrne	00218$
	jp	00118$
00218$:
	ld	a, _safe_tests_state_machine+0
	cp	a, #0x03
	jrne	00221$
	jp	00126$
00221$:
	jp	00129$
	C$ebike_app.c$1774$3_0$599 ==.
;	ebike_app.c: 1774: case 0:
00104$:
	C$ebike_app.c$1775$3_0$599 ==.
;	ebike_app.c: 1775: if(ui8_torque_sensor_raw || ui8_throttle || ui8_walk_assist)
	tnz	_ui8_torque_sensor_raw+0
	jrne	00105$
	tnz	_ui8_throttle+0
	jrne	00105$
	tnz	_ui8_walk_assist+0
	jrne	00225$
	jp	00134$
00225$:
00105$:
	C$ebike_app.c$1777$4_0$600 ==.
;	ebike_app.c: 1777: safe_tests_state_machine_counter = 0;
	clr	_safe_tests_state_machine_counter+0
	C$ebike_app.c$1778$4_0$600 ==.
;	ebike_app.c: 1778: safe_tests_state_machine = 1;
	mov	_safe_tests_state_machine+0, #0x01
	C$ebike_app.c$1779$4_0$600 ==.
;	ebike_app.c: 1779: break;
	jp	00134$
	C$ebike_app.c$1784$3_0$599 ==.
;	ebike_app.c: 1784: case 1:
00109$:
	C$ebike_app.c$1785$3_0$599 ==.
;	ebike_app.c: 1785: safe_tests_state_machine_counter++;
	inc	_safe_tests_state_machine_counter+0
	C$ebike_app.c$1789$3_0$599 ==.
;	ebike_app.c: 1789: if (safe_tests_state_machine_counter > 50)
	ld	a, _safe_tests_state_machine_counter+0
	cp	a, #0x32
	jrule	00111$
	C$ebike_app.c$1791$4_0$601 ==.
;	ebike_app.c: 1791: configuration_variables.ui8_error_states |= ERROR_STATE_EBIKE_WHEEL_BLOCKED;
	ldw	x, #_configuration_variables+34
	ldw	y, #_configuration_variables+34
	ld	a, (y)
	or	a, #0x01
	ld	(x), a
	C$ebike_app.c$1792$4_0$601 ==.
;	ebike_app.c: 1792: safe_tests_state_machine_counter = 0;
	clr	_safe_tests_state_machine_counter+0
	C$ebike_app.c$1793$4_0$601 ==.
;	ebike_app.c: 1793: safe_tests_state_machine = 2;
	mov	_safe_tests_state_machine+0, #0x02
	C$ebike_app.c$1794$4_0$601 ==.
;	ebike_app.c: 1794: break;
	jp	00134$
00111$:
	C$ebike_app.c$1798$3_0$599 ==.
;	ebike_app.c: 1798: if(ui16_wheel_speed_x10 > 40) // seems that 4km/h may be the min value we can measure for the bicycle wheel speed
	ldw	x, _ui16_wheel_speed_x10+0
	cpw	x, #0x0028
	jrule	00113$
	C$ebike_app.c$1800$4_0$602 ==.
;	ebike_app.c: 1800: safe_tests_state_machine_counter = 0;
	clr	_safe_tests_state_machine_counter+0
	C$ebike_app.c$1801$4_0$602 ==.
;	ebike_app.c: 1801: safe_tests_state_machine = 3;
	mov	_safe_tests_state_machine+0, #0x03
	C$ebike_app.c$1802$4_0$602 ==.
;	ebike_app.c: 1802: break;
	jp	00134$
00113$:
	C$ebike_app.c$1806$3_0$599 ==.
;	ebike_app.c: 1806: if((ui8_torque_sensor_raw == 0)&&(ui8_throttle == 0)&&(ui8_walk_assist == 0))
	tnz	_ui8_torque_sensor_raw+0
	jreq	00228$
	jp	00134$
00228$:
	tnz	_ui8_throttle+0
	jreq	00229$
	jp	00134$
00229$:
	tnz	_ui8_walk_assist+0
	jreq	00230$
	jp	00134$
00230$:
	C$ebike_app.c$1808$4_0$603 ==.
;	ebike_app.c: 1808: safe_tests_state_machine = 0;
	clr	_safe_tests_state_machine+0
	C$ebike_app.c$1810$3_0$599 ==.
;	ebike_app.c: 1810: break;
	jp	00134$
	C$ebike_app.c$1813$3_0$599 ==.
;	ebike_app.c: 1813: case 2:
00118$:
	C$ebike_app.c$1814$3_0$599 ==.
;	ebike_app.c: 1814: if((ui8_torque_sensor_raw == 0)&&(ui8_throttle == 0)&&(ui8_walk_assist == 0))
	tnz	_ui8_torque_sensor_raw+0
	jrne	00122$
	tnz	_ui8_throttle+0
	jrne	00122$
	tnz	_ui8_walk_assist+0
	jrne	00122$
	C$ebike_app.c$1816$4_0$604 ==.
;	ebike_app.c: 1816: safe_tests_state_machine_counter++;
	inc	_safe_tests_state_machine_counter+0
	C$ebike_app.c$1818$4_0$604 ==.
;	ebike_app.c: 1818: if(safe_tests_state_machine_counter > 30)
	ld	a, _safe_tests_state_machine_counter+0
	cp	a, #0x1e
	jrugt	00234$
	jp	00134$
00234$:
	C$ebike_app.c$1820$5_0$605 ==.
;	ebike_app.c: 1820: configuration_variables.ui8_error_states &= ~ERROR_STATE_EBIKE_WHEEL_BLOCKED;
	ldw	x, #_configuration_variables+34
	ldw	y, #_configuration_variables+34
	ld	a, (y)
	and	a, #0xfe
	ld	(x), a
	C$ebike_app.c$1821$5_0$605 ==.
;	ebike_app.c: 1821: safe_tests_state_machine = 0;
	clr	_safe_tests_state_machine+0
	C$ebike_app.c$1822$5_0$605 ==.
;	ebike_app.c: 1822: break;
	jra	00134$
00122$:
	C$ebike_app.c$1828$4_0$606 ==.
;	ebike_app.c: 1828: safe_tests_state_machine_counter = 0;
	clr	_safe_tests_state_machine_counter+0
	C$ebike_app.c$1830$3_0$599 ==.
;	ebike_app.c: 1830: break;
	jra	00134$
	C$ebike_app.c$1833$3_0$599 ==.
;	ebike_app.c: 1833: case 3:
00126$:
	C$ebike_app.c$1834$3_0$599 ==.
;	ebike_app.c: 1834: if(ui16_wheel_speed_x10 == 0)
	ldw	x, _ui16_wheel_speed_x10+0
	jrne	00134$
	C$ebike_app.c$1836$4_0$607 ==.
;	ebike_app.c: 1836: safe_tests_state_machine = 0;
	clr	_safe_tests_state_machine+0
	C$ebike_app.c$1837$4_0$607 ==.
;	ebike_app.c: 1837: break;
	jra	00134$
	C$ebike_app.c$1841$3_0$599 ==.
;	ebike_app.c: 1841: default:
00129$:
	C$ebike_app.c$1842$3_0$599 ==.
;	ebike_app.c: 1842: safe_tests_state_machine = 0;
	clr	_safe_tests_state_machine+0
	C$ebike_app.c$1844$1_0$596 ==.
;	ebike_app.c: 1844: }
	jra	00134$
00132$:
	C$ebike_app.c$1849$2_0$608 ==.
;	ebike_app.c: 1849: configuration_variables.ui8_error_states &= ~ERROR_STATE_EBIKE_WHEEL_BLOCKED; // disable error state in case it was enable
	ldw	x, #_configuration_variables+34
	ldw	y, #_configuration_variables+34
	ld	a, (y)
	and	a, #0xfe
	ld	(x), a
	C$ebike_app.c$1850$2_0$608 ==.
;	ebike_app.c: 1850: safe_tests_state_machine = 0;
	clr	_safe_tests_state_machine+0
00134$:
	C$ebike_app.c$1852$1_0$596 ==.
;	ebike_app.c: 1852: }
	C$ebike_app.c$1852$1_0$596 ==.
	XFebike_app$safe_tests$0$0 ==.
	ret
	.area CODE
	.area CONST
	.area INITIALIZER
Febike_app$__xinit_ui8_adc_battery_max_current$0_0$0 == .
__xinit__ui8_adc_battery_max_current:
	.db #0x1c	; 28
Febike_app$__xinit_ui8_target_battery_max_power_x10$0_0$0 == .
__xinit__ui8_target_battery_max_power_x10:
	.db #0x1c	; 28
Febike_app$__xinit_ui8_throttle$0_0$0 == .
__xinit__ui8_throttle:
	.db #0x00	; 0
Febike_app$__xinit_ui8_torque_sensor_value1$0_0$0 == .
__xinit__ui8_torque_sensor_value1:
	.db #0x00	; 0
Febike_app$__xinit_ui8_torque_sensor$0_0$0 == .
__xinit__ui8_torque_sensor:
	.db #0x00	; 0
Febike_app$__xinit_ui8_torque_sensor_raw$0_0$0 == .
__xinit__ui8_torque_sensor_raw:
	.db #0x00	; 0
Febike_app$__xinit_ui8_ebike_app_state$0_0$0 == .
__xinit__ui8_ebike_app_state:
	.db #0x01	; 1
Febike_app$__xinit_ui16_pas_pwm_cycles_ticks$0_0$0 == .
__xinit__ui16_pas_pwm_cycles_ticks:
	.dw #0x124f
Febike_app$__xinit_ui8_pedaling_forward$0_0$0 == .
__xinit__ui8_pedaling_forward:
	.db #0x01	; 1
Febike_app$__xinit_ui8_pas_cadence_rpm$0_0$0 == .
__xinit__ui8_pas_cadence_rpm:
	.db #0x00	; 0
Febike_app$__xinit_ui8_pedal_human_power$0_0$0 == .
__xinit__ui8_pedal_human_power:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_boost_enable$0_0$0 == .
__xinit__ui8_startup_boost_enable:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_boost_fade_enable$0_0$0 == .
__xinit__ui8_startup_boost_fade_enable:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_boost_state_machine$0_0$0 == .
__xinit__ui8_startup_boost_state_machine:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_boost_no_torque$0_0$0 == .
__xinit__ui8_startup_boost_no_torque:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_boost_timer$0_0$0 == .
__xinit__ui8_startup_boost_timer:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_boost_fade_steps$0_0$0 == .
__xinit__ui8_startup_boost_fade_steps:
	.db #0x00	; 0
Febike_app$__xinit_ui16_wheel_speed_sensor_pwm_cycles_ticks$0_0$0 == .
__xinit__ui16_wheel_speed_sensor_pwm_cycles_ticks:
	.dw #0x048e
Febike_app$__xinit_ui8_wheel_speed_max$0_0$0 == .
__xinit__ui8_wheel_speed_max:
	.db #0x00	; 0
Febike_app$__xinit_ui32_wheel_speed_sensor_tick_counter$0_0$0 == .
__xinit__ui32_wheel_speed_sensor_tick_counter:
	.byte #0x00,#0x00,#0x00,#0x00	; 0
Febike_app$__xinit_ui8_received_package_flag$0_0$0 == .
__xinit__ui8_received_package_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_rx_counter$0_0$0 == .
__xinit__ui8_rx_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui8_tx_counter$0_0$0 == .
__xinit__ui8_tx_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui8_state_machine$0_0$0 == .
__xinit__ui8_state_machine:
	.db #0x00	; 0
Febike_app$__xinit_ui8_uart_received_first_package$0_0$0 == .
__xinit__ui8_uart_received_first_package:
	.db #0x00	; 0
Febike_app$__xinit_ui8_master_comm_package_id$0_0$0 == .
__xinit__ui8_master_comm_package_id:
	.db #0x00	; 0
Febike_app$__xinit_ui8_slave_comm_package_id$0_0$0 == .
__xinit__ui8_slave_comm_package_id:
	.db #0x00	; 0
Febike_app$__xinit_ui8_tstr_state_machine$0_0$0 == .
__xinit__ui8_tstr_state_machine:
	.db #0x00	; 0
Febike_app$__xinit_ui8_rtst_counter$0_0$0 == .
__xinit__ui8_rtst_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui16_adc_motor_temperatured_accumulated$0_0$0 == .
__xinit__ui16_adc_motor_temperatured_accumulated:
	.dw #0x0000
Febike_app$__xinit_safe_tests_state_machine$0_0$0 == .
__xinit__safe_tests_state_machine:
	.db #0x00	; 0
Febike_app$__xinit_safe_tests_state_machine_counter$0_0$0 == .
__xinit__safe_tests_state_machine_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui32_battery_voltage_accumulated_x10000$0_0$0 == .
__xinit__ui32_battery_voltage_accumulated_x10000:
	.byte #0x00,#0x00,#0x00,#0x00	; 0
Febike_app$__xinit_ui16_battery_current_accumulated_x5$0_0$0 == .
__xinit__ui16_battery_current_accumulated_x5:
	.dw #0x0000
Febike_app$__xinit_ui8_battery_state_of_charge$0_0$0 == .
__xinit__ui8_battery_state_of_charge:
	.db #0x00	; 0
Febike_app$__xinit_ui8_timer_counter$0_0$0 == .
__xinit__ui8_timer_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui8_startup_counter$0_0$0 == .
__xinit__ui8_startup_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui8_lights_counter$0_0$0 == .
__xinit__ui8_lights_counter:
	.db #0x00	; 0
Febike_app$__xinit_ui16_walk_assist_delay_off$0_0$0 == .
__xinit__ui16_walk_assist_delay_off:
	.dw #0x0000
Febike_app$__xinit_ui8_walk_assist_delay_off_flag$0_0$0 == .
__xinit__ui8_walk_assist_delay_off_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_display_ready_flag$0_0$0 == .
__xinit__ui8_display_ready_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_enable_walk_assist$0_0$0 == .
__xinit__ui8_enable_walk_assist:
	.db #0x00	; 0
Febike_app$__xinit_ui8_walk_assist_flag$0_0$0 == .
__xinit__ui8_walk_assist_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_walk_assist$0_0$0 == .
__xinit__ui8_walk_assist:
	.db #0x00	; 0
Febike_app$__xinit_ui8_walk_assist_current_per_cent$0_0$0 == .
__xinit__ui8_walk_assist_current_per_cent:
	.db #0x00	; 0
Febike_app$__xinit_ui8_walk_assist_start$0_0$0 == .
__xinit__ui8_walk_assist_start:
	.db #0x00	; 0
Febike_app$__xinit_ui8_walk_assist_pwm$0_0$0 == .
__xinit__ui8_walk_assist_pwm:
	.db #0x00	; 0
Febike_app$__xinit_ui8_walk_assist_pwm_step$0_0$0 == .
__xinit__ui8_walk_assist_pwm_step:
	.db #0x00	; 0
Febike_app$__xinit_ui8_default_flag$0_0$0 == .
__xinit__ui8_default_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_lights_flag$0_0$0 == .
__xinit__ui8_lights_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_mode_flag$0_0$0 == .
__xinit__ui8_mode_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_boost_flag$0_0$0 == .
__xinit__ui8_boost_flag:
	.db #0x00	; 0
Febike_app$__xinit_ui8_pwm_started$0_0$0 == .
__xinit__ui8_pwm_started:
	.db #0x00	; 0
Febike_app$__xinit_ui8_pwm_stopped$0_0$0 == .
__xinit__ui8_pwm_stopped:
	.db #0x00	; 0
	.area CABS (ABS)
