Added and simplified COM module.
Directly use pins, no complicated redirections. Router modules will probably use real UARTs or MCUs programmed as UARTs.
This commit is contained in:
58
avr/main.asm
58
avr/main.asm
@@ -7,24 +7,35 @@
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; generic
|
||||
|
||||
.equ clock=1000000 ; Define the clock frequency
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; COM module
|
||||
|
||||
.equ COM_DDR_DATA DDRA
|
||||
.equ COM_PORT_DATA PORTA
|
||||
.equ COM_PIN_DATA PINA
|
||||
.equ COM_PINMASK_DATA (1<<PORTA1)
|
||||
.equ COM_PINNUM_DATA PORTA1
|
||||
.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400
|
||||
|
||||
.equ COM_DDR_ATTN DDRA
|
||||
.equ COM_PORT_ATTN PORTA
|
||||
.equ COM_PIN_ATTN PINA
|
||||
.equ COM_PINMASK_ATTN (1<<PORTA7)
|
||||
.equ COM_PINNUM_ATTN PORTA7
|
||||
.equ COM_RINGBUFFER_SIZE = 32 ; 32 bytes for now
|
||||
|
||||
.equ COM_DDR_DATA = DDRA
|
||||
.equ COM_PORT_DATA = PORTA
|
||||
.equ COM_PIN_DATA = PINA
|
||||
.equ COM_PINNUM_DATA = PORTA1
|
||||
|
||||
.equ COM_DDR_ATTN = DDRA
|
||||
.equ COM_PORT_ATTN = PORTA
|
||||
.equ COM_PIN_ATTN = PINA
|
||||
.equ COM_PINNUM_ATTN = PORTA7
|
||||
|
||||
.equ COM_IRQ_ADDR_ATTN = PCMSK0
|
||||
.equ COM_IRQ_BIT_ATTN = 7 ; bit 7 in PCMSK0
|
||||
.equ COM_IRQ_GIFR_ATTN = PCIF0
|
||||
.equ COM_IRQ_GIMSK_ATTN = PCIE0
|
||||
|
||||
.equ COM_IRQ_ADDR_ATTN PCMSK0
|
||||
.equ COM_IRQ_MASK_ATTN (1<<7) ; bit 7 in PCMSK0
|
||||
.equ COM_IRQ_GIFR_ATTN (1 << PCIF0)
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +45,9 @@
|
||||
.cseg
|
||||
.org 000000
|
||||
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Reset and interrupt vectors
|
||||
|
||||
rjmp main ; Reset vector
|
||||
@@ -60,11 +73,11 @@
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
.include "utils.asm"
|
||||
.include "ringbuffer.asm"
|
||||
.include "timer.asm"
|
||||
.include "led.asm"
|
||||
.include "com.asm"
|
||||
.include "utils.asm"
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +87,6 @@
|
||||
.dseg
|
||||
|
||||
ledA3Sram: .byte LED_SRAM_SIZE
|
||||
wanA7A1Sram: .byte COM_SRAM_SIZE
|
||||
|
||||
|
||||
|
||||
@@ -83,11 +95,7 @@ wanA7A1Sram: .byte COM_SRAM_SIZE
|
||||
|
||||
.cseg
|
||||
|
||||
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
|
||||
comA7A1Flash: .db 1, 0 ; id, flags
|
||||
.db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA1) ; port info for DATA line
|
||||
.db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA7) ; port info for ATTN line
|
||||
.db 0, 0x80 ; ATTN: PCINT irq type, irq mask (e.g. for PCMSK0)
|
||||
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
|
||||
blinkPattern: .db 5, 5, 5, 5, 5, 10, 0xff, 0xff ; 3 short blinks, 1s pause, restart
|
||||
|
||||
|
||||
@@ -134,7 +142,7 @@ main_loop:
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; ---------------------------------------------------------------------------
|
||||
; initModules
|
||||
;
|
||||
; Call init functions of the used modules. Add your routine calls here.
|
||||
@@ -157,7 +165,7 @@ initModules:
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; ---------------------------------------------------------------------------
|
||||
; runModulesUntilIdle
|
||||
;
|
||||
; Call run functions of the used modules. Add your routine calls here.
|
||||
@@ -178,7 +186,7 @@ runModulesUntilIdle_Timer: ; repeat this block for every run function
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEvery100ms
|
||||
;
|
||||
; Called every 100ms. Add your routine calls here.
|
||||
@@ -203,7 +211,7 @@ onEvery100ms:
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; ---------------------------------------------------------------------------
|
||||
; onEverySecond
|
||||
;
|
||||
; Called every second. Add your routine calls here.
|
||||
|
||||
Reference in New Issue
Block a user