romconsole.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. *****************************
  2. {IDF_TARGET_NAME} ROM console
  3. *****************************
  4. When an {IDF_TARGET_NAME} is unable to boot from flash ROM (and the fuse disabling it hasn't been blown), it boots into a rom console. The console
  5. is based on TinyBasic, and statements entered should be in the form of BASIC statements. As is common in the BASIC language, without a
  6. preceeding line number, commands entered are executed immediately; lines with a prefixed line number are stored as part of a program.
  7. Full list of supported statements and functions
  8. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. System
  10. ------
  11. - BYE - *exits Basic, reboots and retries booting from flash*
  12. - END - *stops execution from the program, also "STOP"*
  13. - MEM - *displays memory usage statistics*
  14. - NEW - *clears the current program*
  15. - RUN - *executes the current program*
  16. IO, Documentation
  17. -----------------
  18. - PEEK( address ) - *get a 32-bit value from a memory address*
  19. - POKE - *write a 32-bit value to memory*
  20. - USR(addr, arg1, ..) - *Execute a machine language function*
  21. - PRINT expression - *print out the expression, also "?"*
  22. - PHEX expression - *print expression as a hex number*
  23. - REM stuff - *remark/comment, also "'"*
  24. Expressions, Math
  25. -----------------
  26. - A=V, LET A=V - *assign value to a variable*
  27. - +, -, \*, / - *Math*
  28. - <,<=,=,<>,!=,>=,> - *Comparisons*
  29. - ABS( expression ) - *returns the absolute value of the expression*
  30. - RSEED( v ) - *sets the random seed to v*
  31. - RND( m ) - *returns a random number from 0 to m*
  32. - A=1234 - * Assign a decimal value*
  33. - A=&h1A2 - * Assign a hex value*
  34. - A=&b1001 - *Assign a binary value*
  35. Control
  36. -------
  37. - IF expression statement - *perform statement if expression is true*
  38. - FOR variable = start TO end - *start for block*
  39. - FOR variable = start TO end STEP value - *start for block with step*
  40. - NEXT - *end of for block*
  41. - GOTO linenumber - *continue execution at this line number*
  42. - GOSUB linenumber - *call a subroutine at this line number*
  43. - RETURN - *return from a subroutine*
  44. - DELAY - *Delay a given number of milliseconds*
  45. Pin IO
  46. ------
  47. - IODIR - *Set a GPIO-pin as an output (1) or input (0)*
  48. - IOSET - *Set a GPIO-pin, configured as output, to high (1) or low (0)*
  49. - IOGET - *Get the value of a GPIO-pin*
  50. Example programs
  51. ~~~~~~~~~~~~~~~~
  52. Here are a few example commands and programs to get you started...
  53. Read UART_DATE register of uart0
  54. --------------------------------
  55. ::
  56. > PHEX PEEK(&h3FF40078)
  57. 15122500
  58. Set GPIO2 using memory writes to GPIO_OUT_REG
  59. ---------------------------------------------
  60. Note: you can do this easier with the IOSET command
  61. ::
  62. > POKE &h3FF44004,PEEK(&h3FF44004) OR &b100
  63. Get value of GPIO0
  64. ------------------
  65. ::
  66. > IODIR 0,0
  67. > PRINT IOGET(0)
  68. 0
  69. Blink LED
  70. ---------
  71. Hook up an LED between GPIO2 and ground. When running the program, the LED should blink 10 times.
  72. ::
  73. 10 IODIR 2,1
  74. 20 FOR A=1 TO 10
  75. 30 IOSET 2,1
  76. 40 DELAY 250
  77. 50 IOSET 2,0
  78. 60 DELAY 250
  79. 70 NEXT A
  80. RUN
  81. Credits
  82. ~~~~~~~
  83. The ROM console is based on "TinyBasicPlus" by Mike Field and Scott Lawrence, which is based on "68000 TinyBasic" by Gordon Brandly