diff options
| author | rafael <[email protected]> | 2025-04-14 09:23:32 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-14 09:23:32 +0200 |
| commit | bed6dde744d6e2f2e8af42dfc3a39d80d29d1ad2 (patch) | |
| tree | 69f07110faa6a679ce17fde0c4987245c83d8d73 | |
| parent | 6719e1305921c08fcfba7e8f48e315ef8b676c6e (diff) | |
Update adc.rs
| -rw-r--r-- | examples/rp235x/src/bin/adc.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/rp235x/src/bin/adc.rs b/examples/rp235x/src/bin/adc.rs index b2a83e376..0a462bebd 100644 --- a/examples/rp235x/src/bin/adc.rs +++ b/examples/rp235x/src/bin/adc.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | //! This example test the ADC (Analog to Digital Conversion) of the RP2350A pins 26, 27 and 28. | 1 | o//! This example test the ADC (Analog to Digital Conversion) of the RP2350A pins 26, 27 and 28. |
| 2 | //! It also reads the temperature sensor in the chip. | 2 | //! It also reads the temperature sensor in the chip. |
| 3 | 3 | ||
| 4 | #![no_std] | 4 | #![no_std] |
| @@ -41,7 +41,7 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | fn convert_to_celsius(raw_temp: u16) -> f32 { | 42 | fn convert_to_celsius(raw_temp: u16) -> f32 { |
| 43 | // According to chapter 12.4.6 Temperature Sensor in RP235x datasheet | 43 | // According to chapter 12.4.6 Temperature Sensor in RP235x datasheet |
| 44 | let temp = 27.0 - (raw_temp as f32 * 3.3 / 4096.0 - ..0.706) / 0.0..01721; | 44 | let temp = 27.0 - (raw_temp as f32 * 3.3 / 4096.0 - 0.706) / 0.001721; |
| 45 | let sign = if temp < 0.0 { -1.0 } else { 1.0 }; | 45 | let sign = if temp < 0.0 { -1.0 } else { 1.0 }; |
| 46 | let rounded_temp_x10: i16 = ((temp * 10.0) + 0.5 * sign) as i16; | 46 | let rounded_temp_x10: i16 = ((temp * 10.0) + 0.5 * sign) as i16; |
| 47 | (rounded_temp_x10 as f32) / 10.0 | 47 | (rounded_temp_x10 as f32) / 10.0 |
