Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_HAL_ESP32: add control options to UART driver #28721

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
AP_HAL_ESP32: UARTDriver: add placeholder for flow and half-duplex co…
…ntrol

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
  • Loading branch information
srmainwaring committed Nov 24, 2024
commit 2368f42ef9072762c3c8da55db020c3c9348073a
57 changes: 57 additions & 0 deletions libraries/AP_HAL_ESP32/UARTDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,31 @@ class ESP32::UARTDriver : public AP_HAL::UARTDriver
// }
// };
//bool lock_port(uint32_t write_key, uint32_t read_key) override;

//! @todo enable wait_timeout override
#if 0
bool wait_timeout(uint16_t n, uint32_t timeout_ms) override;
#endif

//! @todo enable flow control
#if 0
void set_flow_control(enum flow_control flow_control) override;
enum flow_control get_flow_control(void) override { return _flow_control; }
#endif

//! @todo enable parity and stop bits
#if 0
void configure_parity(uint8_t v) override;
void set_stop_bits(int n) override;

/*
software control of the CTS/RTS pins if available. Return false if
not available
*/
bool set_RTS_pin(bool high) override;
bool set_CTS_pin(bool high) override;
#endif

/*
return timestamp estimate in microseconds for when the start of
a nbytes packet arrived on the uart. This should be treated as a
Expand Down Expand Up @@ -122,6 +147,38 @@ class ESP32::UARTDriver : public AP_HAL::UARTDriver
uint64_t _receive_timestamp[2];
uint8_t _receive_timestamp_idx;

//! @todo enable flow control
#if 0
// handling of flow control
enum flow_control _flow_control = FLOW_CONTROL_DISABLE;
bool _rts_is_active;
uint32_t _last_write_completed_us;
uint32_t _first_write_started_us;
uint32_t _total_written;

// statistics
uint32_t _tx_stats_bytes;
uint32_t _rx_stats_bytes;

// we remember config options from set_options to apply on sdStart()
uint32_t _cr1_options;
uint32_t _cr2_options;
uint32_t _cr3_options;
#endif
uint16_t _last_options;

//! @todo enable half-duplex control
#if 0
// half duplex control. After writing we throw away bytes for 4 byte widths to
// prevent reading our own bytes back
#if CH_CFG_USE_EVENTS == TRUE
bool half_duplex;
event_listener_t hd_listener;
eventflags_t hd_tx_active;
void half_duplex_setup_tx(void);
#endif
#endif

void _receive_timestamp_update(void);

protected:
Expand Down