devttys0 / libmpsse

Open source library for SPI/I2C control via FTDI chips
256 stars 172 forks source link

Input pins are set to output type, buggy and/or dangerous if using inputs #23

Open tranzistoren opened 7 years ago

tranzistoren commented 7 years ago

In mpsse.c, lines 274-275:

        /* Clock, data out, chip select pins are outputs; all others are inputs. */
        mpsse->tris = DEFAULT_TRIS;

in mpsse.h, line 114:

'#define DEFAULT_TRIS            (SK | DO | CS | GPIO0 | GPIO1 | GPIO2 | GPIO3)  /* SK/DO/CS and GPIOs are outputs, DI is an input */

Pins that should be set as inputs are set as outputs. Quick fix:

#define DEFAULT_TRIS            (SK | DO | CS)  /* SK/DO/CS are outputs, others are inputs */
dukelec commented 7 years ago

Set all gpio default as input, and allow set direction for low port later: https://github.com/dukelec/libmpsse