Dispatcher

UART Command Line Exercise

Task

An operator types commands on USART1 while your program runs, fixing typos with Backspace. Run each line as corrected at Enter, for as long as the board runs:

line PA5 reply LED ON high OK LED OFF low OK STATUS unchanged LED:1 if PA5 is high, LED:0 if low LED ONN unchanged ERR other unchanged ERR empty unchanged none

The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: an operator's terminal wired to U1 STM32F4, its TX into USART1 RX on PA10 carrying the keys, USART1 TX on PA9 back to its RX carrying the replies, and a common ground; PA5 drives LED D1 through a resistor to ground, with logic analyzer TP1 on PA5

Pass condition

Send only the replies, each ending in \n. The terminal shows the typing itself. The replies and PA5's changes are compared in order.

Expected for the typos case: LED OM, Backspace, N runs as LED ON, replies OK and takes PA5 high; STAUS, three Backspaces, ATUS runs as STATUS and replies LED:1; LED OFFF, Backspace runs as LED OFF, replies OK and takes PA5 low; STATUS replies LED:0

Notes

Each key arrives as one byte:

Enter \r Backspace 0x7F or 0x08, by terminal

A command must match exactly. A longer line gets ERR. The given code sets up USART1 and PA5, low at reset.

Related challenges

Loading the interactive arena.