andy25
Occasional Contributor
2 years agoNios V i2c ALT_AVALON_I2C_STATUS_CODE
altera_avalon_i2c.h defines:
typedef alt_u32 ALT_AVALON_I2C_STATUS_CODE;
Which is an unsigned type, which is a problem because the errors are all negative.
This compiles with a warning:
ALT_AVALON_I2C_STATUS_CODE status = alt_avalon_i2c_master_tx( i2c_dev, txbuffer, 2, ALT_AVALON_I2C_NO_INTERRUPTS ); if (status == ALT_AVALON_I2C_ERROR) { uart.println("error"); }
main.cpp:221:15: warning: comparison of integer expressions of different signedness: 'ALT_AVALON_I2C_STATUS_CODE' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 221 | if (status == ALT_AVALON_I2C_ERROR) {
And a switch(status) errors:
freertos_bsp/drivers/inc/altera_avalon_i2c.h:102:33: error: narrowing conversion of '-1' from 'int' to 'long unsigned int' [-Wnarrowing] 102 | #define ALT_AVALON_I2C_ERROR (-1)
Please change ALT_AVALON_I2C_STATUS_CODE to a signed type.
-Andy