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:
Tim Crawford
2021-07-28 07:36:42 -06:00
committed by Jeremy Soller
parent 38b2a628f9
commit 99af8a35f5
41 changed files with 169 additions and 167 deletions

View File

@@ -57,7 +57,7 @@ void i2c_reset(struct I2C * i2c, bool kill) {
*(i2c->hoctl2) = 0;
}
int i2c_start(struct I2C * i2c, uint8_t addr, bool read) __reentrant {
int16_t i2c_start(struct I2C * i2c, uint8_t addr, bool read) __reentrant {
// If we are already in a transaction
if (*(i2c->hosta) & HOSTA_BYTE_DONE) {
// If we are switching direction
@@ -94,8 +94,8 @@ void i2c_stop(struct I2C * i2c) {
i2c_reset(i2c, false);
}
static int i2c_transaction(struct I2C * i2c, uint8_t * data, int length, bool read) {
int i;
static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, int16_t length, bool read) {
int16_t i;
for (i = 0; i < length; i++) {
if (read) {
// If last byte
@@ -131,7 +131,7 @@ static int i2c_transaction(struct I2C * i2c, uint8_t * data, int length, bool re
// If error occured, kill transaction and return error
if (status & HOSTA_ERR) {
i2c_reset(i2c, true);
return -(int)(status);
return -(int16_t)(status);
} else
// If byte done, break
if (status & HOSTA_BYTE_DONE) {
@@ -141,7 +141,7 @@ static int i2c_transaction(struct I2C * i2c, uint8_t * data, int length, bool re
// If timeout occured, kill transaction and return error
if (timeout == 0) {
i2c_reset(i2c, true);
return -(0x1000 | (int)status);
return -(0x1000 | (int16_t)status);
}
if (read) {
@@ -153,10 +153,10 @@ static int i2c_transaction(struct I2C * i2c, uint8_t * data, int length, bool re
return i;
}
int i2c_read(struct I2C * i2c, uint8_t * data, int length) __reentrant {
int16_t i2c_read(struct I2C * i2c, uint8_t * data, int16_t length) __reentrant {
return i2c_transaction(i2c, data, length, true);
}
int i2c_write(struct I2C * i2c, uint8_t * data, int length) __reentrant {
int16_t i2c_write(struct I2C * i2c, uint8_t * data, int16_t length) __reentrant {
return i2c_transaction(i2c, data, length, false);
}

View File

@@ -33,8 +33,8 @@ extern struct Kbc __code KBC;
uint8_t kbc_status(struct Kbc * kbc);
uint8_t kbc_read(struct Kbc * kbc);
bool kbc_keyboard(struct Kbc * kbc, uint8_t data, int timeout);
bool kbc_mouse(struct Kbc * kbc, uint8_t data, int timeout);
bool kbc_keyboard(struct Kbc * kbc, uint8_t data, int16_t timeout);
bool kbc_mouse(struct Kbc * kbc, uint8_t data, int16_t timeout);
volatile uint8_t __xdata __at(0x1300) KBHICR;
volatile uint8_t __xdata __at(0x1302) KBIRQR;

View File

@@ -20,7 +20,7 @@ uint8_t kbc_read(struct Kbc * kbc) {
return *(kbc->data_in);
}
static bool kbc_wait(struct Kbc * kbc, int timeout) {
static bool kbc_wait(struct Kbc * kbc, int16_t timeout) {
while (*(kbc->status) & KBC_STS_OBF) {
if (timeout == 0) return false;
timeout -= 1;
@@ -29,14 +29,14 @@ static bool kbc_wait(struct Kbc * kbc, int timeout) {
return true;
}
bool kbc_keyboard(struct Kbc * kbc, uint8_t data, int timeout) {
bool kbc_keyboard(struct Kbc * kbc, uint8_t data, int16_t timeout) {
if (!kbc_wait(kbc, timeout)) return false;
*(kbc->status) &= ~0x20;
*(kbc->keyboard_out) = data;
return true;
}
bool kbc_mouse(struct Kbc * kbc, uint8_t data, int timeout) {
bool kbc_mouse(struct Kbc * kbc, uint8_t data, int16_t timeout) {
if (!kbc_wait(kbc, timeout)) return false;
*(kbc->status) |= 0x20;
*(kbc->mouse_out) = data;

View File

@@ -4,13 +4,13 @@
#if EC_ESPI
// eSPI signature (byte 7 = 0xA4)
static __code const unsigned char __at(0x40) SIGNATURE[16] = {
static __code const uint8_t __at(0x40) SIGNATURE[16] = {
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA4, 0x95,
0x85, 0x12, 0x5A, 0x5A, 0xAA, 0x00, 0x55, 0x55,
};
#else // EC_ESPI
// LPC signature (byte 7 = 0xA5)
static __code const unsigned char __at(0x40) SIGNATURE[16] = {
static __code const uint8_t __at(0x40) SIGNATURE[16] = {
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0x94,
0x85, 0x12, 0x5A, 0x5A, 0xAA, 0x00, 0x55, 0x55,
};