From 06434512c7722b51b2bd330886dc4f10d0ef1fd7 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 29 Apr 2025 00:37:31 +0200 Subject: [PATCH] avr: added new version of tcrt1000. --- avr/modules/tcrt1000/main2.asm | 106 ++++++++++----------------------- 1 file changed, 30 insertions(+), 76 deletions(-) diff --git a/avr/modules/tcrt1000/main2.asm b/avr/modules/tcrt1000/main2.asm index 96908ed..ae6adbc 100644 --- a/avr/modules/tcrt1000/main2.asm +++ b/avr/modules/tcrt1000/main2.asm @@ -1,5 +1,5 @@ ; *************************************************************************** -; copyright : (C) 2023 by Martin Preuss +; copyright : (C) 2025 by Martin Preuss ; email : martin@libchipcard.de ; ; *************************************************************************** @@ -12,10 +12,8 @@ .equ TCRT1K_INTERVAL = 7 .equ TCRT1K_LIMIT = 170 -.equ TCRT1K_STATE_OPEN = 255 -.equ TCRT1K_STATE_CLOSED = 0 - -.equ TCRT1K_FLAGS_REPORT_CHANGE_BIT = 0 +.equ TCRT1K_FLAGS_VALID_BIT = 7 +.equ TCRT1K_FLAGS_VALUE_BIT = 0 ; *************************************************************************** @@ -25,9 +23,6 @@ tcrt1kDataBegin: tcrt1kTimer: .byte 1 - tcrt1kLastState: .byte 1 - tcrt1kLastValue: .byte 1 - tcrt1kStateCounter: .byte 1 tcrt1kFlags: .byte 1 tcrt1kDataEnd: @@ -83,15 +78,19 @@ TCRT1K_Fini: +; --------------------------------------------------------------------------- +; @routine TCRT1K_Every100ms @global +; + TCRT1K_Every100ms: lds r16, tcrt1kTimer dec r16 breq TCRT1K_Every100ms_readValue sts tcrt1kTimer, r16 - cpi r16, 2 - breq TCRT1K_Every100ms_ledOn cpi r16, 1 breq TCRT1K_Every100ms_startMeasure + cpi r16, 2 + breq TCRT1K_Every100ms_ledOn ret TCRT1K_Every100ms_ledOn: sbi TCRT1K_LED_PORT, TCRT1K_LED_PIN ; LED on @@ -107,83 +106,38 @@ TCRT1K_Every100ms_readValue: sts tcrt1kTimer, r16 in r16, ADCH ; read value from ADC cbi TCRT1K_LED_PORT, TCRT1K_LED_PIN ; LED off - sts tcrt1kLastValue, r16 - + ; convert to 1/0 + lds r17, tcrt1kFlags + cbr r17, (1<