diff --git a/avr/devices/n00/n00_defs.asm b/avr/devices/n00/n00_defs.asm index 4c6b549..fac8d5e 100644 --- a/avr/devices/n00/n00_defs.asm +++ b/avr/devices/n00/n00_defs.asm @@ -47,7 +47,8 @@ ; --------------------------------------------------------------------------- ; COM module -.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400 +.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 +.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter .equ COM_DDR_DATA = DDRA .equ COM_PORT_DATA = PORTA diff --git a/avr/devices/n06/n06_defs.asm b/avr/devices/n06/n06_defs.asm index 4c6b549..9cb3ec3 100644 --- a/avr/devices/n06/n06_defs.asm +++ b/avr/devices/n06/n06_defs.asm @@ -47,7 +47,8 @@ ; --------------------------------------------------------------------------- ; COM module -.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400 +.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 +.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter .equ COM_DDR_DATA = DDRA .equ COM_PORT_DATA = PORTA @@ -60,7 +61,7 @@ .equ COM_PINNUM_ATTN = PORTA7 .equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = 7 ; bit 7 in PCMSK0 +.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 .equ COM_IRQ_GIFR_ATTN = PCIF0 .equ COM_IRQ_GIMSK_ATTN = PCIE0 diff --git a/avr/devices/n11/n11_defs.asm b/avr/devices/n11/n11_defs.asm index 52bd6f0..b6b3abf 100644 --- a/avr/devices/n11/n11_defs.asm +++ b/avr/devices/n11/n11_defs.asm @@ -47,7 +47,7 @@ ; COM module .equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 - ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter +.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter .equ COM_DDR_DATA = DDRA .equ COM_PORT_DATA = PORTA .equ COM_PIN_DATA = PINA @@ -59,7 +59,7 @@ .equ COM_PINNUM_ATTN = PORTA7 .equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = 7 ; bit 7 in PCMSK0 +.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 .equ COM_IRQ_GIFR_ATTN = PCIF0 .equ COM_IRQ_GIMSK_ATTN = PCIE0 diff --git a/avr/devices/n11/n11_main.asm b/avr/devices/n11/n11_main.asm index ae43814..0054078 100644 --- a/avr/devices/n11/n11_main.asm +++ b/avr/devices/n11/n11_main.asm @@ -161,6 +161,10 @@ firmwareStart: rjmp main .include "modules/comproto/msg_device.asm" .include "modules/comproto/msg_reboot.asm" #endif + #ifdef MODULES_LCD + .include "modules/com2/screen.asm" + .include "modules/comproto/screen.asm" + #endif #endif #ifdef MODULES_TWI_MASTER .include "modules/twimaster/main.asm" @@ -194,9 +198,18 @@ firmwareStart: rjmp main .dseg +programRamBegin: +#ifdef MODULES_LCD + screenCounter: .byte 1 +#endif + +programRamEnd: + + #ifdef MODULES_LCD sramTimerWriteStats: .byte 2 + sramTimerScreen: .byte 2 #endif sramTimerEnqueueValues: .byte 2 #ifdef MODULES_SI7021 @@ -221,12 +234,6 @@ sramTimerEnqueueValues: .byte 2 .cseg -#ifdef MODULES_LED -ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1< CARRY @@ -43,16 +43,16 @@ com2SendByte_setLow: com2SendByte_setHigh: cbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as input, pullup R makes it ONE nop ; +1 (to make pin change available) - Utils_WaitNanoSecs COM_BIT_LENGTH/2, 11, r22 ; wait for half a bit length for line to safely settle + Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 0, r22 ; wait for half a bit length for line to safely settle sbis COM_PIN_DATA, COM_PINNUM_DATA ; +1 if no skip, +2 if skipped rjmp com2SendByte_error ; +2 if error (collision: we wanted line to be high but it is low) - Utils_WaitNanoSecs COM_BIT_LENGTH/2, 0, r22 + Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 11, r22 com2SendByte_loopEnd: dec r21 ; +1 brne com2SendByte_loop ; +2, sum per loop: 10 cycles ; send stopbit cbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as input, pullup R makes it ONE - Utils_WaitNanoSecs COM_BIT_LENGTH, 4, r22 ; wait for one bit length + Utils_WaitNanoSecs COM_BIT_LENGTH, 0, r22 ; wait for one bit length rjmp com2LowLevelSecRet com2SendByte_error: @@ -81,7 +81,7 @@ com2ReceiveByte: ; wait for startbit rcall com2WaitForDataLow ; (R16, R17, R22) brcc com2ReceiveByte_error - Utils_WaitNanoSecs COM_BIT_LENGTH/2, 5, r22 ; goto middle of startbit to maximize sync stability + Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 10, r22 ; goto middle of startbit to maximize sync stability com2ReceiveByte_loop: Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits sec ; +1 @@ -149,7 +149,7 @@ com2WaitForAttnHigh: ; --------------------------------------------------------------------------- ; com2WaitForDataState1ms ; -; Waits up to 1ms for high DATA line +; Waits up to 500us for high DATA line ; IN: ; - R16: state to wait for (00 for low, 0xff for high) ; OUT: @@ -163,12 +163,14 @@ com2WaitForDataState1ms_loop: eor r22, r16 andi r22, (1<