Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/constants.inc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ CPUSpeed equ $07
VARS EQU $5c4b ; addr of variables area
NEXT_ONE_r3 EQU $19b8 ; find next variable

ESPTimeout EQU 65535*4;65535 ; Use 10000 for 3.5MHz, but 28NHz needs to be 65535
ESPTimeoutInSeconds EQU 60 ; Seconds, use this one to adjust timeout
; ESPTimeoutI is an 64-bit const which fits CheckESPTimeout
ESPTimeoutI EQU 65535 + ((22*ESPTimeoutInSeconds/10)<<16) ; formula for 28MHz

BORDCR EQU 23624

Expand Down
24 changes: 3 additions & 21 deletions src/esp-timeout.asm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
InitESPTimeout:
MODULE InitESPTimeout
push hl
ld hl, ESPTimeout mod 65536 ; Timeout is a 32-bit value, so save the two LSBs first,
ld hl, ESPTimeoutI mod 65536 ; Timeout is a 32-bit value, so save the two LSBs first,
ld (CheckESPTimeout.Value), hl
ld hl, ESPTimeout / 65536 ; then the two MSBs.
ld hl, ESPTimeoutI / 65536 ; then the two MSBs.
ld (CheckESPTimeout.Value2), hl
pop hl
ret
Expand All @@ -18,7 +18,6 @@ Value EQU $+1
ld hl, SMC
dec hl
ld (Value), hl
call WaitRaster
ld a, h
or l
jr z, Rollover
Expand All @@ -36,26 +35,9 @@ Value2 EQU $+1
or l
jr z, Failure ; If we hit here, 32 bit value is $00000000
dec hl
call WaitRaster
ld (Value2), hl
ld hl, ESPTimeout mod 65536
ld hl, ESPTimeoutI mod 65536
ld (Value), hl
jr Success

// https://github.com/remy/next-http/issues/7
WaitRaster:
push bc
push af
.waitloop:
ld bc, $243b
ld a, $1f ; only really care about lsb
out (c), a
inc b
in a, (c)
cp 192
jr nz, .waitloop
pop af
pop bc
ret

ENDMODULE
11 changes: 9 additions & 2 deletions src/uart.asm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ SMC_skip_baud_init
rla ; Now in Bit 0
or %10000000 ; Set MSB to req. write to upper 7 bits
out (c), a
ret
; stale data taken out from FIFO at max speed
.staleFIFOclean
ld bc, UART_GetStatus
in a, (c)
rra
ret nc
ld bc, UART_RxD
in a, (c)
jr .staleFIFOclean

.baudTable:
DEFW 243,248,256,260,269,278,286,234 ; 115K
Expand Down Expand Up @@ -106,7 +114,6 @@ write:
IFDEF TESTING
call debug
ENDIF

ld bc, UART_GetStatus
.wait
in a, (c)
Expand Down