; *************************************************************************** ; copyright : (C) 2023 by Martin Preuss ; email : martin@libchipcard.de ; ; *************************************************************************** ; * This file is part of the project "AqHome". * ; * Please see toplevel file COPYING of that project for license details. * ; *************************************************************************** ; *************************************************************************** ; data .dseg ledSimpleTimer: .byte 1 ledSimpleOnTime: .byte 1 ledSimpleOffTime: .byte 1 ; *************************************************************************** ; code .cseg LED_SIMPLE_BEGIN: ; --------------------------------------------------------------------------- ; LedSimple_Init ; ; IN: ; - nothing ; OUT: ; - CFLAG: set if okay, clear on error ; USED: R1, R2, R3, R4, R16, R17, X LedSimple_Init: sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on rcall LedSimple_SetDefaultTiming ; (R16) sec ret ; --------------------------------------------------------------------------- ; @routine LedSimple_Every100ms @global ; ; @clobbers r16 LedSimple_Every100ms: lds r16, ledSimpleTimer dec r16 breq LedSimple_Every100ms_zero rjmp LedSimple_Every100ms_setTimer LedSimple_Every100ms_zero: sbic LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; skip next op if LED is on rjmp LedSimple_Tick_isOff ; is on sbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; off lds r16, ledSimpleOffTime rjmp LedSimple_Every100ms_setTimer LedSimple_Tick_isOff: cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on lds r16, ledSimpleOnTime LedSimple_Every100ms_setTimer: sts ledSimpleTimer, r16 ret ; @end ; --------------------------------------------------------------------------- ; @routine LedSimple_SetDefaultTiming @global ; ; Set default timing for LED. ; @clobbers r16 ; LedSimple_SetDefaultTiming: ldi r16, LED_SIMPLE_ONTIME sts ledSimpleOnTime, r16 sts ledSimpleTimer, r16 ldi r16, LED_SIMPLE_OFFTIME sts ledSimpleOffTime, r16 cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on ret ; @end ; --------------------------------------------------------------------------- ; @routine LedSimple_SetFastTiming @global ; ; Set fast blinking timing for LED. Switch LED on. ; @clobbers r16 ; LedSimple_SetFastTiming: ldi r16, 5 sts ledSimpleOnTime, r16 sts ledSimpleTimer, r16 ldi r16, 3 sts ledSimpleOffTime, r16 cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on ret ; @end LED_SIMPLE_END: .equ MODULE_SIZE_LED_SIMPLE = LED_SIMPLE_END-LED_SIMPLE_BEGIN