Make Safety ADC use sequnece feature of ADC and use DMA to write data

This commit is contained in:
2020-11-30 00:01:26 +01:00
parent 898feac168
commit 91d9db6a4e
7 changed files with 101 additions and 74 deletions

View File

@@ -31,20 +31,20 @@
enum safety_adc_meas_channel {SAFETY_ADC_MEAS_VREF, SAFETY_ADC_MEAS_TEMP};
void safety_adc_init();
void safety_adc_init(void);
void safety_adc_deinit();
void safety_adc_deinit(void);
void safety_adc_trigger_meas(enum safety_adc_meas_channel measurement);
void safety_adc_trigger_meas(void);
/**
* @brief Poll ADC result.
* @param results adc results
* @return 1 if measurement successful, 0 if not ready, -1 if ADC aborted or not started
*/
int safety_adc_poll_result(uint16_t *adc_result);
int safety_adc_poll_result(void);
enum safety_adc_check_result handle_safety_adc();
const uint16_t *safety_adc_get_values(void);
float safety_adc_convert_channel(enum safety_adc_meas_channel channel, uint16_t analog_value);

View File

@@ -101,7 +101,7 @@ enum analog_value_monitor {
*/
#define MEAS_ADC_SAFETY_FLAG_KEY 0xe554dac3UL
#define SAFETY_CONTROLLER_ADC_DELAY_MS 120
#define SAFETY_CONTROLLER_ADC_DELAY_MS 250
#define SAFETY_CONFIG_DEFAULT_PERSIST ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_MEAS_ADC_OFF, false), \
ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_MEAS_ADC_WATCHDOG, false), \
@@ -132,7 +132,7 @@ enum analog_value_monitor {
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_STACK, SAFETY_FLAG_CONFIG_WEIGHT_PANIC), \
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_SAFETY_ADC, SAFETY_FLAG_CONFIG_WEIGHT_PANIC), \
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_SYSTICK, SAFETY_FLAG_CONFIG_WEIGHT_PANIC), \
/* Watchdog timeout is not handled perioodically, but only on startup.
/* Watchdog timeout is not handled periodically, but only on startup.
* Therefore, it is not listed here */\
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_WTCHDG_FIRED, SAFETY_FLAG_CONFIG_WEIGHT_NONE), \
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_UNCAL, SAFETY_FLAG_CONFIG_WEIGHT_NONE), \