Use explicitly sized types from stdint
Replace bare int types with stdint types. This was done with: grep -rwl 'int' src/ | xargs sed -i 's/\<int\>/int16_t/g' grep -rwl 'unsigned long' src/ | xargs sed -i 's/\<unsigned long\>/uint32_t/g' grep -rwl 'unsigned char' src/ | xargs sed -i 's/\<unsigned char\>/uint8_t/g' Then reverted for *main(), putchar(), and getchar(). The Arduino declarations for parallel_main() were also corrected to match their definitions. SDCC does *not* generate the same code in all instances, due to `int` being treated different than `short int`. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
38b2a628f9
commit
99af8a35f5
@ -10,7 +10,7 @@
|
||||
|
||||
#define TIMEOUT (F_CPU/1000)
|
||||
|
||||
int i2c_start(struct I2C * i2c, uint8_t addr, bool read) {
|
||||
int16_t i2c_start(struct I2C * i2c, uint8_t addr, bool read) {
|
||||
uint32_t count;
|
||||
|
||||
// reset TWI control register
|
||||
@ -46,8 +46,8 @@ void i2c_stop(struct I2C * i2c) {
|
||||
TWCR = BIT(TWINT) | BIT(TWEN) | BIT(TWSTO);
|
||||
}
|
||||
|
||||
int i2c_write(struct I2C * i2c, uint8_t * data, int length) {
|
||||
int i;
|
||||
int16_t i2c_write(struct I2C * i2c, uint8_t * data, int16_t length) {
|
||||
int16_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
// load data into data register
|
||||
TWDR = data[i];
|
||||
@ -65,8 +65,8 @@ int i2c_write(struct I2C * i2c, uint8_t * data, int length) {
|
||||
return i;
|
||||
}
|
||||
|
||||
int i2c_read(struct I2C * i2c, uint8_t * data, int length) {
|
||||
int i;
|
||||
int16_t i2c_read(struct I2C * i2c, uint8_t * data, int16_t length) {
|
||||
int16_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
if ((i + 1) < length) {
|
||||
// start TWI module and acknowledge data after reception
|
||||
|
Reference in New Issue
Block a user