Fixed it

I misinterpeted the documentation of the MAX7311.
Code: Select all
void init_max7311(void)
{
#define RXBYTES 0
#define TXBYTES 3
max7311_tx_data[0] = 0x06; /* Port 1 configuration */
max7311_tx_data[1] = 0xFF; /* Set IO00-IO07 as input */
max7311_tx_data[2] = 0x00; /* Set IO08-IO15 as output */
/* transmit out 3 bytes */
i2cAcquireBus(&I2CD1);
i2cMasterTransmit(&I2CD1, &max7311, max7311_addr, max7311_tx_data, TXBYTES, max7311_rx_data, RXBYTES);
while (I2CD1.id_state != I2C_READY)
{
chThdSleepMilliseconds(1);
}
i2cReleaseBus(&I2CD1);
max7311_tx_data[0] = 0x02; /* Output port 1 */
max7311_tx_data[1] = 0x00; /* Set IO00-IO07 low / dont care */
max7311_tx_data[2] = 0x00; /* Set IO08-IO15 high */
/* transmit out 3 bytes */
i2cAcquireBus(&I2CD1);
i2cMasterTransmit(&I2CD1, &max7311, max7311_addr, max7311_tx_data, TXBYTES, max7311_rx_data, RXBYTES);
while (I2CD1.id_state != I2C_READY)
{
chThdSleepMilliseconds(1);
}
i2cReleaseBus(&I2CD1);
#undef RXBYTES
#undef TXBYTES
}
Did the trick. The registers needed to be written one by one, each with the address header byte. The status outputs are also inverted, therefore a 0x00 is needed on the IO08-IO15 to turn them high.