Compare commits
3 Commits
ffe195d7b2
...
2d3b61550b
Author | SHA1 | Date | |
---|---|---|---|
2d3b61550b | |||
85fe0f6749 | |||
5ae31a1705 |
@ -36,6 +36,7 @@ static volatile int * volatile streaming_flag_ptr = NULL;
|
||||
static uint32_t filter_startup_cnt;
|
||||
static volatile float adc_pt1000_raw_reading_hf;
|
||||
static volatile uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES];
|
||||
static volatile uint32_t adc_watchdog_counter = 0UL;
|
||||
|
||||
volatile float * volatile stream_buffer = NULL;
|
||||
volatile uint32_t stream_count;
|
||||
@ -322,7 +323,6 @@ static inline __attribute__((optimize("O3"))) float adc_pt1000_dma_avg_pre_filte
|
||||
void ADC_IRQHandler(void)
|
||||
{
|
||||
uint32_t adc1_sr;
|
||||
static uint32_t watchdog_errors;
|
||||
|
||||
adc1_sr = ADC1->SR;
|
||||
|
||||
@ -331,16 +331,12 @@ void ADC_IRQHandler(void)
|
||||
pt1000_error |= ADC_PT1000_OVERFLOW;
|
||||
/* Disable ADC in case of overrrun*/
|
||||
adc_pt1000_disable();
|
||||
|
||||
if (!(adc1_sr & ADC_SR_AWD)) {
|
||||
watchdog_errors = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (adc1_sr & ADC_SR_AWD) {
|
||||
ADC1->SR &= ~ADC_SR_AWD;
|
||||
watchdog_errors++;
|
||||
if (watchdog_errors >= ADC_PT1000_WATCHDOG_SAMPLE_COUNT)
|
||||
adc_watchdog_counter++;
|
||||
if (adc_watchdog_counter >= ADC_PT1000_WATCHDOG_SAMPLE_COUNT)
|
||||
pt1000_error |= ADC_PT1000_WATCHDOG_ERROR;
|
||||
}
|
||||
}
|
||||
@ -376,6 +372,9 @@ void DMA2_Stream0_IRQHandler()
|
||||
if (streaming_flag_ptr)
|
||||
append_stream_buffer(adc_val);
|
||||
|
||||
if (adc_watchdog_counter > 0UL)
|
||||
adc_watchdog_counter--;
|
||||
|
||||
/* Call moving average filter */
|
||||
adc_pt1000_filter(adc_val);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@
|
||||
* @brief Number of ADC samples the value has to be outside the Watchdog limit (@ref ADC_PT1000_UPPER_WATCHDOG and @ref ADC_PT1000_LOWER_WATCHDOG)
|
||||
* in order to produce a watchdog error
|
||||
*/
|
||||
#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 10U
|
||||
#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 25U
|
||||
|
||||
enum adc_pt1000_error {ADC_PT1000_NO_ERR= 0, ADC_PT1000_WATCHDOG_ERROR=(1UL<<0), ADC_PT1000_OVERFLOW=(1UL<<1), ADC_PT1000_INACTIVE = (1UL<<2)};
|
||||
|
||||
|
@ -274,8 +274,11 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
|
||||
shellmatta_printf(handle, "\x1b[1A\x1b[150D\x1b[K");
|
||||
shell_cmd_pt1000_res(handle, "", 0UL);
|
||||
|
||||
led_set(0, led_status);
|
||||
led_set(1, !led_status);
|
||||
led_set(1, led_status);
|
||||
if (adc_pt1000_check_error() & ADC_PT1000_WATCHDOG_ERROR) {
|
||||
led_set(0, 1);
|
||||
}
|
||||
|
||||
led_status ^= 0x1;
|
||||
|
||||
systick_wait_ms(150);
|
||||
|
Loading…
x
Reference in New Issue
Block a user