@@ -70,9 +70,11 @@ typedef enum {
70
70
ParityForced0 = 4
71
71
} SerialParity ;
72
72
73
+ /** Serial interrupt sources
74
+ */
73
75
typedef enum {
74
- RxIrq ,
75
- TxIrq
76
+ RxIrq , /**< Receive Data Register Full */
77
+ TxIrq /**< Transmit Data Register Empty */
76
78
} SerialIrq ;
77
79
78
80
typedef enum {
@@ -109,61 +111,95 @@ extern "C" {
109
111
/**
110
112
* \defgroup hal_GeneralSerial Serial Configuration Functions
111
113
*
112
- * # Defined behaviour
113
- * * ::serial_init initializes the serial peripheral
114
+ * # Defined behavior
115
+ * * ::serial_init initializes the serial peripheral.
114
116
* * ::serial_init sets the default parameters for serial peripheral
115
- * * ::serial_init configures its specified pins
116
- * * ::serial_free releases the serial peripheral
117
+ ^^^ FIXME, are the defaults given, or platform specific?
118
+ Set to 9600, 8N1? Use MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE?
119
+
120
+ * * ::serial_init configures its specified pins.
121
+ * * ::serial_free releases the serial peripheral.
117
122
* * ::serial_baud configures the baud rate
123
+ * ^^^ FIXME, are any baudrates mandatory?
124
+
118
125
* * ::serial_format configures the transmission format (number of bits, parity and the number of stop bits)
119
- * * ::serial_irq_handler registers the interrupt handler which will be invoked when the interrupt fires
120
- * * ::serial_irq_set enables or disables serial irq (RX or TX)
121
- * * ::serial_getc returns the character from serial buffer
122
- * * ::serial_getc is a blocking call (waits for the character)
123
- * * ::serial_putc sends a character
124
- * * ::serial_putc is a blocking call (waits for a peripheral to be available)
125
- * * ::serial_readable returns non-zero value if a character can be read, 0 if nothing to read
126
- * * ::serial_writable returns non-zero value if a character can be written, 0 otherwise
126
+ ^^^ FIXME, which values are mandatory?
127
+ Any other than 8N1?
128
+
129
+ * * ::serial_irq_handler registers the interrupt handler which will be invoked when the interrupt fires.
130
+ * * ::serial_irq_set enables or disables the serial RX or TX IRQ.
131
+ * * If `RxIrq` is enabled by ::serial_irq_set, ::serial_irq_handler will be invoked whenever
132
+ * Receive Data Register Full IRQ is generated.
133
+ * * If `TxIrq` is enabled by ::serial_irq_set, ::serial_irq_handler will be invoked whenever
134
+ * Transmit Data Register Empty IRQ is generated.
135
+ * * If the interrupt condition holds true, when the interrupt is enabled with ::serial_irq_set,
136
+ * the ::serial_irq_handler is called instantly.
137
+ * * ::serial_getc returns the character from serial buffer.
138
+ * * ::serial_getc is a blocking call (waits for the character).
139
+ * * ::serial_putc sends a character.
140
+ * * ::serial_putc is a blocking call (waits for a peripheral to be available).
141
+ * * ::serial_readable returns non-zero value if a character can be read, 0 otherwise.
142
+ * * ::serial_writable returns non-zero value if a character can be written, 0 otherwise.
127
143
* * ::serial_clear clears the serial peripheral
128
- * * ::serial_break_set sets the break signal
129
- * * ::serial_pinout_tx configures the TX pin for UART function
130
- * * ::serial_set_flow_control configures serial flow control
131
- * * ::serial_set_flow_control sets flow control in the hardware if a serial peripheral supports it, otherwise software emulation is used
132
- * * ::serial_tx_asynch starts the serial asynchronous transfer
133
- * * ::serial_tx_asynch writes `tx_length` bytes from the `tx` to the bus
134
- * * The callback given to ::serial_tx_asynch is invoked when the transfer completes
135
- * * ::serial_tx_asynch specifies the logical OR of events to be registered
136
- * * The ::serial_tx_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm
137
- * * ::serial_rx_asynch starts the serial asynchronous transfer
138
- * * ::serial_rx_asynch reads `rx_length` bytes to the `rx`buffer
139
- * * The callback given to ::serial_rx_asynch is invoked when the transfer completes
140
- * * ::serial_tx_asynch specifies the logical OR of events to be registered
141
- * * The ::serial_tx_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm
142
- * * ::serial_tx_asynch specifies the character in range 0-254 to be matched
143
- * * ::serial_tx_active returns non-zero if the TX transaction is ongoing, 0 otherwise
144
- * * ::serial_rx_active returns non-zero if the RX transaction is ongoing, 0 otherwise
145
- * * ::serial_irq_handler_asynch returns event flags if an RX transfer termination condition was met, otherwise returns 0
146
- * * ::serial_tx_abort_asynch aborts the ongoing TX transaction
147
- * * ::serial_tx_abort_asynch disables the enabled interupt for TX
148
- * * ::serial_tx_abort_asynch flushes the TX hardware buffer if TX FIFO is used
149
- * * ::serial_rx_abort_asynch aborts the ongoing RX transaction
150
- * * ::serial_rx_abort_asynch disables the enabled interupt for RX
151
- * * ::serial_rx_abort_asynch flushes the TX hardware buffer if RX FIFO is used
152
- *
153
- * # Undefined behaviour
154
- *
155
- * * Calling ::serial_init multiple times on the same `serial_t` without ::serial_free
156
- * * Passing invalid pin to ::serial_init, ::serial_pinout_tx
157
- * * Calling any function other than ::serial_init on a non-initialized or freed `serial_t`
158
- * * Passing an invalid pointer as `obj` to any function
159
- * * Passing an invalid pointer as `handler` to ::serial_irq_handler, ::serial_tx_asynch, ::serial_rx_asynch
160
- * * Calling ::spi_abort while no async transfer is being processed (no transfer or a synchronous transfer)
144
+ ^^^ FIXME, what does that actually mean?
145
+ Reset both RX and TX FIFOs (and shift registers)?
146
+
147
+ * * ::serial_break_set sets the break signal.
148
+ * * ::serial_break_clear clears the break signal.
149
+ * * ::serial_pinout_tx configures the TX pin as an output (to be used in half-duplex mode).
150
+ * * ::serial_set_flow_control configures serial flow control.
151
+ * * ::serial_set_flow_control sets flow control in the hardware if a serial peripheral supports it,
152
+ * otherwise software emulation is used.
153
+ * * ::serial_tx_asynch starts the serial asynchronous transfer.
154
+ * * ::serial_tx_asynch writes `tx_length` bytes from the `tx` to the bus.
155
+ * * ::serial_tx_asynch ignores the `tx_width` argument
156
+ ^^^ FIXME, is this valid; does deprecated == ignored?
157
+
158
+ * * The callback given to ::serial_tx_asynch is invoked when the transfer completes.
159
+ * * ::serial_tx_asynch specifies the logical OR of events to be registered.
160
+ * * The ::serial_tx_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm.
161
+ * * ::serial_rx_asynch starts the serial asynchronous transfer.
162
+ * * ::serial_rx_asynch reads `rx_length` bytes to the `rx` buffer.
163
+ * * ::serial_rx_asynch ignores the `rx_width` argument
164
+ ^^^ FIXME, is this valid; does deprecated == ignored?
165
+
166
+ * * The callback given to ::serial_rx_asynch is invoked when the transfer completes.
167
+ * * ::serial_rx_asynch specifies the logical OR of events to be registered.
168
+ * * The ::serial_rx_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm.
169
+ * * ::serial_rx_asynch specifies a character in range 0-254 to be matched, 255 is a reserved value.
170
+ * * If SERIAL_EVENT_RX_CHARACTER_MATCH event is not registered, the `char_match` is ignored.
171
+ * * The SERIAL_EVENT_RX_CHARACTER_MATCH event is set in the callback when SERIAL_EVENT_RX_CHARACTER_MATCH event is
172
+ * registered AND `char_match` is present in the received data.
173
+ * * ::serial_tx_active returns non-zero if the TX transaction is ongoing, 0 otherwise.
174
+ * * ::serial_rx_active returns non-zero if the RX transaction is ongoing, 0 otherwise.
175
+ * * ::serial_irq_handler_asynch returns event flags if a transfer termination condition was met, otherwise returns 0.
176
+ * * ::serial_irq_handler_asynch takes no longer than one packet transfer time (packet_bits / baudrate) to execute.
177
+ * * ::serial_tx_abort_asynch aborts the ongoing TX transaction.
178
+ * * ::serial_tx_abort_asynch disables the enabled interupt for TX.
179
+ * * ::serial_tx_abort_asynch flushes the TX hardware buffer if TX FIFO is used.
180
+ * * ::serial_rx_abort_asynch aborts the ongoing RX transaction.
181
+ * * ::serial_rx_abort_asynch disables the enabled interupt for RX.
182
+ * * ::serial_rx_abort_asynch flushes the TX hardware buffer if RX FIFO is used.
183
+ * * Correct operation guaranteed when interrupt latency is shorter than one packet transfer time (packet_bits / baudrate)
184
+ * if the flow control is not used.
185
+ * * Correct operation guaranteed regardless of interrupt latency if the flow control is used.
186
+ *
187
+ * # Undefined behavior
188
+ * * Calling ::serial_init multiple times on the same `serial_t` without ::serial_free.
189
+ * * Passing invalid pin to ::serial_init, ::serial_pinout_tx.
190
+ * * Calling any function other than ::serial_init on am uninitialized or freed `serial_t`.
191
+ * * Passing an invalid pointer as `obj` to any function.
192
+ * * Passing an invalid pointer as `handler` to ::serial_irq_handler, ::serial_tx_asynch, ::serial_rx_asynch.
193
+ * * Calling ::serial_tx_abort while no async TX transfer is being processed.
194
+ * * Calling ::serial_rx_abort while no async RX transfer is being processed.
195
+ * * Devices behavior is undefined when the interrupt latency is longer than one packet transfer time
196
+ * (packet_bits / baudrate) if the flow control is not used.
161
197
* @{
162
198
*/
163
199
164
200
/**
165
201
* \defgroup hal_GeneralSerial_tests Serial hal tests
166
- * The Serial HAL tests ensure driver conformance to defined behaviour .
202
+ * The Serial HAL tests ensure driver conformance to defined behavior .
167
203
*
168
204
* To run the Serial hal tests use the command:
169
205
*
@@ -349,7 +385,6 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
349
385
* @param rx_width Deprecated argument
350
386
* @param handler The serial handler
351
387
* @param event The logical OR of events to be registered
352
- * @param handler The serial handler
353
388
* @param char_match A character in range 0-254 to be matched
354
389
* @param hint A suggestion for how to use DMA with this transfer
355
390
*/
0 commit comments