;--------------------------------------------------------
; File Created by SDCC : free open source ISO C Compiler
; Version 4.5.0 #15242 (Linux)
;--------------------------------------------------------
	.module main
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _main
	.globl _RTC_ITConfig
	.globl _RTC_WakeUpCmd
	.globl _RTC_SetWakeUpCounter
	.globl _RTC_WakeUpClockConfig
	.globl _GPIO_ResetBits
	.globl _GPIO_SetBits
	.globl _GPIO_Init
	.globl _CLK_PeripheralClockConfig
	.globl _CLK_RTCClockConfig
	.globl _CLK_SYSCLKSourceSwitchCmd
	.globl _CLK_SYSCLKDivConfig
	.globl _CLK_GetSYSCLKSource
	.globl _CLK_SYSCLKSourceConfig
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area DATA
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area INITIALIZED
;--------------------------------------------------------
; Stack segment in internal ram
;--------------------------------------------------------
	.area SSEG
__start__stack:
	.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

;--------------------------------------------------------
; interrupt vector
;--------------------------------------------------------
	.area HOME
__interrupt_vect:
	int s_GSINIT ; reset
	int _TRAP_IRQHandler ; trap
	int 0x000000 ; int0
	int _FLASH_IRQHandler ; int1
	int _DMA1_CHANNEL0_1_IRQHandler ; int2
	int _DMA1_CHANNEL2_3_IRQHandler ; int3
	int _RTC_CSSLSE_IRQHandler ; int4
	int _EXTIE_F_PVD_IRQHandler ; int5
	int _EXTIB_G_IRQHandler ; int6
	int _EXTID_H_IRQHandler ; int7
	int _EXTI0_IRQHandler ; int8
	int _EXTI1_IRQHandler ; int9
	int _EXTI2_IRQHandler ; int10
	int _EXTI3_IRQHandler ; int11
	int _EXTI4_IRQHandler ; int12
	int _EXTI5_IRQHandler ; int13
	int _EXTI6_IRQHandler ; int14
	int _EXTI7_IRQHandler ; int15
	int _LCD_AES_IRQHandler ; int16
	int _SWITCH_CSS_BREAK_DAC_IRQHandler ; int17
	int _ADC1_COMP_IRQHandler ; int18
	int _TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler ; int19
	int _TIM2_CC_USART2_RX_IRQHandler ; int20
	int _TIM3_UPD_OVF_TRG_BRK_USART3_TX_IRQHandler ; int21
	int _TIM3_CC_USART3_RX_IRQHandler ; int22
	int _TIM1_UPD_OVF_TRG_COM_IRQHandler ; int23
	int _TIM1_CC_IRQHandler ; int24
	int _TIM4_UPD_OVF_TRG_IRQHandler ; int25
	int _SPI1_IRQHandler ; int26
	int _USART1_TX_TIM5_UPD_OVF_TRG_BRK_IRQHandler ; int27
	int _USART1_RX_TIM5_CC_IRQHandler ; int28
	int _I2C1_SPI2_IRQHandler ; int29
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area HOME
	.area GSINIT
	.area GSFINAL
	.area GSINIT
	call	___sdcc_external_startup
	tnz	a
	jreq	__sdcc_init_data
	jp	__sdcc_program_startup
__sdcc_init_data:
; stm8_genXINIT() start
	ldw x, #l_DATA
	jreq	00002$
00001$:
	clr (s_DATA - 1, x)
	decw x
	jrne	00001$
00002$:
	ldw	x, #l_INITIALIZER
	jreq	00004$
00003$:
	ld	a, (s_INITIALIZER - 1, x)
	ld	(s_INITIALIZED - 1, x), a
	decw	x
	jrne	00003$
00004$:
; stm8_genXINIT() end
	.area GSFINAL
	jp	__sdcc_program_startup
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area HOME
	.area HOME
__sdcc_program_startup:
	jp	_main
;	return from main will return to caller
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area CODE
;	../src/main.c: 28: void main(void)
;	-----------------------------------------
;	 function main
;	-----------------------------------------
_main:
;	../src/main.c: 30: GPIO_Init(GPIOB, GPIO_Pin_2, GPIO_Mode_Out_PP_Low_Fast);
	push	#0xe0
	ld	a, #0x04
	ldw	x, #0x5005
	call	_GPIO_Init
;	../src/main.c: 33: CLK_Config();
	call	_CLK_Config
;	../src/main.c: 34: PWR_Config();
	call	_PWR_Config
;	../src/main.c: 35: Led2_Init;
	push	#0xe0
	ld	a, #0x04
	ldw	x, #0x5005
	call	_GPIO_Init
;	../src/main.c: 36: Mono_Init;
	push	#0xd0
	ld	a, #0x01
	ldw	x, #0x5005
	call	_GPIO_Init
;	../src/main.c: 37: blink2();
	call	_blink2
;	../src/main.c: 41: CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
	push	#0x00
	ld	a, #0x10
	call	_CLK_RTCClockConfig
;	../src/main.c: 42: CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
	push	#0x01
	ld	a, #0x12
	call	_CLK_PeripheralClockConfig
;	../src/main.c: 45: RTC_WakeUpCmd(DISABLE);
	clr	a
	call	_RTC_WakeUpCmd
;	../src/main.c: 46: RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div2);
	ld	a, #0x03
	call	_RTC_WakeUpClockConfig
;	../src/main.c: 47: RTC_SetWakeUpCounter(250);
	ldw	x, #0x00fa
	call	_RTC_SetWakeUpCounter
;	../src/main.c: 48: RTC_WakeUpCmd(ENABLE);
	ld	a, #0x01
	call	_RTC_WakeUpCmd
;	../src/main.c: 50: RTC_ITConfig(RTC_IT_WUT, ENABLE);
	ld	a, #0x01
	ldw	x, #0x0040
	call	_RTC_ITConfig
;	../src/main.c: 52: enableInterrupts();
	rim
;	../src/main.c: 53: while (1){
00102$:
;	../src/main.c: 54: blink2();
	call	_blink2
;	../src/main.c: 55: halt();
	halt
	jra	00102$
;	../src/main.c: 57: }
	ret
;	../src/main.c: 59: static void PWR_Config(void){
;	-----------------------------------------
;	 function PWR_Config
;	-----------------------------------------
_PWR_Config:
;	../src/main.c: 60: PWR->CSR1 = PWR_CSR1_PVDIF;
	mov	0x50b2+0, #0x20
;	../src/main.c: 61: PWR->CSR2 = PWR_CSR2_RESET_VALUE;
	mov	0x50b3+0, #0x00
;	../src/main.c: 62: PWR->CSR2 |= PWR_CSR2_ULP;
	bset	0x50b3, #1
;	../src/main.c: 63: PWR->CSR2 |= PWR_CSR2_FWU;
	bset	0x50b3, #2
;	../src/main.c: 64: }
	ret
;	../src/main.c: 66: static void CLK_Config(void)
;	-----------------------------------------
;	 function CLK_Config
;	-----------------------------------------
_CLK_Config:
;	../src/main.c: 68: CLK_SYSCLKSourceSwitchCmd(ENABLE);
	ld	a, #0x01
	call	_CLK_SYSCLKSourceSwitchCmd
;	../src/main.c: 69: CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSI);
	ld	a, #0x02
	call	_CLK_SYSCLKSourceConfig
;	../src/main.c: 70: CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
	clr	a
	call	_CLK_SYSCLKDivConfig
;	../src/main.c: 71: while (CLK_GetSYSCLKSource() != CLK_SYSCLKSource_LSI);
00101$:
	call	_CLK_GetSYSCLKSource
	cp	a, #0x02
	jrne	00101$
	ret
	jra	00101$
;	../src/main.c: 72: }
	ret
;	../src/main.c: 85: static void blink2() {
;	-----------------------------------------
;	 function blink2
;	-----------------------------------------
_blink2:
;	../src/main.c: 86: Mono_ON;
	ld	a, #0x01
	ldw	x, #0x5005
	call	_GPIO_ResetBits
;	../src/main.c: 87: Led2_ON;
	ld	a, #0x04
	ldw	x, #0x5005
	call	_GPIO_SetBits
;	../src/main.c: 88: Led2_OFF;
	ld	a, #0x04
	ldw	x, #0x5005
	call	_GPIO_ResetBits
;	../src/main.c: 89: Mono_OFF;
	ld	a, #0x01
	ldw	x, #0x5005
;	../src/main.c: 90: }
	jp	_GPIO_SetBits
	.area CODE
	.area CONST
	.area INITIALIZER
	.area CABS (ABS)
