Skip to content

Commit 692e666

Browse files
committed
Silence signed/unsigned comparison warnings in GCC.
i2c_frequency() compares a uint32_t ref variable to the int hz function parameter passed in by the caller. I forced this to be an uint32_t comparison. i2c_slave_write() declared i and count variables to be of type uint32_t but used them as int type throughout the code (in comparisons and returns) so I switched them to be of signed int type. spi_frequency() contains a change similar to that made in i2c_frequency().
1 parent 461a3dd commit 692e666

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/i2c_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void i2c_frequency(i2c_t *obj, int hz) {
215215
for (i = 1; i < 5; i*=2) {
216216
for (j = 0; j < 0x40; j++) {
217217
ref = PCLK / (i*ICR[j]);
218-
if (ref > hz)
218+
if (ref > (uint32_t)hz)
219219
continue;
220220
error = hz - ref;
221221
if (error < p_error) {
@@ -392,7 +392,7 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) {
392392
}
393393

394394
int i2c_slave_write(i2c_t *obj, const char *data, int length) {
395-
uint32_t i, count = 0;
395+
int i, count = 0;
396396

397397
// set tx mode
398398
obj->i2c->C1 |= I2C_C1_TX_MASK;

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL25Z/spi_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void spi_frequency(spi_t *obj, int hz) {
153153
divisor = 2;
154154
for (spr = 0; spr <= 8; spr++, divisor *= 2) {
155155
ref = PCLK / (prescaler*divisor);
156-
if (ref > hz)
156+
if (ref > (uint32_t)hz)
157157
continue;
158158
error = hz - ref;
159159
if (error < p_error) {

0 commit comments

Comments
 (0)