From cea3137b5a608083ccd5d44a27aa2c4893e7d596 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 5 Sep 2024 18:47:32 +0200 Subject: [PATCH] avr: add LED module LED_SIMPLE very much shorter version with only basic functionality. --- avr/modules/0BUILD | 1 + avr/modules/led_simple/0BUILD | 11 +++++ avr/modules/led_simple/main.asm | 83 +++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 avr/modules/led_simple/0BUILD create mode 100644 avr/modules/led_simple/main.asm diff --git a/avr/modules/0BUILD b/avr/modules/0BUILD index 30c65e7..882f6ee 100644 --- a/avr/modules/0BUILD +++ b/avr/modules/0BUILD @@ -10,6 +10,7 @@ flash lcd led + led_simple reed si7021 stats diff --git a/avr/modules/led_simple/0BUILD b/avr/modules/led_simple/0BUILD new file mode 100644 index 0000000..febd367 --- /dev/null +++ b/avr/modules/led_simple/0BUILD @@ -0,0 +1,11 @@ + + + + + + main.asm + + + + + diff --git a/avr/modules/led_simple/main.asm b/avr/modules/led_simple/main.asm new file mode 100644 index 0000000..2a7c975 --- /dev/null +++ b/avr/modules/led_simple/main.asm @@ -0,0 +1,83 @@ +; *************************************************************************** +; 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 + + + +; *************************************************************************** +; 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 + ldi r16, LED_SIMPLE_ONTIME + sts ledSimpleTimer, r16 + sec + ret + + +; --------------------------------------------------------------------------- +; LedSimple_Every100ms +; +; IN: +; - nothing +; OUT: +; - nothing +; USED: + +LedSimple_Every100ms: + lds r16, ledSimpleTimer + dec r16 + brne 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 + ldi r16, LED_SIMPLE_OFFTIME + rjmp LedSimple_Every100ms_setTimer +LedSimple_Tick_isOff: + cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on + ldi r16, LED_SIMPLE_ONTIME +LedSimple_Every100ms_setTimer: + sts ledSimpleTimer, r16 + ret + + + +LED_SIMPLE_END: +.equ MODULE_SIZE_LED_SIMPLE = LED_SIMPLE_END-LED_SIMPLE_BEGIN + + +