sending works again with n20.
This commit is contained in:
@@ -128,16 +128,38 @@ uartBitbang_RawReceiveMsg_end:
|
||||
; @param X ptr to buffer to send
|
||||
; @return CFLAGS set if okay, cleared otherwise (index of error variable in R16)
|
||||
; @return R16 index of error variable (if CFLAGS cleared)
|
||||
; @clobbers R16, R22 (R17, R21, X)
|
||||
; @clobbers R16 (R17, R21, R22, R24, R25, X)
|
||||
|
||||
uartBitbang_SendMsg:
|
||||
rcall uartBitbang_AcquireBus
|
||||
brcc uartBitbang_SendMsg_lineBusyError
|
||||
|
||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||
|
||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||
|
||||
rcall uartBitbang_RawSendMsg ; (R16, R17, R21, R22, R24, R25, X)
|
||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; release ATTN line (by setting direction to IN)
|
||||
ret
|
||||
uartBitbang_SendMsg_lineBusyError:
|
||||
ldi r16, NET_IFACE_OFFS_ERR_BUSY_LOW
|
||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine uartBitbang_RawSendMsg
|
||||
;
|
||||
; Send packet over wire.
|
||||
;
|
||||
; @param X ptr to buffer to send
|
||||
; @return CFLAGS set if okay, cleared otherwise (index of error variable in R16)
|
||||
; @return R16 index of error variable (if CFLAGS cleared)
|
||||
; @clobbers R16, R17 (R21, R22, R24, R25, X)
|
||||
|
||||
uartBitbang_RawSendMsg:
|
||||
adiw xh:xl, NETMSG_OFFS_MSGLEN
|
||||
ld r17, X
|
||||
sbiw xh:xl, NETMSG_OFFS_MSGLEN
|
||||
@@ -145,25 +167,68 @@ uartBitbang_SendMsg:
|
||||
inc r17 ; account for msglen byte
|
||||
inc r17 ; account for crc byte
|
||||
|
||||
uartBitbang_SendMsg_loop:
|
||||
uartBitbang_RawSendMsg_loop:
|
||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||
|
||||
ld r16, X+
|
||||
rcall uartBitbang_SendByte ; send byte (R16, R21, R22)
|
||||
brcc uartBitbang_SendMsg_releaseBusRet
|
||||
brcc uartBitbang_RawSendMsg_ioError
|
||||
dec r17
|
||||
brne uartBitbang_SendMsg_loop
|
||||
brne uartBitbang_RawSendMsg_loop
|
||||
ldi r16, NET_IFACE_OFFS_PACKETSOUT_LOW
|
||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||
sec
|
||||
uartBitbang_SendMsg_releaseBusRet:
|
||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; release ATTN line (by setting direction to IN)
|
||||
brcc uartBitbang_SendMsg_ioError
|
||||
; packet successfully sent
|
||||
ret
|
||||
uartBitbang_SendMsg_ioError:
|
||||
uartBitbang_RawSendMsg_ioError:
|
||||
ldi r16, NET_IFACE_OFFS_ERR_COLLISIONS_LOW
|
||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||
clc
|
||||
ret
|
||||
uartBitbang_SendMsg_lineBusyError:
|
||||
ldi r16, NET_IFACE_OFFS_ERR_BUSY_LOW
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine uartBitbang_WaitForAttnHigh
|
||||
;
|
||||
; Wait up to 1ms for data pin to become high
|
||||
; @return CFLAG set if okay, clear otherwise
|
||||
; @clobbers R17, R22
|
||||
|
||||
uartBitbang_WaitForAttnHigh:
|
||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
||||
UART_BB_M_WAIT_FOR_PIN_HIGH COM_ATTN_INPUT, COM_ATTN_PIN
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine uartBitbang_AcquireBus
|
||||
;
|
||||
; Reserve bus if free (otherwise return error)
|
||||
; Expects interrupts to be disabled.
|
||||
;
|
||||
; @return CFLAG set if okay (bus acquired), cleared on error
|
||||
; @clobbers: none
|
||||
|
||||
uartBitbang_AcquireBus:
|
||||
; check for ATTN line: busy?
|
||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as input
|
||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable pullup on ATTN
|
||||
nop ; needed to sample current input
|
||||
sbis COM_ATTN_INPUT, COM_ATTN_PIN ; ATTN low?
|
||||
rjmp uartBitbang_AcquireBus_busy ; jump if it is
|
||||
sbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as output
|
||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; set ATTN low
|
||||
sec
|
||||
ret
|
||||
uartBitbang_AcquireBus_busy:
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user