for (bit = 0; bit < 8; ++bit)
{
- crc ^= (value & 0x01);
+ crc = (uint16_t) (crc ^ (value & 0x01));
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_SSID_OFF] = 0x60 | ((ao_config.aprs_ssid & 0xf) << 1);
+ TNC_AX25_HEADER[TNC_SSID_OFF] = (uint8_t) (0x60 | ((ao_config.aprs_ssid & 0xf) << 1));
#endif
}
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);
value /= 91;
}
}
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);
}
/*
*/
static uint32_t
-ao_fixed_log2(uint32_t x)
+ao_fixed_log2(int32_t ix)
{
uint32_t result;
uint32_t frac = fixed23_one;
+ uint32_t x;
/* Bounds check for sanity */
- if (x <= 0)
+ if (ix <= 0)
return 0;
+ x = (uint32_t) ix;
+
if (x >= fixed30_one)
return 0xffffffff;
#define APRS_LOG_CONVERT fixed23_real(1.714065192056127)
#define APRS_LOG_BASE fixed23_real(346.920048461100941)
-static int
+static int32_t
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.
*/
-static int tncPositionPacket(void)
+static uint8_t tncPositionPacket(void)
{
static int32_t latitude;
static int32_t longitude;
/* 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);
if (lon > 1800000000)
lon = 1800000000;
- lat_deg = lat / 10000000;
+ lat_deg = (uint16_t) (lat / 10000000);
lat -= lat_deg * 10000000;
lat *= 60;
- lat_min = lat / 10000000;
+ lat_min = (uint16_t) (lat / 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_min = lon / 10000000;
+ lon_min = (uint16_t) (lon / 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;
buf += tncComment(buf);
- return buf - tncBuffer;
+ return (uint8_t) (buf - tncBuffer);
}
static int16_t
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;
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;
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);
- 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
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);
}
else
{
BMX160_ACC_RANGE_16G);
for (r = 0x3; r <= 0x1b; r++)
- (void) _ao_bmx160_reg_read(r);
+ (void) _ao_bmx160_reg_read((uint8_t) r);
/* Configure gyro:
*
_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_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