Skip to content

Commit 5ec4071

Browse files
Some doc issues (#1772)
* Fix doxygen for uart example Fixes #1685 * Clarify uart write will block until data "has been sent to the UART transmit buffer" Fixes #1481 * Add note to flash API about erasing sectors Fixes: #650
1 parent 6328fff commit 5ec4071

File tree

2 files changed

+16
-7
lines changed
  • src/rp2_common
    • hardware_flash/include/hardware
    • hardware_uart/include/hardware

2 files changed

+16
-7
lines changed

src/rp2_common/hardware_flash/include/hardware/flash.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ extern "C" {
5656
*
5757
* \param flash_offs Offset into flash, in bytes, to start the erase. Must be aligned to a 4096-byte flash sector.
5858
* \param count Number of bytes to be erased. Must be a multiple of 4096 bytes (one sector).
59+
*
60+
* @note Erasing a flash sector sets all the bits in all the pages in that sector to one.
61+
* You can then "program" flash pages in the sector to turn some of the bits to zero.
62+
* Once a bit is set to zero it can only be changed back to one by erasing the whole sector again.
5963
*/
6064
void flash_range_erase(uint32_t flash_offs, size_t count);
6165

@@ -65,6 +69,10 @@ void flash_range_erase(uint32_t flash_offs, size_t count);
6569
* \param flash_offs Flash address of the first byte to be programmed. Must be aligned to a 256-byte flash page.
6670
* \param data Pointer to the data to program into flash
6771
* \param count Number of bytes to program. Must be a multiple of 256 bytes (one page).
72+
*
73+
* @note: Programming a flash page effectively changes some of the bits from one to zero.
74+
* The only way to change a zero bit back to one is to "erase" the whole sector that the page resides in.
75+
* So you may need to make sure you have called flash_range_erase before calling flash_range_program.
6876
*/
6977

7078
void flash_range_program(uint32_t flash_offs, const uint8_t *data, size_t count);

src/rp2_common/hardware_uart/include/hardware/uart.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ extern "C" {
5656
* \code
5757
* int main() {
5858
*
59-
* // Initialise UART 0
60-
* uart_init(uart0, 115200);
61-
*
6259
* // Set the GPIO pin mux to the UART - 0 is TX, 1 is RX
60+
* // Do this before calling uart_init to avoid losing data
6361
* gpio_set_function(0, GPIO_FUNC_UART);
6462
* gpio_set_function(1, GPIO_FUNC_UART);
6563
*
64+
* // Initialise UART 0
65+
* uart_init(uart0, 115200);
66+
*
6667
* uart_puts(uart0, "Hello world!");
6768
* }
6869
* \endcode
@@ -310,7 +311,7 @@ static inline bool uart_is_readable(uart_inst_t *uart) {
310311
/*! \brief Write to the UART for transmission.
311312
* \ingroup hardware_uart
312313
*
313-
* This function will block until all the data has been sent to the UART
314+
* This function will block until all the data has been sent to the UART transmit buffer
314315
*
315316
* \param uart UART instance. \ref uart0 or \ref uart1
316317
* \param src The bytes to send
@@ -347,7 +348,7 @@ static inline void uart_read_blocking(uart_inst_t *uart, uint8_t *dst, size_t le
347348
/*! \brief Write single character to UART for transmission.
348349
* \ingroup hardware_uart
349350
*
350-
* This function will block until the entire character has been sent
351+
* This function will block until the entire character has been sent to the UART transmit buffer
351352
*
352353
* \param uart UART instance. \ref uart0 or \ref uart1
353354
* \param c The character to send
@@ -359,7 +360,7 @@ static inline void uart_putc_raw(uart_inst_t *uart, char c) {
359360
/*! \brief Write single character to UART for transmission, with optional CR/LF conversions
360361
* \ingroup hardware_uart
361362
*
362-
* This function will block until the character has been sent
363+
* This function will block until the character has been sent to the UART transmit buffer
363364
*
364365
* \param uart UART instance. \ref uart0 or \ref uart1
365366
* \param c The character to send
@@ -376,7 +377,7 @@ static inline void uart_putc(uart_inst_t *uart, char c) {
376377
/*! \brief Write string to UART for transmission, doing any CR/LF conversions
377378
* \ingroup hardware_uart
378379
*
379-
* This function will block until the entire string has been sent
380+
* This function will block until the entire string has been sent to the UART transmit buffer
380381
*
381382
* \param uart UART instance. \ref uart0 or \ref uart1
382383
* \param s The null terminated string to send

0 commit comments

Comments
 (0)