avr: fixed a few errors in new uart_bitbang module.
This commit is contained in:
@@ -66,7 +66,8 @@
|
|||||||
.equ COM_TXD_PIN = PORTB1
|
.equ COM_TXD_PIN = PORTB1
|
||||||
|
|
||||||
.equ COM_RXD_DDR = DDRB
|
.equ COM_RXD_DDR = DDRB
|
||||||
.equ COM_RXD_DATA = PINB
|
.equ COM_RXD_INPUT = PINB
|
||||||
|
.equ COM_RXD_OUTPUT = PORTB
|
||||||
.equ COM_RXD_PIN = PORTB1
|
.equ COM_RXD_PIN = PORTB1
|
||||||
|
|
||||||
.equ COM_ATTN_DDR = DDRB
|
.equ COM_ATTN_DDR = DDRB
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ uartBitbang_SendByte_setHigh:
|
|||||||
cbi COM_TXD_DDR, COM_TXD_PIN ; +2 set DATA as input, pullup R makes it ONE
|
cbi COM_TXD_DDR, COM_TXD_PIN ; +2 set DATA as input, pullup R makes it ONE
|
||||||
nop ; +1 (to make pin change available)
|
nop ; +1 (to make pin change available)
|
||||||
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 0, 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_RXD_DATA, COM_RXD_PIN ; +1 if no skip, +2 if skipped
|
sbis COM_RXD_INPUT, COM_RXD_PIN ; +1 if no skip, +2 if skipped
|
||||||
rjmp uartBitbang_SendByte_error ; +2 if error (collision: we wanted line to be high but it is low)
|
rjmp uartBitbang_SendByte_error ; +2 if error (collision: we wanted line to be high but it is low)
|
||||||
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 11, r22
|
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 11, r22
|
||||||
uartBitbang_SendByte_loopEnd:
|
uartBitbang_SendByte_loopEnd:
|
||||||
@@ -126,6 +126,8 @@ uartBitbang_SendByte_error:
|
|||||||
; @clobbers R16, R20, R21, R22 (R17)
|
; @clobbers R16, R20, R21, R22 (R17)
|
||||||
|
|
||||||
uartBitbang_ReceiveByte:
|
uartBitbang_ReceiveByte:
|
||||||
|
cbi COM_RXD_OUTPUT, COM_RXD_PIN ; disable internal pullup for RXD
|
||||||
|
cbi COM_RXD_DDR, COM_RXD_PIN ; set RXD port as input
|
||||||
ldi r21, 8 ; bits left
|
ldi r21, 8 ; bits left
|
||||||
clr r20 ; byte currently receiving
|
clr r20 ; byte currently receiving
|
||||||
; wait for startbit
|
; wait for startbit
|
||||||
@@ -135,7 +137,7 @@ uartBitbang_ReceiveByte:
|
|||||||
uartBitbang_ReceiveByte_loop:
|
uartBitbang_ReceiveByte_loop:
|
||||||
Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits
|
||||||
sec ; +1
|
sec ; +1
|
||||||
sbic COM_RXD_DATA, COM_RXD_PIN ; LOW: +2, HIGH: +1
|
sbic COM_RXD_INPUT, COM_RXD_PIN ; LOW: +2, HIGH: +1
|
||||||
rjmp uartBitbang_ReceiveByte_shiftIn ; HIGH: +2, rjmp, use set CFLAG
|
rjmp uartBitbang_ReceiveByte_shiftIn ; HIGH: +2, rjmp, use set CFLAG
|
||||||
clc ; LOW: +1
|
clc ; LOW: +1
|
||||||
uartBitbang_ReceiveByte_shiftIn:
|
uartBitbang_ReceiveByte_shiftIn:
|
||||||
@@ -162,7 +164,7 @@ uartBitbang_ReceiveByte_error:
|
|||||||
; @clobbers R17, R22
|
; @clobbers R17, R22
|
||||||
|
|
||||||
uartBitbang_WaitForDataLow:
|
uartBitbang_WaitForDataLow:
|
||||||
UART_BB_M_WAIT_FOR_PIN_LOW COM_RXD_DATA, COM_RXD_PIN
|
UART_BB_M_WAIT_FOR_PIN_LOW COM_RXD_INPUT, COM_RXD_PIN
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -176,7 +178,7 @@ uartBitbang_WaitForDataLow:
|
|||||||
; @clobbers R17, R22
|
; @clobbers R17, R22
|
||||||
|
|
||||||
uartBitbang_WaitForDataHigh:
|
uartBitbang_WaitForDataHigh:
|
||||||
UART_BB_M_WAIT_FOR_PIN_LOW COM_RXD_DATA, COM_RXD_PIN
|
UART_BB_M_WAIT_FOR_PIN_HIGH COM_RXD_INPUT, COM_RXD_PIN
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ UART_BitBang_Init:
|
|||||||
cbi COM_TXD_DATA, COM_TXD_PIN ; disable internal pullup for TXD
|
cbi COM_TXD_DATA, COM_TXD_PIN ; disable internal pullup for TXD
|
||||||
cbi COM_TXD_DDR, COM_TXD_PIN ; set TXD port as input
|
cbi COM_TXD_DDR, COM_TXD_PIN ; set TXD port as input
|
||||||
|
|
||||||
cbi COM_RXD_DATA, COM_RXD_PIN ; disable internal pullup for RXD
|
cbi COM_RXD_OUTPUT, COM_RXD_PIN ; disable internal pullup for RXD
|
||||||
cbi COM_RXD_DDR, COM_RXD_PIN ; set RXD port as input
|
cbi COM_RXD_DDR, COM_RXD_PIN ; set RXD port as input
|
||||||
|
|
||||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ uartBitbang_ReceivePacketIntoBuffer:
|
|||||||
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
||||||
pop r17 ; pop from R16 to R17
|
pop r17 ; pop from R16 to R17
|
||||||
brcc uartBitbang_ReceivePacketIntoBuffer_ioError
|
brcc uartBitbang_ReceivePacketIntoBuffer_ioError
|
||||||
#ifdef COM_ACCEPT_ALL_DEST ; accept every destination address
|
#ifndef COM_ACCEPT_ALL_DEST ; accept every destination address
|
||||||
rjmp uartBitbang_ReceivePacketIntoBuffer_acceptAddr
|
|
||||||
#else
|
|
||||||
; compare destination address (accept "FF" and own address)
|
; compare destination address (accept "FF" and own address)
|
||||||
cp r16, r17
|
cp r16, r17
|
||||||
breq uartBitbang_ReceivePacketIntoBuffer_acceptAddr
|
breq uartBitbang_ReceivePacketIntoBuffer_acceptAddr
|
||||||
|
|||||||
Reference in New Issue
Block a user