diff --git a/source/Core/BSP/Pinecilv2/IRQ.cpp b/source/Core/BSP/Pinecilv2/IRQ.cpp index d9d32406..9912c374 100644 --- a/source/Core/BSP/Pinecilv2/IRQ.cpp +++ b/source/Core/BSP/Pinecilv2/IRQ.cpp @@ -38,6 +38,10 @@ void read_adc_fifo(void) { uint32_t raw_reading = ADC_Read_FIFO(); ADC_Result_Type parsed = {0, 0, 0}; ADC_Parse_Result(&raw_reading, 1, &parsed); + // Rollover prevention + if (parsed.value > ((1 << 14) - 1)) { + parsed.value = ((1 << 14) - 1); + } switch (parsed.posChan) { case TMP36_ADC_CHANNEL: diff --git a/source/Core/BSP/Pinecilv2/Setup.cpp b/source/Core/BSP/Pinecilv2/Setup.cpp index 8b7a03e6..46aea229 100644 --- a/source/Core/BSP/Pinecilv2/Setup.cpp +++ b/source/Core/BSP/Pinecilv2/Setup.cpp @@ -50,6 +50,7 @@ void hardware_init() { gpio_set_mode(OLED_RESET_Pin, GPIO_OUTPUT_MODE); gpio_set_mode(KEY_A_Pin, GPIO_INPUT_PD_MODE); gpio_set_mode(KEY_B_Pin, GPIO_INPUT_PD_MODE); + gpio_set_mode(TMP36_INPUT_Pin, GPIO_HZ_MODE); gpio_set_mode(TIP_TEMP_Pin, GPIO_HZ_MODE); gpio_set_mode(VIN_Pin, GPIO_HZ_MODE); @@ -163,7 +164,7 @@ void setup_adc(void) { } #endif -#if 0 +#if 1 // this sets the CVSP field (ADC conversion speed) { uint32_t regCfg2;