mirror of https://github.com/ARMmbed/mbed-os.git
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().pull/24/head
parent
461a3dd0d2
commit
692e666ced
|
@ -215,7 +215,7 @@ void i2c_frequency(i2c_t *obj, int hz) {
|
||||||
for (i = 1; i < 5; i*=2) {
|
for (i = 1; i < 5; i*=2) {
|
||||||
for (j = 0; j < 0x40; j++) {
|
for (j = 0; j < 0x40; j++) {
|
||||||
ref = PCLK / (i*ICR[j]);
|
ref = PCLK / (i*ICR[j]);
|
||||||
if (ref > hz)
|
if (ref > (uint32_t)hz)
|
||||||
continue;
|
continue;
|
||||||
error = hz - ref;
|
error = hz - ref;
|
||||||
if (error < p_error) {
|
if (error < p_error) {
|
||||||
|
@ -392,7 +392,7 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_slave_write(i2c_t *obj, const char *data, int length) {
|
int i2c_slave_write(i2c_t *obj, const char *data, int length) {
|
||||||
uint32_t i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
// set tx mode
|
// set tx mode
|
||||||
obj->i2c->C1 |= I2C_C1_TX_MASK;
|
obj->i2c->C1 |= I2C_C1_TX_MASK;
|
||||||
|
|
|
@ -153,7 +153,7 @@ void spi_frequency(spi_t *obj, int hz) {
|
||||||
divisor = 2;
|
divisor = 2;
|
||||||
for (spr = 0; spr <= 8; spr++, divisor *= 2) {
|
for (spr = 0; spr <= 8; spr++, divisor *= 2) {
|
||||||
ref = PCLK / (prescaler*divisor);
|
ref = PCLK / (prescaler*divisor);
|
||||||
if (ref > hz)
|
if (ref > (uint32_t)hz)
|
||||||
continue;
|
continue;
|
||||||
error = hz - ref;
|
error = hz - ref;
|
||||||
if (error < p_error) {
|
if (error < p_error) {
|
||||||
|
|
Loading…
Reference in New Issue