Don't use doubles in firmware

The FPU supports only single-precision floats.
This commit is contained in:
Michael Ossmann
2025-12-30 18:14:28 -05:00
parent f6c23be2d9
commit d5361ea523
2 changed files with 8 additions and 3 deletions

View File

@@ -39,8 +39,13 @@ radio_error_t radio_set_sample_rate(
radio_config_t* config = &radio->channel[chan_id].config;
// TODO get the actual tuned frequency from sample_rate_frac_set
sample_rate.hz = (double) sample_rate.num / (double) sample_rate.div;
/*
* Store the sample rate rounded to the nearest Hz for convenience.
*/
if (sample_rate.div == 0) {
return RADIO_ERR_INVALID_PARAM;
}
sample_rate.hz = (sample_rate.num + (sample_rate.div >> 1)) / sample_rate.div;
if (config->mode == TRANSCEIVER_MODE_OFF) {
config->sample_rate[element] = sample_rate;

View File

@@ -77,7 +77,7 @@ typedef enum {
typedef struct {
uint32_t num;
uint32_t div;
double hz;
uint32_t hz;
} radio_sample_rate_t;
typedef struct {