Skip to content

Instantly share code, notes, and snippets.

@Crest

Crest/swd.fs Secret

Created May 25, 2020 09:31
Show Gist options
  • Save Crest/4661650057935952013dc092573c7f46 to your computer and use it in GitHub Desktop.
Save Crest/4661650057935952013dc092573c7f46 to your computer and use it in GitHub Desktop.
0 variable swd
swd constant swd-rx
swd 1 + constant swd-/rts
swd 2 + constant swd-tx
swd 3 + constant swd-cts
: swd. ( -- ) swd @ hex. ;
: swd-key? ( -- flag ) swd-/rts c@ 0<> ;
: swd-key ( -- char ) begin swd-key? until swd-rx c@ 0 swd-/rts c! ;
: swd-emit? ( -- flag ) swd-cts c@ 0= ;
: swd-emit ( char -- ) begin swd-emit? until swd-tx c! $ff swd-cts c! ;
: swd-init ( -- )
['] swd-key? hook-key? !
['] swd-key hook-key !
['] swd-emit? hook-emit? !
['] swd-emit hook-emit ! ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment