python/CMakeLists.txt: rework Python development files detection
[libftdi] / src / ftdi.c
index 6b78fa3..de07d6e 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
@@ -2900,8 +2918,12 @@ static unsigned char type2bit(unsigned char type, enum ftdi_chip_type chip)
             }
         }
         case TYPE_230X: /* FT230X is only UART */
+        case TYPE_AM:
+        case TYPE_BM:
+        case TYPE_4232H:
         default: return 0;
     }
+    /* fallback */
     return 0;
 }
 
@@ -3499,7 +3521,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
             i = 0x40;
         }
         if ((ftdi->type == TYPE_230X) && (i >=  0x40) && (i < 0x50)) {
-            uint16_t data;
+            uint16_t data = 0;
             if (ftdi_read_eeprom_location(ftdi, i, &data)) {
                 fprintf(stderr, "Reading Factory Configuration Data failed\n");
                 i = 0x50;
@@ -4607,7 +4629,7 @@ int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr,
     switch (ftdi->type)
     {
         case TYPE_BM:
-        case  TYPE_2232C:
+        case TYPE_2232C:
             chip_type_location = 0x14;
             break;
         case TYPE_2232H:
@@ -4617,6 +4639,9 @@ int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr,
         case TYPE_232H:
             chip_type_location = 0x1e;
             break;
+        case TYPE_AM:
+        case TYPE_R:
+        case TYPE_230X:
         default:
             ftdi_error_return(-4, "Device can't access unprotected area");
     }