No bugs identified.
Signed-off-by: Keith Packard <keithp@keithp.com>
ao_spi_recv(ao_m25_instruction, 1, AO_M25_SPI_BUS);
} while (ao_m25_instruction[0] & M25_STATUS_WIP);
M25_DESELECT(cs);
- ao_m25_wip &= ~cs;
+ ao_m25_wip &= (ao_port_t) ~cs;
}
}
#endif
ao_m25_wait_wip(mask);
- ao_m25_instruction[1] = pos >> 16;
- ao_m25_instruction[2] = pos >> 8;
- ao_m25_instruction[3] = pos;
+ ao_m25_instruction[1] = (uint8_t) (pos >> 16);
+ ao_m25_instruction[2] = (uint8_t) (pos >> 8);
+ ao_m25_instruction[3] = (uint8_t) (pos);
return mask;
}
{
uint8_t d[2];
ao_mma655x_start();
- d[0] = addr | (ao_parity(addr) << 7);
+ d[0] = (uint8_t) (addr | (ao_parity(addr) << 7));
d[1] = 0;
ao_spi_send(&d, 2, AO_MMA655X_SPI_INDEX);
ao_mma655x_restart();
PRINTD(DEBUG_LOW, "write %x %x\n", addr, value);
addr |= (1 << 6); /* write mode */
- d[0] = addr | (ao_parity(addr^value) << 7);
+ d[0] = (uint8_t) (addr | (ao_parity(addr^value) << 7));
d[1] = value;
ao_mma655x_start();
ao_spi_send(d, 2, AO_MMA655X_SPI_INDEX);
ao_mma655x_stop();
-
- addr &= ~(1 << 6);
}
static uint16_t
PRINTD(DEBUG_LOW, "value RECV %02x %02x\n", d[0], d[1]);
v = (uint16_t) d[1] << 2;
- v |= d[0] >> 6;
- v |= (uint16_t) (d[0] & 3) << 10;
+ v = (uint16_t) (v | (d[0] >> 6));
+ v = (uint16_t) (v | ((d[0] & 3) << 10));
return v;
}
a = ao_mma655x_value();
- st_change = a_st - a;
+ st_change = (int16_t) (a_st - a);
PRINTD(DEBUG_HIGH, "self test %d normal %d change %d\n", a_st, a, st_change);
v = -32768;
if (v > 32767)
v = 32767;
- return v;
+ return (int16_t) v;
}
/* Wait for a synchronous sample to finish */
ao_mmc5983_raw(&raw);
/* Bias by 32768 to convert from uint16_t to int16_t */
- s->x = (int32_t) (((uint16_t) raw.x0 << 8) | raw.x1) - 32768;
- s->y = (int32_t) (((uint16_t) raw.y0 << 8) | raw.y1) - 32768;
- s->z = (int32_t) (((uint16_t) raw.z0 << 8) | raw.z1) - 32768;;
+ s->x = (int16_t) ((((uint16_t) raw.x0 << 8) | raw.x1) - 32768);
+ s->y = (int16_t) ((((uint16_t) raw.y0 << 8) | raw.y1) - 32768);
+ s->z = (int16_t) ((((uint16_t) raw.z0 << 8) | raw.z1) - 32768);
}
/* Synchronously sample the sensors */
ao_mmc5983_sync_sample(&reset);
/* The zero point is the average of SET and RESET values */
- ao_mmc5983_offset.x = ((int32_t) set.x + (int32_t) reset.x) / 2;
- ao_mmc5983_offset.y = ((int32_t) set.y + (int32_t) reset.y) / 2;
- ao_mmc5983_offset.z = ((int32_t) set.z + (int32_t) reset.z) / 2;
+ ao_mmc5983_offset.x = (int16_t) (((int32_t) set.x + (int32_t) reset.x) / 2);
+ ao_mmc5983_offset.y = (int16_t) (((int32_t) set.y + (int32_t) reset.y) / 2);
+ ao_mmc5983_offset.z = (int16_t) (((int32_t) set.z + (int32_t) reset.z) / 2);
}
/* Configure the device to automatically sample at 200Hz */
/* byte swap */
while (i--) {
uint16_t t = *d;
- *d++ = (t >> 8) | (t << 8);
+ *d++ = (uint16_t) ((t >> 8) | (t << 8));
}
#endif
}
/* byte swap */
while (i--) {
uint16_t t = *d;
- *d++ = (t >> 8) | (t << 8);
+ *d++ = (uint16_t) ((uint16_t) (t >> 8) | (uint16_t) (t << 8));
}
#endif
}
prom[15] = 0;
for (cnt = 0; cnt < 16; cnt++) {
- n_rem ^= *p++;
+ n_rem ^= (uint16_t) *p++;
for (n_bit = 8; n_bit > 0; n_bit--) {
if (n_rem & 0x8000)
- n_rem = (n_rem << 1) ^ 0x3000;
+ n_rem = (uint16_t) ((n_rem << 1) ^ 0x3000U);
else
n_rem = (n_rem << 1);
}
}
n_rem = (n_rem >> 12) & 0xf;
prom[15] = crc_byte;
- return n_rem;
+ return (uint8_t) n_rem;
}
static bool
#define AO_MS5607_CONVERT_D2_4096 0x58
#define AO_MS5607_ADC_READ 0x00
-#define AO_MS5607_PROM_READ(ad) (0xA0 | ((ad) << 1))
+#define AO_MS5607_PROM_READ(ad) (0xA0U | (uint8_t) ((ad) << 1))
struct ao_ms5607_prom {
uint16_t reserved;
int64_t OFF;
int64_t SENS;
- dT = sample->temp - ((int32_t) ao_ms5607_prom.tref << 8);
+ dT = (int32_t) ((int32_t) sample->temp - ((int32_t) ao_ms5607_prom.tref << 8));
- TEMP = 2000 + (((int64_t) dT * ao_ms5607_prom.tempsens) >> 23);
+ TEMP = (int32_t) (2000 + (((int64_t) dT * ao_ms5607_prom.tempsens) >> 23));
#if HAS_MS5611
OFF = ((int64_t) ao_ms5607_prom.off << 16) + (((int64_t) ao_ms5607_prom.tco * dT) >> 7);
#endif
if (TEMP < 2000) {
- int32_t T2 = ((int64_t) dT * (int64_t) dT) >> 31;
+ int32_t T2 = (int32_t) (((int64_t) dT * (int64_t) dT) >> 31);
int32_t TEMPM = TEMP - 2000;
int64_t OFF2 = (61 * (int64_t) TEMPM * (int64_t) TEMPM) >> 4;
int64_t SENS2 = 2 * (int64_t) TEMPM * (int64_t) TEMPM;
SENS -= SENS2;
}
- value->pres = ((((int64_t) sample->pres * SENS) >> 21) - OFF) >> 15;
+ value->pres = (int32_t) (((((int64_t) sample->pres * SENS) >> 21) - OFF) >> 15);
value->temp = TEMP;
}