Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
authorBdale Garbee <bdale@gag.com>
Thu, 7 Apr 2022 04:51:13 +0000 (22:51 -0600)
committerBdale Garbee <bdale@gag.com>
Thu, 7 Apr 2022 04:51:13 +0000 (22:51 -0600)
152 files changed:
altoslib/AltosConfigData.java
altoslib/AltosConfigValues.java
altosui/AltosConfigFCUI.java
ao-bringup/turnon_easymega_v1.0
ao-tools/ao-telem/ao-telem.c
configure.ac
src/Makefile.defs
src/attiny/ao_arch_funcs.h
src/attiny/ao_async.c
src/attiny/ao_exti.c
src/attiny/ao_exti.h
src/attiny/ao_led_tiny.c
src/attiny/ao_spi_attiny.c
src/drivers/ao_aprs.c
src/drivers/ao_bmx160.c
src/drivers/ao_btm.c
src/drivers/ao_button.c
src/drivers/ao_cc1120.c
src/drivers/ao_cc1120_CC1120.h
src/drivers/ao_cc115l.c
src/drivers/ao_cc1200.c
src/drivers/ao_cc1200_CC1200.h
src/drivers/ao_companion.c
src/drivers/ao_gps_skytraq.c
src/drivers/ao_gps_ublox.c
src/drivers/ao_hmc5883.c
src/drivers/ao_lco.c
src/drivers/ao_lco.h
src/drivers/ao_lco_bits.c
src/drivers/ao_lco_cmd.c
src/drivers/ao_lco_func.c
src/drivers/ao_lco_two.c
src/drivers/ao_m25.c
src/drivers/ao_mma655x.c
src/drivers/ao_mmc5983.c
src/drivers/ao_mpu6000.c
src/drivers/ao_mpu9250.c
src/drivers/ao_ms5607.c
src/drivers/ao_ms5607.h
src/drivers/ao_ms5607_convert.c
src/drivers/ao_packet_master.c
src/drivers/ao_packet_slave.c
src/drivers/ao_pad.c
src/drivers/ao_quadrature.c
src/drivers/ao_rn4678.c
src/kernel/ao.h
src/kernel/ao_beep.h
src/kernel/ao_cmd.c
src/kernel/ao_companion.h
src/kernel/ao_config.c
src/kernel/ao_config.h
src/kernel/ao_convert_pa.c
src/kernel/ao_convert_volt.c
src/kernel/ao_data.h
src/kernel/ao_distance.c
src/kernel/ao_fec.h
src/kernel/ao_fec_rx.c
src/kernel/ao_fec_tx.c
src/kernel/ao_flight.c
src/kernel/ao_freq.c
src/kernel/ao_gps_report_mega.c
src/kernel/ao_gps_report_metrum.c
src/kernel/ao_kalman.c
src/kernel/ao_log.c
src/kernel/ao_log.h
src/kernel/ao_log_fireone.c
src/kernel/ao_log_gps.c
src/kernel/ao_log_mega.c
src/kernel/ao_log_metrum.c
src/kernel/ao_log_micro.c
src/kernel/ao_log_mini.c
src/kernel/ao_log_motor.c
src/kernel/ao_microflight.c
src/kernel/ao_microkalman.c
src/kernel/ao_monitor.c
src/kernel/ao_pyro.c
src/kernel/ao_radio_cmac.c
src/kernel/ao_radio_cmac.h
src/kernel/ao_radio_cmac_cmd.c
src/kernel/ao_report.c
src/kernel/ao_report_micro.c
src/kernel/ao_romconfig.c
src/kernel/ao_sample.c
src/kernel/ao_send_packet.c
src/kernel/ao_serial.h
src/kernel/ao_stdio.c
src/kernel/ao_storage.c
src/kernel/ao_task.h
src/kernel/ao_telemetry.c
src/kernel/ao_telemetry.h
src/kernel/ao_tracker.c
src/kernel/ao_tracker.h
src/lpc/ao_adc_lpc.c
src/lpc/ao_arch_funcs.h
src/lpc/ao_beep_lpc.c
src/lpc/ao_exti_lpc.c
src/lpc/ao_flash_lpc.c
src/lpc/ao_serial_lpc.c
src/lpc/ao_spi_lpc.c
src/lpc/ao_timer_lpc.c
src/lpc/ao_usb_lpc.c
src/lpc/lpc.h
src/micropeak-v2.0/ao_micro.c
src/product/ao_flash_task.c
src/product/ao_micropeak.c
src/stm/ao_arch_funcs.h
src/stm/ao_beep_stm.c
src/stm/ao_boot_pin.c
src/stm/ao_dma_stm.c
src/stm/ao_eeprom_stm.c
src/stm/ao_exti_stm.c
src/stm/ao_i2c_stm.c
src/stm/ao_lcd_stm.c
src/stm/ao_led_stm.c
src/stm/ao_profile.h
src/stm/ao_pwm_stm.c
src/stm/ao_serial_stm.c
src/stm/ao_timer.c
src/stm/ao_usb_stm.c
src/stm/stm32l.h
src/stm32l0/ao_adc_stm32l0.c
src/stm32l0/ao_arch_funcs.h
src/stm32l0/ao_exti_stm.c
src/stm32l0/ao_flash_stm32l0.c
src/stm32l0/ao_lpuart_stm.c
src/stm32l0/ao_serial_stm.c
src/stm32l0/ao_spi_stm32l0.c
src/stm32l0/stm32l0.h
src/stmf0/ao_adc_fast.c
src/stmf0/ao_adc_stm.c
src/stmf0/ao_arch_funcs.h
src/stmf0/ao_beep_stm.c
src/stmf0/ao_boot_pin.c
src/stmf0/ao_crc.h
src/stmf0/ao_dma_stm.c
src/stmf0/ao_exti_stm.c
src/stmf0/ao_flash_stm.c
src/stmf0/ao_gpio.c
src/stmf0/ao_led_stmf0.c
src/stmf0/ao_serial_stm.c
src/stmf0/ao_timer.c
src/stmf0/ao_usb_stm.c
src/stmf0/stm32f0.h
src/telefireeight-v1.0/ao_pins.h
src/telefireeight-v2.0/ao_pins.h
src/telefireone-v1.0/ao_pins.h
src/telefireone-v1.0/ao_telefireone.c
src/telefiretwo-v0.1/ao_pins.h
src/telegps-v0.3/ao_pins.h
src/telelco-v2.0/ao_lco_v2.c
src/telemega-v5.0/ao_pins.h
telegps/TeleGPSConfigUI.java

index b6105f92fc3cb27265e087fb530d84da2f2f79e8..cd649113b1a6b8293b3766f05a74f97ae6f79d0b 100644 (file)
@@ -83,6 +83,9 @@ public class AltosConfigData {
        /* HAS_BEEP */
        public int              beep;
 
+       /* HAS_RADIO_10MW */
+       public int              radio_10mw;
+
        /* Storage info replies */
        public int      storage_size;
        public int      storage_erase_unit;
@@ -315,6 +318,8 @@ public class AltosConfigData {
 
                beep = AltosLib.MISSING;
 
+               radio_10mw = AltosLib.MISSING;
+
                tracker_motion = AltosLib.MISSING;
                tracker_interval = AltosLib.MISSING;
 
@@ -505,6 +510,9 @@ public class AltosConfigData {
                /* HAS_BEEP */
                try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {}
 
+               /* HAS_RADIO_10MW */
+               try { radio_10mw = get_int(line, "Radio 10mw limit:"); } catch (Exception e) {}
+
                /* HAS_TRACKER */
                try {
                        int[] values = get_values(line, "Tracker setting:");
@@ -730,6 +738,11 @@ public class AltosConfigData {
                /* HAS_BEEP */
                if (beep != AltosLib.MISSING)
                        beep = source.beep();
+
+               /* HAS_RADIO_10MW */
+               if (radio_10mw != AltosLib.MISSING)
+                       radio_10mw = source.radio_10mw();
+
                /* HAS_TRACKER */
                if (tracker_motion != AltosLib.MISSING)
                        tracker_motion = source.tracker_motion();
@@ -785,6 +798,7 @@ public class AltosConfigData {
                dest.set_aprs_format(aprs_format);
                dest.set_aprs_offset(aprs_offset);
                dest.set_beep(beep);
+               dest.set_radio_10mw(radio_10mw);
                dest.set_tracker_motion(tracker_motion);
                dest.set_tracker_interval(tracker_interval);
        }
@@ -904,6 +918,10 @@ public class AltosConfigData {
                if (beep != AltosLib.MISSING)
                        link.printf("c b %d\n", beep);
 
+               /* HAS_RADIO_10MW */
+               if (radio_10mw != AltosLib.MISSING)
+                       link.printf("c p %d\n", radio_10mw);
+
                /* HAS_TRACKER */
                if (tracker_motion != AltosLib.MISSING && tracker_interval != AltosLib.MISSING)
                        link.printf("c t %d %d\n", tracker_motion, tracker_interval);
index 8fa3fa41b697056ee271f76b1db6dddf1b2e2b0a..65b5f0018de5136fbc48b003c5ff52dd0ded9cf3 100644 (file)
@@ -119,4 +119,8 @@ public interface AltosConfigValues {
        public abstract int tracker_interval() throws AltosConfigDataException;
 
        public abstract void set_tracker_interval(int tracker_motion);
+
+       public abstract int radio_10mw() throws AltosConfigDataException;
+
+       public abstract void set_radio_10mw(int radio_10mw);
 }
index 562c695207613638bb3a61253d04bd3290964a1e..75b294d9b2c01d5acdd440d80a64350420580045 100644 (file)
@@ -42,6 +42,7 @@ public class AltosConfigFCUI
        JLabel                  radio_calibration_label;
        JLabel                  radio_frequency_label;
        JLabel                  radio_enable_label;
+       JLabel                  radio_10mw_label;
        JLabel                  rate_label;
        JLabel                  aprs_interval_label;
        JLabel                  aprs_ssid_label;
@@ -69,6 +70,7 @@ public class AltosConfigFCUI
        AltosUIFreqList         radio_frequency_value;
        JLabel                  radio_calibration_value;
        JRadioButton            radio_enable_value;
+       JRadioButton            radio_10mw_value;
        AltosUIRateList         rate_value;
        JComboBox<String>       aprs_interval_value;
        JComboBox<Integer>      aprs_ssid_value;
@@ -349,6 +351,13 @@ public class AltosConfigFCUI
                        beep_value.setToolTipText("Older firmware could not select beeper frequency");
        }
 
+       void set_radio_10mw_tool_tip() {
+               if (radio_10mw_value.isVisible())
+                       radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
+               else
+                       radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
+       }
+
        /* Build the UI using a grid bag */
        public AltosConfigFCUI(JFrame in_owner, boolean remote) {
                super (in_owner, title, false);
@@ -582,6 +591,31 @@ public class AltosConfigFCUI
                set_radio_enable_tool_tip();
                row++;
 
+               /* Radio 10mW limit */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = row;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
+               radio_10mw_label = new JLabel("Limit transmit to 10mW:");
+               pane.add(radio_10mw_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 4; c.gridy = row;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               radio_10mw_value = new JRadioButton("Limited");
+               radio_10mw_value.addItemListener(this);
+               pane.add(radio_10mw_value, c);
+               set_radio_10mw_tool_tip();
+               row++;
+
                /* Telemetry Rate */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = row;
@@ -1438,6 +1472,22 @@ public class AltosConfigFCUI
                        return AltosLib.MISSING;
        }
 
+       public void set_radio_10mw(int new_radio_10mw) {
+               if (new_radio_10mw != AltosLib.MISSING) {
+                       radio_10mw_value.setSelected(new_radio_10mw != 0);
+               }
+               radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
+               radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
+               set_radio_10mw_tool_tip();
+       }
+
+       public int radio_10mw() {
+               if (radio_10mw_value.isVisible())
+                       return radio_10mw_value.isSelected() ? 1 : 0;
+               else
+                       return AltosLib.MISSING;
+       }
+
        String[] tracker_motion_values() {
                if (AltosConvert.imperial_units)
                        return tracker_motion_values_ft;
index b14ed2ab9895c835d20f3de84bdb2775753db31b..2a3309844efa516aba4d850fe5f05a59ba2e573a 100755 (executable)
@@ -71,6 +71,6 @@ echo 'E 0' > $dev
 
 echo 'E 1' > $dev
 
-./test-easymega
+./test-easymega-v1.0
 
 exit $?
index 984184d65b88e5189e6a1f7e353d628bb1780376..3b7c379acaf24be30d7bf46388e3d935ae476532 100644 (file)
@@ -37,13 +37,196 @@ static void usage(char *program)
 
 #define bool(b)        ((b) ? "true" : "false")
 
+static int ignore_crc;
+
+static void
+process(FILE *file)
+{
+       char    line[1024];
+       int c;
+
+       while (fgets(line, sizeof (line), file)) {
+               union ao_telemetry_all telem;
+               char call[AO_MAX_CALLSIGN+1];
+               char version[AO_MAX_VERSION+1];
+
+               if (cc_telemetry_parse(line, &telem)) {
+                       int rssi = (int8_t) telem.generic.rssi / 2 - 74;
+
+                       printf ("serial %5d rssi %d status %02x tick %5d type %3d ",
+                               telem.generic.serial, rssi, telem.generic.status,
+                               telem.generic.tick, telem.generic.type);
+                       if (!ignore_crc && (telem.generic.status & (1 << 7)) == 0) {
+                               printf ("CRC error\n");
+                               continue;
+                       }
+                       switch (telem.generic.type) {
+                       case AO_TELEMETRY_SENSOR_TELEMETRUM:
+                       case AO_TELEMETRY_SENSOR_TELEMINI:
+                       case AO_TELEMETRY_SENSOR_TELENANO:
+                               printf ("state %1d accel %5d pres %5d ",
+                                       telem.sensor.state, telem.sensor.accel, telem.sensor.pres);
+                               printf ("accel %6.2f speed %6.2f height %5d ",
+                                       telem.sensor.acceleration / 16.0,
+                                       telem.sensor.speed / 16.0,
+                                       telem.sensor.height);
+                               printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d\n",
+                                       telem.sensor.ground_pres,
+                                       telem.sensor.ground_accel,
+                                       telem.sensor.accel_plus_g,
+                                       telem.sensor.accel_minus_g);
+                               break;
+                       case AO_TELEMETRY_CONFIGURATION:
+                               memcpy(call, telem.configuration.callsign, AO_MAX_CALLSIGN);
+                               memcpy(version, telem.configuration.version, AO_MAX_VERSION);
+                               call[AO_MAX_CALLSIGN] = '\0';
+                               version[AO_MAX_CALLSIGN] = '\0';
+                               printf ("device %3d flight %5d config %3d.%03d delay %2d main %4d log_max %5d",
+                                       telem.configuration.device,
+                                       telem.configuration.flight,
+                                       telem.configuration.config_major,
+                                       telem.configuration.config_minor,
+                                       telem.configuration.apogee_delay,
+                                       telem.configuration.main_deploy,
+                                       telem.configuration.flight_log_max);
+                               printf (" call %8s version %8s\n", call, version);
+                               break;
+                       case AO_TELEMETRY_LOCATION:
+                               printf ("sats %d flags %s%s%s%s",
+                                       telem.location.flags & 0xf,
+                                       (telem.location.flags & (1 << 4)) ? "valid" : "invalid",
+                                       (telem.location.flags & (1 << 5)) ? ",running" : "",
+                                       (telem.location.flags & (1 << 6)) ? ",date" : "",
+                                       (telem.location.flags & (1 << 7)) ? ",course" : "");
+                               printf (" alt %5d lat %12.7f lon %12.7f",
+                                       AO_TELEMETRY_LOCATION_ALTITUDE(&telem.location),
+                                       telem.location.latitude / 1e7,
+                                       telem.location.longitude / 1e7);
+                               if ((telem.location.flags & (1 << 6)) != 0) {
+                                       printf (" year %2d month %2d day %2d",
+                                               telem.location.year,
+                                               telem.location.month,
+                                               telem.location.day);
+                                       printf (" hour %2d minute %2d second %2d",
+                                               telem.location.hour,
+                                               telem.location.minute,
+                                               telem.location.second);
+                               }
+                               printf (" pdop %3.1f hdop %3.1f vdop %3.1f mode %d",
+                                       telem.location.pdop / 5.0,
+                                       telem.location.hdop / 5.0,
+                                       telem.location.vdop / 5.0,
+                                       telem.location.mode);
+                               if ((telem.location.flags & (1 << 7)) != 0)
+                                       printf (" ground_speed %6.2f climb_rate %6.2f course %d",
+                                               telem.location.ground_speed / 100.0,
+                                               telem.location.climb_rate / 100.0,
+                                               telem.location.course * 2);
+                               printf ("\n");
+                               break;
+                       case AO_TELEMETRY_SATELLITE:
+                               printf ("sats %d", telem.satellite.channels);
+                               for (c = 0; c < 12 && c < telem.satellite.channels; c++) {
+                                       printf (" sat %d svid %d c_n_1 %d",
+                                               c,
+                                               telem.satellite.sats[c].svid,
+                                               telem.satellite.sats[c].c_n_1);
+                               }
+                               printf ("\n");
+                               break;
+                       case AO_TELEMETRY_MEGA_SENSOR_MPU:
+                       case AO_TELEMETRY_MEGA_SENSOR_BMX160:
+                               printf ("orient %3d accel %5d pres %9d temp %5d accel_x %5d accel_y %5d accel_z %5d gyro_x %5d gyro_y %5d gyro_z %5d mag_x %5d mag_y %5d mag_z %5d\n",
+                                       telem.mega_sensor.orient,
+                                       telem.mega_sensor.accel,
+                                       telem.mega_sensor.pres,
+                                       telem.mega_sensor.temp,
+                                       telem.mega_sensor.accel_x,
+                                       telem.mega_sensor.accel_y,
+                                       telem.mega_sensor.accel_z,
+                                       telem.mega_sensor.gyro_x,
+                                       telem.mega_sensor.gyro_y,
+                                       telem.mega_sensor.gyro_z,
+                                       telem.mega_sensor.mag_x,
+                                       telem.mega_sensor.mag_y,
+                                       telem.mega_sensor.mag_z);
+                               break;
+                       case AO_TELEMETRY_COMPANION:
+                               printf("board_id %3d update_period %3d channels %2d",
+                                      telem.companion.board_id,
+                                      telem.companion.update_period,
+                                      telem.companion.channels);
+                               for (c = 0; c < telem.companion.channels; c++)
+                                       printf(" %6d", telem.companion.companion_data[c]);
+                               printf("\n");
+                               break;
+                       case AO_TELEMETRY_MEGA_DATA:
+                               printf ("state %1d v_batt %5d v_pyro %5d ",
+                                       telem.mega_data.state,
+                                       telem.mega_data.v_batt,
+                                       telem.mega_data.v_pyro);
+                               for (c = 0; c < 6; c++)
+                                       printf ("s%1d %5d ", c,
+                                               telem.mega_data.sense[c] |
+                                               (telem.mega_data.sense[c] << 8));
+
+                               printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d ",
+                                       telem.mega_data.ground_pres,
+                                       telem.mega_data.ground_accel,
+                                       telem.mega_data.accel_plus_g,
+                                       telem.mega_data.accel_minus_g);
+
+                               printf ("accel %6.2f speed %6.2f height %5d\n",
+                                       telem.mega_data.acceleration / 16.0,
+                                       telem.mega_data.speed / 16.0,
+                                       telem.mega_data.height);
+
+                               break;
+                       case AO_TELEMETRY_METRUM_SENSOR:
+                               printf ("state %1d accel %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d v_batt %5d sense_a %5d sense_m %5d\n",
+                                       telem.metrum_sensor.state,
+                                       telem.metrum_sensor.accel,
+                                       telem.metrum_sensor.pres,
+                                       telem.metrum_sensor.temp / 100.0,
+                                       telem.metrum_sensor.acceleration / 16.0,
+                                       telem.metrum_sensor.speed / 16.0,
+                                       telem.metrum_sensor.height,
+                                       telem.metrum_sensor.v_batt,
+                                       telem.metrum_sensor.sense_a,
+                                       telem.metrum_sensor.sense_m);
+                               break;
+                       case AO_TELEMETRY_METRUM_DATA:
+                               printf ("ground_pres %9d ground_accel %5d accel_plus %5d accel_minus %5d\n",
+                                       telem.metrum_data.ground_pres,
+                                       telem.metrum_data.ground_accel,
+                                       telem.metrum_data.accel_plus_g,
+                                       telem.metrum_data.accel_minus_g);
+                               break;
+                       case AO_TELEMETRY_MINI:
+                               printf ("state %1d v_batt %5d sense_a %5d sense_m %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d ground_pres %9d\n",
+                                       telem.mini.state,
+                                       telem.mini.v_batt,
+                                       telem.mini.sense_a,
+                                       telem.mini.sense_m,
+                                       telem.mini.pres,
+                                       telem.mini.temp / 100.0,
+                                       telem.mini.acceleration / 16.0,
+                                       telem.mini.speed / 16.0,
+                                       telem.mini.height,
+                                       telem.mini.ground_pres);
+                               break;
+                       default:
+                               printf("\n");
+                       }
+               }
+       }
+}
+
 int
 main (int argc, char **argv)
 {
-       char    line[80];
        int c, i, ret = 0;
        FILE *file;
-       int ignore_crc = 0;
        while ((c = getopt_long(argc, argv, "c", options, NULL)) != -1) {
                switch (c) {
                case 'c':
@@ -54,190 +237,19 @@ main (int argc, char **argv)
                        break;
                }
        }
-       for (i = optind; i < argc; i++) {
-               file = fopen(argv[i], "r");
-               if (!file) {
-                       perror(argv[i]);
-                       ret++;
-                       continue;
-               }
-               while (fgets(line, sizeof (line), file)) {
-                       union ao_telemetry_all telem;
-                       char call[AO_MAX_CALLSIGN+1];
-                       char version[AO_MAX_VERSION+1];
-
-                       if (cc_telemetry_parse(line, &telem)) {
-                               int rssi = (int8_t) telem.generic.rssi / 2 - 74;
-
-                               printf ("serial %5d rssi %d status %02x tick %5d type %3d ",
-                                       telem.generic.serial, rssi, telem.generic.status,
-                                       telem.generic.tick, telem.generic.type);
-                               if (!ignore_crc && (telem.generic.status & (1 << 7)) == 0) {
-                                       printf ("CRC error\n");
-                                       continue;
-                               }
-                               switch (telem.generic.type) {
-                               case AO_TELEMETRY_SENSOR_TELEMETRUM:
-                               case AO_TELEMETRY_SENSOR_TELEMINI:
-                               case AO_TELEMETRY_SENSOR_TELENANO:
-                                       printf ("state %1d accel %5d pres %5d ",
-                                               telem.sensor.state, telem.sensor.accel, telem.sensor.pres);
-                                       printf ("accel %6.2f speed %6.2f height %5d ",
-                                               telem.sensor.acceleration / 16.0,
-                                               telem.sensor.speed / 16.0,
-                                               telem.sensor.height);
-                                       printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d\n",
-                                               telem.sensor.ground_pres,
-                                               telem.sensor.ground_accel,
-                                               telem.sensor.accel_plus_g,
-                                               telem.sensor.accel_minus_g);
-                                       break;
-                               case AO_TELEMETRY_CONFIGURATION:
-                                       memcpy(call, telem.configuration.callsign, AO_MAX_CALLSIGN);
-                                       memcpy(version, telem.configuration.version, AO_MAX_VERSION);
-                                       call[AO_MAX_CALLSIGN] = '\0';
-                                       version[AO_MAX_CALLSIGN] = '\0';
-                                       printf ("device %3d flight %5d config %3d.%03d delay %2d main %4d log_max %5d",
-                                               telem.configuration.device,
-                                               telem.configuration.flight,
-                                               telem.configuration.config_major,
-                                               telem.configuration.config_minor,
-                                               telem.configuration.apogee_delay,
-                                               telem.configuration.main_deploy,
-                                               telem.configuration.flight_log_max);
-                                       printf (" call %8s version %8s\n", call, version);
-                                       break;
-                               case AO_TELEMETRY_LOCATION:
-                                       printf ("sats %d flags %s%s%s%s",
-                                               telem.location.flags & 0xf,
-                                               (telem.location.flags & (1 << 4)) ? "valid" : "invalid",
-                                               (telem.location.flags & (1 << 5)) ? ",running" : "",
-                                               (telem.location.flags & (1 << 6)) ? ",date" : "",
-                                               (telem.location.flags & (1 << 7)) ? ",course" : "");
-                                       printf (" alt %5d lat %12.7f lon %12.7f",
-                                               AO_TELEMETRY_LOCATION_ALTITUDE(&telem.location),
-                                               telem.location.latitude / 1e7,
-                                               telem.location.longitude / 1e7);
-                                       if ((telem.location.flags & (1 << 6)) != 0) {
-                                               printf (" year %2d month %2d day %2d",
-                                                       telem.location.year,
-                                                       telem.location.month,
-                                                       telem.location.day);
-                                               printf (" hour %2d minute %2d second %2d",
-                                                       telem.location.hour,
-                                                       telem.location.minute,
-                                                       telem.location.second);
-                                       }
-                                       printf (" pdop %3.1f hdop %3.1f vdop %3.1f mode %d",
-                                               telem.location.pdop / 5.0,
-                                               telem.location.hdop / 5.0,
-                                               telem.location.vdop / 5.0,
-                                               telem.location.mode);
-                                       if ((telem.location.flags & (1 << 7)) != 0)
-                                               printf (" ground_speed %6.2f climb_rate %6.2f course %d",
-                                                       telem.location.ground_speed / 100.0,
-                                                       telem.location.climb_rate / 100.0,
-                                                       telem.location.course * 2);
-                                       printf ("\n");
-                                       break;
-                               case AO_TELEMETRY_SATELLITE:
-                                       printf ("sats %d", telem.satellite.channels);
-                                       for (c = 0; c < 12 && c < telem.satellite.channels; c++) {
-                                               printf (" sat %d svid %d c_n_1 %d",
-                                                       c,
-                                                       telem.satellite.sats[c].svid,
-                                                       telem.satellite.sats[c].c_n_1);
-                                       }
-                                       printf ("\n");
-                                       break;
-                               case AO_TELEMETRY_MEGA_SENSOR_MPU:
-                               case AO_TELEMETRY_MEGA_SENSOR_BMX160:
-                                       printf ("orient %3d accel %5d pres %9d temp %5d accel_x %5d accel_y %5d accel_z %5d gyro_x %5d gyro_y %5d gyro_z %5d mag_x %5d mag_y %5d mag_z %5d\n",
-                                               telem.mega_sensor.orient,
-                                               telem.mega_sensor.accel,
-                                               telem.mega_sensor.pres,
-                                               telem.mega_sensor.temp,
-                                               telem.mega_sensor.accel_x,
-                                               telem.mega_sensor.accel_y,
-                                               telem.mega_sensor.accel_z,
-                                               telem.mega_sensor.gyro_x,
-                                               telem.mega_sensor.gyro_y,
-                                               telem.mega_sensor.gyro_z,
-                                               telem.mega_sensor.mag_x,
-                                               telem.mega_sensor.mag_y,
-                                               telem.mega_sensor.mag_z);
-                                       break;
-                               case AO_TELEMETRY_COMPANION:
-                                       printf("board_id %3d update_period %3d channels %2d",
-                                              telem.companion.board_id,
-                                              telem.companion.update_period,
-                                              telem.companion.channels);
-                                       for (c = 0; c < telem.companion.channels; c++)
-                                               printf(" %6d", telem.companion.companion_data[c]);
-                                       printf("\n");
-                                       break;
-                               case AO_TELEMETRY_MEGA_DATA:
-                                       printf ("state %1d v_batt %5d v_pyro %5d ",
-                                               telem.mega_data.state,
-                                               telem.mega_data.v_batt,
-                                               telem.mega_data.v_pyro);
-                                       for (c = 0; c < 6; c++)
-                                               printf ("s%1d %5d ", c,
-                                                       telem.mega_data.sense[c] |
-                                                       (telem.mega_data.sense[c] << 8));
-
-                                       printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d ",
-                                               telem.mega_data.ground_pres,
-                                               telem.mega_data.ground_accel,
-                                               telem.mega_data.accel_plus_g,
-                                               telem.mega_data.accel_minus_g);
-
-                                       printf ("accel %6.2f speed %6.2f height %5d\n",
-                                               telem.mega_data.acceleration / 16.0,
-                                               telem.mega_data.speed / 16.0,
-                                               telem.mega_data.height);
-
-                                       break;
-                               case AO_TELEMETRY_METRUM_SENSOR:
-                                       printf ("state %1d accel %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d v_batt %5d sense_a %5d sense_m %5d\n",
-                                               telem.metrum_sensor.state,
-                                               telem.metrum_sensor.accel,
-                                               telem.metrum_sensor.pres,
-                                               telem.metrum_sensor.temp / 100.0,
-                                               telem.metrum_sensor.acceleration / 16.0,
-                                               telem.metrum_sensor.speed / 16.0,
-                                               telem.metrum_sensor.height,
-                                               telem.metrum_sensor.v_batt,
-                                               telem.metrum_sensor.sense_a,
-                                               telem.metrum_sensor.sense_m);
-                                       break;
-                               case AO_TELEMETRY_METRUM_DATA:
-                                       printf ("ground_pres %9d ground_accel %5d accel_plus %5d accel_minus %5d\n",
-                                               telem.metrum_data.ground_pres,
-                                               telem.metrum_data.ground_accel,
-                                               telem.metrum_data.accel_plus_g,
-                                               telem.metrum_data.accel_minus_g);
-                                       break;
-                               case AO_TELEMETRY_MINI:
-                                       printf ("state %1d v_batt %5d sense_a %5d sense_m %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d ground_pres %9d\n",
-                                               telem.mini.state,
-                                               telem.mini.v_batt,
-                                               telem.mini.sense_a,
-                                               telem.mini.sense_m,
-                                               telem.mini.pres,
-                                               telem.mini.temp / 100.0,
-                                               telem.mini.acceleration / 16.0,
-                                               telem.mini.speed / 16.0,
-                                               telem.mini.height,
-                                               telem.mini.ground_pres);
-                                       break;
-                               default:
-                                       printf("\n");
-                               }
+       if (optind < argc) {
+               for (i = optind; i < argc; i++) {
+                       file = fopen(argv[i], "r");
+                       if (!file) {
+                               perror(argv[i]);
+                               ret++;
+                               continue;
                        }
-               }
-               fclose (file);
+                       process(file);
+                       fclose (file);
 
-       }
+               }
+       } else
+               process(stdin);
        return ret;
 }
index 7c204d0a02699f6936d24c77a5e3e2594b2a02cf..442fafd34fc83d4766d86a7a0b746c368beb06d2 100644 (file)
@@ -18,13 +18,13 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([altos], 1.9.10.3)
+AC_INIT([altos], 1.9.10.4)
 ANDROID_VERSION=34
 AC_CONFIG_SRCDIR([src/kernel/ao.h])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
-RELEASE_DATE=2022-02-09
+RELEASE_DATE=2022-02-21
 AC_SUBST(RELEASE_DATE)
 
 DOC_DATE=`LC_ALL=C date -d $RELEASE_DATE +'%d %b %Y'`
index 897f7ac1b35ade9d2574b45c6e1f1208f6923a6a..d9b719973da61e5c52fabe871d8b3111318b7630 100644 (file)
@@ -16,7 +16,8 @@ WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align \
        -Wmissing-declarations \
        -Wnested-externs \
        -Wshadow \
-       -Warray-bounds=2
+       -Warray-bounds=2 \
+       -Wconversion
 
 OPT=-Os -Wl,-Map=$(PROGNAME)-$(VERSION).map
 
index e51f456b5965594aa4f075257109d8d292bcef79..1f422a37645bd92d7d7c2764a29c5f3b26a7efde 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #define ao_spi_get_mask(reg,mask,bus,speed) do {       \
-               (reg) &= ~(mask);                       \
+               (reg) &= (uint8_t) ~(mask);             \
        } while (0)
 
 #define ao_spi_put_mask(reg,mask,bus) do {     \
index f7a29d3b799f88e0ab71dd2e92f4db3f167d4e30..945f4b1414b153867669f056417e10f958bdce2e 100644 (file)
@@ -33,7 +33,7 @@ ao_async_start(void)
 void
 ao_async_stop(void)
 {
-       LED_PORT &= ~(1 << AO_LED_SERIAL);
+       LED_PORT &= (uint8_t) ~(1 << AO_LED_SERIAL);
 }
 
 void
@@ -45,11 +45,11 @@ ao_async_byte(uint8_t byte)
        uint8_t         bit;
        uint8_t         w_hi, w_lo;
 
-       /*    start           data           stop */
-       w = (0x000 << 0) | (byte << 1) | (0x001 << 9);
+       /*                start           data           stop */
+       w = (uint16_t) ((0x000 << 0) | (byte << 1) | (0x001 << 9));
 
-       w_hi = w >> 8;
-       w_lo = w;
+       w_hi = (uint8_t) (w >> 8);
+       w_lo = (uint8_t) w;
 
        ao_arch_block_interrupts();
 
index c5b7eb2b078380b531b200058e7dc3a0470a781d..076cecc1f54d0939ce12be191f98129c257d6e05 100644 (file)
@@ -33,7 +33,7 @@ ao_exti_setup_port(uint8_t pin, uint8_t mode, void (*callback)(void))
 {
        (void) mode;
        pcint_callback = callback;
-       pcint_mask = (1 << pin);
+       pcint_mask = (uint8_t) (1 << pin);
        ao_exti_disable(PORTB, pin);
        GIMSK |= (1 << PCIE);
 }
index 8b22458e2ccd672c04475020a1b686ef3968ad04..1d1426e9d9bac47fa67da04bbb886ef6e9346f3c 100644 (file)
@@ -26,7 +26,7 @@ ao_exti_setup_port(uint8_t pin, uint8_t mode, void (*callback)(void));
 
 #define ao_exti_enable(gpio, pin)      (PCMSK |= (1 << (pin)))
 
-#define ao_exti_disable(gpio, pin)     (PCMSK &= ~(1 << (pin)))
+#define ao_exti_disable(gpio, pin)     (PCMSK &= (uint8_t) ~(1 << (pin)))
 
 #define ao_exti_init()
 
index cd620f4672f80318dbcb3e685b64a2726faffaa7..dab74fee1851a5ee40b1f711380c8b8278da7f61 100644 (file)
@@ -30,19 +30,19 @@ ao_led_on(uint8_t colors)
 void
 ao_led_off(uint8_t colors)
 {
-       LED_PORT &= ~colors;
+       LED_PORT &= (uint8_t) ~colors;
 }
 
 void
 ao_led_set(uint8_t colors)
 {
-       LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE);
+       LED_PORT = (uint8_t) ((LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE));
 }
 
 void
 ao_led_toggle(uint8_t colors)
 {
-       LED_PORT ^= (colors & LEDS_AVAILABLE);
+       LED_PORT = (uint8_t) (LED_PORT ^ (colors & LEDS_AVAILABLE));
 }
 
 void
@@ -56,6 +56,6 @@ ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
 void
 ao_led_init(void)
 {
-       LED_PORT &= ~LEDS_AVAILABLE;
+       LED_PORT &= (uint8_t) ~LEDS_AVAILABLE;
        LED_DDR |= LEDS_AVAILABLE;
 }
index 1c90ad56082326a9981aef4f538f1584159ab6fc..506ebf1550d84b1ee4ddec58045f175bc7fc4cd1 100644 (file)
@@ -117,7 +117,7 @@ ao_spi_init(void)
 #else
        USICR = SPI_USICR_FAST_2;
 #endif
-       SPI_DIR &= ~(1 << DDB0);        /* DI */
+       SPI_DIR &= (uint8_t) ~(1 << DDB0);      /* DI */
        SPI_DIR |= (1 << DDB1);         /* DO */
        SPI_DIR |= (1 << DDB2);         /* SCLK */
 }
index 826985c6e06e2f0b004a05c36a2b6976cd6a49ba..3ac4cd535b231a8ac11622e5719dfe115839a202 100644 (file)
@@ -186,7 +186,7 @@ static uint16_t sysCRC16(const uint8_t *buffer, uint8_t length, uint16_t crc)
 
         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
@@ -282,7 +282,7 @@ tncSetCallsign(void)
                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
 }
 
@@ -490,7 +490,7 @@ static void tnc1200TimerTick()
 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;
        }
 }
@@ -611,7 +611,7 @@ fixed23_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);
 }
 
 /*
@@ -620,15 +620,18 @@ fixed30_mul(uint32_t x, uint32_t y)
  */
 
 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;
 
@@ -693,16 +696,16 @@ ao_fixed_log2(uint32_t x)
 #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;
@@ -736,8 +739,8 @@ static int tncPositionPacket(void)
            /* 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);
 
@@ -787,19 +790,19 @@ static int tncPositionPacket(void)
            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;
@@ -814,7 +817,7 @@ static int tncPositionPacket(void)
 
     buf += tncComment(buf);
 
-    return buf - tncBuffer;
+    return (uint8_t) (buf - tncBuffer);
 }
 
 static int16_t
@@ -827,7 +830,7 @@ tncFill(uint8_t *buf, int16_t len)
     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;
@@ -860,8 +863,8 @@ void ao_aprs_send(void)
     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;
index 427a081bc36e21db5e56a65e92101225f0690517..eabe0783253d05c788ff97c2cfc4cf9d12abe9c0 100644 (file)
@@ -109,7 +109,7 @@ _ao_bmm150_reg_read2(uint8_t lo_addr, uint8_t 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);
 }
 
 /*
@@ -217,7 +217,7 @@ static int16_t compensate_x(int16_t mag_data_x, uint16_t data_rhall)
            //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
@@ -282,7 +282,7 @@ static int16_t compensate_y(int16_t mag_data_y, uint16_t data_rhall)
             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
         {
@@ -504,7 +504,7 @@ _ao_bmx160_setup(void)
                             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:
         *
@@ -560,16 +560,16 @@ _ao_bmx160_setup(void)
        _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
index b7ff0b9edb4d383da76e414ae1b67baccc0bd1dc..b82fb999fe8957536c42bab002ebeda57161486b 100644 (file)
@@ -29,7 +29,7 @@
 #define ao_serial_btm_drain    ao_serial1_drain
 #endif
 
-int8_t                 ao_btm_stdio;
+uint8_t                ao_btm_stdio;
 uint8_t                ao_btm_connected;
 
 #define BT_DEBUG 0
@@ -197,7 +197,7 @@ ao_btm_get_line(void)
        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;
        }
@@ -242,7 +242,7 @@ ao_btm_putchar(char c)
  * Wait for the bluetooth device to return
  * status from the previously executed command
  */
-static uint8_t
+static int
 ao_btm_wait_reply(void)
 {
        for (;;) {
@@ -265,7 +265,7 @@ ao_btm_string(const char *cmd)
                ao_btm_putchar(c);
 }
 
-static uint8_t
+static int
 ao_btm_cmd(const char *cmd)
 {
        ao_btm_drain();
@@ -282,7 +282,7 @@ ao_btm_cmd(const char *cmd)
        return ao_btm_wait_reply();
 }
 
-static uint8_t
+static int
 ao_btm_set_name(void)
 {
        char    sn[8];
@@ -294,7 +294,7 @@ ao_btm_set_name(void)
        *--s = '\r';
        n = ao_serial_number;
        do {
-               *--s = '0' + n % 10;
+               *--s = (uint8_t) ('0' + n % 10);
        } while (n /= 10);
        while ((c = *s++))
                ao_btm_putchar(c);
index 53728bceef47d99c26b54fe6ad58a637dc985c8c..4c18400a406d175725e599d2c62ca78b2f9989c2 100644 (file)
@@ -125,7 +125,7 @@ _ao_button_check(uint8_t b)
 static void
 _ao_button_init(uint8_t b)
 {
-       uint8_t m = ao_arch_irqsave();
+       uint32_t        m = ao_arch_irqsave();
        uint8_t value = _ao_button_get(b);
        ao_button_state[b].value = value;
        ao_button_state[b].time = ao_time();
index 1ebc0ea20bc9afcda54969bd3b944aebeee316cc..133f98036511735474d34a7079c67f74aee6a0a5 100644 (file)
@@ -69,12 +69,12 @@ ao_radio_reg_read(uint16_t addr)
                data[0] = ((1 << CC1120_READ)  |
                           (0 << CC1120_BURST) |
                           CC1120_EXTENDED);
-               data[1] = addr;
+               data[1] = (uint8_t) addr;
                d = 2;
        } else {
                data[0] = ((1 << CC1120_READ)  |
                           (0 << CC1120_BURST) |
-                          addr);
+                          (uint8_t) addr);
                d = 1;
        }
        ao_radio_select();
@@ -100,12 +100,12 @@ ao_radio_reg_write(uint16_t addr, uint8_t value)
                data[0] = ((0 << CC1120_READ)  |
                           (0 << CC1120_BURST) |
                           CC1120_EXTENDED);
-               data[1] = addr;
+               data[1] = (uint8_t) addr;
                d = 2;
        } else {
                data[0] = ((0 << CC1120_READ)  |
                           (0 << CC1120_BURST) |
-                          addr);
+                          (uint8_t) addr);
                d = 1;
        }
        data[d] = value;
@@ -127,7 +127,7 @@ _ao_radio_burst_read_start (uint16_t addr)
                addr |= ((1 << CC1120_READ)  |
                         (1 << CC1120_BURST));
        }
-       ao_radio_spi_send_byte(addr);
+       ao_radio_spi_send_byte((uint8_t) addr);
 }
 
 static void
@@ -614,7 +614,7 @@ _ao_radio_set_regs(const uint16_t *regs, int nreg)
        int i;
 
        for (i = 0; i < nreg; i++) {
-               ao_radio_reg_write(regs[0], regs[1]);
+               ao_radio_reg_write(regs[0], (uint8_t) regs[1]);
                regs += 2;
        }
 }
@@ -629,7 +629,7 @@ ao_radio_set_mode(uint16_t new_mode)
        if (new_mode == ao_radio_mode)
                return;
 
-       changes = new_mode & (~ao_radio_mode);
+       changes = (uint16_t) (new_mode & (~ao_radio_mode));
 
        if (changes & AO_RADIO_MODE_BITS_PACKET) {
                ao_radio_set_regs(packet_setup);
@@ -720,13 +720,13 @@ ao_radio_get(uint8_t len)
        if (!ao_radio_configured)
                ao_radio_setup();
        if (ao_config.radio_setting != last_radio_setting) {
-               ao_radio_reg_write(CC1120_FREQ2, ao_config.radio_setting >> 16);
-               ao_radio_reg_write(CC1120_FREQ1, ao_config.radio_setting >> 8);
-               ao_radio_reg_write(CC1120_FREQ0, ao_config.radio_setting);
+               ao_radio_reg_write(CC1120_FREQ2, (uint8_t) (ao_config.radio_setting >> 16));
+               ao_radio_reg_write(CC1120_FREQ1, (uint8_t) (ao_config.radio_setting >> 8));
+               ao_radio_reg_write(CC1120_FREQ0, (uint8_t) (ao_config.radio_setting));
                last_radio_setting = ao_config.radio_setting;
        }
        if (ao_config.radio_rate != last_radio_rate) {
-               ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET;
+               ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET;
                last_radio_rate = ao_config.radio_rate;
        }
        ao_radio_set_len(len);
@@ -807,7 +807,7 @@ ao_radio_test_cmd(void)
        static uint8_t radio_on;
        ao_cmd_white();
        if (ao_cmd_lex_c != '\n') {
-               mode = ao_cmd_decimal();
+               mode = (uint8_t) ao_cmd_decimal();
        }
        mode++;
        if ((mode & 2) && !radio_on) {
@@ -846,7 +846,7 @@ ao_radio_test_cmd(void)
 }
 
 static void
-ao_radio_wait_isr(uint16_t timeout)
+ao_radio_wait_isr(AO_TICK_TYPE timeout)
 {
        ao_arch_block_interrupts();
        while (!ao_radio_wake && !ao_radio_mcu_wake && !ao_radio_abort)
@@ -951,12 +951,12 @@ ao_radio_send_aprs(ao_radio_fill_func fill)
                }
 
                if (done) {
-                       ao_radio_set_len(total & 0xff);
+                       ao_radio_set_len((uint8_t) (total & 0xff));
                        ao_radio_set_mode(AO_RADIO_MODE_APRS_FINISH);
                } else
                        ao_radio_set_mode(AO_RADIO_MODE_APRS_BUF);
 
-               ao_radio_fifo_write(buf, cnt);
+               ao_radio_fifo_write(buf, (uint8_t) cnt);
 
                if (!started) {
                        ao_radio_start_tx();
@@ -1067,7 +1067,7 @@ ao_radio_rx_wait(void)
 }
 
 uint8_t
-ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, AO_TICK_TYPE timeout)
 {
        uint8_t         len;
        uint8_t         radio_rssi = 0;
@@ -1084,7 +1084,7 @@ ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
        rx_packet_tick = 0;
 #endif
        len = size + 2;                 /* CRC bytes */
-       len += 1 + ~(len & 1);          /* 1 or two pad bytes */
+       len += (uint8_t) (1 + ~(len & 1)); /* 1 or two pad bytes */
        len *= 2;                       /* 1/2 rate convolution */
        rx_data_count = len * 8;        /* bytes to bits */
        rx_data_cur = 0;
@@ -1158,7 +1158,7 @@ abort:
 
        rssi0 = ao_radio_reg_read(CC1120_RSSI0);
        if (rssi0 & 1) {
-               int8_t rssi = ao_radio_reg_read(CC1120_RSSI1);
+               int8_t rssi = (int8_t) ao_radio_reg_read(CC1120_RSSI1);
                ao_radio_rssi = rssi;
 
                /* Bound it to the representable range */
index 21a31a89d16f6c261373b597d03d4cbd25769a61..3552090beca8470d641d24a4848e311b420c2403 100644 (file)
@@ -66,7 +66,7 @@
        /* Carrier sense threshold - 25dB above the noise */\r
         CC1120_AGC_CS_THR,                     25,         /* Carrier Sense Threshold Configuration */\r
         CC1120_AGC_GAIN_ADJUST,                                   /* RSSI Offset Configuration */\r
-                AO_CC1120_AGC_GAIN_ADJUST,\r
+                (uint16_t) AO_CC1120_AGC_GAIN_ADJUST,\r
 \r
        CC1120_AGC_CFG3,                                   /* AGC Configuration */\r
                (1 << CC1120_AGC_CFG3_RSSI_STEP_THR) |\r
index dc8e9ff315ad303df49ee0b1ccc151767e8c842e..65ab576712043c84a49290af143dbf4d9212c66c 100644 (file)
@@ -449,22 +449,22 @@ ao_radio_set_mode(uint16_t new_mode)
        if (new_mode == ao_radio_mode)
                return;
 
-       changes = new_mode & (~ao_radio_mode);
+       changes = (uint16_t) (new_mode & (~ao_radio_mode));
        if (changes & AO_RADIO_MODE_BITS_PACKET_TX) {
                ao_radio_reg_write(CC115L_MDMCFG4, packet_rate_setup[ao_config.radio_rate].mdmcfg4);
                ao_radio_reg_write(CC115L_DEVIATN, packet_rate_setup[ao_config.radio_rate].deviatn);
 
                for (i = 0; i < sizeof (packet_setup) / sizeof (packet_setup[0]); i += 2)
-                       ao_radio_reg_write(packet_setup[i], packet_setup[i+1]);
+                       ao_radio_reg_write((uint8_t) packet_setup[i], (uint8_t) packet_setup[i+1]);
        }
 
        if (changes & AO_RADIO_MODE_BITS_RDF)
                for (i = 0; i < sizeof (rdf_setup) / sizeof (rdf_setup[0]); i += 2)
-                       ao_radio_reg_write(rdf_setup[i], rdf_setup[i+1]);
+                       ao_radio_reg_write((uint8_t) rdf_setup[i], (uint8_t) rdf_setup[i+1]);
 
        if (changes & AO_RADIO_MODE_BITS_APRS)
                for (i = 0; i < sizeof (aprs_setup) / sizeof (aprs_setup[0]); i += 2)
-                       ao_radio_reg_write(aprs_setup[i], aprs_setup[i+1]);
+                       ao_radio_reg_write((uint8_t) aprs_setup[i], (uint8_t) aprs_setup[i+1]);
 
        if (changes & AO_RADIO_MODE_BITS_INFINITE)
                ao_radio_reg_write(CC115L_PKTCTRL0, AO_PKTCTRL0_INFINITE);
@@ -536,7 +536,7 @@ ao_radio_setup(void)
        ao_delay(AO_MS_TO_TICKS(10));
 
        for (i = 0; i < sizeof (radio_setup) / sizeof (radio_setup[0]); i += 2)
-               ao_radio_reg_write(radio_setup[i], radio_setup[i+1]);
+               ao_radio_reg_write((uint8_t) radio_setup[i], (uint8_t) radio_setup[i+1]);
 
        ao_radio_mode = 0;
 
@@ -570,15 +570,15 @@ ao_radio_get(void)
        if (!ao_radio_configured)
                ao_radio_setup();
        if (ao_config.radio_setting != last_radio_setting) {
-               ao_radio_reg_write(CC115L_FREQ2, ao_config.radio_setting >> 16);
-               ao_radio_reg_write(CC115L_FREQ1, ao_config.radio_setting >> 8);
-               ao_radio_reg_write(CC115L_FREQ0, ao_config.radio_setting);
+               ao_radio_reg_write(CC115L_FREQ2, (uint8_t) (ao_config.radio_setting >> 16));
+               ao_radio_reg_write(CC115L_FREQ1, (uint8_t) (ao_config.radio_setting >> 8));
+               ao_radio_reg_write(CC115L_FREQ0, (uint8_t) (ao_config.radio_setting));
                last_radio_setting = ao_config.radio_setting;
                /* Make sure the RF calibration is current */
                ao_radio_strobe(CC115L_SCAL);
        }
        if (ao_config.radio_rate != last_radio_rate) {
-               ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET_TX;
+               ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET_TX;
                last_radio_rate = ao_config.radio_rate;
        }
 }
@@ -614,11 +614,11 @@ ao_radio_tone_fill(uint8_t *buf, int16_t len)
                        this_time = len;
 
                /* queue the data */
-               memset(buf, t->value, this_time);
+               memset(buf, t->value, (size_t) this_time);
 
                /* mark as sent */
                len -= this_time;
-               ao_radio_tone_offset += this_time;
+               ao_radio_tone_offset += (uint8_t) this_time;
                ret += this_time;
 
                if (ao_radio_tone_offset >= t->len) {
@@ -641,7 +641,7 @@ ao_radio_tone_run(struct ao_radio_tone *tones, int ntones)
        ao_radio_tone = tones;
        ao_radio_tone_current = 0;
        ao_radio_tone_offset = 0;
-       ao_radio_tone_count = ntones;
+       ao_radio_tone_count = (uint8_t) ntones;
        _ao_radio_send_lots(ao_radio_tone_fill, AO_RADIO_MODE_RDF);
        ao_radio_put();
 }
@@ -703,7 +703,7 @@ ao_radio_test_cmd(void)
        static uint8_t radio_on;
        ao_cmd_white();
        if (ao_cmd_lex_c != '\n')
-               mode = ao_cmd_decimal();
+               mode = (uint8_t) ao_cmd_decimal();
        mode++;
        if ((mode & 2) && !radio_on) {
 #if HAS_MONITOR
@@ -786,7 +786,7 @@ ao_radio_send_fill(uint8_t *buf, int16_t len)
        this_time = ao_radio_send_len;
        if (this_time > len)
                this_time = len;
-       memcpy(buf, ao_radio_send_buf, this_time);
+       memcpy(buf, ao_radio_send_buf, (size_t) this_time);
        ao_radio_send_buf += this_time;
        ao_radio_send_len -= this_time;
        if (ao_radio_send_len == 0)
@@ -834,7 +834,7 @@ _ao_radio_send_lots(ao_radio_fill_func fill, uint8_t mode)
 
                /* At the last buffer, set the total length */
                if (done) {
-                       ao_radio_set_len(total & 0xff);
+                       ao_radio_set_len((uint8_t) (total & 0xff));
                        ao_radio_set_mode(mode | AO_RADIO_MODE_BITS_FIXED);
                } else {
                        ao_radio_set_len(0xff);
@@ -843,7 +843,7 @@ _ao_radio_send_lots(ao_radio_fill_func fill, uint8_t mode)
 
                b = buf;
                while (cnt) {
-                       uint8_t this_len = cnt;
+                       uint8_t this_len = (uint8_t) cnt;
 
                        /* Wait for some space in the fifo */
                        while (!ao_radio_abort && (fifo_space = ao_radio_tx_fifo_space()) == 0) {
index 6f04380300c59c8547e2fd3e3f85cf811dc7d426..4ddc96ce09b2dec483e722ea4b03c77ac9858527 100644 (file)
@@ -75,12 +75,12 @@ ao_radio_reg_read(uint16_t addr)
                data[0] = ((1 << CC1200_READ)  |
                           (0 << CC1200_BURST) |
                           CC1200_EXTENDED);
-               data[1] = addr;
+               data[1] = (uint8_t) addr;
                d = 2;
        } else {
                data[0] = ((1 << CC1200_READ)  |
                           (0 << CC1200_BURST) |
-                          addr);
+                          (uint8_t) addr);
                d = 1;
        }
        ao_radio_select();
@@ -106,12 +106,12 @@ ao_radio_reg_write(uint16_t addr, uint8_t value)
                data[0] = ((0 << CC1200_READ)  |
                           (0 << CC1200_BURST) |
                           CC1200_EXTENDED);
-               data[1] = addr;
+               data[1] = (uint8_t) addr;
                d = 2;
        } else {
                data[0] = ((0 << CC1200_READ)  |
                           (0 << CC1200_BURST) |
-                          addr);
+                          (uint8_t) addr);
                d = 1;
        }
        data[d] = value;
@@ -598,7 +598,7 @@ _ao_radio_set_regs(const uint16_t *regs, int nreg)
        int i;
 
        for (i = 0; i < nreg; i++) {
-               ao_radio_reg_write(regs[0], regs[1]);
+               ao_radio_reg_write(regs[0], (uint8_t) regs[1]);
                regs += 2;
        }
 }
@@ -613,7 +613,7 @@ ao_radio_set_mode(uint16_t new_mode)
        if (new_mode == ao_radio_mode)
                return;
 
-       changes = new_mode & (~ao_radio_mode);
+       changes = (uint16_t) (new_mode & (~ao_radio_mode));
 
        if (changes & AO_RADIO_MODE_BITS_PACKET) {
                ao_radio_set_regs(packet_setup);
@@ -716,22 +716,35 @@ ao_radio_get(uint8_t len)
 {
        static uint32_t last_radio_setting;
        static uint8_t  last_radio_rate;
+       static uint8_t  last_radio_10mw;
 
        ao_mutex_get(&ao_radio_mutex);
 
        if (!ao_radio_configured)
                ao_radio_setup();
        if (ao_config.radio_setting != last_radio_setting) {
-               ao_radio_reg_write(CC1200_FREQ2, ao_config.radio_setting >> 16);
-               ao_radio_reg_write(CC1200_FREQ1, ao_config.radio_setting >> 8);
-               ao_radio_reg_write(CC1200_FREQ0, ao_config.radio_setting);
+               ao_radio_reg_write(CC1200_FREQ2, (uint8_t) (ao_config.radio_setting >> 16));
+               ao_radio_reg_write(CC1200_FREQ1, (uint8_t) (ao_config.radio_setting >> 8));
+               ao_radio_reg_write(CC1200_FREQ0, (uint8_t) ao_config.radio_setting);
                last_radio_setting = ao_config.radio_setting;
                ao_radio_strobe(CC1200_SCAL);
        }
        if (ao_config.radio_rate != last_radio_rate) {
-               ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET;
+               ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET;
                last_radio_rate = ao_config.radio_rate;
        }
+       if(ao_config.radio_10mw != last_radio_10mw) {
+               last_radio_10mw = ao_config.radio_10mw;
+               /*
+                * 0x37 "should" be 10dBm, but measurements on TBT
+                * v4.0 show that too hot, so use * 0x32 to make sure 
+                * we're in spec.
+                */
+               if (ao_config.radio_10mw)
+                       ao_radio_reg_write(CC1200_PA_CFG1, 0x32);
+               else
+                       ao_radio_reg_write(CC1200_PA_CFG1, 0x3f);
+       }
        ao_radio_set_len(len);
 }
 
@@ -759,7 +772,7 @@ ao_radio_show_state(char *where)
 /* Wait for the radio to signal an interrupt
  */
 static void
-ao_radio_wait_isr(uint16_t timeout)
+ao_radio_wait_isr(AO_TICK_TYPE timeout)
 {
        ao_arch_block_interrupts();
        while (!ao_radio_wake && !ao_radio_abort)
@@ -881,7 +894,7 @@ ao_radio_test_cmd(void)
        uint8_t mode = 2;
        ao_cmd_white();
        if (ao_cmd_lex_c != '\n')
-               mode = ao_cmd_decimal();
+               mode = (uint8_t) ao_cmd_decimal();
        mode++;
        if ((mode & 2))
                ao_radio_test_on();
@@ -927,7 +940,7 @@ ao_radio_send_aprs(ao_radio_fill_func fill)
 
                /* At the last buffer, set the total length */
                if (done)
-                       ao_radio_set_len(total & 0xff);
+                       ao_radio_set_len((uint8_t) (total & 0xff));
 
                /* Wait for some space in the fifo */
                while (started && ao_radio_int_pin() != 0 && !ao_radio_abort) {
@@ -943,7 +956,7 @@ ao_radio_send_aprs(ao_radio_fill_func fill)
                else
                        ao_radio_set_mode(AO_RADIO_MODE_APRS_BUF);
 
-               ao_radio_fifo_write(buf, cnt);
+               ao_radio_fifo_write(buf, (uint8_t) cnt);
                if (!started) {
                        ao_radio_strobe(CC1200_STX);
                        started = 1;
@@ -1008,7 +1021,7 @@ ao_radio_dump_state(struct ao_radio_state *s)
 #endif
 
 uint8_t
-ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, AO_TICK_TYPE timeout)
 {
        uint8_t success = 0;
 
@@ -1069,13 +1082,13 @@ ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
                                switch (ao_config.radio_rate) {
                                default:
                                case AO_RADIO_RATE_38400:
-                                       timeout = AO_MS_TO_TICKS(size * (8 * 2 * 10) / 384) + 1;
+                                       timeout = AO_MS_TO_TICKS((AO_TICK_TYPE) size * (8 * 2 * 10) / 384) + 1;
                                        break;
                                case AO_RADIO_RATE_9600:
-                                       timeout = AO_MS_TO_TICKS(size * (8 * 2 * 10) / 96) + 1;
+                                       timeout = AO_MS_TO_TICKS((AO_TICK_TYPE) size * (8 * 2 * 10) / 96) + 1;
                                        break;
                                case AO_RADIO_RATE_2400:
-                                       timeout = AO_MS_TO_TICKS(size * (8 * 2 * 10) / 24) + 1;
+                                       timeout = AO_MS_TO_TICKS((AO_TICK_TYPE) size * (8 * 2 * 10) / 24) + 1;
                                        break;
                                }
                        }
@@ -1096,7 +1109,7 @@ ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
                        rssi = -11;
 
                /* Write it back to the packet */
-               ((int8_t *) d)[size-2] = AO_RADIO_FROM_RSSI(rssi);
+               ((uint8_t *) d)[size-2] = AO_RADIO_FROM_RSSI(rssi);
        } else {
                ao_radio_idle();
                ao_radio_rssi = 0;
index f0214c2a25df1f8f80b244290baa59b92ede99e3..8c9db2e949ed9c468d6d21e6f74173256f2aafab 100644 (file)
@@ -55,7 +55,7 @@
         CC1200_AGC_REF,                      0x27,       /* AGC Reference Level Configuration */
         CC1200_AGC_CS_THR,                   0xec,       /* Carrier Sense Threshold Configuration */
        CC1200_AGC_GAIN_ADJUST,                          /* RSSI adjustment */
-               AO_CC1200_AGC_GAIN_ADJUST,
+               (uint16_t) AO_CC1200_AGC_GAIN_ADJUST,
         CC1200_AGC_CFG1,                     0x51,       /* Automatic Gain Control Configuration Reg. 1 */
         CC1200_AGC_CFG0,                     0x87,       /* Automatic Gain Control Configuration Reg. 0 */
         CC1200_FIFO_CFG,                     0x40,       /* FIFO Configuration */
index 093356a59981ecdea92b82927f3ac919f1a1facf..2315b63f43d5a87ad91ea095386da5d838f4e283 100644 (file)
@@ -55,12 +55,12 @@ ao_companion_send_command(uint8_t command)
 {
        ao_companion_command.command = command;
        ao_companion_command.flight_state = ao_flight_state;
-       ao_companion_command.tick = ao_time();
+       ao_companion_command.tick = (uint16_t) ao_time();
        ao_companion_command.serial = ao_serial_number;
        ao_companion_command.flight = ao_flight_number;
-       ao_companion_command.accel = ao_accel;
-       ao_companion_command.speed = ao_speed;
-       ao_companion_command.height = ao_height;
+       ao_companion_command.accel = (int16_t) ao_accel;
+       ao_companion_command.speed = (int16_t) ao_speed;
+       ao_companion_command.height = (int16_t) ao_height;
        ao_companion_command.motor_number = ao_motor_number;
        ao_spi_send(&ao_companion_command, sizeof (ao_companion_command), AO_COMPANION_SPI_BUS);
 }
index d90141b693910d9db54fc67a666a34977fa1236f..3a253eea69559fb19731824c46866995e5b75baa 100644 (file)
@@ -126,7 +126,7 @@ ao_gps_decimal(uint8_t max_width)
                uint8_t c = ao_gps_char;
                if (c < (uint8_t) '0' || (uint8_t) '9' < c)
                        break;
-               v = v * 10 + (uint8_t) (c - (uint8_t) '0');
+               v = (int16_t) (v * 10 + (uint8_t) (c - (uint8_t) '0'));
                ao_gps_num_width++;
                ao_gps_lexchar();
        }
@@ -145,16 +145,15 @@ ao_gps_hex(void)
        ao_gps_num_width = 0;
        while (ao_gps_num_width < 2) {
                uint8_t c = ao_gps_char;
-               uint8_t d;
                if ((uint8_t) '0' <= c && c <= (uint8_t) '9')
-                       d = - '0';
+                       c -= '0';
                else if ((uint8_t) 'A' <= c && c <= (uint8_t) 'F')
-                       d = - 'A' + 10;
+                       c -= 'A' - 10;
                else if ((uint8_t) 'a' <= c && c <= (uint8_t) 'f')
-                       d = - 'a' + 10;
+                       c -= 'a' - 10;
                else
                        break;
-               v = (v << 4) | (c + d);
+               v = (uint8_t) ((v << 4) | c);
                ao_gps_num_width++;
                ao_gps_lexchar();
        }
@@ -164,9 +163,9 @@ ao_gps_hex(void)
 static int32_t
 ao_gps_parse_pos(uint8_t deg_width) 
 {
-       static uint16_t d;
-       static uint8_t  m;
-       static uint16_t f;
+       int16_t         d;
+       int16_t         m;
+       int16_t         f;
        char c;
 
        d = ao_gps_decimal(deg_width);
@@ -256,9 +255,9 @@ ao_nmea_gga(void)
 
        ao_gps_next_tick = ao_time();
        ao_gps_next.flags = AO_GPS_RUNNING | ao_gps_date_flags;
-       ao_gps_next.hour = ao_gps_decimal(2);
-       ao_gps_next.minute = ao_gps_decimal(2);
-       ao_gps_next.second = ao_gps_decimal(2);
+       ao_gps_next.hour = (uint8_t) ao_gps_decimal(2);
+       ao_gps_next.minute = (uint8_t) ao_gps_decimal(2);
+       ao_gps_next.second = (uint8_t) ao_gps_decimal(2);
        ao_gps_skip_field();    /* skip seconds fraction */
 
        ao_gps_next.latitude = ao_gps_parse_pos(2);
@@ -268,17 +267,17 @@ ao_nmea_gga(void)
        if (ao_gps_parse_flag('E', 'W'))
                ao_gps_next.longitude = -ao_gps_next.longitude;
 
-       i = ao_gps_decimal(0xff);
+       i = (uint8_t) ao_gps_decimal(0xff);
        if (i == 1)
                ao_gps_next.flags |= AO_GPS_VALID;
 
-       i = ao_gps_decimal(0xff) << AO_GPS_NUM_SAT_SHIFT;
+       i = (uint8_t) (ao_gps_decimal(0xff) << AO_GPS_NUM_SAT_SHIFT);
        if (i > AO_GPS_NUM_SAT_MASK)
                i = AO_GPS_NUM_SAT_MASK;
        ao_gps_next.flags |= i;
 
        ao_gps_lexchar();
-       i = ao_gps_decimal(0xff);
+       i = (uint8_t) ao_gps_decimal(0xff);
        if (i <= 25) {
                i = (uint8_t) 10 * i;
                if (ao_gps_char == '.')
@@ -307,7 +306,7 @@ ao_nmea_gga(void)
 static void
 ao_nmea_gsv(void)
 {
-       char    c;
+       uint8_t c;
        uint8_t i;
        uint8_t done;
        /* Now read the data into the GPS tracking data record
@@ -326,8 +325,8 @@ ao_nmea_gsv(void)
         *      ...             other SVIDs
         *      72              checksum
         */
-       c = ao_gps_decimal(1);  /* total messages */
-       i = ao_gps_decimal(1);  /* message sequence */
+       c = (uint8_t) ao_gps_decimal(1);        /* total messages */
+       i = (uint8_t) ao_gps_decimal(1);        /* message sequence */
        if (i == 1) {
                ao_gps_tracking_next.channels = 0;
        }
@@ -336,14 +335,14 @@ ao_nmea_gsv(void)
        ao_gps_skip_field();    /* sats in view */
        while (ao_gps_char != '*' && ao_gps_char != '\n' && ao_gps_char != '\r') {
                i = ao_gps_tracking_next.channels;
-               c = ao_gps_decimal(2);  /* SVID */
+               c = (uint8_t) ao_gps_decimal(2);        /* SVID */
                if (i < AO_MAX_GPS_TRACKING)
                        ao_gps_tracking_next.sats[i].svid = c;
                ao_gps_lexchar();
                ao_gps_skip_field();    /* elevation */
                ao_gps_lexchar();
                ao_gps_skip_field();    /* azimuth */
-               c = ao_gps_decimal(2);  /* C/N0 */
+               c = (uint8_t) ao_gps_decimal(2);        /* C/N0 */
                if (i < AO_MAX_GPS_TRACKING) {
                        if ((ao_gps_tracking_next.sats[i].c_n_1 = c) != 0)
                                ao_gps_tracking_next.channels = i + 1;
@@ -366,7 +365,7 @@ ao_nmea_gsv(void)
 static void
 ao_nmea_rmc(void)
 {
-       char    a, c;
+       uint8_t a, c;
        uint8_t i;
        /* Parse the RMC record to read out the current date */
 
@@ -397,9 +396,9 @@ ao_nmea_rmc(void)
                ao_gps_lexchar();
                ao_gps_skip_field();
        }
-       a = ao_gps_decimal(2);
-       c = ao_gps_decimal(2);
-       i = ao_gps_decimal(2);
+       a = (uint8_t) ao_gps_decimal(2);
+       c = (uint8_t) ao_gps_decimal(2);
+       i = (uint8_t) ao_gps_decimal(2);
 
        ao_nmea_finish();
 
index 2556d314547b08cd91a2a3971bf0166a7697a5ff..57cbf22a77b50245975955925096ba85ac9723f5 100644 (file)
@@ -115,8 +115,8 @@ static void ao_ublox_put_i8(int8_t c)
 
 static void ao_ublox_put_u16(uint16_t c)
 {
-       ao_ublox_put_u8(c);
-       ao_ublox_put_u8(c>>8);
+       ao_ublox_put_u8((uint8_t) c);
+       ao_ublox_put_u8((uint8_t) (c>>8));
 }
 
 #if 0
@@ -128,10 +128,10 @@ static void ao_ublox_put_i16(int16_t c)
 
 static void ao_ublox_put_u32(uint32_t c)
 {
-       ao_ublox_put_u8(c);
-       ao_ublox_put_u8(c>>8);
-       ao_ublox_put_u8(c>>16);
-       ao_ublox_put_u8(c>>24);
+       ao_ublox_put_u8((uint8_t) c);
+       ao_ublox_put_u8((uint8_t) (c>>8));
+       ao_ublox_put_u8((uint8_t) (c>>16));
+       ao_ublox_put_u8((uint8_t) (c>>24));
 }
 
 static void ao_ublox_put_i32(int32_t c)
@@ -160,7 +160,7 @@ static void ublox_u16(uint8_t offset)
        uint16_t val;
 
        val = data_byte();
-       val |= data_byte () << 8;
+       val |= (uint16_t) ((uint16_t) data_byte () << 8);
        *ptr = val;
 }
 
@@ -515,8 +515,8 @@ ao_ublox_putstart(uint8_t class, uint8_t id, uint16_t len)
        ao_gps_putchar(0x62);
        ao_ublox_put_u8(class);
        ao_ublox_put_u8(id);
-       ao_ublox_put_u8(len);
-       ao_ublox_put_u8(len >> 8);
+       ao_ublox_put_u8((uint8_t) len);
+       ao_ublox_put_u8((uint8_t) (len >> 8));
 }
 
 static void
@@ -659,7 +659,7 @@ ao_gps(void)
 
                /* Length */
                ao_ublox_len = header_byte();
-               ao_ublox_len |= header_byte() << 8;
+               ao_ublox_len |= (uint16_t) ((uint16_t) header_byte() << 8);
 
                ao_gps_dbg(DBG_PROTO, "%6u class %02x id %02x len %d\n", packet_start_tick, class, id, ao_ublox_len);
 
@@ -738,7 +738,7 @@ ao_gps(void)
                                ao_gps_data.latitude = nav_posllh.lat;
                                ao_gps_data.longitude = nav_posllh.lon;
 
-                               ao_gps_data.year = nav_timeutc.year - 2000;
+                               ao_gps_data.year = (uint8_t) (nav_timeutc.year - 2000);
                                ao_gps_data.month = nav_timeutc.month;
                                ao_gps_data.day = nav_timeutc.day;
 
@@ -748,13 +748,13 @@ ao_gps(void)
 
                                /* we report dop scaled by 10, but ublox provides dop scaled by 100
                                 */
-                               ao_gps_data.pdop = nav_dop.pdop / 10;
-                               ao_gps_data.hdop = nav_dop.hdop / 10;
-                               ao_gps_data.vdop = nav_dop.vdop / 10;
+                               ao_gps_data.pdop = (uint8_t) (nav_dop.pdop / 10);
+                               ao_gps_data.hdop = (uint8_t) (nav_dop.hdop / 10);
+                               ao_gps_data.vdop = (uint8_t) (nav_dop.vdop / 10);
 
-                               ao_gps_data.ground_speed = nav_velned.g_speed;
-                               ao_gps_data.climb_rate = -nav_velned.vel_d;
-                               ao_gps_data.course = nav_velned.heading / 200000;
+                               ao_gps_data.ground_speed = (uint16_t) nav_velned.g_speed;
+                               ao_gps_data.climb_rate = -(int16_t) nav_velned.vel_d;
+                               ao_gps_data.course = (uint8_t) (nav_velned.heading / 200000);
 
                                ao_gps_tracking_data.channels = 0;
 
index 55a193ac5adb58236acb51be0e3a3f9eb78fe5e5..fc339334c51889181cae88d37f80bf33a20ef3f6 100644 (file)
@@ -87,7 +87,7 @@ ao_hmc5883_sample(struct ao_hmc5883_sample *sample)
        /* byte swap */
        while (i--) {
                uint16_t        t = *d;
-               *d++ = (t >> 8) | (t << 8);
+               *d++ = (uint16_t) ((t >> 8) | (t << 8));
        }
 #endif
 }
index 2cb885cfc336996f7b5a3e56e4686ed48ed26c8a..bc8f7b48f7788949ba6ea1cdcb4314b19dddb668 100644 (file)
@@ -46,7 +46,7 @@ void
 ao_lco_show_pad(uint8_t pad)
 {
        ao_mutex_get(&ao_lco_display_mutex);
-       ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad | (ao_lco_drag_race << 4));
+       ao_seven_segment_set(AO_LCO_PAD_DIGIT, (uint8_t) (pad | (ao_lco_drag_race << 4)));
        ao_mutex_put(&ao_lco_display_mutex);
 }
 
@@ -72,11 +72,11 @@ ao_lco_show_box(uint16_t box)
 {
        ao_mutex_get(&ao_lco_display_mutex);
        if (box == AO_LCO_BOX_DRAG) {
-               ao_seven_segment_direct(AO_LCO_BOX_DIGIT_10, SEVEN_SEGMENT_d | (ao_lco_drag_race << 7));
-               ao_seven_segment_direct(AO_LCO_BOX_DIGIT_1, SEVEN_SEGMENT_r | (ao_lco_drag_race << 7));
+               ao_seven_segment_direct(AO_LCO_BOX_DIGIT_10, (uint8_t) (SEVEN_SEGMENT_d | (ao_lco_drag_race << 7)));
+               ao_seven_segment_direct(AO_LCO_BOX_DIGIT_1, (uint8_t) (SEVEN_SEGMENT_r | (ao_lco_drag_race << 7)));
        } else {
-               ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, box % 10 | (ao_lco_drag_race << 4));
-               ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10 | (ao_lco_drag_race << 4));
+               ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, (uint8_t) (box % 10 | (ao_lco_drag_race << 4)));
+               ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, (uint8_t) (box / 10 | (ao_lco_drag_race << 4)));
        }
        ao_mutex_put(&ao_lco_display_mutex);
 }
@@ -86,9 +86,9 @@ ao_lco_show_voltage(uint16_t decivolts)
 {
        uint8_t tens, ones, tenths;
 
-       tenths = decivolts % 10;
-       ones = (decivolts / 10) % 10;
-       tens = (decivolts / 100) % 10;
+       tenths = (uint8_t) (decivolts % 10);
+       ones = (uint8_t) ((decivolts / 10) % 10);
+       tens = (uint8_t) ((decivolts / 100) % 10);
        ao_mutex_get(&ao_lco_display_mutex);
        ao_seven_segment_set(AO_LCO_PAD_DIGIT, tenths);
        ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ones | 0x10);
@@ -127,7 +127,7 @@ static uint8_t              ao_lco_drag_active;
 static AO_TICK_TYPE
 ao_lco_drag_button_check(AO_TICK_TYPE now, AO_TICK_TYPE delay)
 {
-       AO_TICK_TYPE    button_delay = ~0;
+       AO_TICK_TYPE    button_delay = ~0UL;
 
        /*
         * Check to see if the button has been held down long enough
@@ -135,14 +135,14 @@ ao_lco_drag_button_check(AO_TICK_TYPE now, AO_TICK_TYPE delay)
         */
        if (ao_lco_fire_down) {
                if (ao_lco_drag_race) {
-                       if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= AO_LCO_DRAG_RACE_STOP_TIME) {
+                       if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= (AO_TICK_SIGNED) AO_LCO_DRAG_RACE_STOP_TIME) {
                                ao_lco_drag_disable();
                                ao_lco_fire_down = 0;
                        }
                        else
                                button_delay = ao_lco_fire_tick + AO_LCO_DRAG_RACE_STOP_TIME - now;
                } else {
-                       if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= AO_LCO_DRAG_RACE_START_TIME) {
+                       if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= (AO_TICK_SIGNED) AO_LCO_DRAG_RACE_START_TIME) {
                                ao_lco_drag_enable();
                                ao_lco_fire_down = 0;
                        }
@@ -158,7 +158,7 @@ ao_lco_drag_button_check(AO_TICK_TYPE now, AO_TICK_TYPE delay)
 static void
 ao_lco_drag_monitor(void)
 {
-       AO_TICK_TYPE    delay = ~0;
+       AO_TICK_TYPE    delay = ~0UL;
        AO_TICK_TYPE    now;
 
        ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
@@ -170,7 +170,7 @@ ao_lco_drag_monitor(void)
                else
                        ao_sleep_for(&ao_lco_drag_beep_count, delay);
 
-               delay = ~0;
+               delay = ~0UL;
                if (!ao_lco_drag_active)
                        continue;
 
@@ -181,7 +181,7 @@ ao_lco_drag_monitor(void)
 
                /* check to see if there's anything left to do here */
                if (!ao_lco_fire_down && !ao_lco_drag_race && !ao_lco_drag_beep_count) {
-                       delay = ~0;
+                       delay = ~0UL;
                        ao_lco_drag_active = 0;
                }
        }
@@ -190,7 +190,7 @@ ao_lco_drag_monitor(void)
 static void
 ao_lco_step_box(int8_t dir)
 {
-       int16_t new_box = ao_lco_box;
+       int32_t new_box = (int32_t) ao_lco_box;
        do {
                if (new_box == AO_LCO_BOX_DRAG) {
                        if (dir < 0)
@@ -204,10 +204,10 @@ ao_lco_step_box(int8_t dir)
                        else if (new_box < ao_lco_min_box)
                                new_box = AO_LCO_BOX_DRAG;
                }
-               if (new_box == ao_lco_box)
+               if (new_box == (int32_t) ao_lco_box)
                        break;
-       } while (!ao_lco_box_present(new_box));
-       ao_lco_set_box(new_box);
+       } while (!ao_lco_box_present((uint16_t) new_box));
+       ao_lco_set_box((uint16_t) new_box);
 }
 
 static void
@@ -235,12 +235,12 @@ ao_lco_input(void)
                case AO_EVENT_BUTTON:
                        switch (event.unit) {
                        case AO_BUTTON_ARM:
-                               ao_lco_set_armed(event.value);
+                               ao_lco_set_armed((uint8_t) event.value);
                                break;
                        case AO_BUTTON_FIRE:
                                if (ao_lco_armed) {
                                        ao_lco_fire_down = 0;
-                                       ao_lco_set_firing(event.value);
+                                       ao_lco_set_firing((uint8_t) event.value);
                                } else {
                                        if (event.value) {
                                                if (ao_lco_box == AO_LCO_BOX_DRAG) {
@@ -290,7 +290,7 @@ ao_lco_batt_voltage(void)
 
        ao_adc_single_get(&packet);
        decivolt = ao_battery_decivolt(packet.v_batt);
-       ao_lco_show_voltage(decivolt);
+       ao_lco_show_voltage((uint16_t) decivolt);
        ao_delay(AO_MS_TO_TICKS(1000));
 }
 #endif
@@ -319,7 +319,7 @@ ao_lco_main(void)
 static void
 ao_lco_set_debug(void)
 {
-       uint16_t r  = ao_cmd_decimal();
+       uint32_t r  = ao_cmd_decimal();
        if (ao_cmd_status == ao_cmd_success)
                ao_lco_debug = r != 0;
 }
index 452092a092df80a4aa940e27f3b623977b5a1020..65e9a8c9cb76c4a70a6650eb7145a75682056885 100644 (file)
@@ -39,7 +39,7 @@ extern uint8_t        ao_lco_drag_race;       /* true when drag race mode enabled */
 #endif
 
 extern uint8_t ao_lco_pad;             /* Currently selected pad */
-extern int16_t ao_lco_box;             /* Currently selected box */
+extern uint16_t        ao_lco_box;             /* Currently selected box */
 
 extern uint8_t ao_lco_armed;           /* armed mode active */
 extern uint8_t ao_lco_firing;          /* fire button pressed */
@@ -48,7 +48,7 @@ extern struct ao_pad_query    ao_pad_query;   /* Last received QUERY from pad */
 
 #define AO_LCO_PAD_VOLTAGE     0               /* Pad number to show box voltage */
 
-extern uint8_t ao_lco_min_box, ao_lco_max_box;
+extern uint16_t        ao_lco_min_box, ao_lco_max_box;
 
 #define AO_LCO_MASK_SIZE(n)    (((n) + 7) >> 3)
 #define AO_LCO_MASK_ID(n)      ((n) >> 3)
@@ -67,10 +67,10 @@ void
 ao_lco_update(void);
 
 uint8_t
-ao_lco_pad_present(uint8_t box, uint8_t pad);
+ao_lco_pad_present(uint16_t box, uint8_t pad);
 
 uint8_t
-ao_lco_pad_first(uint8_t box);
+ao_lco_pad_first(uint16_t box);
 
 void
 ao_lco_set_pad(uint8_t new_pad);
index b97662a0b29fd1eda6423eb5d1092b7b5300a8d3..c88170b8c91dec772d36747715b955978d502de0 100644 (file)
 uint8_t                ao_lco_debug;
 
 uint8_t                ao_lco_pad;
-int16_t                ao_lco_box;
+uint16_t       ao_lco_box;
 
 uint8_t                ao_lco_armed;                                   /* arm active */
 uint8_t                ao_lco_firing;                                  /* fire active */
 
-uint8_t                ao_lco_min_box, ao_lco_max_box;
+uint16_t       ao_lco_min_box, ao_lco_max_box;
 
 #if AO_LCO_DRAG
 uint8_t                ao_lco_drag_race;
@@ -136,7 +136,7 @@ ao_lco_igniter_status(void)
 }
 
 uint8_t
-ao_lco_pad_present(uint8_t box, uint8_t pad)
+ao_lco_pad_present(uint16_t box, uint8_t pad)
 {
        /* voltage measurement is always valid */
        if (pad == AO_LCO_PAD_VOLTAGE)
@@ -149,7 +149,7 @@ ao_lco_pad_present(uint8_t box, uint8_t pad)
 }
 
 uint8_t
-ao_lco_pad_first(uint8_t box)
+ao_lco_pad_first(uint16_t box)
 {
        uint8_t pad;
 
@@ -160,7 +160,7 @@ ao_lco_pad_first(uint8_t box)
 }
 
 static uint8_t
-ao_lco_get_channels(uint8_t box, struct ao_pad_query *query)
+ao_lco_get_channels(uint16_t box, struct ao_pad_query *query)
 {
        int8_t                  r;
 
@@ -169,7 +169,7 @@ ao_lco_get_channels(uint8_t box, struct ao_pad_query *query)
                ao_lco_channels[box] = query->channels;
                ao_lco_valid[box] = AO_LCO_VALID_LAST | AO_LCO_VALID_EVER;
        } else
-               ao_lco_valid[box] &= ~AO_LCO_VALID_LAST;
+               ao_lco_valid[box] &= (uint8_t) ~AO_LCO_VALID_LAST;
        PRINTD("ao_lco_get_channels(%d) rssi %d valid %d ret %d offset %d\n", box, ao_radio_cmac_rssi, ao_lco_valid[box], r, ao_lco_tick_offset[box]);
        ao_wakeup(&ao_pad_query);
        return ao_lco_valid[box];
@@ -201,7 +201,7 @@ ao_lco_box_reset_present(void)
 }
 
 static void
-ao_lco_box_set_present(uint8_t box)
+ao_lco_box_set_present(uint16_t box)
 {
        if (box < ao_lco_min_box)
                ao_lco_min_box = box;
@@ -209,7 +209,7 @@ ao_lco_box_set_present(uint8_t box)
                ao_lco_max_box = box;
        if (box >= AO_PAD_MAX_BOXES)
                return;
-       ao_lco_box_mask[AO_LCO_MASK_ID(box)] |= 1 << AO_LCO_MASK_SHIFT(box);
+       ao_lco_box_mask[AO_LCO_MASK_ID(box)] |= (uint8_t) (1 << AO_LCO_MASK_SHIFT(box));
 }
 
 void
@@ -232,9 +232,9 @@ ao_lco_set_box(uint16_t new_box)
 void
 ao_lco_step_pad(int8_t dir)
 {
-       int8_t  new_pad;
+       int16_t new_pad;
 
-       new_pad = ao_lco_pad;
+       new_pad = (int16_t) ao_lco_pad;
        do {
                new_pad += dir;
                if (new_pad > AO_PAD_MAX_CHANNELS)
@@ -243,8 +243,8 @@ ao_lco_step_pad(int8_t dir)
                        new_pad = AO_PAD_MAX_CHANNELS;
                if (new_pad == ao_lco_pad)
                        break;
-       } while (!ao_lco_pad_present(ao_lco_box, new_pad));
-       ao_lco_set_pad(new_pad);
+       } while (!ao_lco_pad_present(ao_lco_box, (uint8_t) new_pad));
+       ao_lco_set_pad((uint8_t) new_pad);
 }
 
 void
@@ -255,7 +255,7 @@ ao_lco_set_armed(uint8_t armed)
        if (ao_lco_armed) {
 #if AO_LCO_DRAG
                if (ao_lco_drag_race) {
-                       uint8_t box;
+                       uint16_t        box;
 
                        for (box = ao_lco_min_box; box <= ao_lco_max_box; box++)
                                if (ao_lco_selected[box])
@@ -323,7 +323,7 @@ void
 ao_lco_monitor(void)
 {
        AO_TICK_TYPE            delay;
-       uint8_t                 box;
+       uint16_t                box;
 
        for (;;) {
                PRINTD("monitor armed %d firing %d\n",
@@ -380,7 +380,7 @@ void
 ao_lco_toggle_drag(void)
 {
        if (ao_lco_drag_race && ao_lco_pad != AO_LCO_PAD_VOLTAGE) {
-               ao_lco_selected[ao_lco_box] ^= (1 << (ao_lco_pad - 1));
+               ao_lco_selected[ao_lco_box] ^= (uint8_t) (1 << (ao_lco_pad - 1));
                PRINTD("Toggle box %d pad %d (pads now %x) to drag race\n",
                       ao_lco_pad, ao_lco_box, ao_lco_selected[ao_lco_box]);
                ao_lco_drag_add_beeps(ao_lco_pad);
index 0184363533390736f2e831f829285e8a83e6e676..391b4547560bc69a8950cf15dad8448c21548bf8 100644 (file)
@@ -32,8 +32,8 @@ static uint8_t        lco_channels;
 static void
 lco_args(void) 
 {
-       lco_box = ao_cmd_decimal();
-       lco_channels = ao_cmd_hex();
+       lco_box = (uint16_t) ao_cmd_decimal();
+       lco_channels = (uint8_t) ao_cmd_hex();
 }
 
 static struct ao_pad_query     ao_pad_query;
@@ -126,7 +126,7 @@ lco_fire_cmd(void)
        int8_t          r;
 
        lco_args();
-       secs = ao_cmd_decimal();
+       secs = (uint8_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        r = lco_query();
@@ -140,7 +140,7 @@ lco_fire_cmd(void)
                lco_arm();
        }
 
-       secs = secs * 10 - 5;
+       secs = (uint8_t) (secs * 10 - 5);
        if (secs > 100)
                secs = 100;
        for (i = 0; i < secs; i++) {
@@ -159,7 +159,7 @@ lco_static_cmd(void)
        int8_t          r;
 
        lco_args();
-       secs = ao_cmd_decimal();
+       secs = (uint8_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        r = lco_query();
@@ -173,7 +173,7 @@ lco_static_cmd(void)
                lco_arm();
        }
 
-       secs = secs * 10 - 5;
+       secs = (uint8_t) (secs * 10 - 5);
        if (secs > 100)
                secs = 100;
        for (i = 0; i < secs; i++) {
index 1960683fa6b214a56cd7fd87800cd1a7c6e7562d..5aacd0e48c3f51dd52d81fb1e75e15cff0bd4693 100644 (file)
@@ -45,7 +45,7 @@ ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset)
        }
 #endif
        ao_mutex_get(&ao_lco_mutex);
-       command.tick = ao_time();
+       command.tick = (uint16_t) ao_time();
        command.box = box;
        command.cmd = AO_PAD_QUERY;
        command.channels = 0;
@@ -53,7 +53,7 @@ ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset)
        sent_time = ao_time();
        r = ao_radio_cmac_recv(query, sizeof (*query), timeout);
        if (r == AO_RADIO_CMAC_OK)
-               *tick_offset = sent_time - query->tick;
+               *tick_offset = (uint16_t) sent_time - query->tick;
        ao_mutex_put(&ao_lco_mutex);
        return r;
 }
index 8d4476efdbe08c1c4f6ff6185ff2e5f8b591be5b..0eb90080acb76dae8d288b8fe466d6d39b06ab32 100644 (file)
@@ -85,15 +85,15 @@ ao_lco_input(void)
                case AO_EVENT_BUTTON:
                        switch (event.unit) {
                        case AO_BUTTON_BOX:
-                               ao_lco_set_box(event.value);
+                               ao_lco_set_box((uint16_t) event.value);
                                ao_lco_set_armed(0);
                                break;
                        case AO_BUTTON_ARM:
-                               ao_lco_set_armed(event.value);
+                               ao_lco_set_armed((uint8_t) event.value);
                                break;
                        case AO_BUTTON_FIRE:
                                if (ao_lco_armed)
-                                       ao_lco_set_firing(event.value);
+                                       ao_lco_set_firing((uint8_t) event.value);
                                break;
                        }
                        break;
@@ -114,9 +114,9 @@ ao_lco_main(void)
        ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input");
        ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn");
        ao_add_task(&ao_lco_igniter_status_task, ao_lco_igniter_status, "lco igniter status");
-       ao_led_on(~0);
+       ao_led_on((uint16_t) ~0);
        ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
-       ao_led_off(~0);
+       ao_led_off((uint16_t) ~0);
        ao_lco_monitor();
 }
 
@@ -124,9 +124,9 @@ ao_lco_main(void)
 static void
 ao_lco_set_debug(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status == ao_cmd_success)
-               ao_lco_debug = r;
+               ao_lco_debug = r != 0;
 }
 
 const struct ao_cmds ao_lco_cmds[] = {
index 2e4cbedf989d23991c54245b6a6a18d392e2d1b1..accf943a3fbe6e079ad0825b21f53d08823828fb 100644 (file)
@@ -125,7 +125,7 @@ ao_m25_wait_wip(ao_port_t cs)
                        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;
        }
 }
 
@@ -192,9 +192,9 @@ ao_m25_set_address(uint32_t pos)
 #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;
 }
 
index 7736a0f89c4889d49cb3a86a31667fb226d56794..3fd8e064602bc092f00319c2a3878c3b65f0fc80 100644 (file)
@@ -89,7 +89,7 @@ ao_mma655x_reg_read(uint8_t addr)
 {
        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();
@@ -110,13 +110,11 @@ ao_mma655x_reg_write(uint8_t addr, uint8_t value)
 
        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
@@ -143,8 +141,8 @@ ao_mma655x_value(void)
        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;
 }
 
@@ -225,7 +223,7 @@ ao_mma655x_setup(void)
 
                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);
 
index 4dd4a598c2c0ba04a3df2471e89c9b9af49f4e66..73e30d0390bde6e3cb8fc82b419c5a456d2b3fa8 100644 (file)
@@ -141,7 +141,7 @@ sat_sub(int16_t a, int16_t b)
                v = -32768;
        if (v > 32767)
                v = 32767;
-       return v;
+       return (int16_t) v;
 }
 
 /* Wait for a synchronous sample to finish */
@@ -179,9 +179,9 @@ ao_mmc5983_sample(struct ao_mmc5983_sample *s)
        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 */
@@ -217,9 +217,9 @@ ao_mmc5983_cal(void)
        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 */
index 79658c552bf2e38b7c917d287523f148df86d271..c33032af7e5dc017e363b19171a585eb62e0f76a 100644 (file)
@@ -113,7 +113,7 @@ _ao_mpu6000_sample(struct ao_mpu6000_sample *sample)
        /* byte swap */
        while (i--) {
                uint16_t        t = *d;
-               *d++ = (t >> 8) | (t << 8);
+               *d++ = (uint16_t) ((t >> 8) | (t << 8));
        }
 #endif
 }
index 09b65bfa749c8cd7de7b1e5f6ff712d5cc602c74..a77abf98dfe7bcfa2d6ce3b8267b1571dd7d642b 100644 (file)
@@ -176,7 +176,7 @@ _ao_mpu9250_sample(struct ao_mpu9250_sample *sample)
        /* 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
 }
index c5e733a46e6bf4dacca71dd40ba9e581cd745d90..f73b095622cd5a4eccf9f1d0b7e28a7ade50caf7 100644 (file)
@@ -59,17 +59,17 @@ ao_ms5607_crc(uint8_t *prom)
 
        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
index 322cc4684a292ddba5bf9e9cc667b1a38237f06a..02350bb0cbf5977a05cc5a3fa141216b24cfdbf6 100644 (file)
@@ -34,7 +34,7 @@
 #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;
index 0e96f60bbff3284e21edd6f78dd03c5cb28a87f7..a7c2fbc26e0099e5521a159c8c27334f6a4fa951 100644 (file)
@@ -26,9 +26,9 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value
        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);
@@ -39,7 +39,7 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value
 #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;
@@ -57,6 +57,6 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value
                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;
 }
index a44b34cf0acdd84cd0905f745066dec630f6a08b..688ab6db557db23a3140b329c409ac8647ea1bfd 100644 (file)
@@ -45,14 +45,14 @@ ao_packet_echo(void)
        while (ao_packet_enable) {
                c = ao_packet_getchar();
                if (c != AO_READ_AGAIN)
-                       putchar(c);
+                       putchar((char) c);
        }
        ao_exit();
 }
 
 static struct ao_task  ao_packet_echo_task;
-static uint16_t                ao_packet_master_delay;
-static uint16_t                ao_packet_master_time;
+static AO_TICK_TYPE    ao_packet_master_delay;
+static AO_TICK_TYPE    ao_packet_master_time;
 
 #define AO_PACKET_MASTER_DELAY_SHORT   AO_MS_TO_TICKS(100)
 #define AO_PACKET_MASTER_DELAY_LONG    AO_MS_TO_TICKS(1000)
@@ -74,10 +74,10 @@ ao_packet_master_busy(void)
 static void
 ao_packet_master_check_busy(void)
 {
-       int16_t idle;
+       AO_TICK_SIGNED  idle;
        if (ao_packet_master_delay != AO_PACKET_MASTER_DELAY_SHORT)
                return;
-       idle = (int16_t) (ao_time() - ao_packet_master_time);
+       idle = (AO_TICK_SIGNED) (ao_time() - ao_packet_master_time);
 
        if (idle > AO_PACKET_MASTER_DELAY_TIMEOUT)
                ao_packet_master_delay = AO_PACKET_MASTER_DELAY_LONG;
@@ -87,7 +87,7 @@ static void
 ao_packet_master(void)
 {
        ao_config_get();
-       ao_tx_packet.addr = ao_serial_number;
+       ao_tx_packet.addr = (uint8_t) ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
        ao_packet_master_time = ao_time();
        ao_packet_master_delay = AO_PACKET_MASTER_DELAY_SHORT;
index 314ce14a2bc3866406e54c9306eefc842ec307b0..74b6d296d1fc45ab626238a3b7c08c830d0bd0d2 100644 (file)
@@ -21,7 +21,7 @@
 static void
 ao_packet_slave(void)
 {
-       ao_tx_packet.addr = ao_serial_number;
+       ao_tx_packet.addr = (uint8_t) ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
        ao_packet_restart = 1;
        while (ao_packet_enable) {
index f5c51c8b874a6ac30dd14fdc0861996562d6536f..eb7c29729b8e4c993c5f2a76d70e72de26fb19d4 100644 (file)
@@ -181,7 +181,7 @@ ao_pad_decivolt(int16_t adc, int16_t r_plus, int16_t r_minus)
 {
        int32_t mul = (int32_t) AO_ADC_REFERENCE_DV * (r_plus + r_minus);
        int32_t div = (int32_t) AO_ADC_MAX * r_minus;
-       return ((int32_t) adc * mul + mul/2) / div;
+       return (int16_t) (((int32_t) adc * mul + mul/2) / div);
 }
 
 static void
@@ -211,7 +211,7 @@ ao_pad_monitor(void)
                sample = ao_data_ring_next(sample);
 
                /* Reply battery voltage */
-               query.battery = ao_pad_decivolt(packet->adc.batt, AO_PAD_R_V_BATT_BATT_SENSE, AO_PAD_R_BATT_SENSE_GND);
+               query.battery = (uint8_t) ao_pad_decivolt(packet->adc.batt, AO_PAD_R_V_BATT_BATT_SENSE, AO_PAD_R_BATT_SENSE_GND);
 
                /* Current pyro voltage */
                pyro = ao_pad_decivolt(packet->adc.pyro,
@@ -288,7 +288,7 @@ ao_pad_monitor(void)
                        prev = cur;
                }
 
-               if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_PAD_ARM_TIME)
+               if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_PAD_ARM_TIME)
                        ao_pad_armed = 0;
 
                if (ao_pad_armed) {
@@ -340,10 +340,10 @@ ao_pad_read_box(void)
 #endif
 
 #ifdef AO_PAD_SELECTOR_PORT
-static int ao_pad_read_box(void) {
+static uint8_t ao_pad_read_box(void) {
        AO_PORT_TYPE    value = ao_gpio_get_all(AO_PAD_SELECTOR_PORT);
        unsigned        pin;
-       int             select = 1;
+       uint8_t         select = 1;
 
        for (pin = 0; pin < sizeof (AO_PORT_TYPE) * 8; pin++) {
                if (AO_PAD_SELECTOR_PINS & (1 << pin)) {
@@ -398,7 +398,7 @@ ao_pad(void)
                        if (command.channels & ~(AO_PAD_ALL_CHANNELS))
                                break;
 
-                       tick_difference = command.tick - (uint16_t) ao_time();
+                       tick_difference = (int16_t) (command.tick - (uint16_t) ao_time());
                        PRINTD ("arm tick %d local tick %d\n", command.tick, (uint16_t) ao_time());
                        if (tick_difference < 0)
                                tick_difference = -tick_difference;
@@ -421,7 +421,7 @@ ao_pad(void)
                                break;
                        }
 
-                       query.tick = ao_time();
+                       query.tick = (uint16_t) ao_time();
                        query.box = ao_pad_box;
                        query.channels = AO_PAD_ALL_CHANNELS;
                        query.armed = ao_pad_armed;
@@ -439,7 +439,7 @@ ao_pad(void)
                                PRINTD ("not armed\n");
                                break;
                        }
-                       if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
+                       if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_SEC_TO_TICKS(20)) {
                                PRINTD ("late pad arm_time %ld time %ld\n",
                                        (long) ao_pad_arm_time, ao_time());
                                break;
@@ -457,7 +457,7 @@ ao_pad(void)
 #if HAS_LOG
                        if (!ao_log_running) ao_log_start();
 #endif
-                       if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
+                       if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_SEC_TO_TICKS(20)) {
                                PRINTD ("late pad arm_time %ld time %ld\n",
                                        (long) ao_pad_arm_time, (long) ao_time());
                                break;
@@ -516,7 +516,7 @@ ao_pad_manual(void)
        ignite = 1 << ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
-       repeat = ao_cmd_decimal();
+       repeat = (uint8_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success) {
                repeat = 1;
                ao_cmd_status = ao_cmd_success;
@@ -536,7 +536,7 @@ static struct ao_task ao_pad_monitor_task;
 static void
 ao_pad_set_debug(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status == ao_cmd_success)
                ao_pad_debug = r != 0;
 }
@@ -546,10 +546,10 @@ static void
 ao_pad_alarm_debug(void)
 {
        uint8_t which, value;
-       which = ao_cmd_decimal();
+       which = ao_cmd_decimal() != 0;
        if (ao_cmd_status != ao_cmd_success)
                return;
-       value = ao_cmd_decimal();
+       value = ao_cmd_decimal() != 0;
        if (ao_cmd_status != ao_cmd_success)
                return;
        printf ("Set %s to %d\n", which ? "siren" : "strobe", value);
@@ -585,9 +585,9 @@ void
 ao_pad_init(void)
 {
 #ifdef AO_PAD_SELECTOR_PORT
-       unsigned pin;
+       int pin;
 
-       for (pin = 0; pin < sizeof (AO_PORT_TYPE) * 8; pin++) {
+       for (pin = 0; pin < (int) sizeof (AO_PORT_TYPE) * 8; pin++) {
                if (AO_PAD_SELECTOR_PINS & (1 << pin))
                        ao_enable_input(AO_PAD_SELECTOR_PORT, pin, AO_EXTI_MODE_PULL_UP);
        }
index 97e67aa07bfd72f5cf934fbb33516afd363a509b..b50f1bf5c90b4c1e52f0ac73a77ca55a47b26203 100644 (file)
@@ -73,7 +73,7 @@ ao_quadrature_read(struct stm_gpio *gpio, uint8_t pin_a, uint8_t pin_b, struct a
        a = ao_debounce(a, &debounce_state[0]);
        b = ao_debounce(b, &debounce_state[1]);
 
-       return a | (b << 1);
+       return (uint16_t) (a | (b << 1));
 }
 
 #define _ao_quadrature_get(q)  ao_quadrature_read(port(q), bita(q), bitb(q), ao_debounce_state[q])
@@ -130,10 +130,10 @@ static void
 ao_quadrature_isr(void)
 {
 #if AO_QUADRATURE_COUNT > 0
-       _ao_quadrature_set(0, _ao_quadrature_get(0));
+       _ao_quadrature_set(0, (uint8_t) _ao_quadrature_get(0));
 #endif
 #if AO_QUADRATURE_COUNT > 1
-       _ao_quadrature_set(1, _ao_quadrature_get(1));
+       _ao_quadrature_set(1, (uint8_t) _ao_quadrature_get(1));
 #endif
 }
 
@@ -163,7 +163,7 @@ ao_quadrature_wait(uint8_t q)
 static void
 ao_quadrature_test(void)
 {
-       uint8_t q;
+       uint32_t q;
        int32_t c;
        uint8_t s;
 #ifndef AO_QUADRATURE_SINGLE_CODE
@@ -215,7 +215,7 @@ static const struct ao_cmds ao_quadrature_cmds[] = {
 #define init(q) do {                                                   \
                ao_enable_input(port(q), bita(q), 0);                   \
                ao_enable_input(port(q), bitb(q), 0);                   \
-               _ao_quadrature_start_one(q, _ao_quadrature_get(q));     \
+               _ao_quadrature_start_one(q, (uint8_t) _ao_quadrature_get(q)); \
        } while (0)
 
 void
index 3983dc941598ff6e584d1e53e8b688323e7a7dd5..3c07e7216cc34b3c084bffeee28ce12eed5aa44d 100644 (file)
@@ -108,7 +108,7 @@ static const char *status_strings[] = {
 #define NUM_STATUS_STRING      (sizeof status_strings/sizeof status_strings[0])
 
 static char            ao_rn_buffer[64];
-static int             ao_rn_buf_cnt, ao_rn_buf_ptr;
+static size_t          ao_rn_buf_cnt, ao_rn_buf_ptr;
 static int             ao_rn_draining;
 static AO_TICK_TYPE    ao_rn_buf_time;
 
@@ -146,9 +146,9 @@ _ao_wrap_rn_pollchar(void)
                                /* If we filled the buffer, just give up */
                                ao_rn_draining = 1;
                        } else {
-                               ao_rn_buffer[ao_rn_buf_cnt++] = c;
+                               ao_rn_buffer[ao_rn_buf_cnt++] = (char) c;
                                for (i = 0; i < NUM_STATUS_STRING; i++) {
-                                       int cmp = strlen(status_strings[i]);
+                                       size_t cmp = strlen(status_strings[i]);
                                        if (cmp >= ao_rn_buf_cnt)
                                                cmp = ao_rn_buf_cnt-1;
                                        if (memcmp(ao_rn_buffer+1, status_strings[i], cmp) == 0)
@@ -158,7 +158,7 @@ _ao_wrap_rn_pollchar(void)
                                        ao_rn_draining = 1;
                        }
                } else if (c == STATUS_CHAR) {
-                       ao_rn_buffer[0] = c;
+                       ao_rn_buffer[0] = (char) c;
                        ao_rn_buf_cnt = 1;
                        ao_rn_buf_ptr = 0;
                        ao_rn_buf_time = ao_time();
@@ -227,17 +227,17 @@ ao_rn_wait_char(AO_TICK_TYPE giveup_time)
                        ao_arch_release_interrupts();
                        return AO_READ_AGAIN;
                }
-               _ao_serial_rn_sleep_for(delay);
+               _ao_serial_rn_sleep_for((AO_TICK_TYPE) delay);
        }
        ao_arch_release_interrupts();
        return c;
 }
 
 static int
-ao_rn_wait_for(int timeout, char *match)
+ao_rn_wait_for(AO_TICK_TYPE timeout, char *match)
 {
        char            reply[AO_RN_MAX_REPLY_LEN + 1];
-       int             match_len = strlen(match);
+       size_t          match_len = strlen(match);
        AO_TICK_TYPE    giveup_time = ao_time() + timeout;
        int             c;
 
@@ -318,7 +318,7 @@ ao_rn_set_name(void)
        *--s = '\0';
        n = ao_serial_number;
        do {
-               *--s = '0' + n % 10;
+               *--s = (uint8_t) ('0' + n % 10);
        } while (n /= 10);
        ao_rn_send_cmd(AO_RN_SET_NAME_CMD "TeleBT-", s);
        return ao_rn_wait_status();
@@ -521,7 +521,7 @@ static void
 ao_rn_factory(void)
 {
        int     i;
-       int     v = 0;
+       uint8_t v = 0;
 
        /*
         * Factory reset. Flip pin P3_1 5 times within the first five
index af070cc11c5fdded1ca1a8e5d63b76315a57a933..9ca2c60eac711c94734d199eca9603ac98ec5169 100644 (file)
@@ -112,7 +112,7 @@ extern volatile AO_TICK_TYPE ao_tick_count;
 #define AO_HERTZ               100
 #endif
 #define AO_MS_TO_TICKS(ms)     ((ms) / (1000 / AO_HERTZ))
-#define AO_SEC_TO_TICKS(s)     ((s) * AO_HERTZ)
+#define AO_SEC_TO_TICKS(s)     ((AO_TICK_TYPE) (s) * AO_HERTZ)
 
 /* Returns the current time in ticks */
 AO_TICK_TYPE
@@ -531,7 +531,7 @@ struct ao_telemetry_tiny_recv {
  * for reporting RSSI. So, now we use these values everywhere
  */
 #define AO_RSSI_FROM_RADIO(radio)      ((int16_t) ((int8_t) (radio) >> 1) - 74)
-#define AO_RADIO_FROM_RSSI(rssi)       (((int8_t) (rssi) + 74) << 1)
+#define AO_RADIO_FROM_RSSI(rssi)       ((uint8_t) (((rssi) + 74) << 1))
 
 /*
  * ao_radio_recv tacks on rssi and status bytes
@@ -603,7 +603,7 @@ ao_radio_send(const void *d, uint8_t size);
 
 #if HAS_RADIO_RECV
 uint8_t
-ao_radio_recv(void *d, uint8_t size, uint8_t timeout);
+ao_radio_recv(void *d, uint8_t size, AO_TICK_TYPE timeout);
 
 void
 ao_radio_recv_abort(void);
@@ -724,8 +724,8 @@ struct ao_stdio {
 };
 
 extern struct ao_stdio ao_stdios[];
-extern int8_t ao_cur_stdio;
-extern int8_t ao_num_stdios;
+extern uint8_t ao_cur_stdio;
+extern uint8_t ao_num_stdios;
 
 void
 flush(void);
@@ -735,7 +735,7 @@ extern uint8_t ao_stdin_ready;
 uint8_t
 ao_echo(void);
 
-int8_t
+uint8_t
 ao_add_stdio(int (*pollchar)(void),
             void (*putchar)(char) ,
             void (*flush)(void));
@@ -828,15 +828,15 @@ struct ao_fifo {
        char    fifo[AO_FIFO_SIZE];
 };
 
-#define ao_fifo_insert(f,c) do { \
-       (f).fifo[(f).insert] = (c); \
-       (f).insert = ((f).insert + 1) & (AO_FIFO_SIZE-1); \
-} while(0)
+#define ao_fifo_insert(f,c) do {                                       \
+               (f).fifo[(f).insert] = (char) (c);                      \
+               (f).insert = ((f).insert + 1) & (AO_FIFO_SIZE-1);       \
+       } while(0)
 
-#define ao_fifo_remove(f,c) do {\
-       c = (f).fifo[(f).remove]; \
-       (f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1); \
-} while(0)
+#define ao_fifo_remove(f,c) do {                                       \
+               c = (f).fifo[(f).remove];                               \
+               (f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1);       \
+       } while(0)
 
 #define ao_fifo_full(f)                ((((f).insert + 1) & (AO_FIFO_SIZE-1)) == (f).remove)
 #define ao_fifo_mostly(f)      ((((f).insert - (f).remove) & (AO_FIFO_SIZE-1)) >= (AO_FIFO_SIZE * 3 / 4))
@@ -965,7 +965,7 @@ ao_sqrt(uint32_t op);
  * ao_freq.c
  */
 
-int32_t ao_freq_to_set(int32_t freq, int32_t cal);
+uint32_t ao_freq_to_set(uint32_t freq, uint32_t cal);
 
 /*
  * ao_ms5607.c
index 8141d85a3d7d5b39ec675df4fa77966f096aeef3..0e4c6056a8ed670ba8d3899227aa4186eb3dfa5a 100644 (file)
 #define AO_BEEP_MID_PANIC      AO_BEEP_MID_DEFAULT
 
 #ifndef AO_BEEP_MAKE_LOW
-#define AO_BEEP_MAKE_LOW(m)    ((m) * 150 / 94)        /* 2500Hz */
+#define AO_BEEP_MAKE_LOW(m)    ((uint8_t) ((m) * 150 / 94))    /* 2500Hz */
 #endif
 
 #ifndef AO_BEEP_MAKE_HIGH
-#define AO_BEEP_MAKE_HIGH(m)   ((m) * 75 / 94)         /* 5000Hz */
+#define AO_BEEP_MAKE_HIGH(m)   ((uint8_t) ((m) * 75 / 94))     /* 5000Hz */
 #endif
 
 #define AO_BEEP_LOW    AO_BEEP_MAKE_LOW(AO_BEEP_MID)
index 4ae63781fcb0900e39acdfc02ad8f737819d4b03..d8ba8372f5d0e308109ad6bd17c84a1a7c0d4541 100644 (file)
@@ -132,8 +132,8 @@ ao_getnibble(void)
 void
 ao_cmd_put16(uint16_t v)
 {
-       ao_cmd_put8(v >> 8);
-       ao_cmd_put8(v);
+       ao_cmd_put8((uint8_t) (v >> 8));
+       ao_cmd_put8((uint8_t) v);
 }
 
 void
@@ -160,11 +160,11 @@ int8_t
 ao_cmd_hexchar(char c)
 {
        if ('0' <= c && c <= '9')
-               return (c - '0');
+               return (int8_t) (c - '0');
        if ('a' <= c && c <= 'f')
-               return (c - 'a' + 10);
+               return (int8_t) (c - 'a' + 10);
        if ('A' <= c && c <= 'F')
-               return (c - 'A' + 10);
+               return (int8_t) (c - 'A' + 10);
        return -1;
 }
 
@@ -182,7 +182,7 @@ get_hex(uint8_t lim)
                                ao_cmd_status = ao_cmd_lex_error;
                        break;
                }
-               result = (result << 4) | n;
+               result = (uint32_t) ((result << 4) | (uint32_t) n);
                ao_cmd_lex();
        }
        return result;
@@ -191,7 +191,7 @@ get_hex(uint8_t lim)
 uint8_t
 ao_cmd_hexbyte(void)
 {
-       return get_hex(2);
+       return (uint8_t) get_hex(2);
 }
 
 uint32_t
@@ -270,6 +270,8 @@ ao_reboot(void)
 #endif
 
 #if HAS_VERSION
+#define _stringify(x) #x
+#define stringify(x) _stringify(x)
 static void
 version(void)
 {
@@ -307,7 +309,7 @@ version(void)
               , (unsigned) ((uint32_t) AO_BOOT_APPLICATION_BOUND - (uint32_t) AO_BOOT_APPLICATION_BASE)
 #endif
                );
-       printf("software-version %s\n", ao_version);
+       printf("software-version %." stringify(AO_MAX_VERSION) "s\n", ao_version);
 }
 #endif
 
@@ -325,7 +327,7 @@ help(void)
        uint8_t cmd;
        const struct ao_cmds * cs;
        const char *h;
-       uint8_t e;
+       size_t e;
 
        for (cmds = 0; cmds < ao_ncmds; cmds++) {
                cs = ao_cmds[cmds];
index bd702fe3664065d0c6e0b1e40788c6a89634a49a..a8fd100cef062cb9698314bfbc99ecb46e9f4b0d 100644 (file)
@@ -34,7 +34,7 @@ struct ao_companion_command {
        int16_t         accel;
        int16_t         speed;
        int16_t         height;
-       int16_t         motor_number;
+       uint16_t        motor_number;
 };
 
 struct ao_companion_setup {
index ece60ad355124e4bdcf4a703b6e8434713f82433..84efb11cd0e2e3474723e9bf51ea339f9130a2e1 100644 (file)
@@ -54,6 +54,7 @@ uint8_t ao_force_freq;
 #define AO_CONFIG_DEFAULT_IGNITE_MODE  AO_IGNITE_MODE_DUAL
 #define AO_CONFIG_DEFAULT_PAD_ORIENTATION      AO_PAD_ORIENTATION_ANTENNA_UP
 #define AO_CONFIG_DEFAULT_PYRO_TIME    AO_MS_TO_TICKS(50)
+#define AO_CONFIG_DEFAULT_RADIO_10MW   0
 #if HAS_CONFIG_SAVE
 #ifndef USE_INTERNAL_FLASH
 #error Please define USE_INTERNAL_FLASH
@@ -76,7 +77,7 @@ uint8_t ao_force_freq;
 #define AO_CONFIG_DEFAULT_RADIO_POWER          0x60
 #endif
 #define AO_CONFIG_DEFAULT_RADIO_AMP            0
-#define AO_CONFIG_DEFAULT_APRS_SSID            (ao_serial_number % 10)
+#define AO_CONFIG_DEFAULT_APRS_SSID            ((uint8_t) (ao_serial_number % 10))
 #define AO_CONFIG_DEFAULT_RADIO_RATE           AO_RADIO_RATE_38400
 
 #if HAS_CONFIG_SAVE
@@ -176,7 +177,7 @@ _ao_config_get(void)
                if (minor < 9)
                        memset(&ao_config.aes_key, '\0', AO_AES_LEN);
                if (minor < 10)
-                       ao_config.frequency = 434550 + ao_config._legacy_radio_channel * 100;
+                       ao_config.frequency = 434550U + ao_config._legacy_radio_channel * 100U;
                if (minor < 11)
                        ao_config.apogee_lockout = 0;
 #if AO_PYRO_NUM
@@ -188,7 +189,7 @@ _ao_config_get(void)
 #if HAS_RADIO_POWER
                if (minor < 14)
                        ao_config.radio_power = AO_CONFIG_DEFAULT_RADIO_POWER;
-               #endif
+#endif
 #if HAS_RADIO_AMP
                if (minor  < 14)
                        ao_config.radio_amp = AO_CONFIG_DEFAULT_RADIO_AMP;
@@ -245,6 +246,10 @@ _ao_config_get(void)
 #if HAS_APRS
                if (minor < 24)
                        ao_config.aprs_offset = 0;
+#endif
+#if HAS_RADIO_10MW
+               if (minor < 25)
+                       ao_config.radio_10mw = AO_CONFIG_DEFAULT_RADIO_10MW;
 #endif
                ao_config.minor = AO_CONFIG_MINOR;
                ao_config_dirty = 1;
@@ -386,7 +391,7 @@ ao_config_main_deploy_set(void)
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.main_deploy = r;
+       ao_config.main_deploy = (uint16_t) r;
        _ao_config_edit_finish();
 }
 
@@ -449,11 +454,11 @@ ao_config_accel_calibrate_auto(char *orientation)
                }
        }
 #if HAS_IMU
-       accel_cal_along = accel_along_total >> ACCEL_CALIBRATE_SHIFT;
-       accel_cal_across = accel_across_total >> ACCEL_CALIBRATE_SHIFT;
-       accel_cal_through = accel_through_total >> ACCEL_CALIBRATE_SHIFT;
+       accel_cal_along = (int16_t) (accel_along_total >> ACCEL_CALIBRATE_SHIFT);
+       accel_cal_across = (int16_t) (accel_across_total >> ACCEL_CALIBRATE_SHIFT);
+       accel_cal_through = (int16_t) (accel_through_total >> ACCEL_CALIBRATE_SHIFT);
 #endif
-       return accel_total >> ACCEL_CALIBRATE_SHIFT;
+       return (int16_t) (accel_total >> ACCEL_CALIBRATE_SHIFT);
 }
 
 static void
@@ -467,10 +472,10 @@ ao_config_accel_calibrate_set(void)
        int16_t accel_through_up = 0, accel_through_down = 0;
 #endif
 
-       up = ao_cmd_decimal();
+       up = (int16_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
-       down = ao_cmd_decimal();
+       down = (int16_t) ao_cmd_decimal();
        auto_cal = (up == 0 && ao_cmd_status != ao_cmd_success);
        if (auto_cal) {
                up = ao_config_accel_calibrate_auto("up");
@@ -496,19 +501,19 @@ ao_config_accel_calibrate_set(void)
        ao_config.accel_minus_g = down;
 #if HAS_IMU
        if (auto_cal) {
-               ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2;
-               ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2;
-               ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2;
+               ao_config.accel_zero_along = (int16_t) ((accel_along_up + accel_along_down) / 2);
+               ao_config.accel_zero_across = (int16_t) ((accel_across_up + accel_across_down) / 2);
+               ao_config.accel_zero_through = (int16_t) ((accel_through_up + accel_through_down) / 2);
        } else {
                int16_t v;
 
-               v = ao_cmd_decimal();
+               v = (int16_t) ao_cmd_decimal();
                if (ao_cmd_status == ao_cmd_success) {
                        ao_config.accel_zero_along = v;
-                       v = ao_cmd_decimal();
+                       v = (int16_t) ao_cmd_decimal();
                        if (ao_cmd_status == ao_cmd_success) {
                                ao_config.accel_zero_across = v;
-                               v = ao_cmd_decimal();
+                               v = (int16_t) ao_cmd_decimal();
                                if (ao_cmd_status == ao_cmd_success)
                                        ao_config.accel_zero_through = v;
                        }
@@ -533,8 +538,12 @@ ao_config_apogee_delay_set(void)
        uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
+       if (r > 255) {
+               ao_cmd_status = ao_cmd_lex_error;
+               return;
+       }
        _ao_config_edit_start();
-       ao_config.apogee_delay = r;
+       ao_config.apogee_delay = (uint8_t) r;
        _ao_config_edit_finish();
 }
 
@@ -548,11 +557,15 @@ ao_config_apogee_lockout_show(void)
 static void
 ao_config_apogee_lockout_set(void) 
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
+       if (r > 65535) {
+               ao_cmd_status = ao_cmd_lex_error;
+               return;
+       }
        _ao_config_edit_start();
-       ao_config.apogee_lockout = r;
+       ao_config.apogee_lockout = (uint16_t) r;
        _ao_config_edit_finish();
 }
 #endif
@@ -594,7 +607,7 @@ ao_config_radio_rate_show(void)
 static void
 ao_config_radio_rate_set(void) 
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        if (AO_RADIO_RATE_MAX < r) {
@@ -602,7 +615,7 @@ ao_config_radio_rate_set(void)
                return;
        }
        _ao_config_edit_start();
-       ao_config.radio_rate = r;
+       ao_config.radio_rate = (uint8_t) r;
        _ao_config_edit_finish();
 #if HAS_TELEMETRY
        ao_telemetry_reset_interval();
@@ -676,11 +689,11 @@ ao_config_ignite_mode_show(void)
 static void
 ao_config_ignite_mode_set(void) 
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.ignite_mode = r;
+       ao_config.ignite_mode = (uint8_t) r;
        _ao_config_edit_finish();
 }
 #endif
@@ -695,7 +708,7 @@ ao_config_pad_orientation_show(void)
 static void
 ao_config_pad_orientation_set(void) 
 {
-       uint16_t r = ao_cmd_decimal() & 1;
+       uint8_t r = ao_cmd_decimal() & 1;
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
@@ -720,11 +733,11 @@ ao_config_radio_enable_show(void)
 static void
 ao_config_radio_enable_set(void) 
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.radio_enable = r;
+       ao_config.radio_enable = r != 0;
        _ao_config_edit_finish();
 #if HAS_TELEMETRY && HAS_RADIO_RATE
        ao_telemetry_reset_interval();
@@ -774,11 +787,11 @@ ao_config_aprs_show(void)
 static void
 ao_config_aprs_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.aprs_interval = r;
+       ao_config.aprs_interval = (uint16_t) r;
        _ao_config_edit_finish();
        ao_telemetry_reset_interval();
 }
@@ -792,11 +805,11 @@ ao_config_aprs_offset_show(void)
 static void
 ao_config_aprs_offset_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.aprs_offset = r;
+       ao_config.aprs_offset = (uint8_t) r;
        _ao_config_edit_finish();
        ao_telemetry_reset_interval();
 }
@@ -845,6 +858,27 @@ ao_config_radio_power_set(void)
 
 #endif
 
+#if HAS_RADIO_10MW
+
+static void
+ao_config_radio_10mw_show(void)
+{
+       printf ("Radio 10mw limit: %d\n", ao_config.radio_10mw);
+}
+
+static void
+ao_config_radio_10mw_set(void)
+{
+       uint32_t r = ao_cmd_decimal();
+       if (ao_cmd_status != ao_cmd_success)
+               return;
+       _ao_config_edit_start();
+       ao_config.radio_10mw = !!r;
+       _ao_config_edit_finish();
+}
+
+#endif
+
 #if HAS_BEEP
 static void
 ao_config_beep_show(void)
@@ -855,11 +889,11 @@ ao_config_beep_show(void)
 static void
 ao_config_beep_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.mid_beep = r;
+       ao_config.mid_beep = (uint8_t) r;
        _ao_config_edit_finish();
 }
 #endif
@@ -876,11 +910,12 @@ ao_config_tracker_show(void)
 static void
 ao_config_tracker_set(void)
 {
-       uint16_t        m, i;
-       m = ao_cmd_decimal();
+       uint16_t        m;
+       uint8_t         i;
+       m = (uint16_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
-       i = ao_cmd_decimal();
+       i = (uint8_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
@@ -903,11 +938,11 @@ ao_config_pyro_time_show(void)
 static void
 ao_config_pyro_time_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.pyro_time = r;
+       ao_config.pyro_time = (uint16_t) r;
        _ao_config_edit_finish();
 }
 #endif
@@ -923,7 +958,7 @@ ao_config_aprs_ssid_show(void)
 static void
 ao_config_aprs_ssid_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        if (15 < r) {
@@ -931,14 +966,14 @@ ao_config_aprs_ssid_set(void)
                return;
        }
        _ao_config_edit_start();
-       ao_config.aprs_ssid = r;
+       ao_config.aprs_ssid = (uint8_t) r;
        _ao_config_edit_finish();
 }
 
 static void
 ao_config_aprs_format_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
@@ -963,11 +998,11 @@ ao_config_pad_box_show(void)
 static void
 ao_config_pad_box_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.pad_box = r;
+       ao_config.pad_box = (uint8_t) r;
        _ao_config_edit_finish();
 }
 
@@ -980,11 +1015,11 @@ ao_config_pad_idle_show(void)
 static void
 ao_config_pad_idle_set(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
        _ao_config_edit_start();
-       ao_config.pad_idle = r;
+       ao_config.pad_idle = (uint8_t) r;
        _ao_config_edit_finish();
 }
 #endif
@@ -1090,6 +1125,10 @@ const struct ao_config_var ao_config_vars[] = {
          ao_config_pad_box_set, ao_config_pad_box_show },
        { "i <seconds>\0Set idle timeout (0 disable)",
          ao_config_pad_idle_set, ao_config_pad_idle_show },
+#endif
+#if HAS_RADIO_10MW
+       { "p <0 no limit, 1 limit>\0Limit radio power to 10mW",
+         ao_config_radio_10mw_set,     ao_config_radio_10mw_show },
 #endif
        { "s\0Show",
          ao_config_show,               0 },
index 1d5a0fb022deab4964b97f857769adf66b867ece..f43401be6051a812f0c9854a408f832a64b83ed9 100644 (file)
 #define AO_CONFIG_MAJOR        1
 #define AO_CONFIG_MINOR        25
 
+/* All cc1200 devices support limiting TX power to 10mW */
+#if !defined(HAS_RADIO_10MW) && defined(AO_CC1200_SPI)
+#define HAS_RADIO_10MW 1
+#endif
+
 #define AO_AES_LEN 16
 
 extern uint8_t ao_config_aes_seq;
@@ -126,6 +131,9 @@ struct ao_config {
 #if HAS_APRS
        uint8_t         aprs_offset;            /* minor version 24 */
 #endif
+#if HAS_RADIO_10MW
+       uint8_t         radio_10mw;             /* minor version 25 */
+#endif
 };
 
 struct ao_config_1_24 {
index 8ae0e7c93bcedd95d90e8e4f3db299c0be09e3ae..44b3d745f8ee7de3bf2bef660ff891f0d0969b05 100644 (file)
@@ -42,7 +42,7 @@ static const alt_t altitude_table[] AO_CONST_ATTRIB = {
 alt_t
 ao_pa_to_altitude(pres_t pa)
 {
-       int16_t o;
+       uint16_t o;
        int16_t part;
        alt_t low, high;
 
@@ -50,12 +50,12 @@ ao_pa_to_altitude(pres_t pa)
                pa = 0;
        if (pa > 120000L)
                pa = 120000L;
-       o = pa >> ALT_SHIFT;
+       o = (uint16_t) (pa >> ALT_SHIFT);
        part = pa & ALT_MASK;
 
        low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part);
-       high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
-       return (low + high) >> ALT_SHIFT;
+       high = (alt_t) FETCH_ALT(o+1) * part;
+       return (low + high + (ALT_SCALE >> 1)) >> ALT_SHIFT;
 }
 
 #ifdef AO_CONVERT_TEST
index 5afedfa5bcd5c72c98af9ec0a8e4ed67cdaaa3e6..c5dfd22d0d6bcf6da48744fdee3e1a19c7b4bc38 100644 (file)
@@ -27,7 +27,7 @@
 int16_t
 ao_battery_decivolt(int16_t adc)
 {
-       return scale(adc, AO_BATTERY_DIV_PLUS, AO_BATTERY_DIV_MINUS);
+       return (int16_t) scale(adc, AO_BATTERY_DIV_PLUS, AO_BATTERY_DIV_MINUS);
 }
 #endif
 
@@ -35,6 +35,6 @@ ao_battery_decivolt(int16_t adc)
 int16_t
 ao_ignite_decivolt(int16_t adc)
 {
-       return scale(adc, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS);
+       return (int16_t) scale(adc, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS);
 }
 #endif
index 1b5f9d10ff0897dea9132b760eec5c6eb813d205..0f96cb897bcf521081c89e6007cc56444697ac73 100644 (file)
@@ -198,7 +198,7 @@ typedef AO_ALT_TYPE alt_t;
 #define ao_data_pres_cook(packet)      ao_ms5607_convert(&packet->ms5607_raw, &packet->ms5607_cooked)
 
 #define ao_data_pres(packet)   ((packet)->ms5607_cooked.pres)
-#define ao_data_temp(packet)   ((packet)->ms5607_cooked.temp)
+#define ao_data_temp(packet)   ((int16_t) (packet)->ms5607_cooked.temp)
 
 #define pres_to_altitude(p)    ao_pa_to_altitude(p)
 
@@ -331,9 +331,9 @@ typedef int16_t accel_t;
 #endif
 
 #if AO_MMA655X_INVERT
-#define ao_data_accel_raw(packet)              (AO_ACCEL_INVERT - (packet)->mma655x)
+#define ao_data_accel_raw(packet)              ((accel_t) (AO_ACCEL_INVERT - (packet)->mma655x))
 #else
-#define ao_data_accel_raw(packet)              ((packet)->mma655x)
+#define ao_data_accel_raw(packet)              ((accel_t) (packet)->mma655x)
 #endif
 #define ao_data_accel_invert(accel)            (AO_ACCEL_INVERT - (accel))
 
index 481a53c11c5bbdc14b8392895d221d90d7204368..d85f20f2c85ed36e111c0300a0bdd9f6199ef800 100644 (file)
@@ -101,7 +101,7 @@ ao_lon_dist(int32_t lon_a, int32_t lon_b)
 
        /* check if it's shorter to go the other way around */
        if ((lon_a >> 1) < (lon_b >> 1) - (1800000000 >> 1))
-               lon_a += 3600000000;
+               lon_a = (int32_t) ((uint32_t) lon_a + 3600000000UL);
        lon_dist = ao_dist(lon_a, lon_b);
        if (c) {
                if (lon_dist & 0x7f800000)
index 9ccc3af1d1df0dc28e66194e3271eaee31d1a199..40e5b15a082124dc7b4271fe8031b5d671d735b7 100644 (file)
@@ -39,10 +39,10 @@ ao_fec_crc_byte(uint8_t byte, uint16_t crc)
 
        for (bit = 0; bit < 8; bit++) {
                if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
-                       crc = (crc << 1) ^ 0x8005;
+                       crc = (uint16_t) ((crc << 1) ^ 0x8005);
                else
                        crc = (crc << 1);
-               byte <<= 1;
+               byte = (uint8_t) (byte << 1);
        }
        return crc;
 }
index 8e4a852221aac60e869576348acae5bab01dab51..ecbb21ac6847c32ad2f4820df4822f05fc0e1160 100644 (file)
@@ -59,7 +59,7 @@ static const uint8_t ao_interleave_order[] = {
 };
 
 static inline uint16_t ao_interleave_index(uint16_t i) {
-       return (i & ~0x1e) | ao_interleave_order[(i & 0x1e) >> 1];
+       return (uint16_t) ((i & ~0x1e) | ao_interleave_order[(i & 0x1e) >> 1]);
 }
 
 #define NUM_STATE      8
@@ -262,7 +262,7 @@ ao_fec_decode(const uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len, ui
                         * the end of the input, in which case
                         * it will be seven.
                         */
-                       int8_t          dist = b - (o + 8);     /* distance to last ready-for-writing bit */
+                       int8_t          dist = (int8_t) (b - (o + 8));  /* distance to last ready-for-writing bit */
                        uint32_t        min_cost;               /* lowest cost */
                        uint8_t         min_state;              /* lowest cost state */
                        uint8_t         byte;
@@ -293,7 +293,7 @@ ao_fec_decode(const uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len, ui
                        printf ("\tbit %3d min_cost %5d old bit %3d old_state %x bits %02x whiten %0x\n",
                                i/2, min_cost, o + 8, min_state, (bits[p][min_state] >> dist) & 0xff, *whiten);
 #endif
-                       byte = (bits[p][min_state] >> dist) ^ *whiten++;
+                       byte = (uint8_t) ((bits[p][min_state] >> dist) ^ *whiten++);
                        *out++ = byte;
                        if (out_len > 2)
                                crc = ao_fec_crc_byte(byte, crc);
index 3feb1301fc05905582e5ff5936286531e52a5b26..8c0e7db4f7e51c4f6e7f92d092eacb3c6faa6713 100644 (file)
@@ -54,7 +54,7 @@ uint8_t
 ao_fec_check_crc(const uint8_t *bytes, uint8_t len)
 {
        uint16_t        computed_crc = ao_fec_crc(bytes, len);
-       uint16_t        received_crc = (bytes[len] << 8) | (bytes[len+1]);
+       uint16_t        received_crc = (uint16_t) ((bytes[len] << 8) | (bytes[len+1]));
 
        return computed_crc == received_crc;
 }
@@ -70,8 +70,8 @@ ao_fec_prepare(const uint8_t *in, uint8_t len, uint8_t *extra)
        uint8_t         num_fec;
 
        /* Append CRC */
-       extra[i++] = crc >> 8;
-       extra[i++] = crc;
+       extra[i++] = (uint8_t) (crc >> 8);
+       extra[i++] = (uint8_t) crc;
 
        /* Append FEC -- 1 byte if odd, two bytes if even */
        num_fec = 2 - (i & 1);
@@ -112,7 +112,7 @@ ao_fec_encode(const uint8_t *in, uint8_t len, uint8_t *out)
                for (byte = 0; byte < 2; byte++) {
                        if (pair + byte == len)
                                in = extra;
-                       fec |= *in++ ^ *whiten++;
+                       fec |= (uint16_t) (*in++ ^ *whiten++);
                        for (bit = 0; bit < 8; bit++) {
                                encode = encode << 2 | ao_fec_encode_table[fec >> 7];
                                fec = (fec << 1) & 0x7ff;
@@ -126,10 +126,10 @@ ao_fec_encode(const uint8_t *in, uint8_t len, uint8_t *out)
 
                        interleave = (interleave << 2) | ((encode >> (byte_shift + bit_shift)) & 0x3);
                }
-               *out++ = interleave >> 24;
-               *out++ = interleave >> 16;
-               *out++ = interleave >> 8;
-               *out++ = interleave >> 0;
+               *out++ = (uint8_t) (interleave >> 24);
+               *out++ = (uint8_t) (interleave >> 16);
+               *out++ = (uint8_t) (interleave >> 8);
+               *out++ = (uint8_t) (interleave >> 0);
        }
-       return (len + extra_len) * 2;
+       return (uint8_t) ((len + extra_len) * 2);
 }
index 8553ccc5854f8f4d27569e1ae8928aaf7fef63da..cee8b2b8b38d008c16460b5c293b8c4b326c005d 100644 (file)
@@ -63,7 +63,7 @@ uint8_t                       ao_sensor_errors;
  * track min/max data over a long interval to detect
  * resting
  */
-static uint16_t                ao_interval_end;
+static AO_TICK_TYPE    ao_interval_end;
 #ifdef HAS_BARO
 static ao_v_t          ao_interval_min_height;
 static ao_v_t          ao_interval_max_height;
@@ -272,7 +272,7 @@ ao_flight(void)
                         * (15 seconds) has past.
                         */
                        if ((ao_accel < AO_MSS_TO_ACCEL(-2.5)) ||
-                           (AO_TICK_SIGNED) (ao_sample_tick - ao_boost_tick) > BOOST_TICKS_MAX)
+                           (AO_TICK_SIGNED) (ao_sample_tick - ao_boost_tick) > (AO_TICK_SIGNED) BOOST_TICKS_MAX)
                        {
 #if HAS_ACCEL
 #if HAS_BARO
@@ -320,7 +320,7 @@ ao_flight(void)
                         */
                        if (ao_config.apogee_lockout) {
                                if ((AO_TICK_SIGNED) (ao_sample_tick - ao_launch_tick) <
-                                   AO_SEC_TO_TICKS(ao_config.apogee_lockout))
+                                   (AO_TICK_SIGNED) AO_SEC_TO_TICKS(ao_config.apogee_lockout))
                                        break;
                        }
 
index 5a701b91a69dad94fc4e39e88a1952c7297b58cc..5443ea221afe904d8a26a68646c5c4ab1089cd9b 100644 (file)
  *                             cal_freq
  */
 
-int32_t ao_freq_to_set(int32_t target_freq, int32_t cal_value)
+uint32_t ao_freq_to_set(uint32_t target_freq, uint32_t cal_value)
 {
-       int64_t prod = (int64_t) target_freq * (int64_t) cal_value;
+       uint64_t        prod = (uint64_t) target_freq * (uint64_t) cal_value;
 
        /* Round to nearest */
-       int32_t target_value = (prod + (434550 / 2)) / 434550;
+       uint32_t target_value = (uint32_t) ((prod + (434550U / 2U)) / 434550U);
 
        return target_value;
 }
index 0cba972be07ce35bb353e97eba0a3e7b9a8c174b..5724d11bd9fa108b923e00d87233128ac7848484 100644 (file)
@@ -85,7 +85,7 @@ ao_gps_report_mega(void)
 #endif
                if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
 
-                       gps_log.tick = ao_gps_tick;
+                       gps_log.tick = (uint16_t) ao_gps_tick;
                        gps_log.type = AO_LOG_GPS_TIME;
                        gps_log.u.gps.latitude = gps_data.latitude;
                        gps_log.u.gps.longitude = gps_data.longitude;
@@ -108,7 +108,7 @@ ao_gps_report_mega(void)
                        ao_log_write(&gps_log);
                }
                if ((new & AO_GPS_NEW_TRACKING) && (n = gps_tracking_data.channels) != 0) {
-                       gps_log.tick = ao_gps_tick;
+                       gps_log.tick = (uint16_t) ao_gps_tick;
                        gps_log.type = AO_LOG_GPS_SAT;
                        i = 0;
                        for (c = 0; c < n; c++)
index b5f58893b78184679adbd9d126c8d5ba3532d871..e7529ee2a84740ed69d0e38208452dcc83c74390 100644 (file)
@@ -41,7 +41,7 @@ ao_gps_report_metrum(void)
                ao_mutex_put(&ao_gps_mutex);
 
                if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
-                       gps_log.tick = ao_gps_tick;
+                       gps_log.tick = (uint16_t) ao_gps_tick;
                        gps_log.type = AO_LOG_GPS_POS;
                        gps_log.u.gps.latitude = gps_data.latitude;
                        gps_log.u.gps.longitude = gps_data.longitude;
@@ -63,7 +63,7 @@ ao_gps_report_metrum(void)
 
                if ((new & AO_GPS_NEW_TRACKING) && (n = gps_tracking_data.channels)) {
                        gps_log.type = AO_LOG_GPS_SAT;
-                       gps_log.tick = ao_gps_tick;
+                       gps_log.tick = (uint16_t) ao_gps_tick;
                        i = 0;
                        for (c = 0; c < n; c++) {
                                svid = gps_tracking_data.sats[c].svid;
index 168812b750aa70c03eeca94fa3a8cd6b20378e62..5f32eb7275de8357d8bb50a80680644dee4817e9 100644 (file)
@@ -178,7 +178,7 @@ ao_kalman_err_accel(void)
        accel = (ao_config.accel_plus_g - ao_sample_accel) * ao_accel_scale;
 
        /* Can't use ao_accel here as it is the pre-prediction value still */
-       ao_error_a = (accel - ao_k_accel) >> 16;
+       ao_error_a = (ao_v_t) ((accel - ao_k_accel) >> 16);
 }
 
 #if !defined(FORCE_ACCEL) && HAS_BARO
@@ -314,9 +314,9 @@ ao_kalman(void)
        ao_kalman_correct_accel();
 #endif
 #endif
-       ao_height = from_fix(ao_k_height);
-       ao_speed = from_fix(ao_k_speed);
-       ao_accel = from_fix(ao_k_accel);
+       ao_height = (ao_v_t) from_fix(ao_k_height);
+       ao_speed = (ao_v_t) from_fix(ao_k_speed);
+       ao_accel = (ao_v_t) from_fix(ao_k_accel);
        if (ao_height > ao_max_height)
                ao_max_height = ao_height;
 #if HAS_BARO
@@ -331,5 +331,5 @@ ao_kalman(void)
                ao_avg_height = (ao_avg_height_scaled + 7) >> 4;
        else 
 #endif
-               ao_avg_height = (ao_avg_height_scaled + 63) >> 7;
+               ao_avg_height = (ao_v_t) ((ao_avg_height_scaled + 63) >> 7);
 }
index 2167d145d2ecd7211832ce01879fcd68bcc3bb17..53d6666929021c37e686074c64700fea699dae59 100644 (file)
@@ -29,7 +29,7 @@ uint32_t ao_log_end_pos;
 uint32_t ao_log_start_pos;
 uint8_t        ao_log_running;
 enum ao_flight_state ao_log_state;
-int16_t ao_flight_number;
+uint16_t ao_flight_number;
 
 void
 ao_log_flush(void)
@@ -77,7 +77,7 @@ ao_log_write_erase(uint8_t pos)
        if (pos == 0) {
                uint8_t i;
                for (i = 1; i < LOG_MAX_ERASE; i++) {
-                       erase.mark = ~LOG_ERASE_MARK;
+                       erase.mark = (uint8_t) ~LOG_ERASE_MARK;
                        erase.flight = 0;
                        ao_config_write(ao_log_erase_pos(i), &erase, sizeof (erase));
                }
@@ -180,7 +180,7 @@ ao_log_check_data(void)
        return 1;
 }
 
-int16_t
+int32_t
 ao_log_flight(uint8_t slot)
 {
        if (ao_storage_is_erased(ao_log_pos_block_start(slot)))
@@ -189,12 +189,12 @@ ao_log_flight(uint8_t slot)
        if (!ao_storage_read(ao_log_pos(slot),
                             &ao_log_data,
                             sizeof (ao_log_type)))
-               return -(int16_t) (slot + 1);
+               return -(int32_t) (slot + 1);
 
        if (!ao_log_check_data() || ao_log_data.type != AO_LOG_FLIGHT)
-               return -(int16_t) (slot + 1);
+               return -(int32_t) (slot + 1);
 
-       return ao_log_data.u.flight.flight;
+       return (int32_t) ao_log_data.u.flight.flight;
 }
 #endif
 
@@ -204,13 +204,13 @@ ao_log_slots(void)
        return (uint8_t) (ao_storage_log_max / ao_config.flight_log_max);
 }
 
-static int16_t
+static uint16_t
 ao_log_max_flight(void)
 {
        uint8_t         log_slot;
        uint8_t         log_slots;
-       int16_t         log_flight;
-       int16_t         max_flight = 0;
+       int32_t         log_flight;
+       uint16_t        max_flight = 0;
 
        /* Scan the log space looking for the biggest flight number */
        log_slots = ao_log_slots();
@@ -219,7 +219,7 @@ ao_log_max_flight(void)
                if (log_flight <= 0)
                        continue;
                if (max_flight == 0 || log_flight > max_flight)
-                       max_flight = log_flight;
+                       max_flight = (uint16_t) log_flight;
        }
        return max_flight;
 }
@@ -340,7 +340,7 @@ ao_log_scan(void)
        /* Find a log slot for the next flight, if available */
        ao_log_current_pos = ao_log_end_pos = 0;
        log_slots = ao_log_slots();
-       log_want = (ao_flight_number - 1) % log_slots;
+       log_want = (uint8_t) ((ao_flight_number - 1) % log_slots);
        log_slot = log_want;
        do {
                if (ao_log_flight(log_slot) == 0) {
@@ -396,14 +396,14 @@ ao_log_list(void)
 {
        uint8_t slot;
        uint8_t slots;
-       int16_t flight;
+       int32_t flight;
 
        slots = ao_log_slots();
        for (slot = 0; slot < slots; slot++)
        {
                flight = ao_log_flight(slot);
                if (flight)
-                       printf ("flight %d start %x end %x\n",
+                       printf ("flight %ld start %x end %x\n",
                                flight,
                                (uint16_t) (ao_log_pos(slot) >> 8),
                                (uint16_t) (ao_log_pos_block_end(slot) >> 8));
@@ -421,14 +421,14 @@ ao_log_delete(void)
 {
        uint8_t slot;
        uint8_t slots;
-       int16_t cmd_flight = 1;
+       int32_t cmd_flight = 1;
 
        ao_cmd_white();
        if (ao_cmd_lex_c == '-') {
                cmd_flight = -1;
                ao_cmd_lex();
        }
-       cmd_flight *= ao_cmd_decimal();
+       cmd_flight *= (int32_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
 
@@ -451,7 +451,7 @@ ao_log_delete(void)
                        }
                }
        }
-       printf("No such flight: %d\n", cmd_flight);
+       printf("No such flight: %ld\n", cmd_flight);
 }
 
 const struct ao_cmds ao_log_cmds[] = {
index 09ae7add80b683f469454cf721c4ad5f7c185410..837fc31eed8ea6a3ecdadf274374e967e2701ce1 100644 (file)
@@ -29,7 +29,7 @@
  * the log. Tasks may wait for this to be initialized
  * by sleeping on this variable.
  */
-extern int16_t ao_flight_number;
+extern uint16_t ao_flight_number;
 extern uint8_t ao_log_mutex;
 extern uint32_t ao_log_current_pos;
 extern uint32_t ao_log_end_pos;
@@ -65,7 +65,7 @@ extern enum ao_flight_state ao_log_state;
 
 /* Return the flight number from the given log slot, 0 if none, -slot on failure */
 
-int16_t
+int32_t
 ao_log_flight(uint8_t slot);
 
 /* Checksum the loaded log record */
@@ -230,7 +230,7 @@ struct ao_log_mega {
                struct {
                        uint16_t        flight;                 /* 4 */
                        int16_t         ground_accel;           /* 6 */
-                       uint32_t        ground_pres;            /* 8 */
+                       int32_t         ground_pres;            /* 8 */
                        int16_t         ground_accel_along;     /* 12 */
                        int16_t         ground_accel_across;    /* 14 */
                        int16_t         ground_accel_through;   /* 16 */
@@ -242,7 +242,7 @@ struct ao_log_mega {
                struct {
                        uint16_t        flight;                 /* 4 */
                        int16_t         ground_accel;           /* 6 */
-                       uint32_t        ground_pres;            /* 8 */
+                       int32_t         ground_pres;            /* 8 */
                        int16_t         ground_accel_along;     /* 12 */
                        int16_t         ground_accel_across;    /* 14 */
                        int16_t         ground_accel_through;   /* 16 */
@@ -390,7 +390,7 @@ struct ao_log_metrum {
                struct {
                        uint16_t        flight;         /* 4 */
                        int16_t         ground_accel;   /* 6 */
-                       uint32_t        ground_pres;    /* 8 */
+                       int32_t         ground_pres;    /* 8 */
                        uint32_t        ground_temp;    /* 12 */
                } flight;       /* 16 */
                /* AO_LOG_STATE */
@@ -450,7 +450,7 @@ struct ao_log_mini {
                struct {
                        uint16_t        flight;         /* 4 */
                        uint16_t        r6;
-                       uint32_t        ground_pres;    /* 8 */
+                       int32_t         ground_pres;    /* 8 */
                } flight;
                /* AO_LOG_STATE */
                struct {
@@ -469,9 +469,9 @@ struct ao_log_mini {
 };                                                     /* 16 */
 
 #define ao_log_pack24(dst,value) do {          \
-               (dst)[0] = (value);             \
-               (dst)[1] = (value) >> 8;        \
-               (dst)[2] = (value) >> 16;       \
+               (dst)[0] = (uint8_t) (value);   \
+               (dst)[1] = (uint8_t) ((value) >> 8);    \
+               (dst)[2] = (uint8_t) ((value) >> 16);   \
        } while (0)
 
 struct ao_log_gps {
index 58119ec85b1ce0917d38fdb3b197bf8452821021..fcf86c542706ac2b2b64d6441e600816408b7ed3 100644 (file)
@@ -76,7 +76,7 @@ ao_log(void)
                        ao_sleep(&ao_log_running);
        
                ao_fireone_data.type = AO_LOG_FLIGHT;
-               ao_fireone_data.tick = ao_time();
+               ao_fireone_data.tick = (uint16_t) ao_time();
                ao_fireone_data.u.flight.flight = ao_flight_number;
                ao_log_firetwo();
 
@@ -87,10 +87,10 @@ ao_log(void)
                for (;;) {
                        /* Write samples to EEPROM */
                        while (ao_fireone_data_pos != ao_data_head) {
-                               ao_fireone_data.tick = ao_data_ring[ao_fireone_data_pos].tick;
+                               ao_fireone_data.tick = (uint16_t) ao_data_ring[ao_fireone_data_pos].tick;
                                ao_fireone_data.type = AO_LOG_SENSOR;
-                               ao_fireone_data.u.sensor.pressure = ao_data_ring[ao_fireone_data_pos].adc.pressure;
-                               ao_fireone_data.u.sensor.thrust = ao_data_ring[ao_fireone_data_pos].adc.thrust;
+                               ao_fireone_data.u.sensor.pressure = (uint16_t) ao_data_ring[ao_fireone_data_pos].adc.pressure;
+                               ao_fireone_data.u.sensor.thrust = (uint16_t) ao_data_ring[ao_fireone_data_pos].adc.thrust;
        //                      for (i = 0; i < 4; i++) {
        //                              ao_fireone_data.u.sensor.thermistor[i] = ao_data_ring[ao_fireone_data_pos].sensor.thermistor[i];
        //                      }
index 211707e58221e5789de8d5fb6b00c79c7777735c..96f8140fdf04a171107eaef814599aed6e918611 100644 (file)
@@ -28,7 +28,7 @@ void
 ao_log_gps_flight(void)
 {
        ao_log_data.type = AO_LOG_FLIGHT;
-       ao_log_data.tick = ao_time();
+       ao_log_data.tick = (uint16_t) ao_time();
        ao_log_data.u.flight.flight = ao_flight_number;
        ao_log_write(&ao_log_data);
 }
@@ -36,7 +36,7 @@ ao_log_gps_flight(void)
 void
 ao_log_gps_data(AO_TICK_TYPE tick, struct ao_telemetry_location *gps_data)
 {
-       ao_log_data.tick = tick;
+       ao_log_data.tick = (uint16_t) tick;
        ao_log_data.type = AO_LOG_GPS_TIME;
        ao_log_data.u.gps.latitude = gps_data->latitude;
        ao_log_data.u.gps.longitude = gps_data->longitude;
@@ -65,7 +65,7 @@ ao_log_gps_tracking(AO_TICK_TYPE tick, struct ao_telemetry_satellite *gps_tracki
 {
        uint8_t c, n, i;
 
-       ao_log_data.tick = tick;
+       ao_log_data.tick = (uint16_t) tick;
        ao_log_data.type = AO_LOG_GPS_SAT;
        i = 0;
        n = gps_tracking_data->channels;
index 78dbd980d527288bbedb1797f9b7401c91872396..432f1b851c7918c00180db1cb4748acc1ab473df 100644 (file)
@@ -48,7 +48,7 @@ ao_log(void)
 
 #if HAS_FLIGHT
        ao_log_data.type = AO_LOG_FLIGHT;
-       ao_log_data.tick = ao_sample_tick;
+       ao_log_data.tick = (uint16_t) ao_sample_tick;
 #if HAS_ACCEL
        ao_log_data.u.flight.ground_accel = ao_ground_accel;
 #endif
@@ -75,7 +75,7 @@ ao_log(void)
                /* Write samples to EEPROM */
                while (ao_log_data_pos != ao_data_head) {
                        AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
-                       ao_log_data.tick = tick;
+                       ao_log_data.tick = (uint16_t) tick;
                        volatile struct ao_data *d = &ao_data_ring[ao_log_data_pos];
                        if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
                                ao_log_data.type = AO_LOG_SENSOR;
@@ -157,7 +157,7 @@ ao_log(void)
                if (ao_flight_state != ao_log_state) {
                        ao_log_state = ao_flight_state;
                        ao_log_data.type = AO_LOG_STATE;
-                       ao_log_data.tick = ao_time();
+                       ao_log_data.tick = (uint16_t) ao_time();
                        ao_log_data.u.state.state = ao_log_state;
                        ao_log_data.u.state.reason = 0;
                        ao_log_write(&ao_log_data);
index 8091e6c63ccd5b9a504f77f2ad7a4ce646d695b1..915b48acb349b4c7a78a69e2d3aebbd6a25b4381 100644 (file)
@@ -36,7 +36,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_metrum))] ;
 void
 ao_log(void)
 {
-       uint16_t        next_sensor, next_other;
+       AO_TICK_TYPE    next_sensor, next_other;
 
        ao_storage_setup();
 
@@ -47,7 +47,7 @@ ao_log(void)
 
 #if HAS_FLIGHT
        ao_log_data.type = AO_LOG_FLIGHT;
-       ao_log_data.tick = ao_sample_tick;
+       ao_log_data.tick = (uint16_t) ao_sample_tick;
 #if HAS_ACCEL
        ao_log_data.u.flight.ground_accel = ao_ground_accel;
 #endif
@@ -66,7 +66,7 @@ ao_log(void)
                /* Write samples to EEPROM */
                while (ao_log_data_pos != ao_data_head) {
                        AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
-                       ao_log_data.tick = tick;
+                       ao_log_data.tick = (uint16_t) tick;
                        if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
                                ao_log_data.type = AO_LOG_SENSOR;
 #if HAS_MS5607
@@ -97,7 +97,7 @@ ao_log(void)
                if (ao_flight_state != ao_log_state) {
                        ao_log_state = ao_flight_state;
                        ao_log_data.type = AO_LOG_STATE;
-                       ao_log_data.tick = ao_time();
+                       ao_log_data.tick = (uint16_t) ao_time();
                        ao_log_data.u.state.state = ao_log_state;
                        ao_log_data.u.state.reason = 0;
                        ao_log_write(&ao_log_data);
index 1cb03715b23eb284573e5e5ba6e22ff1e7c90b8d..cfc0bcfd76ced85de0e99e28ef10d4634f96d50f 100644 (file)
@@ -52,7 +52,7 @@ ao_log_micro_restore(void)
 void
 ao_log_micro_data(void)
 {
-       uint16_t        low_bits = pa;
+       uint16_t        low_bits = (uint16_t) pa;
 
        if (ao_log_offset < MAX_LOG_OFFSET) {
                ao_eeprom_write(ao_log_offset, &low_bits, sizeof (low_bits));
@@ -81,9 +81,9 @@ static void
 ao_log_hex_nibble(uint8_t b)
 {
        if (b < 10)
-               ao_async_byte('0' + b);
+               ao_async_byte((uint8_t) ('0' + b));
        else
-               ao_async_byte('a' - 10 + b);
+               ao_async_byte((uint8_t) ('a' - 10 + b));
 }
 
 void
@@ -115,7 +115,7 @@ ao_log_micro_dump(void)
 
        if (n_samples == (N_SAMPLES_TYPE) (~0))
                n_samples = 0;
-       nbytes = STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples;
+       nbytes = (uint16_t) (STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples);
 
        /*
         * Rewrite n_samples so that it includes the log ID value with
@@ -140,7 +140,7 @@ ao_log_micro_dump(void)
                ao_eeprom_read(b, &byte, 1);
 #if AO_LOG_ID
                if (N_SAMPLES_OFFSET <= b && b < (N_SAMPLES_OFFSET + sizeof(n_samples))) {
-                       byte = n_samples >> ((b - N_SAMPLES_OFFSET) << 3);
+                       byte = (uint8_t) (n_samples >> ((b - N_SAMPLES_OFFSET) << 3));
                }
 #endif
                ao_log_hex(byte);
@@ -148,8 +148,8 @@ ao_log_micro_dump(void)
        }
        ao_log_newline();
        crc = ~crc;
-       ao_log_hex(crc >> 8);
-       ao_log_hex(crc);
+       ao_log_hex((uint8_t) (crc >> 8));
+       ao_log_hex((uint8_t) crc);
        ao_log_newline();
        ao_async_stop();
 }
index 3c46153eef832026cbc11e224602c1e443497a2d..4bbbe0cbeccd3815af84d670bf6edb22c77d4c0e 100644 (file)
@@ -34,7 +34,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mini))] ;
 void
 ao_log(void)
 {
-       uint16_t        next_sensor;
+       AO_TICK_TYPE    next_sensor;
 
        ao_storage_setup();
 
@@ -45,7 +45,7 @@ ao_log(void)
 
 #if HAS_FLIGHT
        ao_log_data.type = AO_LOG_FLIGHT;
-       ao_log_data.tick = ao_sample_tick;
+       ao_log_data.tick = (uint16_t) ao_sample_tick;
        ao_log_data.u.flight.flight = ao_flight_number;
        ao_log_data.u.flight.ground_pres = ao_ground_pres;
        ao_log_write(&ao_log_data);
@@ -61,7 +61,7 @@ ao_log(void)
                /* Write samples to EEPROM */
                while (ao_log_data_pos != ao_data_head) {
                        AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
-                       ao_log_data.tick = tick;
+                       ao_log_data.tick = (uint16_t) tick;
                        if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
                                ao_log_data.type = AO_LOG_SENSOR;
                                ao_log_pack24(ao_log_data.u.sensor.pres,
@@ -86,7 +86,7 @@ ao_log(void)
                if (ao_flight_state != ao_log_state) {
                        ao_log_state = ao_flight_state;
                        ao_log_data.type = AO_LOG_STATE;
-                       ao_log_data.tick = ao_time();
+                       ao_log_data.tick = (uint16_t) ao_time();
                        ao_log_data.u.state.state = ao_log_state;
                        ao_log_data.u.state.reason = 0;
                        ao_log_write(&ao_log_data);
index 4af8bd7818579ead1287f53f8d1f057487a1e28e..376cb229d5ab158c7310ecb483dd49b98a808162 100644 (file)
@@ -36,7 +36,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mega))] ;
 void
 ao_log(void)
 {
-       uint16_t        next_sensor;
+       AO_TICK_TYPE    next_sensor;
 
        ao_storage_setup();
 
@@ -46,7 +46,7 @@ ao_log(void)
                ao_sleep(&ao_log_running);
 
        ao_log_data.type = AO_LOG_FLIGHT;
-       ao_log_data.tick = ao_sample_tick;
+       ao_log_data.tick = (uint16_t) ao_sample_tick;
        ao_log_data.u.flight.ground_accel = ao_ground_accel;
        ao_log_data.u.flight.ground_accel_along = ao_ground_accel_along;
        ao_log_data.u.flight.ground_accel_through = ao_ground_accel_through;
@@ -64,11 +64,11 @@ ao_log(void)
                /* Write samples to EEPROM */
                while (ao_log_data_pos != ao_data_head) {
                        AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
-                       ao_log_data.tick = tick;
+                       ao_log_data.tick = (uint16_t) tick;
                        if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
                                ao_log_data.type = AO_LOG_SENSOR;
-                               ao_log_data.u.sensor.pressure = ao_data_motor_pressure(&ao_data_ring[ao_log_data_pos]);
-                               ao_log_data.u.sensor.v_batt = ao_data_ring[ao_log_data_pos].adc.v_batt;
+                               ao_log_data.u.sensor.pressure = (uint16_t) ao_data_motor_pressure(&ao_data_ring[ao_log_data_pos]);
+                               ao_log_data.u.sensor.v_batt = (uint16_t) ao_data_ring[ao_log_data_pos].adc.v_batt;
                                ao_log_data.u.sensor.accel = ao_data_accel(&ao_data_ring[ao_log_data_pos]);
                                ao_log_data.u.sensor.accel_across = ao_data_across(&ao_data_ring[ao_log_data_pos]);
                                ao_log_data.u.sensor.accel_along = ao_data_along(&ao_data_ring[ao_log_data_pos]);
@@ -86,7 +86,7 @@ ao_log(void)
                if (ao_flight_state != ao_log_state) {
                        ao_log_state = ao_flight_state;
                        ao_log_data.type = AO_LOG_STATE;
-                       ao_log_data.tick = ao_time();
+                       ao_log_data.tick = (uint16_t) ao_time();
                        ao_log_data.u.state.state = ao_log_state;
                        ao_log_data.u.state.reason = 0;
                        ao_log_write(&ao_log_data);
index 3c6caf7bac7db7d0509e069df6c30b1c8d42632d..bf994b8f80b647f1f56825053e1e0edb1e77e288 100644 (file)
@@ -46,7 +46,7 @@ ao_microflight(void)
 {
        int16_t         sample_count;
        int16_t         log_count;
-       uint16_t        time;
+       AO_TICK_TYPE    time;
        uint32_t        pa_interval_min, pa_interval_max;
        int32_t         pa_diff;
        uint8_t         h;
@@ -76,7 +76,7 @@ ao_microflight(void)
 #endif
                pa_hist[h] = pa;
                h = SKIP_PA_HIST(h,1);
-               pa_diff = pa_ground - ao_pa;
+               pa_diff = (int32_t) (pa_ground - ao_pa);
 
 #if BOOST_DETECT
                /* Check for a significant pressure change */
@@ -145,7 +145,7 @@ ao_microflight(void)
                        pa_min = ao_pa;
 
                if (sample_count == (GROUND_AVG - 1)) {
-                       pa_diff = pa_interval_max - pa_interval_min;
+                       pa_diff = (int32_t) (pa_interval_max - pa_interval_min);
 
                        /* Check to see if the pressure is now stable */
                        if (pa_diff < LAND_DETECT)
index 3cfb87ccbfa3bf8b7b8169387858cf2286bb49db..a9b2c7092aa33e20c3716857f45e1b7550551d26 100644 (file)
@@ -70,14 +70,14 @@ int16_t             ao_pa_accel;            /* integer portion */
 void
 ao_microkalman_init(void)
 {
-       ao_pa = pa;
-       ao_k_pa = pa << 8;
+       ao_pa = (uint32_t) pa;
+       ao_k_pa = (uint32_t) (pa << 8);
 }
 
 void
 ao_microkalman_predict(void)
 {
-       ao_k_pa       += fix16_to_fix8((int32_t) ao_pa_speed * AO_MK_STEP + (int32_t) ao_pa_accel * AO_MK_STEP_2_2);
+       ao_k_pa       += (uint32_t) (int32_t) fix16_to_fix8((int32_t) ao_pa_speed * AO_MK_STEP + (int32_t) ao_pa_accel * AO_MK_STEP_2_2);
        ao_k_pa_speed += (int32_t) ao_pa_accel * AO_MK_STEP;
 }
 
@@ -86,12 +86,12 @@ ao_microkalman_correct(void)
 {
        int16_t e;      /* Height error in Pa */
 
-       e = pa - from_fix8(ao_k_pa);
+       e = (int16_t) (pa - from_fix8(ao_k_pa));
 
-       ao_k_pa       += fix16_to_fix8((int32_t) e * AO_K0_10);
+       ao_k_pa       += (uint32_t)(int32_t)fix16_to_fix8(e * AO_K0_10);
        ao_k_pa_speed += (int32_t) e * AO_K1_10;
        ao_k_pa_accel += (int32_t) e * AO_K2_10;
        ao_pa = from_fix8(ao_k_pa);
-       ao_pa_speed = from_fix(ao_k_pa_speed);
-       ao_pa_accel = from_fix(ao_k_pa_accel);
+       ao_pa_speed = (int16_t) from_fix(ao_k_pa_speed);
+       ao_pa_accel = (int16_t) from_fix(ao_k_pa_accel);
 }
index cd5116990b7046e83789dfbbe2431e620be74170..3310a847a6b1ce0995aabd212160c66ec4c3c5dd 100644 (file)
@@ -296,7 +296,7 @@ ao_monitor_enable(void)
 static void
 set_monitor(void)
 {
-       ao_external_monitoring = ao_cmd_hex();
+       ao_external_monitoring = (uint8_t) ao_cmd_hex();
        ao_wakeup(&ao_external_monitoring);
        ao_wakeup(&ao_monitor_head);
        _ao_monitor_adjust();
index ee94eca35c5c22c461cc576b3bf04cd7a4fadd8b..d4091205d2114afff64d11c1bea194a6f70f2936 100644 (file)
@@ -303,7 +303,18 @@ ao_pyro_check(void)
                                if (delay < 0)
                                        delay = 0;
                                delay_done = ao_time() + (AO_TICK_TYPE) delay;
-                               if (!delay_done)
+
+                               /*
+                                * delay_done is the time at which the
+                                * delay ends, but it is also used as
+                                * an indication that a delay is
+                                * active -- non-zero values indicate
+                                * an active delay. This code ensures
+                                * the value is non-zero, which might
+                                * introduce an additional tick
+                                * of delay.
+                                */
+                               if (delay_done == 0)
                                        delay_done = 1;
                                pyro_delay_done[p] = delay_done;
                        }
@@ -312,7 +323,7 @@ ao_pyro_check(void)
                /* Check to see if we're just waiting for
                 * the delay to expire
                 */
-               if (pyro_delay_done[p]) {
+               if (pyro_delay_done[p] != 0) {
 
                        /* Check to make sure the required conditions
                         * remain valid. If not, inhibit the channel
index c7b48e06a338aa7b3c6d08aea9c3eb765f3cce96..5f09344af8915dd273b4ab044ca95fdc5a1df49d 100644 (file)
@@ -37,7 +37,7 @@ round_len(uint8_t len)
                len = AO_CMAC_KEY_LEN;
        rem = len % AO_CMAC_KEY_LEN;
        if (rem != 0)
-               len += (AO_CMAC_KEY_LEN - rem);
+               len += (uint8_t) (AO_CMAC_KEY_LEN - rem);
        return len;
 }
 
@@ -77,7 +77,7 @@ radio_cmac_send(uint8_t len)
  */
 
 static int8_t
-radio_cmac_recv(uint8_t len, uint16_t timeout) 
+radio_cmac_recv(uint8_t len, AO_TICK_TYPE timeout) 
 {
        uint8_t i;
 
@@ -145,7 +145,7 @@ ao_radio_cmac_send(void *packet, uint8_t len)
 }
 
 int8_t
-ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout) 
+ao_radio_cmac_recv(void *packet, uint8_t len, AO_TICK_TYPE timeout) 
 {
        int8_t  i;
        if (len > AO_CMAC_MAX_LEN)
index 5fd6e10539deb8edceb240466b4b81567e285200..2977cd3e69960076b5fef9e5eac53891bae586f5 100644 (file)
@@ -36,7 +36,7 @@ ao_radio_cmac_send(void *packet, uint8_t len);
 #define AO_RADIO_CMAC_TIMEOUT  -4
 
 int8_t
-ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout);
+ao_radio_cmac_recv(void *packet, uint8_t len, AO_TICK_TYPE timeout);
 
 void
 ao_radio_cmac_init(void);
index 1433e96d84523ceb9e5bcbadc491482305a27c4d..fe9eaf27a27a797247619fb222cef77b3f417cd1 100644 (file)
@@ -47,8 +47,8 @@ getbyte(void)
 static void
 radio_cmac_send_cmd(void) 
 {
-       uint8_t i;
-       uint8_t len;
+       uint32_t i;
+       uint32_t len;
 
        len = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
@@ -63,26 +63,31 @@ radio_cmac_send_cmd(void)
                if (ao_cmd_status != ao_cmd_success)
                        return;
        }
-       ao_radio_cmac_send(cmac_data, len);
+       ao_radio_cmac_send(cmac_data, (uint8_t) len);
 }
 
 static void
 radio_cmac_recv_cmd(void) 
 {
-       uint8_t         len, i;
-       uint16_t        timeout;
+       uint32_t len, l;
+       int8_t i;
+       AO_TICK_TYPE    timeout;
 
        len = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
+       if (len > AO_CMAC_MAX_LEN) {
+               ao_cmd_status = ao_cmd_syntax_error;
+               return;
+       }
        timeout = AO_MS_TO_TICKS(ao_cmd_decimal());
        if (ao_cmd_status != ao_cmd_success)
                return;
-       i = ao_radio_cmac_recv(cmac_data, len, timeout);
+       i = ao_radio_cmac_recv(cmac_data, (uint8_t) len, timeout);
        if (i == AO_RADIO_CMAC_OK) {
                printf ("PACKET ");
-               for (i = 0; i < len; i++)
-                       printf("%02x", cmac_data[i]);
+               for (l = 0; l < len; l++)
+                       printf("%02x", cmac_data[l]);
                printf (" %d\n", ao_radio_cmac_rssi);
        } else
                printf ("ERROR %d %d\n", i, ao_radio_cmac_rssi);
index 831ba874cc3656d312aca76ff2409cbb03e8a7fa..4624403a10d61e0a255caf38f56fecdc8bcff4af 100644 (file)
@@ -149,7 +149,7 @@ ao_report_digit(uint8_t digit)
 }
 
 static void
-ao_report_number(int16_t n)
+ao_report_number(ao_v_t n)
 {
        uint8_t digits[10];
        uint8_t ndigits, i;
@@ -158,7 +158,7 @@ ao_report_number(int16_t n)
                n = 0;
        ndigits = 0;
        do {
-               digits[ndigits++] = n % 10;
+               digits[ndigits++] = (uint8_t) (n % 10);
                n /= 10;
        } while (n);
 
@@ -200,8 +200,8 @@ ao_report_igniter_ready(enum ao_igniter igniter)
 uint8_t
 ao_report_igniter(void)
 {
-       return (ao_report_igniter_ready(ao_igniter_drogue) |
-                    (ao_report_igniter_ready(ao_igniter_main) << 1));
+       return (uint8_t) (ao_report_igniter_ready(ao_igniter_drogue) |
+                         (ao_report_igniter_ready(ao_igniter_main) << 1));
 }
 #endif
 
index efada54b516be302d477c891e05947292e9640f8..7abd2311bc4bdcd827ebc3ab332cdfa03cb05eab 100644 (file)
@@ -48,7 +48,7 @@ ao_report_altitude(void)
                agl = 0;
        ndigits = 0;
        do {
-               digits[ndigits++] = agl % 10;
+               digits[ndigits++] = (uint8_t) agl % 10;
                agl /= 10;
        } while (agl);
 
index b75142f52af605c45ac5b2802fe3cc7548112d0a..fe2bc7f5e3126ae44877cf3ca8f174636fad67cf 100644 (file)
@@ -19,7 +19,7 @@
 #include "ao.h"
 
 AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION;
-AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION;
+AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = (uint16_t) ~AO_ROMCONFIG_VERSION;
 AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number = 0;
 #if HAS_RADIO
 AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
index e3b5e084d8f4c52ec454e30739910bfada8a9912..3f5fc7a98c557af012d053dd0b14068305f6924b 100644 (file)
@@ -161,7 +161,7 @@ static void
 ao_sample_set_one_orient(void)
 {
        ao_sample_orients[ao_sample_orient_pos] = ao_sample_orient;
-       ao_sample_orient_pos = (ao_sample_orient_pos + 1) % AO_NUM_ORIENT;
+       ao_sample_orient_pos = (uint8_t) ((ao_sample_orient_pos + 1) % AO_NUM_ORIENT);
 }
 
 static void
@@ -190,7 +190,7 @@ ao_sample_compute_orient(void)
        float rotz;
        rotz = ao_rotation.z * ao_rotation.z - ao_rotation.y * ao_rotation.y - ao_rotation.x * ao_rotation.x + ao_rotation.r * ao_rotation.r;
 
-       ao_sample_orient = acosf(rotz) * (float) (180.0/M_PI);
+       ao_sample_orient = (angle_t) (acosf(rotz) * (float) (180.0/M_PI));
 }
 #endif /* HAS_GYRO */
 
@@ -198,7 +198,7 @@ static void
 ao_sample_preflight_set(void)
 {
 #if HAS_ACCEL
-       ao_ground_accel = ao_sample_accel_sum >> 9;
+       ao_ground_accel = (accel_t) (ao_sample_accel_sum >> 9);
        ao_sample_accel_sum = 0;
 #endif
 #if HAS_BARO
@@ -207,15 +207,15 @@ ao_sample_preflight_set(void)
        ao_sample_pres_sum = 0;
 #endif
 #if HAS_IMU
-       ao_ground_accel_along = ao_sample_accel_along_sum >> 9;
-       ao_ground_accel_across = ao_sample_accel_across_sum >> 9;
-       ao_ground_accel_through = ao_sample_accel_through_sum >> 9;
+       ao_ground_accel_along = (accel_t) (ao_sample_accel_along_sum >> 9);
+       ao_ground_accel_across = (accel_t) (ao_sample_accel_across_sum >> 9);
+       ao_ground_accel_through = (accel_t) (ao_sample_accel_through_sum >> 9);
        ao_sample_accel_along_sum = 0;
        ao_sample_accel_across_sum = 0;
        ao_sample_accel_through_sum = 0;
 #endif
 #if HAS_MOTOR_PRESSURE
-       ao_ground_motor_pressure = ao_sample_motor_pressure_sum >> 9;
+       ao_ground_motor_pressure = (motor_pressure_t) (ao_sample_motor_pressure_sum >> 9);
        ao_sample_motor_pressure_sum = 0;
 #endif
 #if HAS_GYRO
index ee4685998215a7899f123caf2780abc88ebdc00a..ff3ab68d15caa9d0944e6b7ff2c621f98c5e8cf4 100644 (file)
@@ -26,7 +26,7 @@ static uint8_t ao_send[AO_MAX_SEND];
 static void
 ao_send_packet(void)
 {
-       uint16_t count;
+       uint32_t count;
        uint8_t b;
        uint8_t i;
 
@@ -44,7 +44,7 @@ ao_send_packet(void)
                        return;
                ao_send[i] = b;
        }
-       ao_radio_send(ao_send, count);
+       ao_radio_send(ao_send, (uint8_t) count);
 }
 
 static const struct ao_cmds ao_send_packet_cmds[] = {
index 3500a0933d80b268898656fb123b212d5c6ff65c..2bf71015254690f03d7cbb7a57aca3f1f86678fa 100644 (file)
@@ -36,7 +36,7 @@ int
 _ao_serial0_pollchar(void);
 
 uint8_t
-_ao_serial0_sleep_for(uint16_t timeout);
+_ao_serial0_sleep_for(AO_TICK_TYPE timeout);
 
 void
 ao_serial0_putchar(char c);
@@ -59,7 +59,7 @@ int
 _ao_serial1_pollchar(void);
 
 uint8_t
-_ao_serial1_sleep_for(uint16_t timeout);
+_ao_serial1_sleep_for(AO_TICK_TYPE timeout);
 
 void
 ao_serial1_putchar(char c);
@@ -82,7 +82,7 @@ int
 _ao_serial2_pollchar(void);
 
 uint8_t
-_ao_serial2_sleep_for(uint16_t timeout);
+_ao_serial2_sleep_for(AO_TICK_TYPE timeout);
 
 void
 ao_serial2_putchar(char c);
@@ -105,7 +105,7 @@ int
 _ao_serial3_pollchar(void);
 
 uint8_t
-_ao_serial3_sleep_for(uint16_t timeout);
+_ao_serial3_sleep_for(AO_TICK_TYPE timeout);
 
 void
 ao_serial3_putchar(char c);
index c578c57cd920b3bc6ea5e4af4c1af8520cfd8283..7f74f81194bcca5b1782c111c1d63b711b130e29 100644 (file)
 struct ao_stdio ao_stdios[AO_NUM_STDIOS];
 
 #if AO_NUM_STDIOS > 1
-int8_t ao_cur_stdio;
-int8_t ao_num_stdios;
+uint8_t ao_cur_stdio;
+uint8_t ao_num_stdios;
 #else
-int8_t ao_cur_stdio;
+uint8_t ao_cur_stdio;
 #define ao_cur_stdio   0
 #define ao_num_stdios  0
 #endif
@@ -114,7 +114,7 @@ char
 ao_getchar(void) 
 {
        int c;
-       int8_t stdio;
+       uint8_t stdio;
 
        ao_arch_block_interrupts();
        stdio = ao_cur_stdio;
@@ -133,7 +133,7 @@ ao_getchar(void)
        ao_cur_stdio = stdio;
 #endif
        ao_arch_release_interrupts();
-       return c;
+       return (char) c;
 }
 
 uint8_t
@@ -142,7 +142,7 @@ ao_echo(void)
        return ao_stdios[ao_cur_stdio].echo;
 }
 
-int8_t
+uint8_t
 ao_add_stdio(int (*_pollchar)(void),
             void (*putchar)(char),
             void (*_flush)(void)) 
index 43abc43c1ec9e24396aff9a0c5dcc13dce44e386..a2c3738de6094d58d7fa2d31bd65f080da312214 100644 (file)
@@ -39,7 +39,7 @@ ao_storage_read(ao_pos_t pos, void *v_buf, uint16_t len)
                /* Compute portion of transfer within
                 * a single block
                 */
-               this_off = (uint16_t) pos & (ao_storage_unit - 1);
+               this_off = (uint16_t) (pos & (ao_storage_unit - 1));
                this_len = ao_storage_unit - this_off;
                if (this_len > len)
                        this_len = len;
@@ -70,7 +70,7 @@ ao_storage_write(ao_pos_t pos, void *v_buf, uint16_t len)
                /* Compute portion of transfer within
                 * a single block
                 */
-               this_off = (uint16_t) pos & (ao_storage_unit - 1);
+               this_off = (uint16_t) (pos & (ao_storage_unit - 1));
                this_len = ao_storage_unit - this_off;
                if (this_len > len)
                        this_len = len;
@@ -102,7 +102,7 @@ ao_storage_is_erased(uint32_t pos)
                uint32_t this_time = AO_STORAGE_DATA_SIZE;
                if (this_time > read_len)
                        this_time = read_len;
-               if (!ao_storage_read(read_pos, storage_data, this_time)) {
+               if (!ao_storage_read(read_pos, storage_data, (uint16_t) this_time)) {
                        ret = 0;
                        goto done;
                }
index beb4da30e5ad7d799b3780017b805e692c34d656..9197e25cef0f6f1c828d033404227206cd75a934 100644 (file)
@@ -38,7 +38,7 @@
 struct ao_task {
        void *wchan;                    /* current wait channel (NULL if running) */
        AO_TICK_TYPE alarm;             /* abort ao_sleep time */
-       uint16_t task_id;               /* unique id */
+       uint8_t task_id;                /* unique id */
        /* Saved stack pointer */
        union {
                uint32_t        *sp32;
index 3074e4791dfc4c89e305ee924b4cc0ca00591d73..d567f9c2a3604c0a3a073432b869bd7204d8f92e 100644 (file)
@@ -40,16 +40,16 @@ static uint16_t ao_telemetry_desired_interval;
 #define RDF_SPACE      
 #else
 #define RDF_SPACE      
-static uint16_t ao_telemetry_time;
+static AO_TICK_TYPE    ao_telemetry_time;
 #endif
 
 #if HAS_RDF
 static RDF_SPACE uint8_t ao_rdf = 0;
-static RDF_SPACE uint16_t ao_rdf_time;
+static RDF_SPACE AO_TICK_TYPE  ao_rdf_time;
 #endif
 
 #if HAS_APRS
-static uint16_t ao_aprs_time;
+static AO_TICK_TYPE ao_aprs_time;
 
 #include <ao_aprs.h>
 #endif
@@ -138,7 +138,7 @@ ao_send_mega_sensor(void)
 {
        struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
 
-       telemetry.generic.tick = packet->tick;
+       telemetry.generic.tick = (uint16_t) packet->tick;
 #if AO_LOG_NORMALIZED
 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA_5
        telemetry.generic.type = AO_TELEMETRY_MEGA_NORM_MPU6000_MMC5983;
@@ -147,7 +147,7 @@ ao_send_mega_sensor(void)
 #endif
 
 #if HAS_GYRO
-       telemetry.mega_norm.orient = ao_sample_orient;
+       telemetry.mega_norm.orient = (uint8_t) ao_sample_orient;
 #endif
        telemetry.mega_norm.accel = ao_data_accel(packet);
        telemetry.mega_norm.pres = ao_data_pres(packet);
@@ -182,7 +182,7 @@ ao_send_mega_sensor(void)
 #endif
 
 #if HAS_GYRO
-       telemetry.mega_sensor.orient = ao_sample_orient;
+       telemetry.mega_sensor.orient = (uint8_t) ao_sample_orient;
 #endif
        telemetry.mega_sensor.accel = ao_data_accel(packet);
        telemetry.mega_sensor.pres = ao_data_pres(packet);
@@ -235,18 +235,18 @@ ao_send_mega_sensor(void)
        ao_telemetry_send();
 }
 
-static int8_t ao_telemetry_mega_data_max;
-static int8_t ao_telemetry_mega_data_cur;
+static int16_t ao_telemetry_mega_data_max;
+static int16_t ao_telemetry_mega_data_cur;
 
 /* Send mega data packet */
 static void
 ao_send_mega_data(void)
 {
        if (--ao_telemetry_mega_data_cur <= 0) {
-                       struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+               struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
                uint8_t i;
 
-               telemetry.generic.tick = packet->tick;
+               telemetry.generic.tick = (uint16_t) packet->tick;
                telemetry.generic.type = AO_TELEMETRY_MEGA_DATA;
 
                telemetry.mega_data.state = ao_flight_state;
@@ -255,16 +255,16 @@ ao_send_mega_data(void)
 
                /* ADC range is 0-4095, so shift by four to save the high 8 bits */
                for (i = 0; i < AO_ADC_NUM_SENSE; i++)
-                       telemetry.mega_data.sense[i] = packet->adc.sense[i] >> 4;
+                       telemetry.mega_data.sense[i] = (int8_t) (packet->adc.sense[i] >> 4);
 
                telemetry.mega_data.ground_pres = ao_ground_pres;
                telemetry.mega_data.ground_accel = ao_ground_accel;
                telemetry.mega_data.accel_plus_g = ao_config.accel_plus_g;
                telemetry.mega_data.accel_minus_g = ao_config.accel_minus_g;
 
-               telemetry.mega_data.acceleration = ao_accel;
-               telemetry.mega_data.speed = ao_speed;
-               telemetry.mega_data.height = ao_height;
+               telemetry.mega_data.acceleration = (int16_t) ao_accel;
+               telemetry.mega_data.speed = (int16_t) ao_speed;
+               telemetry.mega_data.height = (int16_t) ao_height;
 
                ao_telemetry_mega_data_cur = ao_telemetry_mega_data_max;
                ao_telemetry_send();
@@ -277,9 +277,9 @@ ao_send_mega_data(void)
 static void
 ao_send_metrum_sensor(void)
 {
-               struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+       struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
 
-       telemetry.generic.tick = packet->tick;
+       telemetry.generic.tick = (uint16_t) packet->tick;
        telemetry.generic.type = AO_TELEMETRY_METRUM_SENSOR;
 
        telemetry.metrum_sensor.state = ao_flight_state;
@@ -289,9 +289,9 @@ ao_send_metrum_sensor(void)
        telemetry.metrum_sensor.pres = ao_data_pres(packet);
        telemetry.metrum_sensor.temp = ao_data_temp(packet);
 
-       telemetry.metrum_sensor.acceleration = ao_accel;
-       telemetry.metrum_sensor.speed = ao_speed;
-       telemetry.metrum_sensor.height = ao_height;
+       telemetry.metrum_sensor.acceleration = (int16_t) ao_accel;
+       telemetry.metrum_sensor.speed = (int16_t) ao_speed;
+       telemetry.metrum_sensor.height = (int16_t) ao_height;
 
        telemetry.metrum_sensor.v_batt = packet->adc.v_batt;
        telemetry.metrum_sensor.sense_a = packet->adc.sense_a;
@@ -300,17 +300,17 @@ ao_send_metrum_sensor(void)
        ao_telemetry_send();
 }
 
-static int8_t ao_telemetry_metrum_data_max;
-static int8_t ao_telemetry_metrum_data_cur;
+static int16_t ao_telemetry_metrum_data_max;
+static int16_t ao_telemetry_metrum_data_cur;
 
 /* Send telemetrum data packet */
 static void
 ao_send_metrum_data(void)
 {
        if (--ao_telemetry_metrum_data_cur <= 0) {
-                       struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+               struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
 
-               telemetry.generic.tick = packet->tick;
+               telemetry.generic.tick = (uint16_t) packet->tick;
                telemetry.generic.type = AO_TELEMETRY_METRUM_DATA;
 
                telemetry.metrum_data.ground_pres = ao_ground_pres;
@@ -335,9 +335,9 @@ ao_send_metrum_data(void)
 static void
 ao_send_mini(void)
 {
-               struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+       struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
 
-       telemetry.generic.tick = packet->tick;
+       telemetry.generic.tick = (uint16_t) packet->tick;
        telemetry.generic.type = AO_SEND_MINI;
 
        telemetry.mini.state = ao_flight_state;
@@ -349,9 +349,9 @@ ao_send_mini(void)
        telemetry.mini.pres = ao_data_pres(packet);
        telemetry.mini.temp = ao_data_temp(packet);
 
-       telemetry.mini.acceleration = ao_accel;
-       telemetry.mini.speed = ao_speed;
-       telemetry.mini.height = ao_height;
+       telemetry.mini.acceleration = (int16_t) ao_accel;
+       telemetry.mini.speed = (int16_t) ao_speed;
+       telemetry.mini.height = (int16_t) ao_height;
 
        telemetry.mini.ground_pres = ao_ground_pres;
 
@@ -360,8 +360,8 @@ ao_send_mini(void)
 
 #endif /* AO_SEND_MINI */
 
-static int8_t ao_telemetry_config_max;
-static int8_t ao_telemetry_config_cur;
+static int16_t ao_telemetry_config_max;
+static int16_t ao_telemetry_config_cur;
 static uint16_t ao_telemetry_flight_number;
 
 #ifndef ao_telemetry_battery_convert
@@ -380,13 +380,13 @@ ao_send_configuration(void)
                telemetry.configuration.config_minor = AO_CONFIG_MINOR;
 #if AO_idProduct_NUMBER == 0x25 && HAS_ADC
                /* TeleGPS gets battery voltage instead of apogee delay */
-               telemetry.configuration.apogee_delay = ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt);
+               telemetry.configuration.apogee_delay = (uint16_t) ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt);
 #else
                telemetry.configuration.apogee_delay = ao_config.apogee_delay;
                telemetry.configuration.main_deploy = ao_config.main_deploy;
 #endif
 
-               telemetry.configuration.flight_log_max = ao_config.flight_log_max >> 10;
+               telemetry.configuration.flight_log_max = (uint16_t) (ao_config.flight_log_max >> 10);
                memcpy (telemetry.configuration.callsign,
                        ao_config.callsign,
                        AO_MAX_CALLSIGN);
@@ -400,9 +400,9 @@ ao_send_configuration(void)
 
 #if HAS_GPS
 
-static int8_t ao_telemetry_gps_max;
-static int8_t ao_telemetry_loc_cur;
-static int8_t ao_telemetry_sat_cur;
+static int16_t ao_telemetry_gps_max;
+static int16_t ao_telemetry_loc_cur;
+static int16_t ao_telemetry_sat_cur;
 
 static inline void *
 telemetry_bits(struct ao_telemetry_location *l)
@@ -410,7 +410,7 @@ telemetry_bits(struct ao_telemetry_location *l)
        return ((uint8_t *) l) + offsetof(struct ao_telemetry_location, flags);
 }
 
-static inline int
+static inline size_t
 telemetry_size(void)
 {
        return sizeof(struct ao_telemetry_location) - offsetof(struct ao_telemetry_location, flags);
@@ -426,7 +426,7 @@ ao_send_location(void)
                memcpy(telemetry_bits(&telemetry.location),
                       telemetry_bits(&ao_gps_data),
                       telemetry_size());
-               telemetry.location.tick = ao_gps_tick;
+               telemetry.location.tick = (uint16_t) ao_gps_tick;
                ao_mutex_put(&ao_gps_mutex);
                ao_telemetry_loc_cur = ao_telemetry_gps_max;
                ao_telemetry_send();
@@ -453,15 +453,15 @@ ao_send_satellite(void)
 
 #if HAS_COMPANION
 
-static int8_t ao_telemetry_companion_max;
-static int8_t ao_telemetry_companion_cur;
+static int16_t ao_telemetry_companion_max;
+static int16_t ao_telemetry_companion_cur;
 
 static void
 ao_send_companion(void)
 {
        if (--ao_telemetry_companion_cur <= 0) {
                telemetry.generic.type = AO_TELEMETRY_COMPANION;
-               telemetry.companion.board_id = ao_companion_setup.board_id;
+               telemetry.companion.board_id = (uint8_t) ao_companion_setup.board_id;
                telemetry.companion.update_period = ao_companion_setup.update_period;
                telemetry.companion.channels = ao_companion_setup.channels;
                ao_mutex_get(&ao_companion_mutex);
@@ -500,8 +500,8 @@ ao_set_aprs_time(void)
 static void
 ao_telemetry(void)
 {
-       uint16_t        time;
-       int16_t         delay;
+       AO_TICK_TYPE    time;
+       AO_TICK_SIGNED  delay;
 
        ao_config_get();
        if (!ao_config.radio_enable)
@@ -601,9 +601,9 @@ ao_telemetry(void)
                                        time = ao_aprs_time;
                        }
 #endif /* HAS_APRS */
-                       delay = time - ao_time();
+                       delay = (AO_TICK_SIGNED) (time - ao_time());
                        if (delay > 0) {
-                               ao_sleep_for(&telemetry, delay);
+                               ao_sleep_for(&telemetry, (AO_TICK_TYPE) delay);
                        }
                }
        }
@@ -620,7 +620,7 @@ ao_telemetry_reset_interval(void)
 void
 ao_telemetry_set_interval(uint16_t interval)
 {
-       int8_t  cur = 0;
+       int16_t cur = 0;
 
 #if HAS_RADIO_RATE
        /* Limit max telemetry rate based on available radio bandwidth.
@@ -646,7 +646,7 @@ ao_telemetry_set_interval(uint16_t interval)
        ao_telemetry_mega_data_cur = cur;
 #endif
 #if AO_SEND_METRUM
-       ao_telemetry_metrum_data_max = AO_SEC_TO_TICKS(1) / interval;
+       ao_telemetry_metrum_data_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval);
        if (ao_telemetry_metrum_data_max > cur)
                cur++;
        ao_telemetry_metrum_data_cur = cur;
@@ -655,14 +655,14 @@ ao_telemetry_set_interval(uint16_t interval)
 #if HAS_COMPANION
        if (!ao_companion_setup.update_period)
                ao_companion_setup.update_period = AO_SEC_TO_TICKS(1);
-       ao_telemetry_companion_max = ao_companion_setup.update_period / interval;
+       ao_telemetry_companion_max = (int16_t) (ao_companion_setup.update_period / interval);
        if (ao_telemetry_companion_max > cur)
                cur++;
        ao_telemetry_companion_cur = cur;
 #endif
 
 #if HAS_GPS
-       ao_telemetry_gps_max = AO_SEC_TO_TICKS(1) / interval;
+       ao_telemetry_gps_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval);
        if (ao_telemetry_gps_max > cur)
                cur++;
        ao_telemetry_loc_cur = cur;
@@ -671,7 +671,7 @@ ao_telemetry_set_interval(uint16_t interval)
        ao_telemetry_sat_cur = cur;
 #endif
 
-       ao_telemetry_config_max = AO_SEC_TO_TICKS(5) / interval;
+       ao_telemetry_config_max = (int16_t) (AO_SEC_TO_TICKS(5) / interval);
        if (ao_telemetry_config_max > cur)
                cur++;
        ao_telemetry_config_cur = cur;
index b718085f8e11eb83d295322c135416bc785ec852..251a3fcda3fd36934d4e336617cbb20ef267fed9 100644 (file)
@@ -131,8 +131,8 @@ struct ao_telemetry_location {
 typedef int32_t                gps_alt_t;
 #define AO_TELEMETRY_LOCATION_ALTITUDE(l)      (((gps_alt_t) (l)->altitude_high << 16) | ((l)->altitude_low))
 #define AO_TELEMETRY_LOCATION_SET_ALTITUDE(l,a) (((l)->mode |= AO_GPS_MODE_ALTITUDE_24), \
-                                                ((l)->altitude_high = (a) >> 16), \
-                                                ((l)->altitude_low = (a)))
+                                                ((l)->altitude_high = (int8_t) ((a) >> 16)), \
+                                                ((l)->altitude_low = (uint16_t) (a)))
 #else
 typedef int16_t                gps_alt_t;
 #define AO_TELEMETRY_LOCATION_ALTITUDE(l)      ((gps_alt_t) (l)->altitude_low)
index b7e634656285a2b823c9ff6cb088fbe4c81c5736..e45653a69fc9ef529b88b54fb2fa35470ab1b78b 100644 (file)
@@ -55,14 +55,14 @@ static uint8_t      tracker_mutex;
 static uint8_t log_started;
 static struct ao_telemetry_location gps_data;
 static uint8_t tracker_running;
-static uint16_t tracker_interval;
+static uint8_t tracker_interval;
 
 static void
 ao_tracker(void)
 {
        uint8_t new;
-       int32_t ground_distance;
-       int16_t height;
+       uint32_t ground_distance;
+       gps_alt_t height;
        AO_TICK_TYPE gps_tick;
        uint8_t new_tracker_running;
 
@@ -134,8 +134,8 @@ ao_tracker(void)
                                                height = -height;
 
                                        if (ao_tracker_force_telem > 1)
-                                               printf("head %d ring %d ground_distance %ld height %d\n", gps_head, ring, (long) ground_distance, height);
-                                       if (ground_distance > ao_config.tracker_motion ||
+                                               printf("head %d ring %d ground_distance %lu height %ld\n", gps_head, ring, (long) ground_distance, height);
+                                       if (ground_distance > (uint32_t) ao_config.tracker_motion ||
                                            height > (ao_config.tracker_motion << 1))
                                        {
                                                moving = 1;
@@ -186,9 +186,9 @@ ao_gps_lock(void)
 static uint8_t erasing_current;
 
 void
-ao_tracker_erase_start(uint16_t flight)
+ao_tracker_erase_start(int32_t flight)
 {
-       erasing_current = flight == ao_flight_number;
+       erasing_current = flight == (int32_t) ao_flight_number;
        if (erasing_current) {
                ao_mutex_get(&tracker_mutex);
                ao_log_stop();
@@ -211,9 +211,9 @@ static struct ao_task ao_tracker_task;
 static void
 ao_tracker_set_telem(void)
 {
-       uint16_t r = ao_cmd_hex();
+       uint32_t r = ao_cmd_hex();
        if (ao_cmd_status == ao_cmd_success)
-               ao_tracker_force_telem = r;
+               ao_tracker_force_telem = r != 0;
        ao_cmd_status = ao_cmd_success;
        printf ("flight: %d\n", ao_flight_number);
        printf ("force_telem: %d\n", ao_tracker_force_telem);
index 7d534339808ef5950465acbc053cb0b884ce09c9..27fa15a896dc7a266fa7a385de37274ec7080679 100644 (file)
@@ -30,7 +30,7 @@ void
 ao_tracker_init(void);
 
 void
-ao_tracker_erase_start(uint16_t flight);
+ao_tracker_erase_start(int32_t flight);
 
 void
 ao_tracker_erase_end(void);
index 6324155977a7a4a538bf3cdbd051e274fae42a33..c5a703c23da26fd19cb4c747534c95b6f7849fec 100644 (file)
@@ -92,7 +92,7 @@ static const uint8_t  ao_adc_mask_seq[AO_ADC_NUM] = {
 #define sample(id)     (*out++ = (uint16_t) lpc_adc.dr[id] >> 1)
 
 static inline void lpc_adc_start(void) {
-       lpc_adc.cr = ((ao_adc_mask_seq[ao_adc_sequence] << LPC_ADC_CR_SEL) |
+       lpc_adc.cr = (((uint32_t) ao_adc_mask_seq[ao_adc_sequence] << LPC_ADC_CR_SEL) |
                      (AO_ADC_CLKDIV << LPC_ADC_CR_CLKDIV) |
                      (0 << LPC_ADC_CR_BURST) |
                      (LPC_ADC_CR_CLKS_11 << LPC_ADC_CR_CLKS) |
@@ -160,7 +160,7 @@ void
 ao_adc_init(void)
 {
        lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_ADC);
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_ADC_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_ADC_PD);
 
        /* Enable interrupt when channel is complete */
        lpc_adc.inten = (1 << LPC_ADC_INTEN_ADGINTEN);
index e0280e76466a2f6e4a1752478b828c743de33e6d..e88b0141f9ad7c37ea8785e448d9a59411b142f7 100644 (file)
@@ -23,7 +23,7 @@
 #define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,(1<<bit),bus)
 
 #define ao_enable_port(port) (lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_GPIO))
-#define ao_disable_port(port) (lpc_scb.sysahbclkctrl &= ~(1 << LPC_SCB_SYSAHBCLKCTRL_GPIO))
+#define ao_disable_port(port) (lpc_scb.sysahbclkctrl &= ~(1UL << LPC_SCB_SYSAHBCLKCTRL_GPIO))
 
 #define lpc_all_bit(port,bit)  (((port) << 5) | (bit))
 
@@ -65,7 +65,7 @@ static inline void lpc_set_gpio(int port, int bit) {
 #define ao_enable_input(port,bit,mode) do {                            \
                ao_enable_port(port);                                   \
                lpc_set_gpio(port,bit);                                 \
-               lpc_gpio.dir[port] &= ~(1 << bit);                      \
+               lpc_gpio.dir[port] &= ~(1UL << bit);                    \
                ao_gpio_set_mode(port,bit,mode);                        \
        } while (0)
 
@@ -80,7 +80,7 @@ static inline void lpc_set_gpio(int port, int bit) {
 
 #define ao_enable_analog(port,bit,id) do {                             \
                ao_enable_port(port);                                   \
-               lpc_gpio.dir[port] &= ~(1 << bit);                      \
+               lpc_gpio.dir[port] &= ~(1UL << bit);                    \
                lpc_ioconf.analog_reg(port,bit) = ((analog_func(id) << LPC_IOCONF_FUNC) | \
                                                   (0 << LPC_IOCONF_ADMODE)); \
        } while (0)
index ab06ef48776be45260add4fe20242114b1ba5f6c..13aa337445e9f74b0c90e63c68f47f60c5ee95d7 100644 (file)
@@ -24,7 +24,7 @@ ao_beep(uint8_t beep)
        if (beep == 0) {
                lpc_ct32b1.tcr = ((0 << LPC_CT32B_TCR_CEN) |
                                  (1 << LPC_CT32B_TCR_CRST));
-               lpc_scb.sysahbclkctrl &= ~(1 << LPC_SCB_SYSAHBCLKCTRL_CT32B1);
+               lpc_scb.sysahbclkctrl &= ~(1UL << LPC_SCB_SYSAHBCLKCTRL_CT32B1);
        } else {
                lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_CT32B1);
 
index 12016072f7037e625c5006708fc4c39f507ee88f..5722e17d2b887400ae83df7db76de08d9d38d802 100644 (file)
@@ -53,7 +53,7 @@ pin_isr(5)
 pin_isr(6)
 pin_isr(7)
 
-#define pin_id(port,pin)       ((port) * 24 + (pin));
+#define pin_id(port,pin)       ((uint8_t) ((port) * 24 + (pin)))
 
 static void
 _ao_exti_set_enable(uint8_t pint)
@@ -83,7 +83,7 @@ void
 ao_exti_setup (uint8_t port, uint8_t pin, uint8_t mode, void (*callback)(void)) {
        uint8_t         id = pin_id(port,pin);
        uint8_t         pint;
-       uint32_t        mask;
+       uint8_t         mask;
        uint8_t         prio;
 
        for (pint = 0; pint < LPC_NUM_PINT; pint++)
@@ -98,7 +98,7 @@ ao_exti_setup (uint8_t port, uint8_t pin, uint8_t mode, void (*callback)(void))
        ao_arch_block_interrupts();
        mask = (1 << pint);
        ao_pint_inuse |= mask;
-       ao_pint_enabled &= ~mask;
+       ao_pint_enabled &= (uint8_t) ~mask;
 
        ao_pint_map[id] = pint;
        ao_exti_callback[pint] = callback;
@@ -109,7 +109,7 @@ ao_exti_setup (uint8_t port, uint8_t pin, uint8_t mode, void (*callback)(void))
        /* Set edge triggered */
        lpc_gpio_pin.isel &= ~mask;
 
-       ao_pint_enabled &= ~mask;
+       ao_pint_enabled &= (uint8_t) ~mask;
        ao_pint_mode[pint] = mode;
        _ao_exti_set_enable(pint);
 
@@ -167,7 +167,7 @@ ao_exti_disable(uint8_t port, uint8_t pin) {
        uint8_t         mask = 1 << pint;
 
        ao_arch_block_interrupts();
-       ao_pint_enabled &= ~mask;
+       ao_pint_enabled &= (uint8_t) ~mask;
        _ao_exti_set_enable(pint);
        ao_arch_release_interrupts();
 }
index cb1a060668a173ba6e1c4634c26b8ba887924065..37913091ae7f50796eaf04ae105ef07528b87766 100644 (file)
@@ -76,7 +76,7 @@ static uint32_t       iap_in[5], iap_out[5];
 static uint32_t
 ao_lpc_addr_to_sector(uint8_t *addr)
 {
-       uint32_t        off = addr - LPC_FLASH_BASE;
+       uint32_t        off = (uint32_t) (addr - LPC_FLASH_BASE);
 
        return off >> LPC_FLASH_SECTOR_SHIFT;
 }
@@ -84,7 +84,7 @@ ao_lpc_addr_to_sector(uint8_t *addr)
 static uint8_t
 ao_lpc_addr_is_sector_aligned(uint8_t *addr)
 {
-       uint32_t        off = addr - LPC_FLASH_BASE;
+       uint32_t        off = (uint32_t) (addr - LPC_FLASH_BASE);
        return          (off & LPC_FLASH_SECTOR_MASK) == 0;
 }
 
index d5cf930af949076bf2829c489f69ee2ea001178b..db0e0b0c55a3f2e22513439a4acf2a8a961b239c 100644 (file)
@@ -54,7 +54,7 @@ lpc_usart_isr(void)
        (void) lpc_usart.iir_fcr;
 
        while (lpc_usart.lsr & (1 << LPC_USART_LSR_RDR)) {
-               char c = lpc_usart.rbr_thr;
+               char c = (char) lpc_usart.rbr_thr;
                if (!ao_fifo_full(ao_usart_rx_fifo))
                        ao_fifo_insert(ao_usart_rx_fifo, c);
                wake_input = 1;
@@ -135,11 +135,11 @@ ao_serial0_set_speed(uint8_t speed)
        /* DL MSB */
        lpc_usart.ier = (ao_usart_speeds[speed].dl >> 8) & 0xff;
 
-       lpc_usart.fdr = ((ao_usart_speeds[speed].divaddval << LPC_USART_FDR_DIVADDVAL) |
-                        (ao_usart_speeds[speed].mulval << LPC_USART_FDR_MULVAL));
+       lpc_usart.fdr = (((uint32_t) ao_usart_speeds[speed].divaddval << LPC_USART_FDR_DIVADDVAL) |
+                        ((uint32_t) ao_usart_speeds[speed].mulval << LPC_USART_FDR_MULVAL));
 
        /* Turn access to divisor latches back off */
-       lpc_usart.lcr &= ~(1 << LPC_USART_LCR_DLAB);
+       lpc_usart.lcr &= ~(1UL << LPC_USART_LCR_DLAB);
 }
 
 void
index a8d4cda9229b32d176c480916ff39c55988af6ed..ec48e95c386eeec40a1f90b936606aa22193fede 100644 (file)
@@ -30,7 +30,7 @@ static struct lpc_ssp * const ao_lpc_ssp[LPC_NUM_SPI] = { &lpc_ssp0, &lpc_ssp1 }
                        while ((lpc_ssp->sr & (1 << LPC_SSP_SR_RNE)) == 0) \
                                ;                                       \
                        /* receive a byte */                            \
-                       get lpc_ssp->dr;                                \
+                       get (uint8_t) lpc_ssp->dr;                      \
                }                                                       \
                /* Wait for the SSP to go idle (it already should be) */ \
                while (lpc_ssp->sr & (1 << LPC_SSP_SR_BSY));            \
@@ -147,7 +147,7 @@ ao_spi_init(void)
        lpc_scb.ssp0clkdiv = 1;
 
        /* Reset the device */
-       lpc_scb.presetctrl &= ~(1 << LPC_SCB_PRESETCTRL_SSP0_RST_N);
+       lpc_scb.presetctrl &= ~(1UL << LPC_SCB_PRESETCTRL_SSP0_RST_N);
        lpc_scb.presetctrl |= (1 << LPC_SCB_PRESETCTRL_SSP0_RST_N);
        ao_spi_channel_init(0);
 #endif
@@ -197,7 +197,7 @@ ao_spi_init(void)
        lpc_scb.ssp1clkdiv = 1;
 
        /* Reset the device */
-       lpc_scb.presetctrl &= ~(1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
+       lpc_scb.presetctrl &= ~(1UL << LPC_SCB_PRESETCTRL_SSP1_RST_N);
        lpc_scb.presetctrl |= (1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
        ao_spi_channel_init(1);
 #endif /* HAS_SPI_1 */
index a334ee0d286f8b78fa57ed5a80720545d52e795c..7bd56445e8ba0599d4e92f9a0d309696ac5127d2 100644 (file)
@@ -121,13 +121,13 @@ ao_clock_init(void)
         * make sure the flash part remains happy
         */
 
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_BOD_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_BOD_PD);
        lpc_scb.bodctrl = ((LPC_SCB_BOD_BODRSTLEV_2_63 << LPC_SCB_BOD_BODRSTLEV) |
                           (LPC_SCB_BOD_BODINTVAL_RESERVED << LPC_SCB_BOD_BODINTVAL) |
                           (1 << LPC_SCB_BOD_BODRSTENA));
 
        /* Turn the IRC clock back on */
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_IRC_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_IRC_PD);
        ao_clock_delay();
 
        /* Switch to the IRC clock */
@@ -158,7 +158,7 @@ ao_clock_init(void)
 
        /* Set PLL divider values */
        lpc_scb.syspllctrl = ((AO_LPC_M << LPC_SCB_SYSPLLCTRL_MSEL) |
-                             (p << LPC_SCB_SYSPLLCTRL_PSEL));
+                             ((uint32_t) p << LPC_SCB_SYSPLLCTRL_PSEL));
 
        /* Turn off the external crystal clock */
        lpc_scb.pdruncfg |= (1 << LPC_SCB_PDRUNCFG_SYSOSC_PD);
@@ -169,7 +169,7 @@ ao_clock_init(void)
                              ((AO_LPC_CLKIN > 15000000) << LPC_SCB_SYSOSCCTRL_FREQRANGE));/* set range */
 
        /* Turn on the external crystal clock */
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_SYSOSC_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_SYSOSC_PD);
        ao_clock_delay();
 
        /* Select crystal as PLL input */
@@ -182,7 +182,7 @@ ao_clock_init(void)
                ;
 
        /* Turn on the PLL */
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_SYSPLL_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_SYSPLL_PD);
 
        /* Wait for it to lock */
 
index 9e94de12b1db05e8d3c4927eb6700a65103e028c..044699168bae42aac3858a8d2f6105ff4035de45 100644 (file)
@@ -133,7 +133,7 @@ static void
 ao_usb_set_address(uint8_t address)
 {
        debug("ao_usb_set_address %02x\n", address);
-       lpc_usb.devcmdstat = ((address << LPC_USB_DEVCMDSTAT_DEV_ADDR) |
+       lpc_usb.devcmdstat = (((uint32_t) address << LPC_USB_DEVCMDSTAT_DEV_ADDR) |
                              (1 << LPC_USB_DEVCMDSTAT_DEV_EN) |
                              (0 << LPC_USB_DEVCMDSTAT_SETUP) |
                              (0 << LPC_USB_DEVCMDSTAT_PLL_ON) |
@@ -196,14 +196,14 @@ ao_usb_sram_offset(uint8_t *addr)
 static void
 ao_usb_set_ep(vuint32_t *ep, uint8_t *addr, uint16_t nbytes)
 {
-       *ep = ((ao_usb_sram_offset(addr) << LPC_USB_EP_OFFSET) |
-              (nbytes << LPC_USB_EP_NBYTES) |
+       *ep = (((uint32_t) ao_usb_sram_offset(addr) << LPC_USB_EP_OFFSET) |
+              ((uint32_t) nbytes << LPC_USB_EP_NBYTES) |
               (0 << LPC_USB_EP_ENDPOINT_ISO) |
               (0 << LPC_USB_EP_RATE_FEEDBACK) |
               (0 << LPC_USB_EP_TOGGLE_RESET) |
               (0 << LPC_USB_EP_STALL) |
               (0 << LPC_USB_EP_DISABLED) |
-              (1 << LPC_USB_EP_ACTIVE));
+              (1UL << LPC_USB_EP_ACTIVE));
 }
 
 static inline uint16_t
@@ -326,7 +326,7 @@ ao_usb_reset(void)
 static void
 ao_usb_set_ep0(void)
 {
-       int                     e;
+       uint8_t e;
 
        /* Everything is single buffered for now */
        lpc_usb.epbufcfg = 0;
@@ -425,7 +425,7 @@ ao_usb_ep0_fill(void)
 
        if (len > ao_usb_ep0_out_len)
                len = ao_usb_ep0_out_len;
-       ao_usb_ep0_out_len -= len;
+       ao_usb_ep0_out_len -= (uint8_t) len;
 
        debug_data ("Fill EP0 len %d:", len);
        memcpy(ao_usb_ep0_out_data, rx_buffer, len);
@@ -471,7 +471,7 @@ ao_usb_ep0_in_start(uint16_t max)
        ao_usb_ep0_in_max = max;
        /* Don't send more than asked for */
        if (ao_usb_ep0_in_len > max)
-               ao_usb_ep0_in_len = max;
+               ao_usb_ep0_in_len = (uint8_t) max;
        ao_usb_ep0_flush();
 }
 
@@ -483,8 +483,8 @@ static void
 ao_usb_get_descriptor(uint16_t value, uint16_t length)
 {
        const uint8_t           *descriptor;
-       uint8_t         type = value >> 8;
-       uint8_t         index = value;
+       uint8_t         type = (uint8_t) (value >> 8);
+       uint8_t         index = (uint8_t) value;
 
        descriptor = ao_usb_descriptors;
        while (descriptor[0] != 0) {
@@ -495,7 +495,7 @@ ao_usb_get_descriptor(uint16_t value, uint16_t length)
                        else
                                len = descriptor[0];
                        if (len > length)
-                               len = length;
+                               len = (uint8_t) length;
                        ao_usb_ep0_in_set(descriptor, len);
                        break;
                }
@@ -535,7 +535,7 @@ ao_usb_ep0_setup(void)
                                break;
                        case AO_USB_REQ_SET_ADDRESS:
                                debug ("set address %d\n", ao_usb_setup.value);
-                               ao_usb_address = ao_usb_setup.value;
+                               ao_usb_address = (uint8_t) ao_usb_setup.value;
                                ao_usb_address_pending = 1;
                                break;
                        case AO_USB_REQ_GET_DESCRIPTOR:
@@ -547,7 +547,7 @@ ao_usb_ep0_setup(void)
                                ao_usb_ep0_in_queue_byte(ao_usb_configuration);
                                break;
                        case AO_USB_REQ_SET_CONFIGURATION:
-                               ao_usb_configuration = ao_usb_setup.value;
+                               ao_usb_configuration = (uint8_t) ao_usb_setup.value;
                                debug ("set configuration %d\n", ao_usb_configuration);
                                ao_usb_set_configuration();
                                break;
@@ -704,7 +704,7 @@ lpc_usb_irq_isr(void)
        }
 
        /* Check for reset */
-       if (intstat & (1 << LPC_USB_INT_DEV)) {
+       if (intstat & (1UL << LPC_USB_INT_DEV)) {
                if (lpc_usb.devcmdstat & (1 << LPC_USB_DEVCMDSTAT_DRES_C))
                {
                        lpc_usb.devcmdstat |= (1 << LPC_USB_DEVCMDSTAT_DRES_C);
@@ -799,7 +799,7 @@ _ao_usb_out_recv(void)
        _rx_dbg0("out_recv top");
        ao_usb_out_avail = 0;
 
-       ao_usb_rx_count = AO_USB_OUT_SIZE - ao_usb_epn_out_count(AO_USB_OUT_EP);
+       ao_usb_rx_count = (uint8_t) (AO_USB_OUT_SIZE - ao_usb_epn_out_count(AO_USB_OUT_EP));
 
        _rx_dbg1("out_recv count", ao_usb_rx_count);
        debug ("recv %d\n", ao_usb_rx_count);
@@ -846,7 +846,7 @@ ao_usb_getchar(void)
        while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
                ao_sleep(AO_USB_OUT_SLEEP_ADDR);
        ao_arch_release_interrupts();
-       return c;
+       return (char) c;
 }
 
 void
@@ -873,8 +873,8 @@ ao_usb_disable(void)
                             (1 << LPC_SCB_PDRUNCFG_USBPLL_PD));
 
        /* Disable USB registers and RAM */
-       lpc_scb.sysahbclkctrl &= ~((1 << LPC_SCB_SYSAHBCLKCTRL_USB) |
-                                  (1 << LPC_SCB_SYSAHBCLKCTRL_USBRAM));
+       lpc_scb.sysahbclkctrl &= ~((1UL << LPC_SCB_SYSAHBCLKCTRL_USB) |
+                                  (1UL << LPC_SCB_SYSAHBCLKCTRL_USBRAM));
 
        ao_arch_release_interrupts();
 }
@@ -906,10 +906,10 @@ ao_usb_enable(void)
                                  (1 << LPC_SCB_SYSAHBCLKCTRL_USBRAM));
 
        /* Enable USB PHY */
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_USBPAD_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_USBPAD_PD);
 
        /* Turn on USB PLL */
-       lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_USBPLL_PD);
+       lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_USBPLL_PD);
 
        lpc_scb.usbpllclksel = (LPC_SCB_SYSPLLCLKSEL_SEL_SYSOSC << LPC_SCB_SYSPLLCLKSEL_SEL);
        lpc_scb.usbpllclkuen = (0 << LPC_SCB_USBPLLCLKUEN_ENA);
@@ -946,12 +946,12 @@ ao_usb_enable(void)
        debug ("ao_usb_enable\n");
 
        /* Enable interrupts */
-       lpc_usb.inten = ((1 << LPC_USB_INT_EPOUT(0)) |
-                        (1 << LPC_USB_INT_EPIN(0)) |
-                        (1 << LPC_USB_INT_EPIN(AO_USB_INT_EP)) |
-                        (1 << LPC_USB_INT_EPOUT(AO_USB_OUT_EP)) |
-                        (1 << LPC_USB_INT_EPIN(AO_USB_IN_EP)) |
-                        (1 << LPC_USB_INT_DEV));
+       lpc_usb.inten = ((1UL << LPC_USB_INT_EPOUT(0)) |
+                        (1UL << LPC_USB_INT_EPIN(0)) |
+                        (1UL << LPC_USB_INT_EPIN(AO_USB_INT_EP)) |
+                        (1UL << LPC_USB_INT_EPOUT(AO_USB_OUT_EP)) |
+                        (1UL << LPC_USB_INT_EPIN(AO_USB_IN_EP)) |
+                        (1UL << LPC_USB_INT_DEV));
 
        ao_arch_release_interrupts();
 
index 1cf35dad2e6846fc35d7cfa45846c4b475d7de88..fbf529c941d494d6ed4499ac896b75cebecf7148 100644 (file)
@@ -359,7 +359,7 @@ extern struct lpc_ioconf lpc_ioconf;
 /* PIO1_31 */
 #define  LPC_IOCONF_FUNC_PIO1_31       0
 
-#define  LPC_IOCONF_FUNC_MASK          0x7
+#define  LPC_IOCONF_FUNC_MASK          0x7UL
 
 #define ao_lpc_alternate(func) (((func) << LPC_IOCONF_FUNC) | \
                                (LPC_IOCONF_MODE_INACTIVE << LPC_IOCONF_MODE) | \
@@ -373,7 +373,7 @@ extern struct lpc_ioconf lpc_ioconf;
 #define  LPC_IOCONF_MODE_PULL_DOWN             1
 #define  LPC_IOCONF_MODE_PULL_UP               2
 #define  LPC_IOCONF_MODE_REPEATER              3
-#define  LPC_IOCONF_MODE_MASK                  3
+#define  LPC_IOCONF_MODE_MASK                  3UL
 
 #define LPC_IOCONF_HYS                 5
 
@@ -504,7 +504,7 @@ extern struct lpc_scb lpc_scb;
 #define  LPC_SCB_SYSPLLCTRL_PSEL_2             1
 #define  LPC_SCB_SYSPLLCTRL_PSEL_4             2
 #define  LPC_SCB_SYSPLLCTRL_PSEL_8             3
-#define  LPC_SCB_SYSPLLCTRL_PSEL_MASK          3
+#define  LPC_SCB_SYSPLLCTRL_PSEL_MASK          3UL
 
 #define LPC_SCB_SYSPLLSTAT_LOCK                0
 
@@ -514,7 +514,7 @@ extern struct lpc_scb lpc_scb;
 #define  LPC_SCB_USBPLLCTRL_PSEL_2             1
 #define  LPC_SCB_USBPLLCTRL_PSEL_4             2
 #define  LPC_SCB_USBPLLCTRL_PSEL_8             3
-#define  LPC_SCB_USBPLLCTRL_PSEL_MASK          3
+#define  LPC_SCB_USBPLLCTRL_PSEL_MASK          3UL
 
 #define LPC_SCB_USBPLLSTAT_LOCK                0
 
@@ -524,7 +524,7 @@ extern struct lpc_scb lpc_scb;
 #define  LPC_SCB_SYSOSCCTRL_FREQRANGE_15_25    1
 
 #define LPC_SCB_WDTOSCCTRL_DIVSEL              0
-#define  LPC_SCB_WDTOSCCTRL_DIVSEL_MASK                        0x1f
+#define  LPC_SCB_WDTOSCCTRL_DIVSEL_MASK                        0x1fUL
 #define LPC_SCB_WDTOSCCTRL_FREQSEL             5
 #define  LPC_SCB_WDTOSCCTRL_FREQSEL_0_6                        1
 #define  LPC_SCB_WDTOSCCTRL_FREQSEL_1_05               2
@@ -541,7 +541,7 @@ extern struct lpc_scb lpc_scb;
 #define  LPC_SCB_WDTOSCCTRL_FREQSEL_4_2                        0x0d
 #define  LPC_SCB_WDTOSCCTRL_FREQSEL_4_4                        0x0e
 #define  LPC_SCB_WDTOSCCTRL_FREQSEL_4_6                        0x0f
-#define  LPC_SCB_WDTOSCCTRL_FREQSEL_MASK               0x0f
+#define  LPC_SCB_WDTOSCCTRL_FREQSEL_MASK               0x0fUL
 
 #define LPC_SCB_SYSRSTSTAT_POR         0
 #define LPC_SCB_SYSRSTSTAT_EXTRST      1
@@ -552,14 +552,14 @@ extern struct lpc_scb lpc_scb;
 #define LPC_SCB_SYSPLLCLKSEL_SEL       0
 #define  LPC_SCB_SYSPLLCLKSEL_SEL_IRC          0
 #define  LPC_SCB_SYSPLLCLKSEL_SEL_SYSOSC       1
-#define  LPC_SCB_SYSPLLCLKSEL_SEL_MASK         3
+#define  LPC_SCB_SYSPLLCLKSEL_SEL_MASK         3UL
 
 #define LPC_SCB_SYSPLLCLKUEN_ENA       0
 
 #define LPC_SCB_USBPLLCLKSEL_SEL       0
 #define  LPC_SCB_USBPLLCLKSEL_SEL_IRC          0
 #define  LPC_SCB_USBPLLCLKSEL_SEL_SYSOSC       1
-#define  LPC_SCB_USBPLLCLKSEL_SEL_MASK         3
+#define  LPC_SCB_USBPLLCLKSEL_SEL_MASK         3UL
 
 #define LPC_SCB_USBPLLCLKUEN_ENA       0
 
@@ -568,7 +568,7 @@ extern struct lpc_scb lpc_scb;
 #define  LPC_SCB_MAINCLKSEL_SEL_PLL_INPUT      1
 #define  LPC_SCB_MAINCLKSEL_SEL_WATCHDOG       2
 #define  LPC_SCB_MAINCLKSEL_SEL_PLL_OUTPUT     3
-#define  LPC_SCB_MAINCLKSEL_SEL_MASK           3
+#define  LPC_SCB_MAINCLKSEL_SEL_MASK           3UL
 
 #define LPC_SCB_MAINCLKUEN_ENA         0
 
@@ -777,7 +777,7 @@ extern struct lpc_usart lpc_usart;
 #define LPC_USART_IIR_INTID_CTI                        6
 #define LPC_USART_IIR_INTID_THRE               1
 #define LPC_USART_IIR_INTID_MS                 0
-#define LPC_USART_IIR_INTID_MASK               7
+#define LPC_USART_IIR_INTID_MASK               7UL
 #define LPC_USART_IIR_FIFOEN           6
 #define LPC_USART_IIR_ABEOINT          8
 #define LPC_USART_IIR_ABTOINT          9
@@ -796,18 +796,18 @@ extern struct lpc_usart lpc_usart;
 #define LPC_USART_LCR_WLS_6            1
 #define LPC_USART_LCR_WLS_7            2
 #define LPC_USART_LCR_WLS_8            3
-#define LPC_USART_LCR_WLS_MASK         3
+#define LPC_USART_LCR_WLS_MASK         3UL
 #define LPC_USART_LCR_SBS      2
 #define LPC_USART_LCR_SBS_1            0
 #define LPC_USART_LCR_SBS_2            1
-#define LPC_USART_LCR_SBS_MASK         1
+#define LPC_USART_LCR_SBS_MASK         1UL
 #define LPC_USART_LCR_PE       3
 #define LPC_USART_LCR_PS       4
 #define LPC_USART_LCR_PS_ODD           0
 #define LPC_USART_LCR_PS_EVEN          1
 #define LPC_USART_LCR_PS_ONE           2
 #define LPC_USART_LCR_PS_ZERO          3
-#define LPC_USART_LCR_PS_MASK          3
+#define LPC_USART_LCR_PS_MASK          3UL
 #define LPC_USART_LCR_BC       6
 #define LPC_USART_LCR_DLAB     7
 
@@ -874,7 +874,7 @@ extern struct lpc_usb lpc_usb;
 #define lpc_usb (*(struct lpc_usb *) 0x40080000)
 
 #define LPC_USB_DEVCMDSTAT_DEV_ADDR    0
-#define LPC_USB_DEVCMDSTAT_DEV_ADDR_MASK       0x7f
+#define LPC_USB_DEVCMDSTAT_DEV_ADDR_MASK       0x7fUL
 #define LPC_USB_DEVCMDSTAT_DEV_EN      7
 #define LPC_USB_DEVCMDSTAT_SETUP       8
 #define LPC_USB_DEVCMDSTAT_PLL_ON      9
@@ -893,7 +893,7 @@ extern struct lpc_usb lpc_usb;
 #define LPC_USB_DEVCMDSTAT_VBUSDEBOUNCED       28
 
 #define LPC_USB_INFO_FRAME_NR          0
-#define LPC_USB_INFO_FRAME_NR_MASK     0x3ff
+#define LPC_USB_INFO_FRAME_NR_MASK     0x3ffUL
 #define LPC_USB_INFO_ERR_CODE          11
 #define LPC_USB_INFO_ERR_CODE_NO_ERROR                 0
 #define LPC_USB_INFO_ERR_CODE_PID_ENCODING_ERROR       1
@@ -911,16 +911,16 @@ extern struct lpc_usb lpc_usb;
 #define LPC_USB_INFO_ERR_CODE_BITSTUFF_ERROR           0xd
 #define LPC_USB_INFO_ERR_CODE_SYNC_ERROR               0xe
 #define LPC_USB_INFO_ERR_CODE_WRONG_DATA_TOGGLE                0xf
-#define LPC_USB_INFO_ERR_CODE_MASK                     0xf
+#define LPC_USB_INFO_ERR_CODE_MASK                     0xfUL
 
 #define LPC_USB_EPLISTSTART_EP_LIST                    0
 
 #define LPC_USB_DATABUFSTART_DA_BUF                    0
 
 #define LPC_USB_LPM_HIRD_HW            0
-#define LPC_USB_LPM_HIRD_HW_MASK               0xf
+#define LPC_USB_LPM_HIRD_HW_MASK               0xfUL
 #define LPC_USB_LPM_HIRD_SW            4
-#define LPC_USB_LPM_HIRD_SW_MASK               0xf
+#define LPC_USB_LPM_HIRD_SW_MASK               0xfUL
 #define LPC_USB_LPM_DATA_PENDING       8
 
 #define LPC_USB_EPSKIP_SKIP            0
@@ -977,7 +977,7 @@ extern uint8_t lpc_usb_sram[];
 #define LPC_USB_EP_RATE_FEEDBACK       27
 #define LPC_USB_EP_ENDPOINT_ISO                26
 #define LPC_USB_EP_NBYTES              16
-#define  LPC_USB_EP_NBYTES_MASK                        0x3ff
+#define  LPC_USB_EP_NBYTES_MASK                        0x3ffUL
 #define LPC_USB_EP_OFFSET              0
 
 #define LPC_ISR_PIN_INT0_POS   0
@@ -1062,7 +1062,7 @@ lpc_nvic_pending(int irq) {
 
 #define IRQ_PRIO_REG(irq)      ((irq) >> 2)
 #define IRQ_PRIO_BIT(irq)      (((irq) & 3) << 3)
-#define IRQ_PRIO_MASK(irq)     (0xff << IRQ_PRIO_BIT(irq))
+#define IRQ_PRIO_MASK(irq)     (0xffUL << IRQ_PRIO_BIT(irq))
 
 static inline void
 lpc_nvic_set_priority(int irq, uint8_t prio) {
index efab12c315dd5f1cbbd9bfa8e605fc02d3c454bf..d634982992d5d4bd114c1c2289f9fbe75e5a2f4b 100644 (file)
@@ -50,14 +50,14 @@ ao_pa_get(void)
 
        ao_ms5607_sample(&ao_ms5607_current);
        ao_ms5607_convert(&ao_ms5607_current, &value);
-       pa = value.pres;
+       pa = (uint32_t) value.pres;
 }
 
 static void
 ao_compute_height(void)
 {
-       ground_alt = ao_pa_to_altitude(pa_ground);
-       max_alt = ao_pa_to_altitude(pa_min);
+       ground_alt = ao_pa_to_altitude((pres_t) pa_ground);
+       max_alt = ao_pa_to_altitude((pres_t) pa_min);
        ao_max_height = max_alt - ground_alt;
 }
 
@@ -91,7 +91,7 @@ power_down(void)
                stm_scb.scr |= ((1 << STM_SCB_SCR_SLEEPDEEP) |
                                (1 << STM_SCB_SCR_SLEEPONEXIT));
                stm_pwr.cr |= (1 << STM_PWR_CR_PDDS);
-               stm_pwr.csr &= ~(1 << STM_PWR_CSR_WUF);
+               stm_pwr.csr &= ~(1UL << STM_PWR_CSR_WUF);
                ao_arch_wait_interrupt();
        }
 }
@@ -144,7 +144,7 @@ flight_mode(void)
        ao_report_altitude();
        ao_pips();
        log_micro_dump();
-#if BOOST_DELAY        
+#ifdef BOOST_DELAY
        ao_delay(BOOST_DELAY);
 #endif
        log_erase();
@@ -212,7 +212,7 @@ main(void)
         */
        uint16_t vref = ao_adc_read_vref();
 
-       uint32_t vdda = 3 * stm_vrefint_cal.vrefint_cal * 1000 / vref;
+       uint32_t vdda = 3UL * stm_vrefint_cal.vrefint_cal * 1000 / vref;
 
        /* Power supply > 3.25V means we're on USB power */
        if (vdda > 3250) {
index bbd5675a1528ff7708bd38b8abc7d5380c47fbe6..a1daf06a70f9da1514565e329cec8daa538aaaec 100644 (file)
@@ -29,17 +29,26 @@ ao_panic(uint8_t reason)
        for (;;);
 }
 
-void
-ao_put_string(const char *s)
+static void
+ao_put_stringn(const char *s, int max)
 {
        char    c;
-       while ((c = *s++)) {
+       while (max--) {
+               c = *s++;
+               if (!c)
+                       break;
                if (c == '\n')
                        ao_usb_putchar('\r');
                ao_usb_putchar(c);
        }
 }
 
+void
+ao_put_string(const char *s)
+{
+       ao_put_stringn(s, 65535);
+}
+
 static void
 ao_application(void)
 {
@@ -49,7 +58,7 @@ ao_application(void)
 static uint32_t
 ao_get_hex32(void)
 {
-       int8_t  n;
+       int     n;
        uint32_t v = 0;
 
        for (;;) {
@@ -66,7 +75,7 @@ ao_get_hex32(void)
                        n = n - ('A' - 10);
                else
                        break;
-               v = (v << 4) | n;
+               v = (v << 4) | (uint8_t) n;
                n = ao_usb_getchar();
        }
        return v;
@@ -149,7 +158,7 @@ ao_show_version(void)
        ao_put_hex((uint32_t) AO_BOOT_APPLICATION_BASE);
        ao_usb_putchar(' ');
        ao_put_hex((uint32_t) AO_BOOT_APPLICATION_BOUND);
-       ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
+       ao_put_string("\nsoftware-version "); ao_put_stringn(ao_version, AO_MAX_VERSION);
        ao_put_string("\n");
 }
 
index 8fed3069a3eef7eefe3081a13c4dae1908a7be14..22559aaff085d0df5405f7e9c445d701b4a5055d 100644 (file)
@@ -32,14 +32,14 @@ ao_pa_get(void)
 {
        ao_ms5607_sample(&ao_ms5607_current);
        ao_ms5607_convert(&ao_ms5607_current, &value);
-       pa = value.pres;
+       pa = (uint32_t) value.pres;
 }
 
 static void
 ao_compute_height(void)
 {
-       ground_alt = ao_pa_to_altitude(pa_ground);
-       max_alt = ao_pa_to_altitude(pa_min);
+       ground_alt = ao_pa_to_altitude((pres_t) pa_ground);
+       max_alt = ao_pa_to_altitude((pres_t) pa_min);
        ao_max_height = max_alt - ground_alt;
 }
 
@@ -73,7 +73,7 @@ main(void)
        ao_report_altitude();
        ao_pips();
        ao_log_micro_dump();
-#if BOOST_DELAY        
+#ifdef BOOST_DELAY
        ao_delay(BOOST_DELAY);
 #endif
 
@@ -84,7 +84,8 @@ main(void)
        ao_report_altitude();
        for (;;) {
                cli();
-               set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+#pragma GCC diagnostic ignored "-Wconversion"
+               set_sleep_mode((uint8_t) SLEEP_MODE_PWR_DOWN);
                sleep_mode();
        }
 }
index d2cc11201a7e7c550d36985d9ef0df871d61764e..9f31a36fa6f9e8bc5a58b98f46b6b1ce3a2aa038 100644 (file)
@@ -148,7 +148,7 @@ ao_spi_recv_byte(uint8_t spi_index)
        stm_spi->dr = 0xff;
        while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
                ;
-       return stm_spi->dr;
+       return (uint8_t) stm_spi->dr;
 }
 
 void
@@ -200,15 +200,15 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
 
 #define ao_disable_port(port) do {                                     \
                if ((port) == &stm_gpioa)                               \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOAEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOAEN); \
                else if ((port) == &stm_gpiob)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOBEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOBEN); \
                else if ((port) == &stm_gpioc)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOCEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOCEN); \
                else if ((port) == &stm_gpiod)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIODEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIODEN); \
                else if ((port) == &stm_gpioe)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOEEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOEEN); \
        } while (0)
 
 
index 12d2b0b6439eed06dacc5085d2c81a9f205be883..4db03a5b4a41b95de41c573ec5aafa1584c97522 100644 (file)
@@ -40,9 +40,9 @@ ao_beep(uint8_t beep)
 {
        if (beep == 0) {
                stm_beeper.cr1 = 0;
-               stm_rcc.apb1enr &= ~(1 << RCC_BEEPER);
+               stm_rcc.apb1enr &= ~(1UL << RCC_BEEPER);
        } else {
-               stm_rcc.apb1enr |= (1 << RCC_BEEPER);
+               stm_rcc.apb1enr |= (1UL << RCC_BEEPER);
 
                stm_beeper.cr2 = ((0 << STM_TIM234_CR2_TI1S) |
                                (STM_TIM234_CR2_MMS_RESET << STM_TIM234_CR2_MMS) |
@@ -162,5 +162,5 @@ ao_beep_init(void)
        stm_afr_set(BEEPER_PORT, BEEPER_PIN, BEEPER_AFR);
 
        /* Leave the timer off until requested */
-       stm_rcc.apb1enr &= ~(1 << RCC_BEEPER);
+       stm_rcc.apb1enr &= ~(1UL << RCC_BEEPER);
 }
index f21ce1b251ff5931d5609ebb1926b6d2d68966ed..b289b80439f9c10399d42715ca0026b6280face5 100644 (file)
@@ -41,6 +41,6 @@ ao_boot_check_pin(void)
        /* Reset the chip to turn off the port and the power interface clock */
        ao_gpio_set_mode(&AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0);
        ao_disable_port(&AO_BOOT_APPLICATION_GPIO);
-       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN);
+       stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_PWREN);
        return v == AO_BOOT_APPLICATION_VALUE;
 }
index 962b3acc57b2824a7f79fe768a721bd8dcb633e5..d3162d5ba85c163261e4e3bc815cf4f02398c496 100644 (file)
@@ -102,17 +102,17 @@ void
 ao_dma_start(uint8_t index)
 {
        ao_dma_done[index] = 0;
-       stm_dma.channel[index].ccr |= (1 << STM_DMA_CCR_EN);
+       stm_dma.channel[index].ccr |= (1UL << STM_DMA_CCR_EN);
 }
 
 void
 ao_dma_done_transfer(uint8_t index)
 {
-       stm_dma.channel[index].ccr &= ~(1 << STM_DMA_CCR_EN);
+       stm_dma.channel[index].ccr &= ~(1UL << STM_DMA_CCR_EN);
 #ifndef LEAVE_DMA_ON
        ao_arch_critical(
                if (--ao_dma_active == 0)
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_DMA1EN);
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_DMA1EN);
                );
 #endif
        if (ao_dma_allocated[index])
index db4d6a49f0b5801b08ea1cb8f555cbe7c1960d3e..ed2d2e41728d0fc3a00f5c9ff1638a9db2f8bb50 100644 (file)
@@ -103,7 +103,7 @@ ao_intflash_write8(uint16_t pos, uint8_t d)
        mask = 0xff << shift;
        w = (*addr & ~mask) | (d << shift);
 
-       ao_intflash_write32(pos & ~3, w);
+       ao_intflash_write32(pos & (uint16_t)~3, w);
 }
 
 static uint8_t
@@ -119,7 +119,7 @@ ao_intflash_read(uint16_t pos)
 uint8_t
 ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len)
 {
-       uint16_t pos = pos32;
+       uint16_t pos = (uint16_t) pos32;
        uint8_t *d = v;
 
        if (pos >= ao_eeprom_total || pos + len > ao_eeprom_total)
@@ -130,7 +130,7 @@ ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len)
                if ((pos & 3) == 0 && len >= 4) {
                        uint32_t        w;
 
-                       w = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24);
+                       w = (uint32_t) d[0] | ((uint32_t) d[1] << 8) | ((uint32_t) d[2] << 16) | ((uint32_t) d[3] << 24);
                        ao_intflash_write32(pos, w);
                        pos += 4;
                        d += 4;
@@ -158,7 +158,7 @@ ao_eeprom_read(ao_pos_t pos, void *v, uint16_t len)
        if (pos >= ao_eeprom_total || pos + len > ao_eeprom_total)
                return 0;
        while (len--)
-               *d++ = ao_intflash_read(pos++);
+               *d++ = ao_intflash_read((uint16_t) (pos++));
        return 1;
 }
 
index 3a2748a9a8c5ea908f80d592008fe82f7ca5ff27..2a05a508c13b6a00c2b4e9818162b9af77c95526 100644 (file)
@@ -32,7 +32,7 @@ static void ao_exti_one_isr(uint8_t pin) {
 }
 
 static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
-       uint16_t        pending = (ao_last_exti = stm_exti.pr) & mask;
+       uint16_t        pending = (uint16_t) (ao_last_exti = stm_exti.pr) & mask;
        uint8_t         pin;
        static uint16_t last_mask;
        static uint8_t  last_pin;
index 8f54931808a7f95abab74a9e684b10c47299adf4..e634377cc996545a3118375f3705a81b40eb1abd 100644 (file)
@@ -132,17 +132,17 @@ ao_i2c_ev_isr(uint8_t index)
        if (sr1 & (1 << STM_I2C_SR1_SB))
                stm_i2c->dr = ao_i2c_addr[index];
        if (sr1 & (1 << STM_I2C_SR1_ADDR)) {
-               stm_i2c->cr2 &= ~(1 << STM_I2C_CR2_ITEVTEN);
+               stm_i2c->cr2 &= ~(1UL << STM_I2C_CR2_ITEVTEN);
                ao_i2c_state[index] = I2C_RUNNING;
                ao_wakeup(&ao_i2c_state[index]);
        }
        if (sr1 & (1 << STM_I2C_SR1_BTF)) {
-               stm_i2c->cr2 &= ~(1 << STM_I2C_CR2_ITEVTEN);
+               stm_i2c->cr2 &= ~(1UL << STM_I2C_CR2_ITEVTEN);
                ao_wakeup(&ao_i2c_state[index]);
        }
        if (sr1 & (1 << STM_I2C_SR1_RXNE)) {
                if (ao_i2c_recv_len[index]) {
-                       *(ao_i2c_recv_data[index]++) = stm_i2c->dr;
+                       *(ao_i2c_recv_data[index]++) = (uint8_t) stm_i2c->dr;
                        if (!--ao_i2c_recv_len[index])
                                ao_wakeup(&ao_i2c_recv_len[index]);
                }
@@ -161,7 +161,7 @@ ao_i2c_er_isr(uint8_t index)
        sr1 = stm_i2c->sr1;
        if (sr1 & (1 << STM_I2C_SR1_AF)) {
                ao_i2c_state[index] = I2C_ERROR;
-               stm_i2c->sr1 = sr1 & ~(1 << STM_I2C_SR1_AF);
+               stm_i2c->sr1 = sr1 & ~(1UL << STM_I2C_SR1_AF);
                ao_wakeup(&ao_i2c_state[index]);
        }
 }
index 1947012b86000357445af1ce739a7616cbb03fbf..47246678210688e09c3794c877c71262979e2844 100644 (file)
@@ -42,14 +42,14 @@ static struct stm_gpio *gpios[] = {
        &stm_gpioe
 };
 
-static inline int ao_lcd_stm_seg_enabled(int seg) {
+static inline int ao_lcd_stm_seg_enabled(uint32_t seg) {
        if (seg < 32)
                return (AO_LCD_STM_SEG_ENABLED_0 >> seg) & 1;
        else
                return (AO_LCD_STM_SEG_ENABLED_1 >> (seg - 32)) & 1;
 }
 
-static inline int ao_lcd_stm_com_enabled(int com) {
+static inline int ao_lcd_stm_com_enabled(uint32_t com) {
        return (AO_LCD_STM_COM_ENABLED >> com) & 1;
 }
 
@@ -294,7 +294,7 @@ ao_lcd_set(uint8_t digit, uint8_t segment, uint8_t value)
 
 #ifdef AO_SEGMENT_MAP
 #if AO_LCD_PER_DIGIT
-       n = digit * AO_LCD_SEGMENTS + segment;
+       n = (uint8_t) (digit * AO_LCD_SEGMENTS + segment);
        com = ao_lcd_map[n].com;
        seg = ao_lcd_map[n].seg;
 #else
@@ -315,9 +315,9 @@ ao_lcd_set(uint8_t digit, uint8_t segment, uint8_t value)
 #endif
        n = (seg >> 5) & 1;
        if (value)
-               stm_lcd.ram[com * 2 + n] |= (1 << (seg & 0x1f));
+               stm_lcd.ram[com * 2 + n] |= (1UL << (seg & 0x1f));
        else
-               stm_lcd.ram[com * 2 + n] &= ~(1 << (seg & 0x1f));
+               stm_lcd.ram[com * 2 + n] &= ~(1UL << (seg & 0x1f));
 }
 
 #if LCD_DEBUG
@@ -347,11 +347,11 @@ ao_lcd_stm_init(void)
        unsigned int s, c;
        uint32_t        csr;
 
-       stm_rcc.ahbenr |= ((AO_LCD_STM_USES_GPIOA << STM_RCC_AHBENR_GPIOAEN) |
-                          (AO_LCD_STM_USES_GPIOB << STM_RCC_AHBENR_GPIOBEN) |
-                          (AO_LCD_STM_USES_GPIOC << STM_RCC_AHBENR_GPIOCEN) |
-                          (AO_LCD_STM_USES_GPIOD << STM_RCC_AHBENR_GPIODEN) |
-                          (AO_LCD_STM_USES_GPIOE << STM_RCC_AHBENR_GPIOEEN));
+       stm_rcc.ahbenr |= (((uint32_t) AO_LCD_STM_USES_GPIOA << STM_RCC_AHBENR_GPIOAEN) |
+                          ((uint32_t) AO_LCD_STM_USES_GPIOB << STM_RCC_AHBENR_GPIOBEN) |
+                          ((uint32_t) AO_LCD_STM_USES_GPIOC << STM_RCC_AHBENR_GPIOCEN) |
+                          ((uint32_t) AO_LCD_STM_USES_GPIOD << STM_RCC_AHBENR_GPIODEN) |
+                          ((uint32_t) AO_LCD_STM_USES_GPIOE << STM_RCC_AHBENR_GPIOEEN));
 
        stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_LCDEN);
 
index 7f40eaca301ceaafbcf0ddf410464cb82337ac7c..aa59391bd26f1dc3e46bdead11aa57c11d43c545 100644 (file)
@@ -61,8 +61,8 @@ ao_led_off(AO_LED_TYPE colors)
 void
 ao_led_set(AO_LED_TYPE colors)
 {
-       AO_LED_TYPE     on = colors & LEDS_AVAILABLE;
-       AO_LED_TYPE     off = ~colors & LEDS_AVAILABLE;
+       AO_LED_TYPE     on = colors & (AO_LED_TYPE) LEDS_AVAILABLE;
+       AO_LED_TYPE     off = (AO_LED_TYPE) (~colors & (AO_LED_TYPE) LEDS_AVAILABLE);
 
        ao_led_off(off);
        ao_led_on(on);
@@ -88,7 +88,7 @@ ao_led_init(void)
 
 #ifdef LED_PORT
        stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
-       LED_PORT->odr &= ~LEDS_AVAILABLE;
+       LED_PORT->odr &= ~(uint32_t) LEDS_AVAILABLE;
 #else
 #ifdef LED_PORT_0
        stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
index 68aac0019c3c5f052eddd946ea35a3fac7e17198..fcbba45dd79910289db12503a710a8394a369866 100644 (file)
@@ -25,9 +25,9 @@ static inline uint32_t ao_profile_tick(void) {
        uint16_t        hi, lo, second_hi;
 
        do {
-               hi = stm_tim2.cnt;
-               lo = stm_tim4.cnt;
-               second_hi = stm_tim2.cnt;
+               hi = (uint16_t) stm_tim2.cnt;
+               lo = (uint16_t) stm_tim4.cnt;
+               second_hi = (uint16_t) stm_tim2.cnt;
        } while (hi != second_hi);
        return ((uint32_t) hi << 16) | lo;
 }
index 341f8887a6ab753237d50f7a6c8eeb0673ff4820..9f3dde5492e148771a0ae8a3e60cfdfd82e95f25 100644 (file)
@@ -107,8 +107,8 @@ ao_pwm_cmd(void)
        uint8_t ch;
        uint16_t val;
 
-       ch = ao_cmd_decimal();
-       val = ao_cmd_decimal();
+       ch = (uint8_t) ao_cmd_decimal();
+       val = (uint16_t) ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
 
index 7a552e5d86a5884d0e5653081b11c3921a3b8999..42bad19eb42eca61e3a13b2b4b3241c6e1b28f4f 100644 (file)
@@ -64,7 +64,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
 {
        if (usart->reg->sr & (1 << STM_USART_SR_RXNE)) {
                if (!ao_fifo_full(usart->rx_fifo)) {
-                       ao_fifo_insert(usart->rx_fifo, usart->reg->dr);
+                       ao_fifo_insert(usart->rx_fifo, (char) usart->reg->dr);
                        ao_wakeup(&usart->rx_fifo);
                        if (is_stdin)
                                ao_wakeup(&ao_stdin_ready);
@@ -78,7 +78,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
                        }
 #endif
                } else {
-                       usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+                       usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
                }
        }
 }
@@ -89,11 +89,11 @@ ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
        _ao_usart_rx(usart, is_stdin);
 
        if (!_ao_usart_tx_start(usart))
-               usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
 
        if (usart->reg->sr & (1 << STM_USART_SR_TC)) {
                usart->tx_running = 0;
-               usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
                if (usart->draining) {
                        usart->draining = 0;
                        ao_wakeup(&usart->tx_fifo);
@@ -139,7 +139,7 @@ ao_usart_getchar(struct ao_stm_usart *usart)
 }
 
 static inline uint8_t
-_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout)
+_ao_usart_sleep_for(struct ao_stm_usart *usart, AO_TICK_TYPE timeout)
 {
        return ao_sleep_for(&usart->rx_fifo, timeout);
 }
@@ -276,7 +276,7 @@ _ao_serial1_pollchar(void)
 }
 
 uint8_t
-_ao_serial1_sleep_for(uint16_t timeout)
+_ao_serial1_sleep_for(AO_TICK_TYPE timeout)
 {
        return _ao_usart_sleep_for(&ao_stm_usart1, timeout);
 }
@@ -320,7 +320,7 @@ _ao_serial2_pollchar(void)
 }
 
 uint8_t
-_ao_serial2_sleep_for(uint16_t timeout)
+_ao_serial2_sleep_for(AO_TICK_TYPE timeout)
 {
        return _ao_usart_sleep_for(&ao_stm_usart2, timeout);
 }
@@ -373,7 +373,7 @@ _ao_serial3_pollchar(void)
 }
 
 uint8_t
-_ao_serial3_sleep_for(uint16_t timeout)
+_ao_serial3_sleep_for(AO_TICK_TYPE timeout)
 {
        return _ao_usart_sleep_for(&ao_stm_usart3, timeout);
 }
@@ -397,9 +397,9 @@ static void
 ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
                         void (*isr)(void),
                         struct stm_gpio *port_rts,
-                        int pin_rts,
+                        uint8_t pin_rts,
                         struct stm_gpio *port_cts,
-                        int pin_cts)
+                        uint8_t pin_cts)
 {
        /* Pull RTS low to note that there's space in the FIFO
         */
index eec0a35ad3dbc9807d4c9e5980d77a624a85134a..481b81ef1142b244500f544bc46975594fddc091 100644 (file)
@@ -109,7 +109,7 @@ ao_timer_init(void)
        stm_systick.csr = ((1 << STM_SYSTICK_CSR_ENABLE) |
                           (1 << STM_SYSTICK_CSR_TICKINT) |
                           (STM_SYSTICK_CSR_CLKSOURCE_HCLK_8 << STM_SYSTICK_CSR_CLKSOURCE));
-       stm_nvic.shpr15_12 |= AO_STM_NVIC_CLOCK_PRIORITY << 24;
+       stm_nvic.shpr15_12 |= (uint32_t) AO_STM_NVIC_CLOCK_PRIORITY << 24;
 }
 
 #endif
@@ -125,7 +125,7 @@ ao_clock_init(void)
        while (!(stm_rcc.cr & (1 << STM_RCC_CR_MSIRDY)))
                ao_arch_nop();
 
-       stm_rcc.cfgr = (stm_rcc.cfgr & ~(STM_RCC_CFGR_SW_MASK << STM_RCC_CFGR_SW)) |
+       stm_rcc.cfgr = (stm_rcc.cfgr & ~(uint32_t) (STM_RCC_CFGR_SW_MASK << STM_RCC_CFGR_SW)) |
                (STM_RCC_CFGR_SW_MSI << STM_RCC_CFGR_SW);
 
        /* wait for system to switch to MSI */
@@ -149,7 +149,7 @@ ao_clock_init(void)
 #if AO_HSE_BYPASS
        stm_rcc.cr |= (1 << STM_RCC_CR_HSEBYP);
 #else
-       stm_rcc.cr &= ~(1 << STM_RCC_CR_HSEBYP);
+       stm_rcc.cr &= ~(uint32_t) (1 << STM_RCC_CR_HSEBYP);
 #endif
        /* Enable HSE clock */
        stm_rcc.cr |= (1 << STM_RCC_CR_HSEON);
@@ -225,8 +225,8 @@ ao_clock_init(void)
        stm_rcc.cfgr = cfgr;
 
        /* Disable the PLL */
-       stm_rcc.cr &= ~(1 << STM_RCC_CR_PLLON);
-       while (stm_rcc.cr & (1 << STM_RCC_CR_PLLRDY))
+       stm_rcc.cr &= ~(1UL << STM_RCC_CR_PLLON);
+       while (stm_rcc.cr & (1UL << STM_RCC_CR_PLLRDY))
                asm("nop");
        
        /* PLLVCO to 96MHz (for USB) -> PLLMUL = 6, PLLDIV = 4 */
@@ -238,7 +238,7 @@ ao_clock_init(void)
        cfgr |= (AO_RCC_CFGR_PLLDIV << STM_RCC_CFGR_PLLDIV);
 
        /* PLL source */
-       cfgr &= ~(1 << STM_RCC_CFGR_PLLSRC);
+       cfgr &= ~(1UL << STM_RCC_CFGR_PLLSRC);
        cfgr |= STM_RCC_CFGR_PLLSRC_TARGET_CLOCK;
 
        stm_rcc.cfgr = cfgr;
index 7f81e20e67c01b948f9703659ffc3c1acf4b87ca..8b6d95d866c41fe8f7406a6a00007aab7feea2c3 100644 (file)
@@ -313,7 +313,7 @@ ao_usb_init_ep(uint8_t ep, uint32_t addr, uint32_t type, uint32_t stat_rx, uint3
 static void
 ao_usb_set_ep0(void)
 {
-       int                     e;
+       uint8_t e;
 
        ao_usb_sram_addr = 0;
 
@@ -453,7 +453,7 @@ ao_usb_write(const uint8_t *src, uint32_t *base, uint16_t bytes)
                return;
        while (bytes >= 2) {
                debug_data (" %02x %02x", src[0], src[1]);
-               ao_usb_write_short((src[1] << 8) | src[0], base, offset);
+               ao_usb_write_short((uint16_t) ((uint16_t) (src[1] << 8) | (uint16_t) src[0]), base, offset);
                offset += 2;
                src += 2;
                bytes -= 2;
@@ -477,7 +477,7 @@ ao_usb_read_byte(uint32_t *base, uint16_t offset)
 static inline uint16_t
 ao_usb_read_short(uint32_t *base, uint16_t offset)
 {
-       return base[offset>>1];
+       return (uint16_t) (base[offset>>1]);
 }
 
 static void
@@ -492,8 +492,8 @@ ao_usb_read(uint8_t *dst, uint32_t *base, uint16_t offset, uint16_t bytes)
        }
        while (bytes >= 2) {
                uint16_t        s = ao_usb_read_short(base, offset);
-               dst[0] = s;
-               dst[1] = s >> 8;
+               dst[0] = (uint8_t) s;
+               dst[1] = (uint8_t) (s >> 8);
                debug_data (" %02x %02x", dst[0], dst[1]);
                offset += 2;
                dst += 2;
@@ -545,7 +545,7 @@ ao_usb_ep0_fill(void)
 
        if (len > ao_usb_ep0_out_len)
                len = ao_usb_ep0_out_len;
-       ao_usb_ep0_out_len -= len;
+       ao_usb_ep0_out_len -= (uint8_t) len;
 
        /* Pull all of the data out of the packet */
        debug_data ("Fill EP0 len %d:", len);
@@ -590,7 +590,7 @@ ao_usb_ep0_in_start(uint16_t max)
 {
        /* Don't send more than asked for */
        if (ao_usb_ep0_in_len > max)
-               ao_usb_ep0_in_len = max;
+               ao_usb_ep0_in_len = (uint8_t) max;
        ao_usb_ep0_flush();
 }
 
@@ -602,8 +602,8 @@ static void
 ao_usb_get_descriptor(uint16_t value, uint16_t length)
 {
        const uint8_t           *descriptor;
-       uint8_t         type = value >> 8;
-       uint8_t         index = value;
+       uint8_t         type = (uint8_t) (value >> 8);
+       uint8_t         index = (uint8_t) value;
 
        descriptor = ao_usb_descriptors;
        while (descriptor[0] != 0) {
@@ -614,7 +614,7 @@ ao_usb_get_descriptor(uint16_t value, uint16_t length)
                        else
                                len = descriptor[0];
                        if (len > length)
-                               len = length;
+                               len = (uint8_t) length;
                        ao_usb_ep0_in_set(descriptor, len);
                        break;
                }
@@ -654,7 +654,7 @@ ao_usb_ep0_setup(void)
                                break;
                        case AO_USB_REQ_SET_ADDRESS:
                                debug ("set address %d\n", ao_usb_setup.value);
-                               ao_usb_address = ao_usb_setup.value;
+                               ao_usb_address = (uint8_t) ao_usb_setup.value;
                                ao_usb_address_pending = 1;
                                break;
                        case AO_USB_REQ_GET_DESCRIPTOR:
@@ -666,7 +666,7 @@ ao_usb_ep0_setup(void)
                                ao_usb_ep0_in_queue_byte(ao_usb_configuration);
                                break;
                        case AO_USB_REQ_SET_CONFIGURATION:
-                               ao_usb_configuration = ao_usb_setup.value;
+                               ao_usb_configuration = (uint8_t) ao_usb_setup.value;
                                debug ("set configuration %d\n", ao_usb_configuration);
                                ao_usb_set_configuration();
                                break;
@@ -776,8 +776,8 @@ stm_usb_lp_isr(void)
                epr_write = epr;
                epr_write &= STM_USB_EPR_PRESERVE_MASK;
                epr_write |= STM_USB_EPR_INVARIANT;
-               epr_write &= ~(1 << STM_USB_EPR_CTR_RX);
-               epr_write &= ~(1 << STM_USB_EPR_CTR_TX);
+               epr_write &= ~(1UL << STM_USB_EPR_CTR_RX);
+               epr_write &= ~(1UL << STM_USB_EPR_CTR_TX);
                stm_usb.epr[ep] = epr_write;
 
                switch (ep) {
@@ -822,7 +822,7 @@ stm_usb_lp_isr(void)
 
        if (istr & (1 << STM_USB_ISTR_RESET)) {
                ++reset_count;
-               stm_usb.istr &= ~(1 << STM_USB_ISTR_RESET);
+               stm_usb.istr &= ~(1UL << STM_USB_ISTR_RESET);
                ao_usb_ep0_receive |= AO_USB_EP0_GOT_RESET;
                ao_usb_ep0_handle(ao_usb_ep0_receive);
        }
@@ -832,7 +832,7 @@ void
 stm_usb_fs_wkup_isr(void)
 {
        /* USB wakeup, just clear the bit for now */
-       stm_usb.istr &= ~(1 << STM_USB_ISTR_WKUP);
+       stm_usb.istr &= ~(1UL << STM_USB_ISTR_WKUP);
 }
 
 /* Queue the current IN buffer for transmission */
@@ -919,7 +919,7 @@ _ao_usb_out_recv(void)
        _rx_dbg0("out_recv top");
        ao_usb_out_avail = 0;
 
-       ao_usb_rx_count = ao_usb_bdt[AO_USB_OUT_EPR].single.count_rx & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK;
+       ao_usb_rx_count = (uint8_t) (ao_usb_bdt[AO_USB_OUT_EPR].single.count_rx & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK);
 
        _rx_dbg1("out_recv count", ao_usb_rx_count);
        debug ("recv %d\n", ao_usb_rx_count);
@@ -967,7 +967,7 @@ ao_usb_getchar(void)
        while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
                ao_sleep(AO_USB_OUT_SLEEP_ADDR);
        ao_arch_release_interrupts();
-       return c;
+       return (char) c;
 }
 
 #ifndef HAS_USB_DISABLE
@@ -983,13 +983,13 @@ ao_usb_disable(void)
        stm_usb.istr = 0;
 
        /* Disable USB pull-up */
-       stm_syscfg.pmc &= ~(1 << STM_SYSCFG_PMC_USB_PU);
+       stm_syscfg.pmc &= ~(1UL << STM_SYSCFG_PMC_USB_PU);
 
        /* Switch off the device */
        stm_usb.cntr = (1 << STM_USB_CNTR_PDWN) | (1 << STM_USB_CNTR_FRES);
 
        /* Disable the interface */
-       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USBEN);
+       stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_USBEN);
        ao_arch_release_interrupts();
 }
 #endif
@@ -1003,7 +1003,7 @@ ao_usb_enable(void)
        stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGEN);
 
        /* Disable USB pull-up */
-       stm_syscfg.pmc &= ~(1 << STM_SYSCFG_PMC_USB_PU);
+       stm_syscfg.pmc &= ~(1UL << STM_SYSCFG_PMC_USB_PU);
 
        /* Enable USB device */
        stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USBEN);
index 310b334bae22a64171e66eb6cd6596f9e49240f7..6610f11dd18743752dd99c25b8517202ef73e109 100644 (file)
@@ -40,7 +40,7 @@ struct stm_gpio {
 };
 
 #define STM_MODER_SHIFT(pin)           ((pin) << 1)
-#define STM_MODER_MASK                 3
+#define STM_MODER_MASK                 3UL
 #define STM_MODER_INPUT                        0
 #define STM_MODER_OUTPUT               1
 #define STM_MODER_ALTERNATE            2
@@ -49,7 +49,7 @@ struct stm_gpio {
 static inline void
 stm_moder_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
        gpio->moder = ((gpio->moder &
-                       ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
+                       (uint32_t) ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
                       value << STM_MODER_SHIFT(pin));
 }
 
@@ -84,14 +84,14 @@ stm_moder_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_OTYPER_SHIFT(pin)          (pin)
-#define STM_OTYPER_MASK                        1
+#define STM_OTYPER_MASK                        1UL
 #define STM_OTYPER_PUSH_PULL           0
 #define STM_OTYPER_OPEN_DRAIN          1
 
 static inline void
 stm_otyper_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
        gpio->otyper = ((gpio->otyper &
-                        ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
+                        (uint32_t) ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
                        value << STM_OTYPER_SHIFT(pin));
 }
 
@@ -101,7 +101,7 @@ stm_otyper_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_OSPEEDR_SHIFT(pin)         ((pin) << 1)
-#define STM_OSPEEDR_MASK               3
+#define STM_OSPEEDR_MASK               3UL
 #define STM_OSPEEDR_400kHz             0
 #define STM_OSPEEDR_2MHz               1
 #define STM_OSPEEDR_10MHz              2
@@ -110,7 +110,7 @@ stm_otyper_get(struct stm_gpio *gpio, int pin) {
 static inline void
 stm_ospeedr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
        gpio->ospeedr = ((gpio->ospeedr &
-                       ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
+                         (uint32_t) ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
                       value << STM_OSPEEDR_SHIFT(pin));
 }
 
@@ -129,7 +129,7 @@ stm_ospeedr_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_PUPDR_SHIFT(pin)           ((pin) << 1)
-#define STM_PUPDR_MASK                 3
+#define STM_PUPDR_MASK                 3UL
 #define STM_PUPDR_NONE                 0
 #define STM_PUPDR_PULL_UP              1
 #define STM_PUPDR_PULL_DOWN            2
@@ -138,7 +138,7 @@ stm_ospeedr_get(struct stm_gpio *gpio, int pin) {
 static inline void
 stm_pupdr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
        gpio->pupdr = ((gpio->pupdr &
-                       ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
+                       (uint32_t) ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
                       value << STM_PUPDR_SHIFT(pin));
 }
 
@@ -157,7 +157,7 @@ stm_pupdr_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_AFR_SHIFT(pin)             ((pin) << 2)
-#define STM_AFR_MASK                   0xf
+#define STM_AFR_MASK                   0xfUL
 #define STM_AFR_NONE                   0
 #define STM_AFR_AF0                    0x0
 #define STM_AFR_AF1                    0x1
@@ -184,12 +184,12 @@ stm_afr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
        stm_moder_set(gpio, pin, STM_MODER_ALTERNATE);
        if (pin < 8)
                gpio->afrl = ((gpio->afrl &
-                              ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+                              (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
                              value << STM_AFR_SHIFT(pin));
        else {
                pin -= 8;
                gpio->afrh = ((gpio->afrh &
-                              ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+                              (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
                              value << STM_AFR_SHIFT(pin));
        }
 }
@@ -233,7 +233,7 @@ stm_gpio_get(struct stm_gpio *gpio, int pin) {
 
 static inline uint16_t
 stm_gpio_get_all(struct stm_gpio *gpio) {
-       return gpio->idr;
+       return (uint16_t) gpio->idr;
 }
 
 /*
@@ -301,7 +301,7 @@ extern struct stm_usart stm_usart3;
 
 #define STM_USART_CR2_LINEN    (14)    /* LIN mode enable */
 #define STM_USART_CR2_STOP     (12)    /* STOP bits */
-#define STM_USART_CR2_STOP_MASK        3
+#define STM_USART_CR2_STOP_MASK        3UL
 #define STM_USART_CR2_STOP_1   0
 #define STM_USART_CR2_STOP_0_5 1
 #define STM_USART_CR2_STOP_2   2
@@ -314,7 +314,7 @@ extern struct stm_usart stm_usart3;
 #define STM_USART_CR2_LBDIE    (6)     /* LIN break detection interrupt enable */
 #define STM_USART_CR2_LBDL     (5)     /* lin break detection length */
 #define STM_USART_CR2_ADD      (0)
-#define STM_USART_CR2_ADD_MASK 0xf
+#define STM_USART_CR2_ADD_MASK 0xfUL
 
 #define STM_USART_CR3_ONEBITE  (11)    /* One sample bit method enable */
 #define STM_USART_CR3_CTSIE    (10)    /* CTS interrupt enable */
@@ -365,7 +365,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CR1_CKD_1         0
 #define  STM_TIM1011_CR1_CKD_2         1
 #define  STM_TIM1011_CR1_CKD_4         2
-#define  STM_TIM1011_CR1_CKD_MASK      3
+#define  STM_TIM1011_CR1_CKD_MASK      3UL
 #define STM_TIM1011_CR1_ARPE   7
 #define STM_TIM1011_CR1_URS    2
 #define STM_TIM1011_CR1_UDIS   1
@@ -378,7 +378,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_SMCR_ETPS_2       1
 #define  STM_TIM1011_SMCR_ETPS_4       2
 #define  STM_TIM1011_SMCR_ETPS_8       3
-#define  STM_TIM1011_SMCR_ETPS_MASK    3
+#define  STM_TIM1011_SMCR_ETPS_MASK    3UL
 #define STM_TIM1011_SMCR_ETF   8
 #define  STM_TIM1011_SMCR_ETF_NONE             0
 #define  STM_TIM1011_SMCR_ETF_CK_INT_2         1
@@ -396,7 +396,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_SMCR_ETF_DTS_32_5         13
 #define  STM_TIM1011_SMCR_ETF_DTS_32_6         14
 #define  STM_TIM1011_SMCR_ETF_DTS_32_8         15
-#define  STM_TIM1011_SMCR_ETF_MASK             15
+#define  STM_TIM1011_SMCR_ETF_MASK             15UL
 
 #define STM_TIM1011_DIER_CC1E  1
 #define STM_TIM1011_DIER_UIE   0
@@ -418,7 +418,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CCMR1_OC1M_FORCE_ACTIVE           5
 #define  STM_TIM1011_CCMR1_OC1M_PWM_MODE_1             6
 #define  STM_TIM1011_CCMR1_OC1M_PWM_MODE_2             7
-#define  STM_TIM1011_CCMR1_OC1M_MASK                   7
+#define  STM_TIM1011_CCMR1_OC1M_MASK                   7UL
 #define STM_TIM1011_CCMR1_OC1PE        3
 #define STM_TIM1011_CCMR1_OC1FE        2
 #define STM_TIM1011_CCMR1_CC1S 0
@@ -426,7 +426,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CCMR1_CC1S_INPUT_TI1              1
 #define  STM_TIM1011_CCMR1_CC1S_INPUT_TI2              2
 #define  STM_TIM1011_CCMR1_CC1S_INPUT_TRC              3
-#define  STM_TIM1011_CCMR1_CC1S_MASK                   3
+#define  STM_TIM1011_CCMR1_CC1S_MASK                   3UL
 
 #define  STM_TIM1011_CCMR1_IC1F_NONE           0
 #define  STM_TIM1011_CCMR1_IC1F_CK_INT_2       1
@@ -444,13 +444,13 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CCMR1_IC1F_DTS_32_5       13
 #define  STM_TIM1011_CCMR1_IC1F_DTS_32_6       14
 #define  STM_TIM1011_CCMR1_IC1F_DTS_32_8       15
-#define  STM_TIM1011_CCMR1_IC1F_MASK           15
+#define  STM_TIM1011_CCMR1_IC1F_MASK           15UL
 #define STM_TIM1011_CCMR1_IC1PSC       2
 #define  STM_TIM1011_CCMR1_IC1PSC_1            0
 #define  STM_TIM1011_CCMR1_IC1PSC_2            1
 #define  STM_TIM1011_CCMR1_IC1PSC_4            2
 #define  STM_TIM1011_CCMR1_IC1PSC_8            3
-#define  STM_TIM1011_CCMR1_IC1PSC_MASK         3
+#define  STM_TIM1011_CCMR1_IC1PSC_MASK         3UL
 #define STM_TIM1011_CCMR1_CC1S         0
 
 #define STM_TIM1011_CCER_CC1NP         3
@@ -464,7 +464,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_TI1_RMP_LSI               1
 #define  STM_TIM1011_TI1_RMP_LSE               2
 #define  STM_TIM1011_TI1_RMP_RTC               3
-#define  STM_TIM1011_TI1_RMP_MASK              3
+#define  STM_TIM1011_TI1_RMP_MASK              3UL
 
 /* Flash interface */
 
@@ -547,7 +547,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CR_RTCPRE_HSE_DIV_4   1
 #define  STM_RCC_CR_RTCPRE_HSE_DIV_8   2
 #define  STM_RCC_CR_RTCPRE_HSE_DIV_16  3
-#define  STM_RCC_CR_RTCPRE_HSE_MASK    3
+#define  STM_RCC_CR_RTCPRE_HSE_MASK    3UL
 
 #define STM_RCC_CR_CSSON       (28)
 #define STM_RCC_CR_PLLRDY      (25)
@@ -566,7 +566,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_MCOPRE_DIV_4     2
 #define  STM_RCC_CFGR_MCOPRE_DIV_8     3
 #define  STM_RCC_CFGR_MCOPRE_DIV_16    4
-#define  STM_RCC_CFGR_MCOPRE_MASK      7
+#define  STM_RCC_CFGR_MCOPRE_MASK      7UL
 
 #define STM_RCC_CFGR_MCOSEL    (24)
 #define  STM_RCC_CFGR_MCOSEL_DISABLE   0
@@ -577,13 +577,13 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_MCOSEL_PLL       5
 #define  STM_RCC_CFGR_MCOSEL_LSI       6
 #define  STM_RCC_CFGR_MCOSEL_LSE       7
-#define  STM_RCC_CFGR_MCOSEL_MASK      7
+#define  STM_RCC_CFGR_MCOSEL_MASK      7UL
 
 #define STM_RCC_CFGR_PLLDIV    (22)
 #define  STM_RCC_CFGR_PLLDIV_2         1
 #define  STM_RCC_CFGR_PLLDIV_3         2
 #define  STM_RCC_CFGR_PLLDIV_4         3
-#define  STM_RCC_CFGR_PLLDIV_MASK      3
+#define  STM_RCC_CFGR_PLLDIV_MASK      3UL
 
 #define STM_RCC_CFGR_PLLMUL    (18)
 #define  STM_RCC_CFGR_PLLMUL_3         0
@@ -595,7 +595,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PLLMUL_24                6
 #define  STM_RCC_CFGR_PLLMUL_32                7
 #define  STM_RCC_CFGR_PLLMUL_48                8
-#define  STM_RCC_CFGR_PLLMUL_MASK      0xf
+#define  STM_RCC_CFGR_PLLMUL_MASK      0xfUL
 
 #define STM_RCC_CFGR_PLLSRC    (16)
 
@@ -605,7 +605,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PPRE2_DIV_4      5
 #define  STM_RCC_CFGR_PPRE2_DIV_8      6
 #define  STM_RCC_CFGR_PPRE2_DIV_16     7
-#define  STM_RCC_CFGR_PPRE2_MASK       7
+#define  STM_RCC_CFGR_PPRE2_MASK       7UL
 
 #define STM_RCC_CFGR_PPRE1     (8)
 #define  STM_RCC_CFGR_PPRE1_DIV_1      0
@@ -613,7 +613,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PPRE1_DIV_4      5
 #define  STM_RCC_CFGR_PPRE1_DIV_8      6
 #define  STM_RCC_CFGR_PPRE1_DIV_16     7
-#define  STM_RCC_CFGR_PPRE1_MASK       7
+#define  STM_RCC_CFGR_PPRE1_MASK       7UL
 
 #define STM_RCC_CFGR_HPRE      (4)
 #define  STM_RCC_CFGR_HPRE_DIV_1       0
@@ -625,21 +625,21 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_HPRE_DIV_128     0xd
 #define  STM_RCC_CFGR_HPRE_DIV_256     0xe
 #define  STM_RCC_CFGR_HPRE_DIV_512     0xf
-#define  STM_RCC_CFGR_HPRE_MASK                0xf
+#define  STM_RCC_CFGR_HPRE_MASK                0xfUL
 
 #define STM_RCC_CFGR_SWS       (2)
 #define  STM_RCC_CFGR_SWS_MSI          0
 #define  STM_RCC_CFGR_SWS_HSI          1
 #define  STM_RCC_CFGR_SWS_HSE          2
 #define  STM_RCC_CFGR_SWS_PLL          3
-#define  STM_RCC_CFGR_SWS_MASK         3
+#define  STM_RCC_CFGR_SWS_MASK         3UL
 
 #define STM_RCC_CFGR_SW                (0)
 #define  STM_RCC_CFGR_SW_MSI           0
 #define  STM_RCC_CFGR_SW_HSI           1
 #define  STM_RCC_CFGR_SW_HSE           2
 #define  STM_RCC_CFGR_SW_PLL           3
-#define  STM_RCC_CFGR_SW_MASK          3
+#define  STM_RCC_CFGR_SW_MASK          3UL
 
 #define STM_RCC_AHBENR_DMA1EN          (24)
 #define STM_RCC_AHBENR_FLITFEN         (15)
@@ -692,7 +692,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CSR_RTCSEL_LSE                        1
 #define  STM_RCC_CSR_RTCSEL_LSI                        2
 #define  STM_RCC_CSR_RTCSEL_HSE                        3
-#define  STM_RCC_CSR_RTCSEL_MASK               3
+#define  STM_RCC_CSR_RTCSEL_MASK               3UL
 
 #define STM_RCC_CSR_LSEBYP             (10)
 #define STM_RCC_CSR_LSERDY             (9)
@@ -710,10 +710,10 @@ extern struct stm_pwr stm_pwr;
 #define STM_PWR_CR_LPRUN       (14)
 
 #define STM_PWR_CR_VOS         (11)
-#define  STM_PWR_CR_VOS_1_8            1
-#define  STM_PWR_CR_VOS_1_5            2
-#define  STM_PWR_CR_VOS_1_2            3
-#define  STM_PWR_CR_VOS_MASK           3
+#define  STM_PWR_CR_VOS_1_8            1UL
+#define  STM_PWR_CR_VOS_1_5            2UL
+#define  STM_PWR_CR_VOS_1_2            3UL
+#define  STM_PWR_CR_VOS_MASK           3UL
 
 #define STM_PWR_CR_FWU         (10)
 #define STM_PWR_CR_ULP         (9)
@@ -728,7 +728,7 @@ extern struct stm_pwr stm_pwr;
 #define  STM_PWR_CR_PLS_2_9    5
 #define  STM_PWR_CR_PLS_3_1    6
 #define  STM_PWR_CR_PLS_EXT    7
-#define  STM_PWR_CR_PLS_MASK   7
+#define  STM_PWR_CR_PLS_MASK   7UL
 
 #define STM_PWR_CR_PVDE                (4)
 #define STM_PWR_CR_CSBF                (3)
@@ -775,7 +775,7 @@ extern struct stm_tim67 stm_tim6;
 #define  STM_TIM67_CR2_MMS_RESET       0
 #define  STM_TIM67_CR2_MMS_ENABLE      1
 #define  STM_TIM67_CR2_MMS_UPDATE      2
-#define  STM_TIM67_CR2_MMS_MASK                7
+#define  STM_TIM67_CR2_MMS_MASK                7UL
 
 #define STM_TIM67_DIER_UDE     (8)
 #define STM_TIM67_DIER_UIE     (0)
@@ -801,7 +801,7 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_CR_BIAS_1_4           0
 #define  STM_LCD_CR_BIAS_1_2           1
 #define  STM_LCD_CR_BIAS_1_3           2
-#define  STM_LCD_CR_BIAS_MASK          3
+#define  STM_LCD_CR_BIAS_MASK          3UL
 
 #define STM_LCD_CR_DUTY                        (2)
 #define  STM_LCD_CR_DUTY_STATIC                0
@@ -809,7 +809,7 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_CR_DUTY_1_3           2
 #define  STM_LCD_CR_DUTY_1_4           3
 #define  STM_LCD_CR_DUTY_1_8           4
-#define  STM_LCD_CR_DUTY_MASK          7
+#define  STM_LCD_CR_DUTY_MASK          7UL
 
 #define STM_LCD_CR_VSEL                        (1)
 #define STM_LCD_CR_LCDEN               (0)
@@ -831,7 +831,7 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_FCR_PS_8192           0xd
 #define  STM_LCD_FCR_PS_16384          0xe
 #define  STM_LCD_FCR_PS_32768          0xf
-#define  STM_LCD_FCR_PS_MASK           0xf
+#define  STM_LCD_FCR_PS_MASK           0xfUL
 
 #define STM_LCD_FCR_DIV                        (18)
 #define STM_LCD_FCR_DIV_16             0x0
@@ -850,14 +850,14 @@ extern struct stm_lcd stm_lcd;
 #define STM_LCD_FCR_DIV_29             0xd
 #define STM_LCD_FCR_DIV_30             0xe
 #define STM_LCD_FCR_DIV_31             0xf
-#define STM_LCD_FCR_DIV_MASK           0xf
+#define STM_LCD_FCR_DIV_MASK           0xfUL
 
 #define STM_LCD_FCR_BLINK              (16)
 #define  STM_LCD_FCR_BLINK_DISABLE             0
 #define  STM_LCD_FCR_BLINK_SEG0_COM0           1
 #define  STM_LCD_FCR_BLINK_SEG0_COMALL         2
 #define  STM_LCD_FCR_BLINK_SEGALL_COMALL       3
-#define  STM_LCD_FCR_BLINK_MASK                        3
+#define  STM_LCD_FCR_BLINK_MASK                        3UL
 
 #define STM_LCD_FCR_BLINKF             (13)
 #define  STM_LCD_FCR_BLINKF_8                  0
@@ -868,16 +868,16 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_FCR_BLINKF_256                        5
 #define  STM_LCD_FCR_BLINKF_512                        6
 #define  STM_LCD_FCR_BLINKF_1024               7
-#define  STM_LCD_FCR_BLINKF_MASK               7
+#define  STM_LCD_FCR_BLINKF_MASK               7UL
 
 #define STM_LCD_FCR_CC                 (10)
-#define  STM_LCD_FCR_CC_MASK                   7
+#define  STM_LCD_FCR_CC_MASK                   7UL
 
 #define STM_LCD_FCR_DEAD               (7)
-#define  STM_LCD_FCR_DEAD_MASK                 7
+#define  STM_LCD_FCR_DEAD_MASK                 7UL
 
 #define STM_LCD_FCR_PON                        (4)
-#define  STM_LCD_FCR_PON_MASK                  7
+#define  STM_LCD_FCR_PON_MASK                  7UL
 
 #define STM_LCD_FCR_UDDIE              (3)
 #define STM_LCD_FCR_SOFIE              (1)
@@ -1006,7 +1006,7 @@ stm_nvic_set_priority(int irq, uint8_t prio) {
        uint32_t        v;
 
        v = stm_nvic.ipr[n];
-       v &= ~IRQ_PRIO_MASK(irq);
+       v &= (uint32_t) ~IRQ_PRIO_MASK(irq);
        v |= (prio) << IRQ_PRIO_BIT(irq);
        stm_nvic.ipr[n] = v;
 }
@@ -1064,9 +1064,9 @@ struct stm_mpu {
 extern struct stm_mpu stm_mpu;
 
 #define STM_MPU_TYPER_IREGION  16
-#define  STM_MPU_TYPER_IREGION_MASK    0xff
+#define  STM_MPU_TYPER_IREGION_MASK    0xffUL
 #define STM_MPU_TYPER_DREGION  8
-#define  STM_MPU_TYPER_DREGION_MASK    0xff
+#define  STM_MPU_TYPER_DREGION_MASK    0xffUL
 #define STM_MPU_TYPER_SEPARATE 0
 
 #define STM_MPU_CR_PRIVDEFENA  2
@@ -1074,14 +1074,14 @@ extern struct stm_mpu stm_mpu;
 #define STM_MPU_CR_ENABLE      0
 
 #define STM_MPU_RNR_REGION     0
-#define STM_MPU_RNR_REGION_MASK                0xff
+#define STM_MPU_RNR_REGION_MASK                0xffUL
 
 #define STM_MPU_RBAR_ADDR      5
-#define STM_MPU_RBAR_ADDR_MASK         0x7ffffff
+#define STM_MPU_RBAR_ADDR_MASK         0x7ffffffUL
 
 #define STM_MPU_RBAR_VALID     4
 #define STM_MPU_RBAR_REGION    0
-#define STM_MPU_RBAR_REGION_MASK       0xf
+#define STM_MPU_RBAR_REGION_MASK       0xfUL
 
 #define STM_MPU_RASR_XN                28
 #define STM_MPU_RASR_AP                24
@@ -1091,16 +1091,16 @@ extern struct stm_mpu stm_mpu;
 #define  STM_MPU_RASR_AP_RW_RW         3
 #define  STM_MPU_RASR_AP_RO_NONE       5
 #define  STM_MPU_RASR_AP_RO_RO         6
-#define  STM_MPU_RASR_AP_MASK          7
+#define  STM_MPU_RASR_AP_MASK          7UL
 #define STM_MPU_RASR_TEX       19
-#define  STM_MPU_RASR_TEX_MASK         7
+#define  STM_MPU_RASR_TEX_MASK         7UL
 #define STM_MPU_RASR_S         18
 #define STM_MPU_RASR_C         17
 #define STM_MPU_RASR_B         16
 #define STM_MPU_RASR_SRD       8
-#define  STM_MPU_RASR_SRD_MASK         0xff
+#define  STM_MPU_RASR_SRD_MASK         0xffUL
 #define STM_MPU_RASR_SIZE      1
-#define  STM_MPU_RASR_SIZE_MASK                0x1f
+#define  STM_MPU_RASR_SIZE_MASK                0x1fUL
 #define STM_MPU_RASR_ENABLE    0
 
 #define isr_decl(name) void stm_ ## name ## _isr(void)
@@ -1223,7 +1223,7 @@ extern struct stm_syscfg stm_syscfg;
 #define  STM_SYSCFG_MEMRMP_MEM_MODE_MAIN_FLASH         0
 #define  STM_SYSCFG_MEMRMP_MEM_MODE_SYSTEM_FLASH       1
 #define  STM_SYSCFG_MEMRMP_MEM_MODE_SRAM               3
-#define  STM_SYSCFG_MEMRMP_MEM_MODE_MASK               3
+#define  STM_SYSCFG_MEMRMP_MEM_MODE_MASK               3UL
 
 #define STM_SYSCFG_PMC_USB_PU          0
 
@@ -1236,7 +1236,7 @@ extern struct stm_syscfg stm_syscfg;
 
 static inline void
 stm_exticr_set(struct stm_gpio *gpio, int pin) {
-       uint8_t reg = pin >> 2;
+       uint8_t reg = (uint8_t) (pin >> 2);
        uint8_t shift = (pin & 3) << 2;
        uint8_t val = 0;
 
@@ -1254,7 +1254,7 @@ stm_exticr_set(struct stm_gpio *gpio, int pin) {
        else if (gpio == &stm_gpioe)
                val = STM_SYSCFG_EXTICR_PE;
 
-       stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+       stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & (uint32_t) ~(0xf << shift)) | val << shift;
 }
 
 
@@ -1282,14 +1282,14 @@ extern struct stm_dma stm_dma;
 #define STM_DMA_INDEX(channel)         ((channel) - 1)
 
 #define STM_DMA_ISR(index)             ((index) << 2)
-#define STM_DMA_ISR_MASK                       0xf
+#define STM_DMA_ISR_MASK                       0xfUL
 #define STM_DMA_ISR_TEIF                       3
 #define STM_DMA_ISR_HTIF                       2
 #define STM_DMA_ISR_TCIF                       1
 #define STM_DMA_ISR_GIF                                0
 
 #define STM_DMA_IFCR(index)            ((index) << 2)
-#define STM_DMA_IFCR_MASK                      0xf
+#define STM_DMA_IFCR_MASK                      0xfUL
 #define STM_DMA_IFCR_CTEIF                     3
 #define STM_DMA_IFCR_CHTIF                     2
 #define STM_DMA_IFCR_CTCIF                     1
@@ -1402,7 +1402,7 @@ extern struct stm_spi stm_spi1, stm_spi2, stm_spi3;
 #define  STM_SPI_CR1_BR_PCLK_64                        5
 #define  STM_SPI_CR1_BR_PCLK_128               6
 #define  STM_SPI_CR1_BR_PCLK_256               7
-#define  STM_SPI_CR1_BR_MASK                   7
+#define  STM_SPI_CR1_BR_MASK                   7UL
 
 #define STM_SPI_CR1_MSTR               2
 #define STM_SPI_CR1_CPOL               1
@@ -1475,7 +1475,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CR1_RES_10            1
 #define  STM_ADC_CR1_RES_8             2
 #define  STM_ADC_CR1_RES_6             3
-#define  STM_ADC_CR1_RES_MASK          3
+#define  STM_ADC_CR1_RES_MASK          3UL
 #define STM_ADC_CR1_AWDEN       23
 #define STM_ADC_CR1_JAWDEN     22
 #define STM_ADC_CR1_PDI                17
@@ -1489,7 +1489,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CR1_DISCNUM_6         5
 #define  STM_ADC_CR1_DISCNUM_7         6
 #define  STM_ADC_CR1_DISCNUM_8         7
-#define  STM_ADC_CR1_DISCNUM_MASK      7
+#define  STM_ADC_CR1_DISCNUM_MASK      7UL
 #define STM_ADC_CR1_JDISCEN    12
 #define STM_ADC_CR1_DISCEN     11
 #define STM_ADC_CR1_JAUTO      10
@@ -1499,7 +1499,7 @@ extern struct stm_adc stm_adc;
 #define STM_ADC_CR1_AWDIE      6
 #define STM_ADC_CR1_EOCIE      5
 #define STM_ADC_CR1_AWDCH      0
-#define  STM_ADC_CR1_AWDCH_MASK                0x1f
+#define  STM_ADC_CR1_AWDCH_MASK                0x1fUL
 
 #define STM_ADC_CR2_SWSTART    30
 #define STM_ADC_CR2_EXTEN      28
@@ -1507,7 +1507,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CR2_EXTEN_RISING      1
 #define  STM_ADC_CR2_EXTEN_FALLING     2
 #define  STM_ADC_CR2_EXTEN_BOTH                3
-#define  STM_ADC_CR2_EXTEN_MASK                3
+#define  STM_ADC_CR2_EXTEN_MASK                3UL
 #define STM_ADC_CR2_EXTSEL     24
 #define  STM_ADC_CR2_EXTSEL_TIM9_CC2   0
 #define  STM_ADC_CR2_EXTSEL_TIM9_TRGO  1
@@ -1521,14 +1521,14 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CR2_EXTSEL_TIM4_TRGO  9
 #define  STM_ADC_CR2_EXTSEL_TIM6_TRGO  10
 #define  STM_ADC_CR2_EXTSEL_EXTI_11    15
-#define  STM_ADC_CR2_EXTSEL_MASK       15
+#define  STM_ADC_CR2_EXTSEL_MASK       15UL
 #define STM_ADC_CR2_JWSTART    22
 #define STM_ADC_CR2_JEXTEN     20
 #define  STM_ADC_CR2_JEXTEN_DISABLE    0
 #define  STM_ADC_CR2_JEXTEN_RISING     1
 #define  STM_ADC_CR2_JEXTEN_FALLING    2
 #define  STM_ADC_CR2_JEXTEN_BOTH       3
-#define  STM_ADC_CR2_JEXTEN_MASK       3
+#define  STM_ADC_CR2_JEXTEN_MASK       3UL
 #define STM_ADC_CR2_JEXTSEL    16
 #define  STM_ADC_CR2_JEXTSEL_TIM9_CC1  0
 #define  STM_ADC_CR2_JEXTSEL_TIM9_TRGO 1
@@ -1542,7 +1542,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CR2_JEXTSEL_TIM10_CC1 9
 #define  STM_ADC_CR2_JEXTSEL_TIM7_TRGO 10
 #define  STM_ADC_CR2_JEXTSEL_EXTI_15   15
-#define  STM_ADC_CR2_JEXTSEL_MASK      15
+#define  STM_ADC_CR2_JEXTSEL_MASK      15UL
 #define STM_ADC_CR2_ALIGN      11
 #define STM_ADC_CR2_EOCS       10
 #define STM_ADC_CR2_DDS                9
@@ -1556,7 +1556,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CR2_DELS_63           5
 #define  STM_ADC_CR2_DELS_127          6
 #define  STM_ADC_CR2_DELS_255          7
-#define  STM_ADC_CR2_DELS_MASK         7
+#define  STM_ADC_CR2_DELS_MASK         7UL
 #define STM_ADC_CR2_CONT       1
 #define STM_ADC_CR2_ADON       0
 
@@ -1565,7 +1565,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CCR_ADCPRE_HSI_1      0
 #define  STM_ADC_CCR_ADCPRE_HSI_2      1
 #define  STM_ADC_CCR_ADCPRE_HSI_4      2
-#define  STM_ADC_CCR_ADCPRE_MASK       3
+#define  STM_ADC_CCR_ADCPRE_MASK       3UL
 
 struct stm_temp_cal {
        uint16_t        vref;
@@ -1654,7 +1654,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define  STM_I2C_CR2_FREQ_16_MHZ       16
 #define  STM_I2C_CR2_FREQ_24_MHZ       24
 #define  STM_I2C_CR2_FREQ_32_MHZ       32
-#define  STM_I2C_CR2_FREQ_MASK         0x3f
+#define  STM_I2C_CR2_FREQ_MASK         0x3fUL
 
 #define STM_I2C_SR1_SMBALERT   15
 #define STM_I2C_SR1_TIMEOUT    14
@@ -1672,7 +1672,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define STM_I2C_SR1_SB         0
 
 #define STM_I2C_SR2_PEC                8
-#define  STM_I2C_SR2_PEC_MASK  0xff00
+#define  STM_I2C_SR2_PEC_MASK  0xff00UL
 #define STM_I2C_SR2_DUALF      7
 #define STM_I2C_SR2_SMBHOST    6
 #define STM_I2C_SR2_SMBDEFAULT 5
@@ -1684,7 +1684,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define STM_I2C_CCR_FS         15
 #define STM_I2C_CCR_DUTY       14
 #define STM_I2C_CCR_CCR                0
-#define  STM_I2C_CCR_MASK      0x7ff
+#define  STM_I2C_CCR_MASK      0x7ffUL
 
 struct stm_tim234 {
        vuint32_t       cr1;
@@ -1721,14 +1721,14 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CR1_CKD_1          0
 #define  STM_TIM234_CR1_CKD_2          1
 #define  STM_TIM234_CR1_CKD_4          2
-#define  STM_TIM234_CR1_CKD_MASK       3
+#define  STM_TIM234_CR1_CKD_MASK       3UL
 #define STM_TIM234_CR1_ARPE    7
 #define STM_TIM234_CR1_CMS     5
 #define  STM_TIM234_CR1_CMS_EDGE       0
 #define  STM_TIM234_CR1_CMS_CENTER_1   1
 #define  STM_TIM234_CR1_CMS_CENTER_2   2
 #define  STM_TIM234_CR1_CMS_CENTER_3   3
-#define  STM_TIM234_CR1_CMS_MASK       3
+#define  STM_TIM234_CR1_CMS_MASK       3UL
 #define STM_TIM234_CR1_DIR     4
 #define  STM_TIM234_CR1_DIR_UP         0
 #define  STM_TIM234_CR1_DIR_DOWN       1
@@ -1747,7 +1747,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CR2_MMS_COMPARE_OC2REF     5
 #define  STM_TIM234_CR2_MMS_COMPARE_OC3REF     6
 #define  STM_TIM234_CR2_MMS_COMPARE_OC4REF     7
-#define  STM_TIM234_CR2_MMS_MASK               7
+#define  STM_TIM234_CR2_MMS_MASK               7UL
 #define STM_TIM234_CR2_CCDS    3
 
 #define STM_TIM234_SMCR_ETP    15
@@ -1757,7 +1757,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_ETPS_DIV_2            1
 #define  STM_TIM234_SMCR_ETPS_DIV_4            2
 #define  STM_TIM234_SMCR_ETPS_DIV_8            3
-#define  STM_TIM234_SMCR_ETPS_MASK             3
+#define  STM_TIM234_SMCR_ETPS_MASK             3UL
 #define STM_TIM234_SMCR_ETF    8
 #define  STM_TIM234_SMCR_ETF_NONE              0
 #define  STM_TIM234_SMCR_ETF_INT_N_2           1
@@ -1775,7 +1775,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_ETF_DTS_32_N_5                13
 #define  STM_TIM234_SMCR_ETF_DTS_32_N_6                14
 #define  STM_TIM234_SMCR_ETF_DTS_32_N_8                15
-#define  STM_TIM234_SMCR_ETF_MASK              15
+#define  STM_TIM234_SMCR_ETF_MASK              15UL
 #define STM_TIM234_SMCR_MSM    7
 #define STM_TIM234_SMCR_TS     4
 #define  STM_TIM234_SMCR_TS_ITR0               0
@@ -1786,7 +1786,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_TS_TI1FP1             5
 #define  STM_TIM234_SMCR_TS_TI2FP2             6
 #define  STM_TIM234_SMCR_TS_ETRF               7
-#define  STM_TIM234_SMCR_TS_MASK               7
+#define  STM_TIM234_SMCR_TS_MASK               7UL
 #define STM_TIM234_SMCR_OCCS   3
 #define STM_TIM234_SMCR_SMS    0
 #define  STM_TIM234_SMCR_SMS_DISABLE           0
@@ -1797,7 +1797,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_SMS_GATED_MODE                5
 #define  STM_TIM234_SMCR_SMS_TRIGGER_MODE      6
 #define  STM_TIM234_SMCR_SMS_EXTERNAL_CLOCK    7
-#define  STM_TIM234_SMCR_SMS_MASK              7
+#define  STM_TIM234_SMCR_SMS_MASK              7UL
 
 #define STM_TIM234_DIER_TDE            14
 #define STM_TIM234_DIER_CC4DE          12
@@ -1841,7 +1841,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_OC2M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR1_OC2M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR1_OC2M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR1_OC2M_MASK                    7
+#define  STM_TIM234_CCMR1_OC2M_MASK                    7UL
 #define STM_TIM234_CCMR1_OC2PE 11
 #define STM_TIM234_CCMR1_OC2FE 10
 #define STM_TIM234_CCMR1_CC2S  8
@@ -1849,7 +1849,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_CC2S_INPUT_TI2               1
 #define  STM_TIM234_CCMR1_CC2S_INPUT_TI1               2
 #define  STM_TIM234_CCMR1_CC2S_INPUT_TRC               3
-#define  STM_TIM234_CCMR1_CC2S_MASK                    3
+#define  STM_TIM234_CCMR1_CC2S_MASK                    3UL
 
 #define STM_TIM234_CCMR1_OC1CE 7
 #define STM_TIM234_CCMR1_OC1M  4
@@ -1861,7 +1861,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_OC1M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR1_OC1M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR1_OC1M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR1_OC1M_MASK                    7
+#define  STM_TIM234_CCMR1_OC1M_MASK                    7UL
 #define STM_TIM234_CCMR1_OC1PE 3
 #define STM_TIM234_CCMR1_OC1FE 2
 #define STM_TIM234_CCMR1_CC1S  0
@@ -1869,7 +1869,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_CC1S_INPUT_TI1               1
 #define  STM_TIM234_CCMR1_CC1S_INPUT_TI2               2
 #define  STM_TIM234_CCMR1_CC1S_INPUT_TRC               3
-#define  STM_TIM234_CCMR1_CC1S_MASK                    3
+#define  STM_TIM234_CCMR1_CC1S_MASK                    3UL
 
 #define STM_TIM234_CCMR1_IC2F  12
 #define  STM_TIM234_CCMR1_IC2F_NONE                    0
@@ -1926,7 +1926,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_OC4M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR2_OC4M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR2_OC4M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR2_OC4M_MASK                    7
+#define  STM_TIM234_CCMR2_OC4M_MASK                    7UL
 #define STM_TIM234_CCMR2_OC4PE 11
 #define STM_TIM234_CCMR2_OC4FE 10
 #define STM_TIM234_CCMR2_CC4S  8
@@ -1934,7 +1934,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_CC4S_INPUT_TI4               1
 #define  STM_TIM234_CCMR2_CC4S_INPUT_TI3               2
 #define  STM_TIM234_CCMR2_CC4S_INPUT_TRC               3
-#define  STM_TIM234_CCMR2_CC4S_MASK                    3
+#define  STM_TIM234_CCMR2_CC4S_MASK                    3UL
 
 #define STM_TIM234_CCMR2_OC3CE 7
 #define STM_TIM234_CCMR2_OC3M  4
@@ -1946,7 +1946,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_OC3M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR2_OC3M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR2_OC3M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR2_OC3M_MASK                    7
+#define  STM_TIM234_CCMR2_OC3M_MASK                    7UL
 #define STM_TIM234_CCMR2_OC3PE 3
 #define STM_TIM234_CCMR2_OC3FE 2
 #define STM_TIM234_CCMR2_CC3S  0
@@ -1954,7 +1954,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_CC3S_INPUT_TI3               1
 #define  STM_TIM234_CCMR2_CC3S_INPUT_TI4               2
 #define  STM_TIM234_CCMR2_CC3S_INPUT_TRC               3
-#define  STM_TIM234_CCMR2_CC3S_MASK                    3
+#define  STM_TIM234_CCMR2_CC3S_MASK                    3UL
 
 #define STM_TIM234_CCER_CC4NP  15
 #define STM_TIM234_CCER_CC4P   13
@@ -1996,7 +1996,7 @@ struct stm_usb {
 #define  STM_USB_EPR_STAT_RX_STALL                     1
 #define  STM_USB_EPR_STAT_RX_NAK                       2
 #define  STM_USB_EPR_STAT_RX_VALID                     3
-#define  STM_USB_EPR_STAT_RX_MASK                      3
+#define  STM_USB_EPR_STAT_RX_MASK                      3UL
 #define  STM_USB_EPR_STAT_RX_WRITE_INVARIANT           0
 #define STM_USB_EPR_SETUP      11
 #define STM_USB_EPR_EP_TYPE    9
@@ -2004,7 +2004,7 @@ struct stm_usb {
 #define  STM_USB_EPR_EP_TYPE_CONTROL                   1
 #define  STM_USB_EPR_EP_TYPE_ISO                       2
 #define  STM_USB_EPR_EP_TYPE_INTERRUPT                 3
-#define  STM_USB_EPR_EP_TYPE_MASK                      3
+#define  STM_USB_EPR_EP_TYPE_MASK                      3UL
 #define STM_USB_EPR_EP_KIND    8
 #define  STM_USB_EPR_EP_KIND_DBL_BUF                   1       /* Bulk */
 #define  STM_USB_EPR_EP_KIND_STATUS_OUT                        1       /* Control */
@@ -2018,9 +2018,9 @@ struct stm_usb {
 #define  STM_USB_EPR_STAT_TX_NAK                       2
 #define  STM_USB_EPR_STAT_TX_VALID                     3
 #define  STM_USB_EPR_STAT_TX_WRITE_INVARIANT           0
-#define  STM_USB_EPR_STAT_TX_MASK                      3
+#define  STM_USB_EPR_STAT_TX_MASK                      3UL
 #define STM_USB_EPR_EA         0
-#define  STM_USB_EPR_EA_MASK                           0xf
+#define  STM_USB_EPR_EA_MASK                           0xfUL
 
 #define STM_USB_CNTR_CTRM      15
 #define STM_USB_CNTR_PMAOVRM   14
@@ -2046,19 +2046,19 @@ struct stm_usb {
 #define STM_USB_ISTR_ESOF      8
 #define STM_USB_ISTR_DIR       4
 #define STM_USB_ISTR_EP_ID     0
-#define  STM_USB_ISTR_EP_ID_MASK               0xf
+#define  STM_USB_ISTR_EP_ID_MASK               0xfUL
 
 #define STM_USB_FNR_RXDP       15
 #define STM_USB_FNR_RXDM       14
 #define STM_USB_FNR_LCK                13
 #define STM_USB_FNR_LSOF       11
-#define  STM_USB_FNR_LSOF_MASK                 0x3
+#define  STM_USB_FNR_LSOF_MASK                 0x3UL
 #define STM_USB_FNR_FN         0
-#define  STM_USB_FNR_FN_MASK                   0x7ff
+#define  STM_USB_FNR_FN_MASK                   0x7ffUL
 
 #define STM_USB_DADDR_EF       7
 #define STM_USB_DADDR_ADD      0
-#define  STM_USB_DADDR_ADD_MASK                        0x7f
+#define  STM_USB_DADDR_ADD_MASK                        0x7fUL
 
 extern struct stm_usb stm_usb;
 
@@ -2081,9 +2081,9 @@ union stm_usb_bdt {
 
 #define STM_USB_BDT_COUNT_RX_BL_SIZE   15
 #define STM_USB_BDT_COUNT_RX_NUM_BLOCK 10
-#define  STM_USB_BDT_COUNT_RX_NUM_BLOCK_MASK   0x1f
+#define  STM_USB_BDT_COUNT_RX_NUM_BLOCK_MASK   0x1fUL
 #define STM_USB_BDT_COUNT_RX_COUNT_RX  0
-#define  STM_USB_BDT_COUNT_RX_COUNT_RX_MASK    0x1ff
+#define  STM_USB_BDT_COUNT_RX_COUNT_RX_MASK    0x1ffUL
 
 #define STM_USB_BDT_SIZE       8
 
index a7af0a08308197fc21a6a395eaf59284e9b4a031..5c0f4c2bd1021e2e25597148710355f5bf93e61c 100644 (file)
@@ -54,8 +54,8 @@ ao_adc_init(void)
                       (0 << STM_ADC_CCR_VREFEN));
 
        /* Calibrate. This also enables the ADC vreg */
-       stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
-       while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+       stm_adc.cr |= (1UL << STM_ADC_CR_ADCAL);
+       while ((stm_adc.cr & (1UL << STM_ADC_CR_ADCAL)) != 0)
                ;
 
        /* Enable */
@@ -77,10 +77,10 @@ ao_adc_shutdown(void)
        stm_adc.isr = (1 << STM_ADC_ISR_ADRDY);
 
        /* Disable ADC vreg */
-       stm_adc.cr &= ~(1 << STM_ADC_CR_ADVREGEN);
+       stm_adc.cr &= ~(1UL << STM_ADC_CR_ADVREGEN);
 
        /* Disable ADC clocks */
-       stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_ADCEN);
+       stm_rcc.apb2enr &= ~(1UL << STM_RCC_APB2ENR_ADCEN);
 }
 
 uint16_t
@@ -104,7 +104,7 @@ ao_adc_read_vref(void)
                ;
 
        /* Fetch result */
-       value = stm_adc.dr;
+       value = (uint16_t) stm_adc.dr;
 
        ao_adc_shutdown();
        return value;
index 297bd66c76684b9762fba85f6e67f68fd7b206a3..f03d96957802674ffc22d54b009be87805c15119 100644 (file)
@@ -133,7 +133,7 @@ ao_spi_recv_byte(uint8_t spi_index)
        stm_spi->dr = 0xff;
        while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
                ;
-       return stm_spi->dr;
+       return (uint8_t) stm_spi->dr;
 }
 
 void
index d808d1e95480c9ede69fc672d8399459a8ca4dd9..d01fe7c0cfc6b34827f190578129c84b975de4aa 100644 (file)
@@ -24,7 +24,7 @@ static void   (*ao_exti_callback[16])(void);
 uint32_t       ao_last_exti;
 
 static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
-       uint16_t        pending = (ao_last_exti = stm_exti.pr) & mask;
+       uint16_t        pending = (uint16_t) (ao_last_exti = stm_exti.pr) & mask;
        uint8_t         pin;
        static uint16_t last_mask;
        static uint8_t  last_pin;
index ba3274422ef969797bb50b0e28e7eb3b6868fa15..521c5c0cfbb95d56317440c6c7be6bb55a0c5cde 100644 (file)
@@ -186,7 +186,7 @@ ao_storage_device_write(ao_pos_t pos, void *buf, uint16_t len)
                flash_write_select(this_pos);
 
                /* Update write buffer with new contents */
-               int this_word = 4 - (pos & 3);
+               uint16_t this_word = 4 - (pos & 3);
                if (this_word > len)
                        this_word = len;
                memcpy(&write_buf.u8[pos & 3], b8, this_word);
index c4a23f5b4f94c8edfba8c387dba676bd05bb8f56..08a0859b0ea1e18ad163b812c0b66ca23c90e7f9 100644 (file)
@@ -85,7 +85,7 @@ _ao_lpuart_rx(struct ao_stm_lpuart *lpuart, int is_stdin)
                        }
 #endif
                } else {
-                       lpuart->reg->cr1 &= ~(1 << STM_LPUART_CR1_RXNEIE);
+                       lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_RXNEIE);
                }
        }
 }
@@ -96,11 +96,11 @@ ao_lpuart_isr(struct ao_stm_lpuart *lpuart, int is_stdin)
        _ao_lpuart_rx(lpuart, is_stdin);
 
        if (!_ao_lpuart_tx_start(lpuart))
-               lpuart->reg->cr1 &= ~(1<< STM_LPUART_CR1_TXEIE);
+               lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_TXEIE);
 
        if (lpuart->reg->isr & (1 << STM_LPUART_ISR_TC)) {
                lpuart->tx_running = 0;
-               lpuart->reg->cr1 &= ~(1 << STM_LPUART_CR1_TCIE);
+               lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_TCIE);
                if (lpuart->draining) {
                        lpuart->draining = 0;
                        ao_wakeup(&lpuart->tx_fifo);
@@ -370,6 +370,6 @@ ao_lpuart1_disable(void)
 # endif
 
        /* Disable LPUART */
-       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_LPUART1EN);
+       stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_LPUART1EN);
 }
  
index ac745d9709387d7aec07b45ba3cc0d5019487822..650f2f1f636c335f80e8c27068948b42c65a1cfc 100644 (file)
@@ -66,7 +66,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
                        }
 #endif
                } else {
-                       usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+                       usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
                }
        }
 }
@@ -77,11 +77,11 @@ ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
        _ao_usart_rx(usart, is_stdin);
 
        if (!_ao_usart_tx_start(usart))
-               usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
 
        if (usart->reg->isr & (1 << STM_USART_ISR_TC)) {
                usart->tx_running = 0;
-               usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
                if (usart->draining) {
                        usart->draining = 0;
                        ao_wakeup(&usart->tx_fifo);
index b8831d5aefa2b0cf925823366706d15153863846..4f76c6c2de96e2ce9b1b1cbda3846598051ecad5 100644 (file)
@@ -229,7 +229,7 @@ ao_spi_recv(void *block, uint16_t len, uint8_t spi_index)
                while ((stm_spi->sr & (1 << STM_SPI_SR_TXE)) == 0);
                stm_spi->dr = 0xff;
                while ((stm_spi->sr & (1 << STM_SPI_SR_RXNE)) == 0);
-               *bytes++ = stm_spi->dr;
+               *bytes++ = (uint8_t) stm_spi->dr;
        }
 #endif
 }
index 90f070ce4b68532b23f4b0077626964e07c7d9fe..41cad245feaf96f0287f79f1fa18107223448d58 100644 (file)
@@ -42,7 +42,7 @@ struct stm_gpio {
 };
 
 #define STM_MODER_SHIFT(pin)           ((pin) << 1)
-#define STM_MODER_MASK                 3
+#define STM_MODER_MASK                 3UL
 #define STM_MODER_INPUT                        0
 #define STM_MODER_OUTPUT               1
 #define STM_MODER_ALTERNATE            2
@@ -50,9 +50,9 @@ struct stm_gpio {
 
 static inline void
 stm_moder_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
-       gpio->moder = ((gpio->moder &
-                       ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
-                      value << STM_MODER_SHIFT(pin));
+       gpio->moder = (((uint32_t) gpio->moder &
+                       (uint32_t) ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
+                      (value << STM_MODER_SHIFT(pin)));
 }
 
 static inline uint32_t
@@ -86,15 +86,15 @@ stm_moder_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_OTYPER_SHIFT(pin)          (pin)
-#define STM_OTYPER_MASK                        1
+#define STM_OTYPER_MASK                        1UL
 #define STM_OTYPER_PUSH_PULL           0
 #define STM_OTYPER_OPEN_DRAIN          1
 
 static inline void
 stm_otyper_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
        gpio->otyper = ((gpio->otyper &
-                        ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
-                       value << STM_OTYPER_SHIFT(pin));
+                        (uint32_t) ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
+                       (value << STM_OTYPER_SHIFT(pin)));
 }
 
 static inline uint32_t
@@ -103,7 +103,7 @@ stm_otyper_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_OSPEEDR_SHIFT(pin)         ((pin) << 1)
-#define STM_OSPEEDR_MASK               3
+#define STM_OSPEEDR_MASK               3UL
 #define STM_OSPEEDR_LOW                        0
 #define STM_OSPEEDR_MEDIUM             1
 #define STM_OSPEEDR_HIGH               2
@@ -112,8 +112,8 @@ stm_otyper_get(struct stm_gpio *gpio, int pin) {
 static inline void
 stm_ospeedr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
        gpio->ospeedr = ((gpio->ospeedr &
-                       ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
-                      value << STM_OSPEEDR_SHIFT(pin));
+                         (uint32_t) ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
+                        (value << STM_OSPEEDR_SHIFT(pin)));
 }
 
 static inline void
@@ -131,7 +131,7 @@ stm_ospeedr_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_PUPDR_SHIFT(pin)           ((pin) << 1)
-#define STM_PUPDR_MASK                 3
+#define STM_PUPDR_MASK                 3UL
 #define STM_PUPDR_NONE                 0
 #define STM_PUPDR_PULL_UP              1
 #define STM_PUPDR_PULL_DOWN            2
@@ -140,8 +140,8 @@ stm_ospeedr_get(struct stm_gpio *gpio, int pin) {
 static inline void
 stm_pupdr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
        gpio->pupdr = ((gpio->pupdr &
-                       ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
-                      value << STM_PUPDR_SHIFT(pin));
+                       (uint32_t) ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
+                      (value << STM_PUPDR_SHIFT(pin)));
 }
 
 static inline void
@@ -159,7 +159,7 @@ stm_pupdr_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_AFR_SHIFT(pin)             ((pin) << 2)
-#define STM_AFR_MASK                   0xf
+#define STM_AFR_MASK                   0xfUL
 #define STM_AFR_AF0                    0x0
 #define STM_AFR_AF1                    0x1
 #define STM_AFR_AF2                    0x2
@@ -185,13 +185,13 @@ stm_afr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
        stm_moder_set(gpio, pin, STM_MODER_ALTERNATE);
        if (pin < 8)
                gpio->afrl = ((gpio->afrl &
-                              ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
-                             value << STM_AFR_SHIFT(pin));
+                              (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+                             (value << STM_AFR_SHIFT(pin)));
        else {
                pin -= 8;
                gpio->afrh = ((gpio->afrh &
-                              ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
-                             value << STM_AFR_SHIFT(pin));
+                              (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+                             (value << STM_AFR_SHIFT(pin)));
        }
 }
        
@@ -234,7 +234,7 @@ stm_gpio_get(struct stm_gpio *gpio, int pin) {
 
 static inline uint16_t
 stm_gpio_get_all(struct stm_gpio *gpio) {
-       return gpio->idr;
+       return (uint16_t) gpio->idr;
 }
 
 /*
@@ -511,7 +511,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CR1_CKD_1         0
 #define  STM_TIM1011_CR1_CKD_2         1
 #define  STM_TIM1011_CR1_CKD_4         2
-#define  STM_TIM1011_CR1_CKD_MASK      3
+#define  STM_TIM1011_CR1_CKD_MASK      3UL
 #define STM_TIM1011_CR1_ARPE   7
 #define STM_TIM1011_CR1_URS    2
 #define STM_TIM1011_CR1_UDIS   1
@@ -524,7 +524,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_SMCR_ETPS_2       1
 #define  STM_TIM1011_SMCR_ETPS_4       2
 #define  STM_TIM1011_SMCR_ETPS_8       3
-#define  STM_TIM1011_SMCR_ETPS_MASK    3
+#define  STM_TIM1011_SMCR_ETPS_MASK    3UL
 #define STM_TIM1011_SMCR_ETF   8
 #define  STM_TIM1011_SMCR_ETF_NONE             0
 #define  STM_TIM1011_SMCR_ETF_CK_INT_2         1
@@ -542,7 +542,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_SMCR_ETF_DTS_32_5         13
 #define  STM_TIM1011_SMCR_ETF_DTS_32_6         14
 #define  STM_TIM1011_SMCR_ETF_DTS_32_8         15
-#define  STM_TIM1011_SMCR_ETF_MASK             15
+#define  STM_TIM1011_SMCR_ETF_MASK             15UL
 
 #define STM_TIM1011_DIER_CC1E  1
 #define STM_TIM1011_DIER_UIE   0
@@ -564,7 +564,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CCMR1_OC1M_FORCE_ACTIVE           5
 #define  STM_TIM1011_CCMR1_OC1M_PWM_MODE_1             6
 #define  STM_TIM1011_CCMR1_OC1M_PWM_MODE_2             7
-#define  STM_TIM1011_CCMR1_OC1M_MASK                   7
+#define  STM_TIM1011_CCMR1_OC1M_MASK                   7UL
 #define STM_TIM1011_CCMR1_OC1PE        3
 #define STM_TIM1011_CCMR1_OC1FE        2
 #define STM_TIM1011_CCMR1_CC1S 0
@@ -572,7 +572,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CCMR1_CC1S_INPUT_TI1              1
 #define  STM_TIM1011_CCMR1_CC1S_INPUT_TI2              2
 #define  STM_TIM1011_CCMR1_CC1S_INPUT_TRC              3
-#define  STM_TIM1011_CCMR1_CC1S_MASK                   3
+#define  STM_TIM1011_CCMR1_CC1S_MASK                   3UL
 
 #define  STM_TIM1011_CCMR1_IC1F_NONE           0
 #define  STM_TIM1011_CCMR1_IC1F_CK_INT_2       1
@@ -590,13 +590,13 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_CCMR1_IC1F_DTS_32_5       13
 #define  STM_TIM1011_CCMR1_IC1F_DTS_32_6       14
 #define  STM_TIM1011_CCMR1_IC1F_DTS_32_8       15
-#define  STM_TIM1011_CCMR1_IC1F_MASK           15
+#define  STM_TIM1011_CCMR1_IC1F_MASK           15UL
 #define STM_TIM1011_CCMR1_IC1PSC       2
 #define  STM_TIM1011_CCMR1_IC1PSC_1            0
 #define  STM_TIM1011_CCMR1_IC1PSC_2            1
 #define  STM_TIM1011_CCMR1_IC1PSC_4            2
 #define  STM_TIM1011_CCMR1_IC1PSC_8            3
-#define  STM_TIM1011_CCMR1_IC1PSC_MASK         3
+#define  STM_TIM1011_CCMR1_IC1PSC_MASK         3UL
 #define STM_TIM1011_CCMR1_CC1S         0
 
 #define STM_TIM1011_CCER_CC1NP         3
@@ -610,7 +610,7 @@ extern struct stm_tim1011 stm_tim11;
 #define  STM_TIM1011_TI1_RMP_LSI               1
 #define  STM_TIM1011_TI1_RMP_LSE               2
 #define  STM_TIM1011_TI1_RMP_RTC               3
-#define  STM_TIM1011_TI1_RMP_MASK              3
+#define  STM_TIM1011_TI1_RMP_MASK              3UL
 
 struct stm_rcc {
        vuint32_t       cr;
@@ -658,7 +658,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CR_RTCPRE_HSE_DIV_4   1
 #define  STM_RCC_CR_RTCPRE_HSE_DIV_8   2
 #define  STM_RCC_CR_RTCPRE_HSE_DIV_16  3
-#define  STM_RCC_CR_RTCPRE_HSE_MASK    3
+#define  STM_RCC_CR_RTCPRE_HSE_MASK    3UL
 
 #define STM_RCC_CR_CSSON       (28)
 #define STM_RCC_CR_PLLRDY      (25)
@@ -681,7 +681,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_ICSCR_MSIRANGE_1048576        4
 #define  STM_RCC_ICSCR_MSIRANGE_2097152        5
 #define  STM_RCC_ICSCR_MSIRANGE_4194304        6
-#define  STM_RCC_ICSCR_MSIRANGE_MASK   0x7
+#define  STM_RCC_ICSCR_MSIRANGE_MASK   0x7UL
 #define STM_RCC_ICSCR_MSICAL   16
 #define STM_RCC_ICSCR_MSITRIM  24
 
@@ -691,7 +691,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_MCOPRE_DIV_4     2
 #define  STM_RCC_CFGR_MCOPRE_DIV_8     3
 #define  STM_RCC_CFGR_MCOPRE_DIV_16    4
-#define  STM_RCC_CFGR_MCOPRE_MASK      7
+#define  STM_RCC_CFGR_MCOPRE_MASK      7UL
 
 #define STM_RCC_CFGR_MCOSEL    (24)
 #define  STM_RCC_CFGR_MCOSEL_DISABLE   0
@@ -702,13 +702,13 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_MCOSEL_PLL       5
 #define  STM_RCC_CFGR_MCOSEL_LSI       6
 #define  STM_RCC_CFGR_MCOSEL_LSE       7
-#define  STM_RCC_CFGR_MCOSEL_MASK      7
+#define  STM_RCC_CFGR_MCOSEL_MASK      7UL
 
 #define STM_RCC_CFGR_PLLDIV    (22)
 #define  STM_RCC_CFGR_PLLDIV_2         1
 #define  STM_RCC_CFGR_PLLDIV_3         2
 #define  STM_RCC_CFGR_PLLDIV_4         3
-#define  STM_RCC_CFGR_PLLDIV_MASK      3
+#define  STM_RCC_CFGR_PLLDIV_MASK      3UL
 
 #define STM_RCC_CFGR_PLLMUL    (18)
 #define  STM_RCC_CFGR_PLLMUL_3         0
@@ -720,7 +720,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PLLMUL_24                6
 #define  STM_RCC_CFGR_PLLMUL_32                7
 #define  STM_RCC_CFGR_PLLMUL_48                8
-#define  STM_RCC_CFGR_PLLMUL_MASK      0xf
+#define  STM_RCC_CFGR_PLLMUL_MASK      0xfUL
 
 #define STM_RCC_CFGR_PLLSRC    (16)
 
@@ -730,7 +730,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PPRE2_DIV_4      5
 #define  STM_RCC_CFGR_PPRE2_DIV_8      6
 #define  STM_RCC_CFGR_PPRE2_DIV_16     7
-#define  STM_RCC_CFGR_PPRE2_MASK       7
+#define  STM_RCC_CFGR_PPRE2_MASK       7UL
 
 #define STM_RCC_CFGR_PPRE1     (8)
 #define  STM_RCC_CFGR_PPRE1_DIV_1      0
@@ -738,7 +738,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PPRE1_DIV_4      5
 #define  STM_RCC_CFGR_PPRE1_DIV_8      6
 #define  STM_RCC_CFGR_PPRE1_DIV_16     7
-#define  STM_RCC_CFGR_PPRE1_MASK       7
+#define  STM_RCC_CFGR_PPRE1_MASK       7UL
 
 #define STM_RCC_CFGR_HPRE      (4)
 #define  STM_RCC_CFGR_HPRE_DIV_1       0
@@ -750,21 +750,21 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_HPRE_DIV_128     0xd
 #define  STM_RCC_CFGR_HPRE_DIV_256     0xe
 #define  STM_RCC_CFGR_HPRE_DIV_512     0xf
-#define  STM_RCC_CFGR_HPRE_MASK                0xf
+#define  STM_RCC_CFGR_HPRE_MASK                0xfUL
 
 #define STM_RCC_CFGR_SWS       (2)
 #define  STM_RCC_CFGR_SWS_MSI          0
 #define  STM_RCC_CFGR_SWS_HSI          1
 #define  STM_RCC_CFGR_SWS_HSE          2
 #define  STM_RCC_CFGR_SWS_PLL          3
-#define  STM_RCC_CFGR_SWS_MASK         3
+#define  STM_RCC_CFGR_SWS_MASK         3UL
 
 #define STM_RCC_CFGR_SW                (0)
 #define  STM_RCC_CFGR_SW_MSI           0
 #define  STM_RCC_CFGR_SW_HSI           1
 #define  STM_RCC_CFGR_SW_HSE           2
 #define  STM_RCC_CFGR_SW_PLL           3
-#define  STM_RCC_CFGR_SW_MASK          3
+#define  STM_RCC_CFGR_SW_MASK          3UL
 
 #define STM_RCC_IOPENR_IOPAEN          0
 #define STM_RCC_IOPENR_IOPBEN          1
@@ -830,7 +830,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CSR_RTCSEL_LSE                        1
 #define  STM_RCC_CSR_RTCSEL_LSI                        2
 #define  STM_RCC_CSR_RTCSEL_HSE                        3
-#define  STM_RCC_CSR_RTCSEL_MASK               3
+#define  STM_RCC_CSR_RTCSEL_MASK               3UL
 
 #define STM_RCC_CSR_LSEBYP             (10)
 #define STM_RCC_CSR_LSERDY             (9)
@@ -853,7 +853,7 @@ extern struct stm_pwr stm_pwr;
 #define  STM_PWR_CR_VOS_1_8            1
 #define  STM_PWR_CR_VOS_1_5            2
 #define  STM_PWR_CR_VOS_1_2            3
-#define  STM_PWR_CR_VOS_MASK           3
+#define  STM_PWR_CR_VOS_MASK           3UL
 #define STM_PWR_CR_FWU         10
 #define STM_PWR_CR_ULP         9
 #define STM_PWR_CR_DBP         8
@@ -866,7 +866,7 @@ extern struct stm_pwr stm_pwr;
 #define  STM_PWR_CR_PLS_2_9    5
 #define  STM_PWR_CR_PLS_3_1    6
 #define  STM_PWR_CR_PLS_EXT    7
-#define  STM_PWR_CR_PLS_MASK   7
+#define  STM_PWR_CR_PLS_MASK   7UL
 #define STM_PWR_CR_PVDE                4
 #define STM_PWR_CR_CSBF                3
 #define STM_PWR_CR_CWUF                2
@@ -912,7 +912,7 @@ extern struct stm_tim67 stm_tim6;
 #define  STM_TIM67_CR2_MMS_RESET       0
 #define  STM_TIM67_CR2_MMS_ENABLE      1
 #define  STM_TIM67_CR2_MMS_UPDATE      2
-#define  STM_TIM67_CR2_MMS_MASK                7
+#define  STM_TIM67_CR2_MMS_MASK                7UL
 
 #define STM_TIM67_DIER_UDE     (8)
 #define STM_TIM67_DIER_UIE     (0)
@@ -938,7 +938,7 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_CR_BIAS_1_4           0
 #define  STM_LCD_CR_BIAS_1_2           1
 #define  STM_LCD_CR_BIAS_1_3           2
-#define  STM_LCD_CR_BIAS_MASK          3
+#define  STM_LCD_CR_BIAS_MASK          3UL
 
 #define STM_LCD_CR_DUTY                        (2)
 #define  STM_LCD_CR_DUTY_STATIC                0
@@ -946,7 +946,7 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_CR_DUTY_1_3           2
 #define  STM_LCD_CR_DUTY_1_4           3
 #define  STM_LCD_CR_DUTY_1_8           4
-#define  STM_LCD_CR_DUTY_MASK          7
+#define  STM_LCD_CR_DUTY_MASK          7UL
 
 #define STM_LCD_CR_VSEL                        (1)
 #define STM_LCD_CR_LCDEN               (0)
@@ -968,7 +968,7 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_FCR_PS_8192           0xd
 #define  STM_LCD_FCR_PS_16384          0xe
 #define  STM_LCD_FCR_PS_32768          0xf
-#define  STM_LCD_FCR_PS_MASK           0xf
+#define  STM_LCD_FCR_PS_MASK           0xfUL
 
 #define STM_LCD_FCR_DIV                        (18)
 #define STM_LCD_FCR_DIV_16             0x0
@@ -987,14 +987,14 @@ extern struct stm_lcd stm_lcd;
 #define STM_LCD_FCR_DIV_29             0xd
 #define STM_LCD_FCR_DIV_30             0xe
 #define STM_LCD_FCR_DIV_31             0xf
-#define STM_LCD_FCR_DIV_MASK           0xf
+#define STM_LCD_FCR_DIV_MASK           0xfUL
 
 #define STM_LCD_FCR_BLINK              (16)
 #define  STM_LCD_FCR_BLINK_DISABLE             0
 #define  STM_LCD_FCR_BLINK_SEG0_COM0           1
 #define  STM_LCD_FCR_BLINK_SEG0_COMALL         2
 #define  STM_LCD_FCR_BLINK_SEGALL_COMALL       3
-#define  STM_LCD_FCR_BLINK_MASK                        3
+#define  STM_LCD_FCR_BLINK_MASK                        3UL
 
 #define STM_LCD_FCR_BLINKF             (13)
 #define  STM_LCD_FCR_BLINKF_8                  0
@@ -1005,16 +1005,16 @@ extern struct stm_lcd stm_lcd;
 #define  STM_LCD_FCR_BLINKF_256                        5
 #define  STM_LCD_FCR_BLINKF_512                        6
 #define  STM_LCD_FCR_BLINKF_1024               7
-#define  STM_LCD_FCR_BLINKF_MASK               7
+#define  STM_LCD_FCR_BLINKF_MASK               7UL
 
 #define STM_LCD_FCR_CC                 (10)
-#define  STM_LCD_FCR_CC_MASK                   7
+#define  STM_LCD_FCR_CC_MASK                   7UL
 
 #define STM_LCD_FCR_DEAD               (7)
-#define  STM_LCD_FCR_DEAD_MASK                 7
+#define  STM_LCD_FCR_DEAD_MASK                 7UL
 
 #define STM_LCD_FCR_PON                        (4)
-#define  STM_LCD_FCR_PON_MASK                  7
+#define  STM_LCD_FCR_PON_MASK                  7UL
 
 #define STM_LCD_FCR_UDDIE              (3)
 #define STM_LCD_FCR_SOFIE              (1)
@@ -1115,7 +1115,7 @@ stm_nvic_set_priority(int irq, uint8_t prio) {
        uint32_t        v;
 
        v = stm_nvic.ipr[n];
-       v &= ~IRQ_PRIO_MASK(irq);
+       v &= (uint32_t) ~IRQ_PRIO_MASK(irq);
        v |= (prio) << IRQ_PRIO_BIT(irq);
        stm_nvic.ipr[n] = v;
 }
@@ -1177,9 +1177,9 @@ struct stm_mpu {
 extern struct stm_mpu stm_mpu;
 
 #define STM_MPU_TYPER_IREGION  16
-#define  STM_MPU_TYPER_IREGION_MASK    0xff
+#define  STM_MPU_TYPER_IREGION_MASK    0xffUL
 #define STM_MPU_TYPER_DREGION  8
-#define  STM_MPU_TYPER_DREGION_MASK    0xff
+#define  STM_MPU_TYPER_DREGION_MASK    0xffUL
 #define STM_MPU_TYPER_SEPARATE 0
 
 #define STM_MPU_CR_PRIVDEFENA  2
@@ -1187,14 +1187,14 @@ extern struct stm_mpu stm_mpu;
 #define STM_MPU_CR_ENABLE      0
 
 #define STM_MPU_RNR_REGION     0
-#define STM_MPU_RNR_REGION_MASK                0xff
+#define STM_MPU_RNR_REGION_MASK                0xffUL
 
 #define STM_MPU_RBAR_ADDR      5
-#define STM_MPU_RBAR_ADDR_MASK         0x7ffffff
+#define STM_MPU_RBAR_ADDR_MASK         0x7ffffffUL
 
 #define STM_MPU_RBAR_VALID     4
 #define STM_MPU_RBAR_REGION    0
-#define STM_MPU_RBAR_REGION_MASK       0xf
+#define STM_MPU_RBAR_REGION_MASK       0xfUL
 
 #define STM_MPU_RASR_XN                28
 #define STM_MPU_RASR_AP                24
@@ -1204,16 +1204,16 @@ extern struct stm_mpu stm_mpu;
 #define  STM_MPU_RASR_AP_RW_RW         3
 #define  STM_MPU_RASR_AP_RO_NONE       5
 #define  STM_MPU_RASR_AP_RO_RO         6
-#define  STM_MPU_RASR_AP_MASK          7
+#define  STM_MPU_RASR_AP_MASK          7UL
 #define STM_MPU_RASR_TEX       19
-#define  STM_MPU_RASR_TEX_MASK         7
+#define  STM_MPU_RASR_TEX_MASK         7UL
 #define STM_MPU_RASR_S         18
 #define STM_MPU_RASR_C         17
 #define STM_MPU_RASR_B         16
 #define STM_MPU_RASR_SRD       8
-#define  STM_MPU_RASR_SRD_MASK         0xff
+#define  STM_MPU_RASR_SRD_MASK         0xffUL
 #define STM_MPU_RASR_SIZE      1
-#define  STM_MPU_RASR_SIZE_MASK                0x1f
+#define  STM_MPU_RASR_SIZE_MASK                0x1fUL
 #define STM_MPU_RASR_ENABLE    0
 
 #define isr_decl(name) void stm_ ## name ## _isr(void)
@@ -1302,7 +1302,7 @@ extern struct stm_syscfg stm_syscfg;
 #define  STM_SYSCFG_MEMRMP_MEM_MODE_MAIN_FLASH         0
 #define  STM_SYSCFG_MEMRMP_MEM_MODE_SYSTEM_FLASH       1
 #define  STM_SYSCFG_MEMRMP_MEM_MODE_SRAM               3
-#define  STM_SYSCFG_MEMRMP_MEM_MODE_MASK               3
+#define  STM_SYSCFG_MEMRMP_MEM_MODE_MASK               3UL
 
 #define STM_SYSCFG_PMC_USB_PU          0
 
@@ -1314,7 +1314,7 @@ extern struct stm_syscfg stm_syscfg;
 #define STM_SYSCFG_EXTICR_PH           5
 
 static inline void
-stm_exticr_set(struct stm_gpio *gpio, int pin) {
+stm_exticr_set(struct stm_gpio *gpio, uint8_t pin) {
        uint8_t reg = pin >> 2;
        uint8_t shift = (pin & 3) << 2;
        uint8_t val = 0;
@@ -1333,7 +1333,7 @@ stm_exticr_set(struct stm_gpio *gpio, int pin) {
        else if (gpio == &stm_gpioe)
                val = STM_SYSCFG_EXTICR_PE;
 
-       stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+       stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xfUL << shift)) | val << shift;
 }
 
 struct stm_dma_channel {
@@ -1363,14 +1363,14 @@ extern struct stm_dma stm_dma1;
 #define STM_DMA_INDEX(channel)         ((channel) - 1)
 
 #define STM_DMA_ISR(index)             ((index) << 2)
-#define STM_DMA_ISR_MASK                       0xf
+#define STM_DMA_ISR_MASK                       0xfUL
 #define STM_DMA_ISR_TEIF                       3
 #define STM_DMA_ISR_HTIF                       2
 #define STM_DMA_ISR_TCIF                       1
 #define STM_DMA_ISR_GIF                                0
 
 #define STM_DMA_IFCR(index)            ((index) << 2)
-#define STM_DMA_IFCR_MASK                      0xf
+#define STM_DMA_IFCR_MASK                      0xfUL
 #define STM_DMA_IFCR_CTEIF                     3
 #define STM_DMA_IFCR_CHTIF                     2
 #define STM_DMA_IFCR_CTCIF                     1
@@ -1508,7 +1508,7 @@ extern struct stm_spi stm_spi1;
 #define  STM_SPI_CR1_BR_PCLK_64                        5
 #define  STM_SPI_CR1_BR_PCLK_128               6
 #define  STM_SPI_CR1_BR_PCLK_256               7
-#define  STM_SPI_CR1_BR_MASK                   7
+#define  STM_SPI_CR1_BR_MASK                   7UL
 
 #define STM_SPI_CR1_MSTR               2
 #define STM_SPI_CR1_CPOL               1
@@ -1596,7 +1596,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CFGR1_EXTEN_RISING    1
 #define  STM_ADC_CFGR1_EXTEN_FALLING   2
 #define  STM_ADC_CFGR1_EXTEN_BOTH      3
-#define  STM_ADC_CFGR1_EXTEN_MASK      3
+#define  STM_ADC_CFGR1_EXTEN_MASK      3UL
 
 #define STM_ADC_CFGR1_EXTSEL   6
 #define STM_ADC_CFGR1_ALIGN    5
@@ -1605,7 +1605,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CFGR1_RES_10          1
 #define  STM_ADC_CFGR1_RES_8           2
 #define  STM_ADC_CFGR1_RES_6           3
-#define  STM_ADC_CFGR1_RES_MASK                3
+#define  STM_ADC_CFGR1_RES_MASK                3UL
 #define STM_ADC_CFGR1_SCANDIR  2
 #define  STM_ADC_CFGR1_SCANDIR_UP      0
 #define  STM_ADC_CFGR1_SCANDIR_DOWN    1
@@ -1732,7 +1732,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define  STM_I2C_CR2_FREQ_16_MHZ       16
 #define  STM_I2C_CR2_FREQ_24_MHZ       24
 #define  STM_I2C_CR2_FREQ_32_MHZ       32
-#define  STM_I2C_CR2_FREQ_MASK         0x3f
+#define  STM_I2C_CR2_FREQ_MASK         0x3fUL
 
 #define STM_I2C_SR1_SMBALERT   15
 #define STM_I2C_SR1_TIMEOUT    14
@@ -1750,7 +1750,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define STM_I2C_SR1_SB         0
 
 #define STM_I2C_SR2_PEC                8
-#define  STM_I2C_SR2_PEC_MASK  0xff00
+#define  STM_I2C_SR2_PEC_MASK  0xff00UL
 #define STM_I2C_SR2_DUALF      7
 #define STM_I2C_SR2_SMBHOST    6
 #define STM_I2C_SR2_SMBDEFAULT 5
@@ -1762,7 +1762,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define STM_I2C_CCR_FS         15
 #define STM_I2C_CCR_DUTY       14
 #define STM_I2C_CCR_CCR                0
-#define  STM_I2C_CCR_MASK      0x7ff
+#define  STM_I2C_CCR_MASK      0x7ffUL
 
 struct stm_tim234 {
        vuint32_t       cr1;
@@ -1799,14 +1799,14 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CR1_CKD_1          0
 #define  STM_TIM234_CR1_CKD_2          1
 #define  STM_TIM234_CR1_CKD_4          2
-#define  STM_TIM234_CR1_CKD_MASK       3
+#define  STM_TIM234_CR1_CKD_MASK       3UL
 #define STM_TIM234_CR1_ARPE    7
 #define STM_TIM234_CR1_CMS     5
 #define  STM_TIM234_CR1_CMS_EDGE       0
 #define  STM_TIM234_CR1_CMS_CENTER_1   1
 #define  STM_TIM234_CR1_CMS_CENTER_2   2
 #define  STM_TIM234_CR1_CMS_CENTER_3   3
-#define  STM_TIM234_CR1_CMS_MASK       3
+#define  STM_TIM234_CR1_CMS_MASK       3UL
 #define STM_TIM234_CR1_DIR     4
 #define  STM_TIM234_CR1_DIR_UP         0
 #define  STM_TIM234_CR1_DIR_DOWN       1
@@ -1825,7 +1825,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CR2_MMS_COMPARE_OC2REF     5
 #define  STM_TIM234_CR2_MMS_COMPARE_OC3REF     6
 #define  STM_TIM234_CR2_MMS_COMPARE_OC4REF     7
-#define  STM_TIM234_CR2_MMS_MASK               7
+#define  STM_TIM234_CR2_MMS_MASK               7UL
 #define STM_TIM234_CR2_CCDS    3
 
 #define STM_TIM234_SMCR_ETP    15
@@ -1835,7 +1835,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_ETPS_DIV_2            1
 #define  STM_TIM234_SMCR_ETPS_DIV_4            2
 #define  STM_TIM234_SMCR_ETPS_DIV_8            3
-#define  STM_TIM234_SMCR_ETPS_MASK             3
+#define  STM_TIM234_SMCR_ETPS_MASK             3UL
 #define STM_TIM234_SMCR_ETF    8
 #define  STM_TIM234_SMCR_ETF_NONE              0
 #define  STM_TIM234_SMCR_ETF_INT_N_2           1
@@ -1853,7 +1853,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_ETF_DTS_32_N_5                13
 #define  STM_TIM234_SMCR_ETF_DTS_32_N_6                14
 #define  STM_TIM234_SMCR_ETF_DTS_32_N_8                15
-#define  STM_TIM234_SMCR_ETF_MASK              15
+#define  STM_TIM234_SMCR_ETF_MASK              15UL
 #define STM_TIM234_SMCR_MSM    7
 #define STM_TIM234_SMCR_TS     4
 #define  STM_TIM234_SMCR_TS_ITR0               0
@@ -1864,7 +1864,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_TS_TI1FP1             5
 #define  STM_TIM234_SMCR_TS_TI2FP2             6
 #define  STM_TIM234_SMCR_TS_ETRF               7
-#define  STM_TIM234_SMCR_TS_MASK               7
+#define  STM_TIM234_SMCR_TS_MASK               7UL
 #define STM_TIM234_SMCR_OCCS   3
 #define STM_TIM234_SMCR_SMS    0
 #define  STM_TIM234_SMCR_SMS_DISABLE           0
@@ -1875,7 +1875,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_SMCR_SMS_GATED_MODE                5
 #define  STM_TIM234_SMCR_SMS_TRIGGER_MODE      6
 #define  STM_TIM234_SMCR_SMS_EXTERNAL_CLOCK    7
-#define  STM_TIM234_SMCR_SMS_MASK              7
+#define  STM_TIM234_SMCR_SMS_MASK              7UL
 
 #define STM_TIM234_DIER_TDE            14
 #define STM_TIM234_DIER_CC4DE          12
@@ -1919,7 +1919,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_OC2M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR1_OC2M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR1_OC2M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR1_OC2M_MASK                    7
+#define  STM_TIM234_CCMR1_OC2M_MASK                    7UL
 #define STM_TIM234_CCMR1_OC2PE 11
 #define STM_TIM234_CCMR1_OC2FE 10
 #define STM_TIM234_CCMR1_CC2S  8
@@ -1927,7 +1927,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_CC2S_INPUT_TI2               1
 #define  STM_TIM234_CCMR1_CC2S_INPUT_TI1               2
 #define  STM_TIM234_CCMR1_CC2S_INPUT_TRC               3
-#define  STM_TIM234_CCMR1_CC2S_MASK                    3
+#define  STM_TIM234_CCMR1_CC2S_MASK                    3UL
 
 #define STM_TIM234_CCMR1_OC1CE 7
 #define STM_TIM234_CCMR1_OC1M  4
@@ -1939,7 +1939,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_OC1M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR1_OC1M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR1_OC1M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR1_OC1M_MASK                    7
+#define  STM_TIM234_CCMR1_OC1M_MASK                    7UL
 #define STM_TIM234_CCMR1_OC1PE 3
 #define STM_TIM234_CCMR1_OC1FE 2
 #define STM_TIM234_CCMR1_CC1S  0
@@ -1947,7 +1947,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR1_CC1S_INPUT_TI1               1
 #define  STM_TIM234_CCMR1_CC1S_INPUT_TI2               2
 #define  STM_TIM234_CCMR1_CC1S_INPUT_TRC               3
-#define  STM_TIM234_CCMR1_CC1S_MASK                    3
+#define  STM_TIM234_CCMR1_CC1S_MASK                    3UL
 
 #define STM_TIM234_CCMR1_IC2F  12
 #define  STM_TIM234_CCMR1_IC2F_NONE                    0
@@ -2004,7 +2004,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_OC4M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR2_OC4M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR2_OC4M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR2_OC4M_MASK                    7
+#define  STM_TIM234_CCMR2_OC4M_MASK                    7UL
 #define STM_TIM234_CCMR2_OC4PE 11
 #define STM_TIM234_CCMR2_OC4FE 10
 #define STM_TIM234_CCMR2_CC4S  8
@@ -2012,7 +2012,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_CC4S_INPUT_TI4               1
 #define  STM_TIM234_CCMR2_CC4S_INPUT_TI3               2
 #define  STM_TIM234_CCMR2_CC4S_INPUT_TRC               3
-#define  STM_TIM234_CCMR2_CC4S_MASK                    3
+#define  STM_TIM234_CCMR2_CC4S_MASK                    3UL
 
 #define STM_TIM234_CCMR2_OC3CE 7
 #define STM_TIM234_CCMR2_OC3M  4
@@ -2024,7 +2024,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_OC3M_FORCE_HIGH              5
 #define  STM_TIM234_CCMR2_OC3M_PWM_MODE_1              6
 #define  STM_TIM234_CCMR2_OC3M_PWM_MODE_2              7
-#define  STM_TIM234_CCMR2_OC3M_MASK                    7
+#define  STM_TIM234_CCMR2_OC3M_MASK                    7UL
 #define STM_TIM234_CCMR2_OC3PE 3
 #define STM_TIM234_CCMR2_OC3FE 2
 #define STM_TIM234_CCMR2_CC3S  0
@@ -2032,7 +2032,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
 #define  STM_TIM234_CCMR2_CC3S_INPUT_TI3               1
 #define  STM_TIM234_CCMR2_CC3S_INPUT_TI4               2
 #define  STM_TIM234_CCMR2_CC3S_INPUT_TRC               3
-#define  STM_TIM234_CCMR2_CC3S_MASK                    3
+#define  STM_TIM234_CCMR2_CC3S_MASK                    3UL
 
 #define STM_TIM234_CCER_CC4NP  15
 #define STM_TIM234_CCER_CC4P   13
index fbf4ad2e88527e2d5e8d88c0d47924e52ff81d95..51860ced435d91c083819e356f15e1e6b74741d1 100644 (file)
@@ -89,7 +89,7 @@ ao_adc_init(void)
 
        /* Reset ADC */
        stm_rcc.apb2rstr |= (1 << STM_RCC_APB2RSTR_ADCRST);
-       stm_rcc.apb2rstr &= ~(1 << STM_RCC_APB2RSTR_ADCRST);
+       stm_rcc.apb2rstr &= ~(1UL << STM_RCC_APB2RSTR_ADCRST);
 
        /* Turn on ADC pins */
        stm_rcc.ahbenr |= AO_ADC_RCC_AHBENR;
@@ -160,11 +160,11 @@ ao_adc_init(void)
        stm_adc.smpr = STM_ADC_SMPR_SMP_1_5 << STM_ADC_SMPR_SMP;
 
        /* Turn off enable and start */
-       stm_adc.cr &= ~((1 << STM_ADC_CR_ADEN) | (1 << STM_ADC_CR_ADSTART));
+       stm_adc.cr &= ~((1UL << STM_ADC_CR_ADEN) | (1 << STM_ADC_CR_ADSTART));
 
        /* Calibrate */
-       stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
-       while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+       stm_adc.cr |= (1UL << STM_ADC_CR_ADCAL);
+       while ((stm_adc.cr & (1UL << STM_ADC_CR_ADCAL)) != 0)
                ;
 
        /* Enable */
@@ -197,7 +197,7 @@ ao_adc_init(void)
        stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN);
 
        /* Set ADC to use DMA channel 1 (option 1) */
-       stm_syscfg.cfgr1 &= ~(1 << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
+       stm_syscfg.cfgr1 &= ~(1UL << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
 
        ao_dma_alloc(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1));
 }
index d48726a1c66ad13761ce8b32ff8f1fadbb87f7a0..e5471b12fd3e01e8cfe1fed6d6ab6005b727bbbe 100644 (file)
@@ -178,7 +178,7 @@ ao_adc_init(void)
 
        /* Reset ADC */
        stm_rcc.apb2rstr |= (1 << STM_RCC_APB2RSTR_ADCRST);
-       stm_rcc.apb2rstr &= ~(1 << STM_RCC_APB2RSTR_ADCRST);
+       stm_rcc.apb2rstr &= ~(1UL << STM_RCC_APB2RSTR_ADCRST);
 
        /* Turn on ADC pins */
        stm_rcc.ahbenr |= AO_ADC_RCC_AHBENR;
@@ -251,8 +251,8 @@ ao_adc_init(void)
 #endif
 
        /* Wait for ADC to be idle */
-       while (stm_adc.cr & ((1 << STM_ADC_CR_ADCAL) |
-                            (1 << STM_ADC_CR_ADDIS)))
+       while (stm_adc.cr & ((1UL << STM_ADC_CR_ADCAL) |
+                            (1UL << STM_ADC_CR_ADDIS)))
                ;
 
        /* Disable */
@@ -263,10 +263,10 @@ ao_adc_init(void)
        }
 
        /* Turn off everything */
-       stm_adc.cr &= ~((1 << STM_ADC_CR_ADCAL) |
-                       (1 << STM_ADC_CR_ADSTP) |
-                       (1 << STM_ADC_CR_ADSTART) |
-                       (1 << STM_ADC_CR_ADEN));
+       stm_adc.cr &= ~((1UL << STM_ADC_CR_ADCAL) |
+                       (1UL << STM_ADC_CR_ADSTP) |
+                       (1UL << STM_ADC_CR_ADSTART) |
+                       (1UL << STM_ADC_CR_ADEN));
 
        /* Configure */
        stm_adc.cfgr1 = ((0 << STM_ADC_CFGR1_AWDCH) |                             /* analog watchdog channel 0 */
@@ -297,8 +297,8 @@ ao_adc_init(void)
                       (0 << STM_ADC_CCR_VREFEN));
 
        /* Calibrate */
-       stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
-       while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+       stm_adc.cr |= (1UL << STM_ADC_CR_ADCAL);
+       while ((stm_adc.cr & (1UL << STM_ADC_CR_ADCAL)) != 0)
                ;
 
        /* Enable */
@@ -313,7 +313,7 @@ ao_adc_init(void)
        stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN);
 
        /* Set ADC to use DMA channel 1 (option 1) */
-       stm_syscfg.cfgr1 &= ~(1 << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
+       stm_syscfg.cfgr1 &= ~(1UL << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
 
        ao_dma_alloc(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1));
 
index d46899d575c409f149fd7e50767debb0422f24d1..8a173b57e5be79e928bebb5acf6ffb0bc1fa3d72 100644 (file)
@@ -151,7 +151,7 @@ ao_spi_recv_byte(uint8_t spi_index)
        stm_spi->dr = 0xff;
        while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
                ;
-       return stm_spi->dr;
+       return (uint8_t) stm_spi->dr;
 }
 
 void
@@ -215,16 +215,16 @@ static inline void ao_enable_port(struct stm_gpio *port)
 static inline void ao_disable_port(struct stm_gpio *port)
 {
        if ((port) == &stm_gpioa) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPAEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPAEN);
                ao_power_unregister(&ao_power_gpioa);
        } else if ((port) == &stm_gpiob) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPBEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPBEN);
                ao_power_unregister(&ao_power_gpiob);
        } else if ((port) == &stm_gpioc) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPCEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPCEN);
                ao_power_unregister(&ao_power_gpioc);
        } else if ((port) == &stm_gpiof) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPFEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPFEN);
                ao_power_unregister(&ao_power_gpiof);
        }
 }
index 39022da16d4fd36e48300c0573ee8894af7b04ec..751e611aae3a45e5150cce85af5dc387ada5ebbf 100644 (file)
@@ -58,7 +58,7 @@ disable(void)
 #if BEEPER_TIMER == 1
        timer.bdtr = 0;
 #endif
-       stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
+       stm_rcc_enr &= ~(1UL << STM_RCC_TIMER);
 
        /* Disconnect the timer from the pin */
        stm_afr_set(BEEPER_PORT, BEEPER_PIN, STM_AFR_NONE);
@@ -389,5 +389,5 @@ ao_beep_init(void)
        ao_enable_output(BEEPER_PORT, BEEPER_PIN, 0);
 
        /* Leave the timer off until requested */
-       stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
+       stm_rcc_enr &= ~(1UL << STM_RCC_TIMER);
 }
index f21ce1b251ff5931d5609ebb1926b6d2d68966ed..b289b80439f9c10399d42715ca0026b6280face5 100644 (file)
@@ -41,6 +41,6 @@ ao_boot_check_pin(void)
        /* Reset the chip to turn off the port and the power interface clock */
        ao_gpio_set_mode(&AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0);
        ao_disable_port(&AO_BOOT_APPLICATION_GPIO);
-       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN);
+       stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_PWREN);
        return v == AO_BOOT_APPLICATION_VALUE;
 }
index b6d91023bde46e4fa8ba37df4a1647f850973d47..59e7e7a6d427b74550e52bb874cb7773aba68d31 100644 (file)
@@ -36,7 +36,7 @@ static inline uint16_t
 ao_crc_in_32_out_16(uint32_t v) {
        stm_crc.dr.u32 = v;
        v = stm_crc.dr.u32;
-       return v ^ (v >> 16);
+       return (uint16_t) (v ^ (v >> 16));
 }
 
 static inline uint16_t
index f3fa13b4f5c11557d8c817565529db9cc7024188..ef551786d62b8d9073a517065a30a81370099f80 100644 (file)
@@ -111,10 +111,10 @@ ao_dma_start(uint8_t index)
 void
 ao_dma_done_transfer(uint8_t index)
 {
-       stm_dma.channel[index].ccr &= ~(1 << STM_DMA_CCR_EN);
+       stm_dma.channel[index].ccr &= ~(1UL << STM_DMA_CCR_EN);
        ao_arch_critical(
                if (--ao_dma_active == 0)
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_DMAEN);
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_DMAEN);
                );
        if (ao_dma_allocated[index])
                ao_dma_mutex[index] = 0;
@@ -125,7 +125,7 @@ ao_dma_done_transfer(uint8_t index)
 void
 ao_dma_abort(uint8_t index)
 {
-       stm_dma.channel[index].ccr &= ~(1 << STM_DMA_CCR_EN);
+       stm_dma.channel[index].ccr &= ~(1UL << STM_DMA_CCR_EN);
        ao_wakeup(&ao_dma_done[index]);
 }
 
index 77c59d05ff2cebb72e0b3c503adb6a98ffc237a3..bba2064d76877725a3c080a05287c3d477811914 100644 (file)
@@ -24,7 +24,7 @@ static void   (*ao_exti_callback[16])(void);
 uint32_t       ao_last_exti;
 
 static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
-       uint16_t        pending = (ao_last_exti = stm_exti.pr) & mask;
+       uint16_t        pending = (uint16_t) ((ao_last_exti = stm_exti.pr) & mask);
        uint8_t         pin;
        static uint16_t last_mask;
        static uint8_t  last_pin;
index 896d536ba0c1612e7fe341b4a4da0d399aa445ba..a33099ab2a7ae9bd3e70638ca045a9d945e0f07c 100644 (file)
@@ -63,7 +63,7 @@ _ao_flash_erase_page(uint32_t *page)
 
        ao_flash_wait_bsy();
 
-       stm_flash.cr &= ~(1 << STM_FLASH_CR_PER);
+       stm_flash.cr &= ~(1UL << STM_FLASH_CR_PER);
 }
 
 static uint32_t
@@ -115,7 +115,7 @@ _ao_flash_page(uint16_t *dst, uint16_t *src)
                ao_flash_wait_bsy();
        }
 
-       stm_flash.cr &= ~(1 << STM_FLASH_CR_PG);
+       stm_flash.cr &= ~(1UL << STM_FLASH_CR_PG);
 }
 
 void
index 024ff948645525e8e3eb06b774542ff975070db9..a21ce4fa3d0e0c755cc3eef7b41ffe5305b668d7 100644 (file)
@@ -23,13 +23,13 @@ ao_gpio_suspend(void *arg)
 {
        struct stm_gpio *port = arg;
        if (port == &stm_gpioa)
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPAEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPAEN);
        else if ((port) == &stm_gpiob)
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPBEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPBEN);
        else if ((port) == &stm_gpioc)
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPCEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPCEN);
        else if ((port) == &stm_gpiof)
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPFEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPFEN);
 }
 
 static void
index 63593aff039c6153da468cc4bc154451621fc581..9448a15ab6873f4bea0383d3dd6ded1de2a6fd1f 100644 (file)
@@ -52,7 +52,7 @@ void
 ao_led_set(AO_LED_TYPE colors)
 {
        AO_LED_TYPE     on = colors & LEDS_AVAILABLE;
-       AO_LED_TYPE     off = ~colors & LEDS_AVAILABLE;
+       AO_LED_TYPE     off = (AO_LED_TYPE) (~colors & LEDS_AVAILABLE);
 
        ao_led_off(off);
        ao_led_on(on);
@@ -78,7 +78,7 @@ ao_led_init(void)
 
 #ifdef LED_PORT
        stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
-       LED_PORT->odr &= ~LEDS_AVAILABLE;
+       LED_PORT->odr &= (uint32_t) ~LEDS_AVAILABLE;
 #else
 #ifdef LED_PORT_0
        stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
index ef35394aab53dec6bbf9f64d816d11ab2c5b5186..21ea8614b0f8fe180f3847f68a97eb6741d830b1 100644 (file)
@@ -75,7 +75,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
                        }
 #endif
                } else {
-                       usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+                       usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
                }
        }
 }
@@ -86,11 +86,11 @@ ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
        _ao_usart_rx(usart, is_stdin);
 
        if (!_ao_usart_tx_start(usart))
-               usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
 
        if (usart->reg->isr & (1 << STM_USART_ISR_TC)) {
                usart->tx_running = 0;
-               usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
                if (usart->draining) {
                        usart->draining = 0;
                        ao_wakeup(&usart->tx_fifo);
@@ -136,7 +136,7 @@ ao_usart_getchar(struct ao_stm_usart *usart)
 }
 
 static inline uint8_t
-_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout)
+_ao_usart_sleep_for(struct ao_stm_usart *usart, AO_TICK_TYPE timeout)
 {
        return ao_sleep_for(&usart->rx_fifo, timeout);
 }
@@ -281,7 +281,7 @@ _ao_serial1_pollchar(void)
 }
 
 uint8_t
-_ao_serial1_sleep_for(uint16_t timeout)
+_ao_serial1_sleep_for(AO_TICK_TYPE timeout)
 {
        return _ao_usart_sleep_for(&ao_stm_usart1, timeout);
 }
@@ -325,7 +325,7 @@ _ao_serial2_pollchar(void)
 }
 
 uint8_t
-_ao_serial2_sleep_for(uint16_t timeout)
+_ao_serial2_sleep_for(AO_TICK_TYPE timeout)
 {
        return _ao_usart_sleep_for(&ao_stm_usart2, timeout);
 }
@@ -379,10 +379,10 @@ void
 ao_serial_shutdown(void)
 {
 #if HAS_SERIAL_1
-       stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_USART1EN);
+       stm_rcc.apb2enr &= ~(1UL << STM_RCC_APB2ENR_USART1EN);
 #endif
 #if HAS_SERIAL_2
-       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USART2EN);
+       stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_USART2EN);
 #endif
 }
 
index 5b180074c07d8ddf7b850bf7e527a25a5e62ed31..b7047e10b9e89ce240b52aabb0723d52dd7a7505 100644 (file)
@@ -183,7 +183,7 @@ ao_clock_normal_start(void)
 #if AO_HSE_BYPASS
        stm_rcc.cr |= (1 << STM_RCC_CR_HSEBYP);
 #else
-       stm_rcc.cr &= ~(1 << STM_RCC_CR_HSEBYP);
+       stm_rcc.cr &= ~(1UL << STM_RCC_CR_HSEBYP);
 #endif
        /* Enable HSE clock */
        stm_rcc.cr |= (1 << STM_RCC_CR_HSEON);
@@ -191,8 +191,8 @@ ao_clock_normal_start(void)
                asm("nop");
 
        /* Disable the PLL */
-       stm_rcc.cr &= ~(1 << STM_RCC_CR_PLLON);
-       while (stm_rcc.cr & (1 << STM_RCC_CR_PLLRDY))
+       stm_rcc.cr &= ~(1UL << STM_RCC_CR_PLLON);
+       while (stm_rcc.cr & (1UL << STM_RCC_CR_PLLRDY))
                asm("nop");
 
        /* Set multiplier */
@@ -201,7 +201,7 @@ ao_clock_normal_start(void)
        cfgr |= (AO_RCC_CFGR_PLLMUL << STM_RCC_CFGR_PLLMUL);
 
        /* PLL source */
-       cfgr &= ~(1 << STM_RCC_CFGR_PLLSRC);
+       cfgr &= ~(1UL << STM_RCC_CFGR_PLLSRC);
        cfgr |= (STM_RCC_CFGR_PLLSRC_TARGET_CLOCK  << STM_RCC_CFGR_PLLSRC);
        stm_rcc.cfgr = cfgr;
 
@@ -261,7 +261,7 @@ ao_clock_normal_switch(void)
        }
 #if !AO_HSI && !AO_NEED_HSI
        /* Turn off the HSI clock */
-       stm_rcc.cr &= ~(1 << STM_RCC_CR_HSION);
+       stm_rcc.cr &= ~(1UL << STM_RCC_CR_HSION);
 #endif
 #ifdef STM_PLLSRC
        /* USB PLL source */
index b736d389c95002e0eae33bcf40028b8d557909b5..0525d11fa287893ba00f2f814bbb958ef5f6b1a1 100644 (file)
@@ -317,9 +317,9 @@ _ao_usb_set_stat_tx(int ep, uint32_t stat_tx)
        epr_old = epr_write = stm_usb.epr[ep].r;
        epr_write &= STM_USB_EPR_PRESERVE_MASK;
        epr_write |= STM_USB_EPR_INVARIANT;
-       epr_write |= set_toggle(epr_old,
-                               STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX,
-                               stat_tx << STM_USB_EPR_STAT_TX);
+       epr_write |= (uint16_t) set_toggle(epr_old,
+                                          STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX,
+                                          stat_tx << STM_USB_EPR_STAT_TX);
        stm_usb.epr[ep].r = epr_write;
        _tx_dbg1("set_stat_tx bottom", epr_write);
 }
@@ -341,8 +341,8 @@ _ao_usb_toggle_dtog(int ep, uint32_t dtog_rx, uint32_t dtog_tx)
        epr_write = stm_usb.epr[ep].r;
        epr_write &= STM_USB_EPR_PRESERVE_MASK;
        epr_write |= STM_USB_EPR_INVARIANT;
-       epr_write |= ((dtog_rx << STM_USB_EPR_DTOG_RX) |
-                     (dtog_tx << STM_USB_EPR_DTOG_TX));
+       epr_write |= (uint16_t) ((dtog_rx << STM_USB_EPR_DTOG_RX) |
+                                (dtog_tx << STM_USB_EPR_DTOG_TX));
        stm_usb.epr[ep].r = epr_write;
        _tx_dbg1("toggle_dtog bottom", epr_write);
 }
@@ -354,9 +354,9 @@ _ao_usb_set_stat_rx(int ep, uint32_t stat_rx) {
        epr_write = epr_old = stm_usb.epr[ep].r;
        epr_write &= STM_USB_EPR_PRESERVE_MASK;
        epr_write |= STM_USB_EPR_INVARIANT;
-       epr_write |= set_toggle(epr_old,
-                             STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX,
-                             stat_rx << STM_USB_EPR_STAT_RX);
+       epr_write |= (uint16_t) set_toggle(epr_old,
+                                          STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX,
+                                          stat_rx << STM_USB_EPR_STAT_RX);
        stm_usb.epr[ep].r = epr_write;
 }
 
@@ -381,22 +381,22 @@ ao_usb_init_ep(uint8_t ep, uint16_t addr, uint16_t type,
 
        ao_arch_block_interrupts();
        epr = stm_usb.epr[ep].r;
-       epr = ((0 << STM_USB_EPR_CTR_RX) |
-              (type << STM_USB_EPR_EP_TYPE) |
-              (kind << STM_USB_EPR_EP_KIND) |
-              (0 << STM_USB_EPR_CTR_TX) |
-              (addr << STM_USB_EPR_EA) |
-              set_toggle(epr,
-
-                         (1 << STM_USB_EPR_DTOG_RX) |
-                         (STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX) |
-                         (1 << STM_USB_EPR_DTOG_TX) |
-                         (STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX),
-
-                         (dtog_rx << STM_USB_EPR_DTOG_RX) |
-                         (stat_rx << STM_USB_EPR_STAT_RX) |
-                         (dtog_tx << STM_USB_EPR_DTOG_TX) |
-                         (stat_tx << STM_USB_EPR_STAT_TX)));
+       epr = (uint16_t) ((0UL << STM_USB_EPR_CTR_RX) |
+                         ((uint32_t) type << STM_USB_EPR_EP_TYPE) |
+                         ((uint32_t) kind << STM_USB_EPR_EP_KIND) |
+                         (0UL << STM_USB_EPR_CTR_TX) |
+                         ((uint32_t) addr << STM_USB_EPR_EA) |
+                         set_toggle(epr,
+
+                                    (1UL << STM_USB_EPR_DTOG_RX) |
+                                    (STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX) |
+                                    (1UL << STM_USB_EPR_DTOG_TX) |
+                                    (STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX),
+
+                                    ((uint32_t) dtog_rx << STM_USB_EPR_DTOG_RX) |
+                                    ((uint32_t) stat_rx << STM_USB_EPR_STAT_RX) |
+                                    ((uint32_t) dtog_tx << STM_USB_EPR_DTOG_TX) |
+                                    ((uint32_t) stat_tx << STM_USB_EPR_STAT_TX)));
        stm_usb.epr[ep].r = epr;
        ao_arch_release_interrupts();
        debug ("writing epr[%d] 0x%04x wrote 0x%04x\n",
@@ -418,30 +418,30 @@ ao_usb_alloc_buffers(void)
        sram_addr += AO_USB_CONTROL_SIZE;
 
 #if AO_USB_HAS_INT
-       sram_addr += (sram_addr & 1);
+       sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
        ao_usb_int_tx_offset = sram_addr;
        sram_addr += AO_USB_INT_SIZE;
 #endif
 
 #if AO_USB_HAS_OUT
-       sram_addr += (sram_addr & 1);
+       sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
        ao_usb_out_rx_offset = sram_addr;
        sram_addr += AO_USB_OUT_SIZE * 2;
 #endif
 
 #if AO_USB_HAS_IN
-       sram_addr += (sram_addr & 1);
+       sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
        ao_usb_in_tx_offset = sram_addr;
        sram_addr += AO_USB_IN_SIZE * 2;
 #endif
 
 #if AO_USB_HAS_IN2
-       sram_addr += (sram_addr & 1);
+       sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
        ao_usb_in_tx2_offset = sram_addr;
        sram_addr += AO_USB_IN_SIZE * 2;
 #endif
 #if AO_USB_HAS_IN3
-       sram_addr += (sram_addr & 1);
+       sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
        ao_usb_in_tx3_offset = sram_addr;
        sram_addr += AO_USB_IN_SIZE * 2;
 #endif
@@ -463,7 +463,7 @@ ao_usb_init_btable(void)
 static void
 ao_usb_set_ep0(void)
 {
-       int                     e;
+       uint8_t e;
 
        ao_usb_init_btable();
 
@@ -641,7 +641,7 @@ ao_usb_tx_byte(uint16_t offset, uint8_t byte)
 {
        if (offset & 1)
                ao_usb_packet_put(offset - 1,
-                                 ao_usb_packet_get(offset - 1) | ((uint16_t) byte) << 8);
+                                 (uint16_t) (ao_usb_packet_get(offset - 1) | ((uint16_t) byte) << 8));
        else
                ao_usb_packet_put(offset, (uint16_t) byte);
 }
@@ -709,7 +709,7 @@ ao_usb_ep0_fill(void)
 
        if (len > ao_usb_ep0_out_len)
                len = ao_usb_ep0_out_len;
-       ao_usb_ep0_out_len -= len;
+       ao_usb_ep0_out_len -= (uint8_t) len;
 
        /* Pull all of the data out of the packet */
        debug_data ("Fill EP0 len %d:", len);
@@ -754,7 +754,7 @@ ao_usb_ep0_in_start(uint16_t max)
 {
        /* Don't send more than asked for */
        if (ao_usb_ep0_in_len > max)
-               ao_usb_ep0_in_len = max;
+               ao_usb_ep0_in_len = (uint8_t) max;
        ao_usb_ep0_flush();
 }
 
@@ -771,7 +771,7 @@ hex_to_ucs2(uint32_t in, uint8_t *out)
 
        for (i = 28; i >= 0; i -= 4) {
                uint8_t bits = (in >> i) & 0xf;
-               *out++ = ((bits < 10) ? '0' : ('a' - 10)) + bits;
+               *out++ = (uint8_t) (((bits < 10) ? '0' : ('a' - 10)) + bits);
                *out++ = 0;
        }
 }
@@ -796,8 +796,8 @@ static void
 ao_usb_get_descriptor(uint16_t value, uint16_t length)
 {
        const uint8_t           *descriptor;
-       uint8_t         type = value >> 8;
-       uint8_t         index = value;
+       uint8_t         type = (uint8_t) (value >> 8);
+       uint8_t         index = (uint8_t) value;
 
        descriptor = ao_usb_descriptors;
        while (descriptor[0] != 0) {
@@ -815,7 +815,7 @@ ao_usb_get_descriptor(uint16_t value, uint16_t length)
                        }
 #endif
                        if (len > length)
-                               len = length;
+                               len = (uint8_t) length;
                        ao_usb_ep0_in_set(descriptor, len);
                        break;
                }
@@ -855,7 +855,7 @@ ao_usb_ep0_setup(void)
                                break;
                        case AO_USB_REQ_SET_ADDRESS:
                                debug ("set address %d\n", ao_usb_setup.value);
-                               ao_usb_address = ao_usb_setup.value;
+                               ao_usb_address = (uint8_t) ao_usb_setup.value;
                                ao_usb_address_pending = 1;
                                break;
                        case AO_USB_REQ_GET_DESCRIPTOR:
@@ -867,7 +867,7 @@ ao_usb_ep0_setup(void)
                                ao_usb_ep0_in_queue_byte(ao_usb_configuration);
                                break;
                        case AO_USB_REQ_SET_CONFIGURATION:
-                               ao_usb_configuration = ao_usb_setup.value;
+                               ao_usb_configuration = (uint8_t) ao_usb_setup.value;
                                debug ("set configuration %d\n", ao_usb_configuration);
                                ao_usb_set_configuration();
                                break;
@@ -970,7 +970,7 @@ static void
 ao_usb_wakeup(void)
 {
        ao_clock_resume();
-       stm_usb.cntr &= ~(1 << STM_USB_CNTR_FSUSP);
+       stm_usb.cntr &= (uint16_t) ~(1 << STM_USB_CNTR_FSUSP);
        ao_power_resume();
 }
 #endif
@@ -980,7 +980,7 @@ stm_usb_isr(void)
 {
        uint32_t        istr = stm_usb.istr;
 
-       stm_usb.istr = ~istr;
+       stm_usb.istr = (uint16_t) ~istr;
        if (istr & (1 << STM_USB_ISTR_CTR)) {
                uint8_t         ep = istr & STM_USB_ISTR_EP_ID_MASK;
                uint16_t        epr, epr_write;
@@ -992,8 +992,8 @@ stm_usb_isr(void)
                epr_write = epr;
                epr_write &= STM_USB_EPR_PRESERVE_MASK;
                epr_write |= STM_USB_EPR_INVARIANT;
-               epr_write &= ~(1 << STM_USB_EPR_CTR_RX);
-               epr_write &= ~(1 << STM_USB_EPR_CTR_TX);
+               epr_write &= (uint16_t) ~(1 << STM_USB_EPR_CTR_RX);
+               epr_write &= (uint16_t) ~(1 << STM_USB_EPR_CTR_TX);
                stm_usb.epr[ep].r = epr_write;
 
                switch (ep) {
@@ -1159,7 +1159,7 @@ ao_usb_putchar(char c)
        _ao_usb_in_wait();
 
        ao_usb_in_flushed = 0;
-       ao_usb_tx_byte(ao_usb_in_tx_offset + AO_USB_IN_SIZE * ao_usb_in_tx_which + ao_usb_tx_count++, c);
+       ao_usb_tx_byte((uint16_t) (ao_usb_in_tx_offset + AO_USB_IN_SIZE * ao_usb_in_tx_which + ao_usb_tx_count++), c);
 
        /* Send the packet when full */
        if (ao_usb_tx_count == AO_USB_IN_SIZE) {
@@ -1247,7 +1247,7 @@ ao_usb_putchar2(char c)
        _ao_usb_in2_wait();
 
        ao_usb_in2_flushed = 0;
-       ao_usb_tx_byte(ao_usb_in_tx2_offset + AO_USB_IN_SIZE * ao_usb_in_tx2_which + ao_usb_tx2_count++, c);
+       ao_usb_tx_byte((uint16_t) (ao_usb_in_tx2_offset + AO_USB_IN_SIZE * ao_usb_in_tx2_which + ao_usb_tx2_count++), c);
 
        /* Send the packet when full */
        if (ao_usb_tx2_count == AO_USB_IN_SIZE) {
@@ -1335,7 +1335,7 @@ ao_usb_putchar3(char c)
        _ao_usb_in3_wait();
 
        ao_usb_in3_flushed = 0;
-       ao_usb_tx_byte(ao_usb_in_tx3_offset + AO_USB_IN_SIZE * ao_usb_in_tx3_which + ao_usb_tx3_count++, c);
+       ao_usb_tx_byte((uint16_t) (ao_usb_in_tx3_offset + AO_USB_IN_SIZE * ao_usb_in_tx3_which + ao_usb_tx3_count++), c);
 
        /* Send the packet when full */
        if (ao_usb_tx3_count == AO_USB_IN_SIZE) {
@@ -1359,7 +1359,7 @@ _ao_usb_out_recv(void)
        /* Switch to new buffer */
        ao_usb_out_rx_which = 1 - ao_usb_out_rx_which;
 
-       ao_usb_rx_count = stm_usb_bdt[AO_USB_OUT_EPR].double_rx[ao_usb_out_rx_which].count & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK;
+       ao_usb_rx_count = (uint8_t) (stm_usb_bdt[AO_USB_OUT_EPR].double_rx[ao_usb_out_rx_which].count & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK);
        ao_usb_rx_pos = 0;
 
        /* Toggle the SW_BUF_RX bit */
@@ -1393,7 +1393,7 @@ _ao_usb_pollchar(void)
        }
 
        /* Pull a character out of the fifo */
-       c = ao_usb_rx_byte(ao_usb_out_rx_offset + ao_usb_out_rx_which * AO_USB_OUT_SIZE + ao_usb_rx_pos++);
+       c = ao_usb_rx_byte((uint16_t) (ao_usb_out_rx_offset + ao_usb_out_rx_which * AO_USB_OUT_SIZE + ao_usb_rx_pos++));
        _rx_dbg1("char", c);
        return c;
 }
@@ -1407,7 +1407,7 @@ ao_usb_getchar(void)
        while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
                ao_sleep(AO_USB_OUT_SLEEP_ADDR);
        ao_arch_release_interrupts();
-       return c;
+       return (char) c;
 }
 #endif
 
@@ -1521,13 +1521,13 @@ ao_usb_disable(void)
        stm_usb.istr = 0;
 
        /* Disable USB pull-up */
-       stm_usb.bcdr &= ~(1 << STM_USB_BCDR_DPPU);
+       stm_usb.bcdr &= (uint16_t) ~(1 << STM_USB_BCDR_DPPU);
 
        /* Switch off the device */
        stm_usb.cntr = (1 << STM_USB_CNTR_PDWN) | (1 << STM_USB_CNTR_FRES);
 
        /* Disable the interface */
-       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USBEN);
+       stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_USBEN);
        ao_arch_release_interrupts();
 }
 
@@ -1537,16 +1537,16 @@ ao_usb_enable(void)
        int     t;
 
        /* Select HSI48 as USB clock source */
-       stm_rcc.cfgr3 &= ~(1 << STM_RCC_CFGR3_USBSW);
+       stm_rcc.cfgr3 &= ~(1UL << STM_RCC_CFGR3_USBSW);
 
        /* Enable USB device */
        stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USBEN);
 
        /* Clear reset condition */
-       stm_rcc.apb1rstr &= ~(1 << STM_RCC_APB1RSTR_USBRST);
+       stm_rcc.apb1rstr &= ~(1UL << STM_RCC_APB1RSTR_USBRST);
 
        /* Disable USB pull-up */
-       stm_usb.bcdr &= ~(1 << STM_USB_BCDR_DPPU);
+       stm_usb.bcdr &= (uint16_t) ~(1 << STM_USB_BCDR_DPPU);
 
        /* Do not touch the GPIOA configuration; USB takes priority
         * over GPIO on pins A11 and A12, but if you select alternate
index 075fd6a90abae403ab4501aa7fa674fea374fe52..1735900c771a8ecaf29b6e88f23fd6bb8cdb40d0 100644 (file)
@@ -43,7 +43,7 @@ struct stm_gpio {
 };
 
 #define STM_MODER_SHIFT(pin)           ((pin) << 1)
-#define STM_MODER_MASK                 3
+#define STM_MODER_MASK                 3UL
 #define STM_MODER_INPUT                        0
 #define STM_MODER_OUTPUT               1
 #define STM_MODER_ALTERNATE            2
@@ -62,7 +62,7 @@ stm_moder_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_OTYPER_SHIFT(pin)          (pin)
-#define STM_OTYPER_MASK                        1
+#define STM_OTYPER_MASK                        1UL
 #define STM_OTYPER_PUSH_PULL           0
 #define STM_OTYPER_OPEN_DRAIN          1
 
@@ -79,7 +79,7 @@ stm_otyper_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_OSPEEDR_SHIFT(pin)         ((pin) << 1)
-#define STM_OSPEEDR_MASK               3
+#define STM_OSPEEDR_MASK               3UL
 #define STM_OSPEEDR_LOW                        0       /* 2MHz */
 #define STM_OSPEEDR_MEDIUM             1       /* 10MHz */
 #define STM_OSPEEDR_HIGH               3       /* 10-50MHz */
@@ -97,7 +97,7 @@ stm_ospeedr_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_PUPDR_SHIFT(pin)           ((pin) << 1)
-#define STM_PUPDR_MASK                 3
+#define STM_PUPDR_MASK                 3UL
 #define STM_PUPDR_NONE                 0
 #define STM_PUPDR_PULL_UP              1
 #define STM_PUPDR_PULL_DOWN            2
@@ -116,7 +116,7 @@ stm_pupdr_get(struct stm_gpio *gpio, int pin) {
 }
 
 #define STM_AFR_SHIFT(pin)             ((pin) << 2)
-#define STM_AFR_MASK                   0xf
+#define STM_AFR_MASK                   0xfUL
 #define STM_AFR_NONE                   0
 #define STM_AFR_AF0                    0x0
 #define STM_AFR_AF1                    0x1
@@ -168,7 +168,7 @@ stm_gpio_get(struct stm_gpio *gpio, int pin) {
 
 static inline uint16_t
 stm_gpio_get_all(struct stm_gpio *gpio) {
-       return gpio->idr;
+       return (uint16_t) gpio->idr;
 }
 
 /*
@@ -309,7 +309,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_MCOPRE_DIV_32    5
 #define  STM_RCC_CFGR_MCOPRE_DIV_64    6
 #define  STM_RCC_CFGR_MCOPRE_DIV_128   7
-#define  STM_RCC_CFGR_MCOPRE_DIV_MASK  7
+#define  STM_RCC_CFGR_MCOPRE_DIV_MASK  7UL
 
 #define STM_RCC_CFGR_MCO       (24)
 # define STM_RCC_CFGR_MCO_DISABLE      0
@@ -321,7 +321,7 @@ extern struct stm_rcc stm_rcc;
 # define STM_RCC_CFGR_MCO_HSE          6
 # define STM_RCC_CFGR_MCO_PLLCLK       7
 # define STM_RCC_CFGR_MCO_HSI48                8
-# define STM_RCC_CFGR_MCO_MASK         (0xf)
+# define STM_RCC_CFGR_MCO_MASK         (0xfUL)
 
 #define STM_RCC_CFGR_PLLMUL    (18)
 #define  STM_RCC_CFGR_PLLMUL_2         0
@@ -339,7 +339,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PLLMUL_14                12
 #define  STM_RCC_CFGR_PLLMUL_15                13
 #define  STM_RCC_CFGR_PLLMUL_16                14
-#define  STM_RCC_CFGR_PLLMUL_MASK      0xf
+#define  STM_RCC_CFGR_PLLMUL_MASK      0xfUL
 
 #define STM_RCC_CFGR_PLLXTPRE  (17)
 
@@ -357,7 +357,7 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_PPRE_DIV_4       5
 #define  STM_RCC_CFGR_PPRE_DIV_8       6
 #define  STM_RCC_CFGR_PPRE_DIV_16      7
-#define  STM_RCC_CFGR_PPRE_MASK                7
+#define  STM_RCC_CFGR_PPRE_MASK                7UL
 
 #define STM_RCC_CFGR_HPRE      (4)
 #define  STM_RCC_CFGR_HPRE_DIV_1       0
@@ -369,21 +369,21 @@ extern struct stm_rcc stm_rcc;
 #define  STM_RCC_CFGR_HPRE_DIV_128     0xd
 #define  STM_RCC_CFGR_HPRE_DIV_256     0xe
 #define  STM_RCC_CFGR_HPRE_DIV_512     0xf
-#define  STM_RCC_CFGR_HPRE_MASK                0xf
+#define  STM_RCC_CFGR_HPRE_MASK                0xfUL
 
 #define STM_RCC_CFGR_SWS       (2)
 #define  STM_RCC_CFGR_SWS_HSI          0
 #define  STM_RCC_CFGR_SWS_HSE          1
 #define  STM_RCC_CFGR_SWS_PLL          2
 #define  STM_RCC_CFGR_SWS_HSI48                3
-#define  STM_RCC_CFGR_SWS_MASK         3
+#define  STM_RCC_CFGR_SWS_MASK         3UL
 
 #define STM_RCC_CFGR_SW                (0)
 #define  STM_RCC_CFGR_SW_HSI           0
 #define  STM_RCC_CFGR_SW_HSE           1
 #define  STM_RCC_CFGR_SW_PLL           2
 #define  STM_RCC_CFGR_SW_HSI48         3
-#define  STM_RCC_CFGR_SW_MASK          3
+#define  STM_RCC_CFGR_SW_MASK          3UL
 
 #define STM_RCC_APB2RSTR_DBGMCURST     22
 #define STM_RCC_APB2RSTR_TIM17RST      18
@@ -707,7 +707,7 @@ stm_nvic_pending(int irq) {
 
 #define IRQ_PRIO_REG(irq)      ((irq) >> 2)
 #define IRQ_PRIO_BIT(irq)      (((irq) & 3) << 3)
-#define IRQ_PRIO_MASK(irq)     (0xff << IRQ_PRIO_BIT(irq))
+#define IRQ_PRIO_MASK(irq)     (0xffUL << IRQ_PRIO_BIT(irq))
 
 static inline void
 stm_nvic_set_priority(int irq, uint8_t prio) {
@@ -836,7 +836,7 @@ extern struct stm_syscfg stm_syscfg;
 #define  STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH  0
 #define  STM_SYSCFG_CFGR1_MEM_MODE_SYSTEM_FLASH        1
 #define  STM_SYSCFG_CFGR1_MEM_MODE_SRAM                3
-#define  STM_SYSCFG_CFGR1_MEM_MODE_MASK                3
+#define  STM_SYSCFG_CFGR1_MEM_MODE_MASK                3UL
 
 #define STM_SYSCFG_EXTICR_PA           0
 #define STM_SYSCFG_EXTICR_PB           1
@@ -847,8 +847,8 @@ extern struct stm_syscfg stm_syscfg;
 
 static inline void
 stm_exticr_set(struct stm_gpio *gpio, int pin) {
-       uint8_t reg = pin >> 2;
-       uint8_t shift = (pin & 3) << 2;
+       uint8_t reg = (uint8_t) pin >> 2;
+       uint8_t shift = ((uint8_t) pin & 3) << 2;
        uint8_t val = 0;
 
        /* Enable SYSCFG */
@@ -863,7 +863,7 @@ stm_exticr_set(struct stm_gpio *gpio, int pin) {
        else if (gpio == &stm_gpiof)
                val = STM_SYSCFG_EXTICR_PF;
 
-       stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+       stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xfUL << shift)) | val << shift;
 }
 
 struct stm_dma_channel {
@@ -890,14 +890,14 @@ extern struct stm_dma stm_dma;
 #define STM_DMA_INDEX(channel)         ((channel) - 1)
 
 #define STM_DMA_ISR(index)             ((index) << 2)
-#define STM_DMA_ISR_MASK                       0xf
+#define STM_DMA_ISR_MASK                       0xfUL
 #define STM_DMA_ISR_TEIF                       3
 #define STM_DMA_ISR_HTIF                       2
 #define STM_DMA_ISR_TCIF                       1
 #define STM_DMA_ISR_GIF                                0
 
 #define STM_DMA_IFCR(index)            ((index) << 2)
-#define STM_DMA_IFCR_MASK                      0xf
+#define STM_DMA_IFCR_MASK                      0xfUL
 #define STM_DMA_IFCR_CTEIF                     3
 #define STM_DMA_IFCR_CHTIF                     2
 #define STM_DMA_IFCR_CTCIF                     1
@@ -910,19 +910,19 @@ extern struct stm_dma stm_dma;
 #define  STM_DMA_CCR_PL_MEDIUM                 (1)
 #define  STM_DMA_CCR_PL_HIGH                   (2)
 #define  STM_DMA_CCR_PL_VERY_HIGH              (3)
-#define  STM_DMA_CCR_PL_MASK                   (3)
+#define  STM_DMA_CCR_PL_MASK                   (3UL)
 
 #define STM_DMA_CCR_MSIZE              (10)
 #define  STM_DMA_CCR_MSIZE_8                   (0)
 #define  STM_DMA_CCR_MSIZE_16                  (1)
 #define  STM_DMA_CCR_MSIZE_32                  (2)
-#define  STM_DMA_CCR_MSIZE_MASK                        (3)
+#define  STM_DMA_CCR_MSIZE_MASK                        (3UL)
 
 #define STM_DMA_CCR_PSIZE              (8)
 #define  STM_DMA_CCR_PSIZE_8                   (0)
 #define  STM_DMA_CCR_PSIZE_16                  (1)
 #define  STM_DMA_CCR_PSIZE_32                  (2)
-#define  STM_DMA_CCR_PSIZE_MASK                        (3)
+#define  STM_DMA_CCR_PSIZE_MASK                        (3UL)
 
 #define STM_DMA_CCR_MINC               (7)
 #define STM_DMA_CCR_PINC               (6)
@@ -1041,7 +1041,7 @@ extern struct stm_spi stm_spi1, stm_spi2, stm_spi3;
 #define  STM_SPI_CR1_BR_PCLK_64                        5
 #define  STM_SPI_CR1_BR_PCLK_128               6
 #define  STM_SPI_CR1_BR_PCLK_256               7
-#define  STM_SPI_CR1_BR_MASK                   7
+#define  STM_SPI_CR1_BR_MASK                   7UL
 
 #define STM_SPI_CR1_MSTR               2
 #define STM_SPI_CR1_CPOL               1
@@ -1146,7 +1146,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CFGR1_EXTEN_RISING    1
 #define  STM_ADC_CFGR1_EXTEN_FALLING   2
 #define  STM_ADC_CFGR1_EXTEN_BOTH      3
-#define  STM_ADC_CFGR1_EXTEN_MASK      3
+#define  STM_ADC_CFGR1_EXTEN_MASK      3UL
 
 #define STM_ADC_CFGR1_EXTSEL   6
 #define STM_ADC_CFGR1_ALIGN    5
@@ -1155,7 +1155,7 @@ extern struct stm_adc stm_adc;
 #define  STM_ADC_CFGR1_RES_10          1
 #define  STM_ADC_CFGR1_RES_8           2
 #define  STM_ADC_CFGR1_RES_6           3
-#define  STM_ADC_CFGR1_RES_MASK                3
+#define  STM_ADC_CFGR1_RES_MASK                3UL
 #define STM_ADC_CFGR1_SCANDIR  2
 #define  STM_ADC_CFGR1_SCANDIR_UP      0
 #define  STM_ADC_CFGR1_SCANDIR_DOWN    1
@@ -1271,7 +1271,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define  STM_I2C_CR2_FREQ_8_MHZ                8
 #define  STM_I2C_CR2_FREQ_16_MHZ       16
 #define  STM_I2C_CR2_FREQ_32_MHZ       32
-#define  STM_I2C_CR2_FREQ_MASK         0x3f
+#define  STM_I2C_CR2_FREQ_MASK         0x3fUL
 
 #define STM_I2C_SR1_SMBALERT   15
 #define STM_I2C_SR1_TIMEOUT    14
@@ -1289,7 +1289,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define STM_I2C_SR1_SB         0
 
 #define STM_I2C_SR2_PEC                8
-#define  STM_I2C_SR2_PEC_MASK  0xff00
+#define  STM_I2C_SR2_PEC_MASK  0xff00UL
 #define STM_I2C_SR2_DUALF      7
 #define STM_I2C_SR2_SMBHOST    6
 #define STM_I2C_SR2_SMBDEFAULT 5
@@ -1301,7 +1301,7 @@ extern struct stm_i2c stm_i2c1, stm_i2c2;
 #define STM_I2C_CCR_FS         15
 #define STM_I2C_CCR_DUTY       14
 #define STM_I2C_CCR_CCR                0
-#define  STM_I2C_CCR_MASK      0x7ff
+#define  STM_I2C_CCR_MASK      0x7ffUL
 
 struct stm_tim1 {
        vuint32_t       cr1;
@@ -1623,14 +1623,14 @@ extern struct stm_tim23 stm_tim2, stm_tim3;
 #define  STM_TIM23_CR1_CKD_1           0
 #define  STM_TIM23_CR1_CKD_2           1
 #define  STM_TIM23_CR1_CKD_4           2
-#define  STM_TIM23_CR1_CKD_MASK        3
+#define  STM_TIM23_CR1_CKD_MASK        3UL
 #define STM_TIM23_CR1_ARPE     7
 #define STM_TIM23_CR1_CMS      5
 #define  STM_TIM23_CR1_CMS_EDGE                0
 #define  STM_TIM23_CR1_CMS_CENTER_1    1
 #define  STM_TIM23_CR1_CMS_CENTER_2    2
 #define  STM_TIM23_CR1_CMS_CENTER_3    3
-#define  STM_TIM23_CR1_CMS_MASK                3
+#define  STM_TIM23_CR1_CMS_MASK                3UL
 #define STM_TIM23_CR1_DIR      4
 #define  STM_TIM23_CR1_DIR_UP          0
 #define  STM_TIM23_CR1_DIR_DOWN                1
@@ -1649,7 +1649,7 @@ extern struct stm_tim23 stm_tim2, stm_tim3;
 #define  STM_TIM23_CR2_MMS_COMPARE_OC2REF      5
 #define  STM_TIM23_CR2_MMS_COMPARE_OC3REF      6
 #define  STM_TIM23_CR2_MMS_COMPARE_OC4REF      7
-#define  STM_TIM23_CR2_MMS_MASK                        7
+#define  STM_TIM23_CR2_MMS_MASK                        7UL
 #define STM_TIM23_CR2_CCDS     3
 
 #define STM_TIM23_SMCR_ETP     15
@@ -1659,7 +1659,7 @@ extern struct stm_tim23 stm_tim2, stm_tim3;
 #define  STM_TIM23_SMCR_ETPS_DIV_2             1
 #define  STM_TIM23_SMCR_ETPS_DIV_4             2
 #define  STM_TIM23_SMCR_ETPS_DIV_8             3
-#define  STM_TIM23_SMCR_ETPS_MASK              3
+#define  STM_TIM23_SMCR_ETPS_MASK              3UL
 #define STM_TIM23_SMCR_ETF     8
 #define  STM_TIM23_SMCR_ETF_NONE               0
 #define  STM_TIM23_SMCR_ETF_INT_N_2            1
index 9d0b963fd32e587d42fac0b845a85d5ec285d43a..4c0147188ad47d9f0e3c91d12259888bb39677f7 100644 (file)
 #define LED_7_PORT             (&stm_gpioa)
 #define LED_7_PIN              10
 
-#define AO_LED_CONTINUITY(c)   (1 << (c))
+#define AO_LED_CONTINUITY(c)   ((AO_LED_TYPE) (1 << (c)))
 #define AO_LED_CONTINUITY_MASK (0xff)
 
 /* ARM */
index e3e8876200728182bd81e55edd7bd697fe9ce49f..91bfd5e6229bd96817d2b4e87c8ac474cc140c59 100644 (file)
 #define LED_7_PORT             (&stm_gpioa)
 #define LED_7_PIN              10
 
-#define AO_LED_CONTINUITY(c)   (1 << (c))
+#define AO_LED_CONTINUITY(c)   ((AO_LED_TYPE) (1 << (c)))
 #define AO_LED_CONTINUITY_MASK (0xff)
 
 /* ARM */
index 044f7434c27e07248882014314f21f79c0efbd67..0d8a206ced3a4baa77a566dab2217857d04ad50e 100644 (file)
 #define LED_PIN_ARMED          5
 
 #define AO_LED_ARMED           (1 << LED_PIN_ARMED)
-#define AO_LED_CONTINUITY(c)   (1 << (4 - (c)))
+#define AO_LED_CONTINUITY(c)   ((AO_LED_TYPE) (1 << (4 - (c))))
 #define AO_LED_CONTINUITY_MASK (0x1 << 4)
 
 #define LEDS_AVAILABLE         (LED_PORT_0_MASK|LED_PORT_1_MASK)
index d9c6586c7fac04417f9a139977340a3ea2938574..84140fd36ee170cc4d8bef4d0801755acfc71512 100644 (file)
@@ -26,7 +26,7 @@
 static void
 set_logging(void)
 {
-       ao_log_running = ao_cmd_hex();
+       ao_log_running = ao_cmd_hex() != 0;
        ao_wakeup(&ao_log_running);
 }
 
index 01bf25e8d29b43d5479c911eaeff8f60383565cb..baf051a45d0a4f6fa72ed2d72e31031ac32835c9 100644 (file)
 #define LED_PIN_ARMED          5
 
 #define AO_LED_ARMED           (1 << LED_PIN_ARMED)
-#define AO_LED_CONTINUITY(c)   (1 << (4 - (c)))
+#define AO_LED_CONTINUITY(c)   ((AO_LED_TYPE) (1 << (4 - (c))))
 #define AO_LED_CONTINUITY_MASK (0x3 << 3)
 
 #define LEDS_AVAILABLE         (LED_PORT_0_MASK|LED_PORT_1_MASK)
index e22331d14061fbaf8b8bbb9d459005fb7caf2242..d3c8e57337a814142e6fcbf8d26992b6ef59b753 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _AO_PINS_H_
 #define _AO_PINS_H_
 
-#define AO_STACK_SIZE  448
+#define AO_STACK_SIZE  440
 
 #define IS_FLASH_LOADER                0
 
index a04ceb9fc89efdd936cf059ea2d72972ee3c40c2..3583be98f9ec23a7586c1d4d00ce46237bd34f27 100644 (file)
@@ -42,7 +42,7 @@ void
 ao_lco_show_pad(uint8_t pad)
 {
        ao_mutex_get(&ao_lco_display_mutex);
-       ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad | (ao_lco_drag_race << 4));
+       ao_seven_segment_set(AO_LCO_PAD_DIGIT, (uint8_t) (pad | (ao_lco_drag_race << 4)));
        ao_mutex_put(&ao_lco_display_mutex);
 }
 
@@ -67,8 +67,8 @@ void
 ao_lco_show_box(uint16_t box)
 {
        ao_mutex_get(&ao_lco_display_mutex);
-       ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, box % 10 | (ao_lco_drag_race << 4));
-       ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10 | (ao_lco_drag_race << 4));
+       ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, (uint8_t) (box % 10 | (ao_lco_drag_race << 4)));
+       ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, (uint8_t) (box / 10 | (ao_lco_drag_race << 4)));
        ao_mutex_put(&ao_lco_display_mutex);
 }
 
@@ -78,9 +78,9 @@ ao_lco_show_voltage(uint16_t decivolts)
        uint8_t tens, ones, tenths;
 
        PRINTD("voltage %d\n", decivolts);
-       tenths = decivolts % 10;
-       ones = (decivolts / 10) % 10;
-       tens = (decivolts / 100) % 10;
+       tenths = (uint8_t) (decivolts % 10);
+       ones = (uint8_t) ((decivolts / 10) % 10);
+       tens = (uint8_t) ((decivolts / 100) % 10);
        ao_mutex_get(&ao_lco_display_mutex);
        ao_seven_segment_set(AO_LCO_PAD_DIGIT, tenths);
        ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ones | 0x10);
@@ -132,7 +132,7 @@ ao_lco_set_select(void)
 static void
 ao_lco_step_box(int8_t dir)
 {
-       int16_t new_box = ao_lco_box;
+       int32_t new_box = (int32_t) ao_lco_box;
 
        do {
                new_box += dir;
@@ -142,8 +142,8 @@ ao_lco_step_box(int8_t dir)
                        new_box = ao_lco_max_box;
                if (new_box == ao_lco_box)
                        break;
-       } while (!ao_lco_box_present(new_box));
-       ao_lco_set_box(new_box);
+       } while (!ao_lco_box_present((uint16_t) new_box));
+       ao_lco_set_box((uint16_t) new_box);
 }
 
 static struct ao_task  ao_lco_drag_task;
@@ -151,7 +151,7 @@ static struct ao_task       ao_lco_drag_task;
 static void
 ao_lco_drag_monitor(void)
 {
-       AO_TICK_TYPE    delay = ~0;
+       AO_TICK_TYPE    delay = ~0UL;
        AO_TICK_TYPE    now;
 
        ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
@@ -162,7 +162,7 @@ ao_lco_drag_monitor(void)
                else
                        ao_sleep_for(&ao_lco_drag_beep_count, delay);
 
-               delay = ~0;
+               delay = ~0UL;
                now = ao_time();
                delay = ao_lco_drag_warn_check(now, delay);
                delay = ao_lco_drag_beep_check(now, delay);
@@ -200,12 +200,12 @@ ao_lco_input(void)
                case AO_EVENT_BUTTON:
                        switch (event.unit) {
                        case AO_BUTTON_ARM:
-                               ao_lco_set_armed(event.value);
+                               ao_lco_set_armed((uint8_t) event.value);
                                ao_lco_set_select();
                                break;
                        case AO_BUTTON_FIRE:
                                if (ao_lco_armed)
-                                       ao_lco_set_firing(event.value);
+                                       ao_lco_set_firing((uint8_t) event.value);
                                break;
                        case AO_BUTTON_DRAG_SELECT:
                                if (event.value)
@@ -256,7 +256,7 @@ ao_lco_batt_voltage(void)
 
        ao_adc_single_get(&packet);
        decivolt = ao_battery_decivolt(packet.v_batt);
-       ao_lco_show_voltage(decivolt);
+       ao_lco_show_voltage((uint16_t) decivolt);
        ao_delay(AO_MS_TO_TICKS(1000));
 }
 
@@ -282,7 +282,7 @@ ao_lco_main(void)
 static void
 ao_lco_set_debug(void)
 {
-       uint16_t r = ao_cmd_decimal();
+       uint32_t r = ao_cmd_decimal();
        if (ao_cmd_status == ao_cmd_success)
                ao_lco_debug = r != 0;
 }
index 4ad2bfb4224a614cf6597258fef595e9eba86342..3f2c9ea44e5365a8c7862499c874b21a8c6a7d50 100644 (file)
@@ -84,8 +84,8 @@
 #define BEEPER_PORT            (&stm_gpioe)
 #define BEEPER_PIN             4
 #define AO_BEEP_MID_DEFAULT    179             /* 2100 Hz */
-#define AO_BEEP_MAKE_LOW(m)    ((m) * 197/179) /* 1900 Hz */
-#define AO_BEEP_MAKE_HIGH(m)   ((m) * 163/179) /* 2300 Hz */
+#define AO_BEEP_MAKE_LOW(m)    ((uint8_t) ((m) * 197U/179U)) /* 1900 Hz */
+#define AO_BEEP_MAKE_HIGH(m)   ((uint8_t) ((m) * 163U/179U)) /* 2300 Hz */
 #define HAS_BATTERY_REPORT     1
 #define HAS_RADIO              1
 #define HAS_TELEMETRY          1
index 465916ec81ea0c2efebdc26cef86f9ede96c81f9..5617b8e435e09818b53b7e94932819675a1d18e7 100644 (file)
@@ -39,6 +39,7 @@ public class TeleGPSConfigUI
        JLabel                  radio_calibration_label;
        JLabel                  radio_frequency_label;
        JLabel                  radio_enable_label;
+       JLabel                  radio_10mw_label;
        JLabel                  rate_label;
        JLabel                  aprs_interval_label;
        JLabel                  aprs_ssid_label;
@@ -58,6 +59,7 @@ public class TeleGPSConfigUI
        AltosUIFreqList         radio_frequency_value;
        JLabel                  radio_calibration_value;
        JRadioButton            radio_enable_value;
+       JRadioButton            radio_10mw_value;
        AltosUIRateList         rate_value;
        JComboBox<String>       aprs_interval_value;
        JComboBox<Integer>      aprs_ssid_value;
@@ -152,6 +154,13 @@ public class TeleGPSConfigUI
                        radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
        }
 
+       void set_radio_10mw_tool_tip() {
+               if (radio_10mw_value.isVisible())
+                       radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
+               else
+                       radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
+       }
+
        void set_rate_tool_tip() {
                if (rate_value.isVisible())
                        rate_value.setToolTipText("Select telemetry baud rate");
@@ -354,6 +363,31 @@ public class TeleGPSConfigUI
                set_radio_enable_tool_tip();
                row++;
 
+               /* Radio 10mW limit */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = row;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
+               radio_10mw_label = new JLabel("Limit transmit to 10mW:");
+               pane.add(radio_10mw_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 4; c.gridy = row;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               radio_10mw_value = new JRadioButton("Limited");
+               radio_10mw_value.addItemListener(this);
+               pane.add(radio_10mw_value, c);
+               set_radio_10mw_tool_tip();
+               row++;
+
                /* Telemetry Rate */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = row;
@@ -811,6 +845,22 @@ public class TeleGPSConfigUI
                        return AltosLib.MISSING;
        }
 
+       public void set_radio_10mw(int new_radio_10mw) {
+               if (new_radio_10mw != AltosLib.MISSING) {
+                       radio_10mw_value.setSelected(new_radio_10mw != 0);
+               }
+               radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
+               radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
+               set_radio_10mw_tool_tip();
+       }
+
+       public int radio_10mw() {
+               if (radio_10mw_value.isVisible())
+                       return radio_10mw_value.isSelected() ? 1 : 0;
+               else
+                       return AltosLib.MISSING;
+       }
+
        public void set_telemetry_rate(int new_rate) {
                if (new_rate != AltosLib.MISSING)
                        rate_value.set_rate(new_rate);