mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-08-24 11:52:50 +02:00
Fixed improper _
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
* Samples the ADC channel for voltage in millivolts and reads the
|
||||
* on-chip temperature sensor, then prints both values.
|
||||
*/
|
||||
static void _print_adc_readings(void) {
|
||||
static void print_adc_readings(void) {
|
||||
uint32_t voltage_mv = adc_driver_read_mv();
|
||||
float temp_c = adc_driver_read_temp_celsius();
|
||||
printf("ADC0: %4lu mV | Chip temp: %.1f C\r\n", voltage_mv, temp_c);
|
||||
@@ -64,7 +64,7 @@ int main(void) {
|
||||
adc_driver_init(ADC_GPIO, ADC_CHANNEL);
|
||||
printf("ADC driver initialized: GPIO%d (channel %d)\r\n", ADC_GPIO, ADC_CHANNEL);
|
||||
while (true) {
|
||||
_print_adc_readings();
|
||||
print_adc_readings();
|
||||
sleep_ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ static uint8_t active_channel = 0;
|
||||
* @param raw 12-bit ADC conversion result (0 - 4095)
|
||||
* @return uint32_t Equivalent voltage in millivolts (0 - 3300)
|
||||
*/
|
||||
static uint32_t _raw_to_mv(uint16_t raw) {
|
||||
static uint32_t raw_to_mv(uint16_t raw) {
|
||||
return (uint32_t)raw * ADC_VREF_MV / ADC_FULL_SCALE;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ static uint32_t _raw_to_mv(uint16_t raw) {
|
||||
* @param raw 12-bit ADC result from the internal temperature sensor (channel 4)
|
||||
* @return float Die temperature in degrees Celsius
|
||||
*/
|
||||
static float _raw_to_celsius(uint16_t raw) {
|
||||
static float raw_to_celsius(uint16_t raw) {
|
||||
float voltage = (float)raw * 3.3f / (float)ADC_FULL_SCALE;
|
||||
return 27.0f - (voltage - 0.706f) / 0.001721f;
|
||||
}
|
||||
@@ -74,12 +74,12 @@ void adc_driver_init(uint32_t gpio, uint8_t channel) {
|
||||
}
|
||||
|
||||
uint32_t adc_driver_read_mv(void) {
|
||||
return _raw_to_mv(adc_read());
|
||||
return raw_to_mv(adc_read());
|
||||
}
|
||||
|
||||
float adc_driver_read_temp_celsius(void) {
|
||||
adc_select_input(4);
|
||||
float result = _raw_to_celsius(adc_read());
|
||||
float result = raw_to_celsius(adc_read());
|
||||
adc_select_input(active_channel);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user