No bugs spotted here, but this quiets -Wconversion warnings
Signed-off-by: Keith Packard <keithp@keithp.com>
for (bit = 0; bit < 8; ++bit)
{
for (bit = 0; bit < 8; ++bit)
{
+ crc = (uint16_t) (crc ^ (value & 0x01));
crc = ( crc & 0x01 ) ? ( crc >> 1 ) ^ 0x8408 : ( crc >> 1 );
value = value >> 1;
} // END for
crc = ( crc & 0x01 ) ? ( crc >> 1 ) ^ 0x8408 : ( crc >> 1 );
value = value >> 1;
} // END for
TNC_AX25_HEADER[TNC_CALLSIGN_OFF + i] = ' ' << 1;
/* Fill in the SSID with the low digit of the serial number */
TNC_AX25_HEADER[TNC_CALLSIGN_OFF + i] = ' ' << 1;
/* Fill in the SSID with the low digit of the serial number */
- TNC_AX25_HEADER[TNC_SSID_OFF] = 0x60 | ((ao_config.aprs_ssid & 0xf) << 1);
+ TNC_AX25_HEADER[TNC_SSID_OFF] = (uint8_t) (0x60 | ((ao_config.aprs_ssid & 0xf) << 1));
static void tncCompressInt(uint8_t *dest, int32_t value, int len) {
int i;
for (i = len - 1; i >= 0; i--) {
static void tncCompressInt(uint8_t *dest, int32_t value, int len) {
int i;
for (i = len - 1; i >= 0; i--) {
- dest[i] = value % 91 + 33;
+ dest[i] = (uint8_t) (value % 91 + 33);
static inline uint32_t
fixed30_mul(uint32_t x, uint32_t y)
{
static inline uint32_t
fixed30_mul(uint32_t x, uint32_t y)
{
- return ((uint64_t) x * y + fixed30_half) >> 30;
+ return (uint32_t) (((uint64_t) x * y + fixed30_half) >> 30);
-ao_fixed_log2(uint32_t x)
+ao_fixed_log2(int32_t ix)
{
uint32_t result;
uint32_t frac = fixed23_one;
{
uint32_t result;
uint32_t frac = fixed23_one;
/* Bounds check for sanity */
/* Bounds check for sanity */
if (x >= fixed30_one)
return 0xffffffff;
if (x >= fixed30_one)
return 0xffffffff;
#define APRS_LOG_CONVERT fixed23_real(1.714065192056127)
#define APRS_LOG_BASE fixed23_real(346.920048461100941)
#define APRS_LOG_CONVERT fixed23_real(1.714065192056127)
#define APRS_LOG_BASE fixed23_real(346.920048461100941)
ao_aprs_encode_altitude(int meters)
{
ao_aprs_encode_altitude(int meters)
{
- return fixed23_floor(fixed23_mul(ao_fixed_log2(meters) + APRS_LOG_CONVERT, APRS_LOG_BASE) + fixed23_half);
+ return (int32_t) fixed23_floor(fixed23_mul(ao_fixed_log2(meters) + APRS_LOG_CONVERT, APRS_LOG_BASE) + fixed23_half);
}
/**
* Generate the plain text position packet.
*/
}
/**
* Generate the plain text position packet.
*/
-static int tncPositionPacket(void)
+static uint8_t tncPositionPacket(void)
{
static int32_t latitude;
static int32_t longitude;
{
static int32_t latitude;
static int32_t longitude;
/* Symbol table ID */
*buf++ = '/';
/* Symbol table ID */
*buf++ = '/';
- lat = ((uint64_t) 380926 * (900000000 - latitude)) / 10000000;
- lon = ((uint64_t) 190463 * (1800000000 + longitude)) / 10000000;
+ lat = (int32_t) (((int64_t) 380926 * (900000000 - latitude)) / 10000000);
+ lon = (int32_t) (((int64_t) 190463 * (1800000000 + longitude)) / 10000000);
alt = ao_aprs_encode_altitude(altitude);
alt = ao_aprs_encode_altitude(altitude);
if (lon > 1800000000)
lon = 1800000000;
if (lon > 1800000000)
lon = 1800000000;
- lat_deg = lat / 10000000;
+ lat_deg = (uint16_t) (lat / 10000000);
lat -= lat_deg * 10000000;
lat *= 60;
lat -= lat_deg * 10000000;
lat *= 60;
- lat_min = lat / 10000000;
+ lat_min = (uint16_t) (lat / 10000000);
lat -= lat_min * 10000000;
lat -= lat_min * 10000000;
- lat_frac = lat / 100000;
+ lat_frac = (uint16_t) (lat / 100000);
- lon_deg = lon / 10000000;
+ lon_deg = (uint16_t) (lon / 10000000);
lon -= lon_deg * 10000000;
lon *= 60;
lon -= lon_deg * 10000000;
lon *= 60;
- lon_min = lon / 10000000;
+ lon_min = (uint16_t) (lon / 10000000);
lon -= lon_min * 10000000;
lon -= lon_min * 10000000;
- lon_frac = lon / 100000;
+ lon_frac = (uint16_t) (lon / 100000);
/* Convert from meters to feet */
alt = (alt * 328 + 50) / 100;
/* Convert from meters to feet */
alt = (alt * 328 + 50) / 100;
- return buf - tncBuffer;
+ return (uint8_t) (buf - tncBuffer);
while (tncMode != TNC_TX_READY && l < len) {
b = 0;
for (bit = 0; bit < 8; bit++) {
while (tncMode != TNC_TX_READY && l < len) {
b = 0;
for (bit = 0; bit < 8; bit++) {
- b = b << 1 | (timeNCO >> 15);
+ b = (uint8_t) (b << 1 | (timeNCO >> 15));
timeNCO += timeNCOFreq;
}
*buf++ = b;
timeNCO += timeNCOFreq;
}
*buf++ = b;
crc = sysCRC16(tncBuffer, tncLength, crc ^ 0xffff);
// Save the CRC in the message.
crc = sysCRC16(tncBuffer, tncLength, crc ^ 0xffff);
// Save the CRC in the message.
- tncBuffer[tncLength++] = crc & 0xff;
- tncBuffer[tncLength++] = (crc >> 8) & 0xff;
+ tncBuffer[tncLength++] = (uint8_t) (crc & 0xff);
+ tncBuffer[tncLength++] = (uint8_t) ((crc >> 8) & 0xff);
// Prepare the variables that are used in the real-time clock interrupt.
tncBitCount = 0;
// Prepare the variables that are used in the real-time clock interrupt.
tncBitCount = 0;
uint8_t lo = _ao_bmm150_reg_read(lo_addr);
uint8_t hi = _ao_bmm150_reg_read(hi_addr);
uint8_t lo = _ao_bmm150_reg_read(lo_addr);
uint8_t hi = _ao_bmm150_reg_read(hi_addr);
- return ((uint16_t) hi << 8) | lo;
+ return (uint16_t) (((uint16_t) hi << 8) | (uint16_t) lo);
//printf("comp_x10 %d\n", process_comp_x10);
retval = ((int16_t)(process_comp_x10 / 8192));
//printf("ret 1 %d\n", retval);
//printf("comp_x10 %d\n", process_comp_x10);
retval = ((int16_t)(process_comp_x10 / 8192));
//printf("ret 1 %d\n", retval);
- retval = (retval + (((int16_t)ao_bmm150_trim.dig_x1) * 8)) / 16;
+ retval = (int16_t) ((retval + (((int16_t)ao_bmm150_trim.dig_x1) * 8)) / 16);
//printf("final %d\n", retval);
}
else
//printf("final %d\n", retval);
}
else
process_comp_y8 = (((process_comp_y6 + ((int32_t)0x100000)) * process_comp_y7) / 4096);
process_comp_y9 = (((int32_t)mag_data_y) * process_comp_y8);
retval = (int16_t)(process_comp_y9 / 8192);
process_comp_y8 = (((process_comp_y6 + ((int32_t)0x100000)) * process_comp_y7) / 4096);
process_comp_y9 = (((int32_t)mag_data_y) * process_comp_y8);
retval = (int16_t)(process_comp_y9 / 8192);
- retval = (retval + (((int16_t)ao_bmm150_trim.dig_y1) * 8)) / 16;
+ retval = (int16_t) ((retval + (((int16_t)ao_bmm150_trim.dig_y1) * 8)) / 16);
BMX160_ACC_RANGE_16G);
for (r = 0x3; r <= 0x1b; r++)
BMX160_ACC_RANGE_16G);
for (r = 0x3; r <= 0x1b; r++)
- (void) _ao_bmx160_reg_read(r);
+ (void) _ao_bmx160_reg_read((uint8_t) r);
_ao_bmm150_reg_write(BMM150_REPZ, BMM150_REPZ_VALUE(15));
/* Read Trim values */
_ao_bmm150_reg_write(BMM150_REPZ, BMM150_REPZ_VALUE(15));
/* Read Trim values */
- ao_bmm150_trim.dig_x1 = _ao_bmm150_reg_read(BMM150_DIG_X1);
- ao_bmm150_trim.dig_y1 = _ao_bmm150_reg_read(BMM150_DIG_Y1);
- ao_bmm150_trim.dig_z4 = _ao_bmm150_reg_read2(BMM150_DIG_Z4_LSB, BMM150_DIG_Z4_MSB);
- ao_bmm150_trim.dig_x2 = _ao_bmm150_reg_read(BMM150_DIG_X2);
- ao_bmm150_trim.dig_y2 = _ao_bmm150_reg_read(BMM150_DIG_Y2);
- ao_bmm150_trim.dig_z2 = _ao_bmm150_reg_read2(BMM150_DIG_Z2_LSB, BMM150_DIG_Z2_MSB);
+ ao_bmm150_trim.dig_x1 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_X1);
+ ao_bmm150_trim.dig_y1 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_Y1);
+ ao_bmm150_trim.dig_z4 = (int8_t) _ao_bmm150_reg_read2(BMM150_DIG_Z4_LSB, BMM150_DIG_Z4_MSB);
+ ao_bmm150_trim.dig_x2 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_X2);
+ ao_bmm150_trim.dig_y2 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_Y2);
+ ao_bmm150_trim.dig_z2 = (int8_t) _ao_bmm150_reg_read2(BMM150_DIG_Z2_LSB, BMM150_DIG_Z2_MSB);
ao_bmm150_trim.dig_z1 = _ao_bmm150_reg_read2(BMM150_DIG_Z1_LSB, BMM150_DIG_Z1_MSB);
ao_bmm150_trim.dig_xyz1 = _ao_bmm150_reg_read2(BMM150_DIG_XYZ1_LSB, BMM150_DIG_XYZ1_MSB);
ao_bmm150_trim.dig_z1 = _ao_bmm150_reg_read2(BMM150_DIG_Z1_LSB, BMM150_DIG_Z1_MSB);
ao_bmm150_trim.dig_xyz1 = _ao_bmm150_reg_read2(BMM150_DIG_XYZ1_LSB, BMM150_DIG_XYZ1_MSB);
- ao_bmm150_trim.dig_z3 = _ao_bmm150_reg_read2(BMM150_DIG_Z3_LSB, BMM150_DIG_Z3_MSB);
- ao_bmm150_trim.dig_xy2 = _ao_bmm150_reg_read(BMM150_DIG_XY2);
+ ao_bmm150_trim.dig_z3 = (int8_t) _ao_bmm150_reg_read2(BMM150_DIG_Z3_LSB, BMM150_DIG_Z3_MSB);
+ ao_bmm150_trim.dig_xy2 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_XY2);
ao_bmm150_trim.dig_xy1 = _ao_bmm150_reg_read(BMM150_DIG_XY1);
/* To get data out of the magnetometer, set the control op mode to 'forced', then read
ao_bmm150_trim.dig_xy1 = _ao_bmm150_reg_read(BMM150_DIG_XY1);
/* To get data out of the magnetometer, set the control op mode to 'forced', then read
#define ao_serial_btm_drain ao_serial1_drain
#endif
#define ao_serial_btm_drain ao_serial1_drain
#endif
uint8_t ao_btm_connected;
#define BT_DEBUG 0
uint8_t ao_btm_connected;
#define BT_DEBUG 0
while ((c = ao_btm_getchar()) != AO_READ_AGAIN) {
ao_btm_log_in_char(c);
if (ao_btm_reply_len < sizeof (ao_btm_reply))
while ((c = ao_btm_getchar()) != AO_READ_AGAIN) {
ao_btm_log_in_char(c);
if (ao_btm_reply_len < sizeof (ao_btm_reply))
- ao_btm_reply[ao_btm_reply_len++] = c;
+ ao_btm_reply[ao_btm_reply_len++] = (char) c;
if (c == '\r' || c == '\n')
break;
}
if (c == '\r' || c == '\n')
break;
}
* Wait for the bluetooth device to return
* status from the previously executed command
*/
* Wait for the bluetooth device to return
* status from the previously executed command
*/
ao_btm_wait_reply(void)
{
for (;;) {
ao_btm_wait_reply(void)
{
for (;;) {
ao_btm_cmd(const char *cmd)
{
ao_btm_drain();
ao_btm_cmd(const char *cmd)
{
ao_btm_drain();
return ao_btm_wait_reply();
}
return ao_btm_wait_reply();
}
ao_btm_set_name(void)
{
char sn[8];
ao_btm_set_name(void)
{
char sn[8];
*--s = '\r';
n = ao_serial_number;
do {
*--s = '\r';
n = ao_serial_number;
do {
+ *--s = (uint8_t) ('0' + n % 10);
} while (n /= 10);
while ((c = *s++))
ao_btm_putchar(c);
} while (n /= 10);
while ((c = *s++))
ao_btm_putchar(c);