altos/ao_freq: Use uint32_t for radio freq setting value
authorKeith Packard <keithp@keithp.com>
Fri, 28 Jan 2022 22:15:42 +0000 (14:15 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 01:26:49 +0000 (17:26 -0800)
These values are always unsigned; changing this resolves some
-Wconversion messages.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao.h
src/kernel/ao_freq.c

index 806b4946fecb57bf891826750b3b79f7a6884c53..bf4b18396a65e89c946aee34a3f4de70c652dcd2 100644 (file)
@@ -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 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;
 }