1 This is an USART Server application for the Keil MCBSTM32F400 evaluation board.
2 The application executes commands sent from the USART Client over the
3 USART interface and is used to physically test compliance of the USART driver
4 with the CMSIS USART driver specification from version 2.0.0 upwards.
7 The USART Server waits to receive a command over the USART interface.
8 After command is received it is executed, and USART Server again waits to receive
10 Command execution finishes by finishing the requested operation or by timeout.
11 All commands except XFER use (mostly fixed) communication configuration and timeout as
12 specified in the USART_Server_Config.h configuration file.
13 Only XFER command is executed using settings configured by SET COM command,
14 after execution of the XFER command the USART interface is configured back to
15 default settings from configuration file, so next command can be received.
16 The XFER command is executed until it finishes or until timeout specified in
18 If timeout is not specified in the command the last specified timeout from
19 previous XFER command is used.
20 If timeout was never specified in the XFER command then default timeout setting
23 Default USART interface configuration:
30 Settings configurable in the USART_Server_Config.h file:
31 - Mode: Asynchronous, Single-wire or IrDA
33 Hardware configuration of the USART Server (peripheral USART1 is used):
42 GND any ground connection on the board
44 Note: In Single-wire mode Tx pin is used for both transmit and receive working
47 Note: On this board there is DB9 connector with routed USART1, just take care
48 of jumpers J13 (TX1-TX3/4) and J14 (RX1-RX3/4) position
49 (IMPORTANT: on board version V1.1 these jumpers are mislabeled)
51 Note: USART pins are MCU pins before RS232 level shifter.
53 USART Server commands (32 bytes long (zero padding), [] means parameter is optional):
54 - GET VER <- followed by 16 bytes Tx data
55 - GET CAP <- followed by 32 bytes Tx data
56 - SET BUF RX/TX,len[,pattern] -> followed by optional 'len' bytes Rx data
57 - GET BUF RX/TX,len <- followed by 'len' bytes Tx data
58 - SET COM mode,data_bits,parity,stop_bits,flow_ctrl,cpol,cpha,baudrate
59 - XFER dir,num[,delay][,timeout][,num_rts] <-> followed by 'num' items data Tx, Rx or Tx and Rx transfer
60 - GET CNT <- followed by 16 bytes Tx data
61 - SET BRK delay,duration
62 - GET BRK <- followed by 1 byte Rx data phase
63 - SET MDM mdm_ctrl,delay,duration
64 - GET MDM <- followed by 1 byte Tx data
66 USART Server command parameters:
67 RX/TX: RX = USART Server's receive buffer, TX = USART Server's transmit buffer
68 len: length of content in following Tx or Rx data phase
69 pattern: value (in hex notation) to pre-fill the buffer with
70 mode: 1 = Asynchronous
71 2 = Synchronous Master
76 data_bits: data bits (5 .. 9)
80 stop_bits: 0 = 1 Stop Bit
88 cpol: This setting is only relevant for Synchronous mode
89 0 = Data are captured on rising edge
90 1 = Data are captured on falling edge
91 cpha: This setting is only relevant for Synchronous mode
92 0 = Sample on first (leading) edge
93 1 = Sample on second (trailing) edge
94 baudrate: baudrate in bauds
95 dir: direction of transfer
98 2 = Transfer (simultaneous Tx and Rx (in synchronous mode only))
99 num: number of items (according CMSIS USART driver specification)
100 delay: initial delay, in milliseconds, before starting requested operation or line control
101 timeout: timeout in milliseconds, after delay, if delay is specified
102 num_rts: number of items after which RTS line should be de-activated
103 (used to test client's CTS line functionality)
104 mdm_ctrl: modem lines requested state (in hex notation):
105 - bit 0.: RTS pin state
106 - bit 1.: DTS pin state
107 - bit 2.: state of GPIO line connected to USART Client's DCD pin
108 - bit 3.: state of GPIO line connected to USART Client's RI pin
109 duration: duration, in milliseconds, of controlling modem lines
111 USART Server responses to commands:
112 - GET VER: 16 bytes containing string representation in form:
114 - GET CAP: 32 bytes containing values representing masks (bit value 1 means supported) or values as follows:
115 "mode_mask,data_bits_mask,parity_mask,stop_bits_mask,flow_control_mask,min_baudrate,max_baudrate"
116 - mode_mask (2 digits in hex): specifies mask of supported modes
117 - bit 0.: Asynchronous
118 - bit 1.: Synchronous Master
119 - bit 2.: Synchronous Slave
120 - bit 3.: Single Wire
123 - data_bits_mask (2 digits in hex): specifies mask of supported data bits
124 - bit 0.: Data Bits 5
125 - bit 1.: Data Bits 6
126 - bit 2.: Data Bits 7
127 - bit 3.: Data Bits 8
128 - bit 4.: Data Bits 9
129 - parity_mask: (1 digits in hex): specifies mask of supported parity options
131 - bit 1.: Even Parity
133 - stop_bits_mask (1 digits in hex): specifies mask of supported stop bits
135 - bit 1.: 2 Stop Bits
136 - bit 2.: 1.5 Stop Bits
137 - bit 3.: 0.5 Stop Bits
138 - flow_control_mask (1 digits in hex): specifies mask of supported flow control options
139 - bit 0.: No Flow Control
143 - modem_line_mask: (1 digits in hex): specifies mask of supported modem lines (input/output)
144 - bit 0.: RTS line available
145 - bit 1.: CTS line available
146 - bit 2.: DTR line available
147 - bit 3.: DSR line available
148 - bit 4.: GPIO for DCD line available
149 - bit 5.: GPIO for RI line available
150 - min_baudrate (dec): minimum supported baudrate (in bauds)
151 - max_baudrate (dec): maximum supported baudrate (in bauds)
152 - GET BUF: 'len' bytes from respective buffer, in binary format
153 - GET CNT: 16 bytes containing value in decimal notation
154 - GET BRK: 1 byte (in hex) containing break signal status
155 - GET MDM: 1 byte (in hex) containing values representing modem lines state:
156 - bit 0.: CTS line current state
157 - bit 1.: DSR line current state
159 The USART Server for the Keil MCBSTM32F400 board is available for different targets:
160 - Release: target with high optimization and no User Interface
161 - Debug: target with low optimization and User Interface (GLCD, LED)
165 -> GET VER <- 16 bytes (for example "1.0.0")
167 -> GET CAP <- 32 bytes (for example "3B,18,7,F,F,03,9600,5000000")
168 Set Tx buffer to 'S':
170 Set Rx buffer to '?':
172 Get 16 bytes of Rx buffer content:
173 -> GET BUF RX,16 <- 16 bytes (for example "????????????????")
174 Set communication mode to asynchronous, 8 data bits, no parity, 1 stop bit,
175 no flow control, 115200 bauds:
176 -> SET COM 0,8,0,0,0,0,0,115200
178 -> XFER 0,16,0,100 <- 16 bytes
180 -> XFER 1,16,0,100 -> 16 bytes
181 Transfer 16 bytes in both directions (in synchronous mode only):
182 -> XFER 2,16,0,100 <-> 16 bytes
184 -> GET CNT <- 16 bytes (for example "16")
186 -> GET BRK <- 1 byte (for example "1")
187 Set activate RTS modem line after 10 ms for 50 ms and then deactivate it:
189 Get modem line state:
190 -> GET MDM <- 1 byte (for example "3")