Skip to content

refactor: consolidate timed waits into cpu.wait* routines#35

Open
agurtovoy wants to merge 1 commit into
masterfrom
refactor/2x-compatible-waits
Open

refactor: consolidate timed waits into cpu.wait* routines#35
agurtovoy wants to merge 1 commit into
masterfrom
refactor/2x-compatible-waits

Conversation

@agurtovoy

Copy link
Copy Markdown
Member

All waits are now 2x-core-compatible.

@agurtovoy
agurtovoy force-pushed the refactor/2x-compatible-waits branch 2 times, most recently from a3f3925 to 41d44fa Compare July 17, 2026 03:09
Comment thread f256/audio.asm
;
; Wait for about 1ms
;
wait_1ms: phx

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, delete local copies of the wait routines, replace calls to local wait_100ms with cpu.wait_100ms.

Comment thread f256/audio.asm
bne wait100l
plx
rts
.endn

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the wait_tens implementation below out of the nested namespace so it can be cleanly accessed by all routines in this module.

Comment thread f256/cpu.asm

; See comment blocks for `wait_20us` and below
WAIT_COUNT_6_3MHz = 21
WAIT_COUNT_12_6MHz = 47

@agurtovoy agurtovoy Jul 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted 2x-core-aware timed sleep* implementations from iec.asm, renamed to wait*, double-checked & tightened up the timings.

All waits are now 2x-core-compatible

Signed-off-by: Aleksey Gurtovoy <aleks@wildbitscomputing.com>
@agurtovoy
agurtovoy force-pushed the refactor/2x-compatible-waits branch from 41d44fa to a2816aa Compare July 17, 2026 04:27
Comment thread f256/cpu.asm


; Wait for approximately but no less than the specified number of ms
wait_ms .macro ms

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primary API for arbitrary ms waits

Comment thread f256/iec.asm
init .proc

jsr sleep_1ms
jsr cpu.wait_1ms

@agurtovoy agurtovoy Jul 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, sleep_N -> cpu.wait_N

Comment thread f256/iec.asm
eoi_pending .byte ?
rx_eoi .fill 0 ; shared with mark
mark .byte ?
sleep20 .byte ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the calibrated count and the init below sequence to the cpu module.

Comment thread f256/iec.asm
_done
rts

sleep_20us

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved/reworked as cpu.wait*

Comment thread f256/k2_lcd.asm
_out:
rts

wait_ms .macro ms

@agurtovoy agurtovoy Jul 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted another set of superseded local routines

@agurtovoy
agurtovoy marked this pull request as ready for review July 17, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant