aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-10-07 11:44:58 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-10-29 11:55:06 -0400
commit9142200b3ac63dc757e8e4fbfb4b1f8d177457b2 (patch)
treea7a2305e0207c3a7a0d3ae6e49a709e37a0bb32c /src
parenta8069e9ba80346e66285eb03fd6435b4ca61cd01 (diff)
downloadkutter-9142200b3ac63dc757e8e4fbfb4b1f8d177457b2.tar.gz
kutter-9142200b3ac63dc757e8e4fbfb4b1f8d177457b2.tar.xz
kutter-9142200b3ac63dc757e8e4fbfb4b1f8d177457b2.zip
stm32: Support reading chip based temperature sensor on stm32f0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/stm32/stm32f0_adc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/stm32/stm32f0_adc.c b/src/stm32/stm32f0_adc.c
index 3561c08d..aeb32bcb 100644
--- a/src/stm32/stm32f0_adc.c
+++ b/src/stm32/stm32f0_adc.c
@@ -1,6 +1,6 @@
// ADC functions on STM32
//
-// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2019-2020 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -15,11 +15,15 @@
DECL_CONSTANT("ADC_MAX", 4095);
+#define ADC_TEMPERATURE_PIN 0xfe
+DECL_ENUMERATION("pin", "ADC_TEMPERATURE", ADC_TEMPERATURE_PIN);
+
static const uint8_t adc_pins[] = {
GPIO('A', 0), GPIO('A', 1), GPIO('A', 2), GPIO('A', 3),
GPIO('A', 4), GPIO('A', 5), GPIO('A', 6), GPIO('A', 7),
GPIO('B', 0), GPIO('B', 1), GPIO('C', 0), GPIO('C', 1),
GPIO('C', 2), GPIO('C', 3), GPIO('C', 4), GPIO('C', 5),
+ ADC_TEMPERATURE_PIN
};
struct gpio_adc
@@ -68,7 +72,11 @@ gpio_adc_setup(uint32_t pin)
}
}
- gpio_peripheral(pin, GPIO_ANALOG, 0);
+ if (pin == ADC_TEMPERATURE_PIN) {
+ ADC1_COMMON->CCR = ADC_CCR_TSEN;
+ } else {
+ gpio_peripheral(pin, GPIO_ANALOG, 0);
+ }
return (struct gpio_adc){ .adc = adc, .chan = 1 << chan };
}