From 4de44fefc63f112f5c804c191da101cd8252978f Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Wed, 3 May 2023 08:52:01 -0500 Subject: [PATCH] Introduce ftdi_set_module_detach_mode() Added a public setter to allow the usage of the AUTO_DETACH_REATACH_SIO_MODULE feature added in 5bf1c1e3ff1616fda20c26cc3e3df7b807744c99. --- src/ftdi.c | 18 ++++++++++++++++++ src/ftdi.h | 1 + 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/ftdi.c b/src/ftdi.c index 6b78fa3..534e3dd 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2218,6 +2218,24 @@ int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned } /** + Set module detach mode. + + \param ftdi pointer to ftdi_context + \param mode detach mode to use. + + \retval 0: all fine + \retval -1: can't enable bitbang mode +*/ +int ftdi_set_module_detach_mode(struct ftdi_context *ftdi, enum ftdi_module_detach_mode mode) +{ + if (ftdi == NULL) + ftdi_error_return(-1, "FTDI context invalid"); + + ftdi->module_detach_mode = mode; + return 0; +} + +/** Disable bitbang mode. \param ftdi pointer to ftdi_context diff --git a/src/ftdi.h b/src/ftdi.h index 0603335..ffeb452 100644 --- a/src/ftdi.h +++ b/src/ftdi.h @@ -520,6 +520,7 @@ extern "C" int ftdi_init(struct ftdi_context *ftdi); struct ftdi_context *ftdi_new(void); int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface); + int ftdi_set_module_detach_mode(struct ftdi_context *ftdi, enum ftdi_module_detach_mode mode); void ftdi_deinit(struct ftdi_context *ftdi); void ftdi_free(struct ftdi_context *ftdi); -- 1.7.1