Introduce ftdi_set_module_detach_mode()
authorChris Johnson <chris.a.johnson@garmin.com>
Wed, 3 May 2023 13:52:01 +0000 (08:52 -0500)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 29 Aug 2023 14:39:48 +0000 (16:39 +0200)
Added a public setter to allow the usage of the
AUTO_DETACH_REATACH_SIO_MODULE feature added in
5bf1c1e3ff1616fda20c26cc3e3df7b807744c99.

src/ftdi.c
src/ftdi.h

index 6b78fa3..534e3dd 100644 (file)
@@ -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
index 0603335..ffeb452 100644 (file)
@@ -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);