🧑‍💻 More SAMD51 ADCs

This commit is contained in:
Scott Lahteine 2023-11-28 21:11:23 -06:00
parent 3457952854
commit 921198e81c

View file

@ -60,11 +60,14 @@
#define GET_PROBE_ADC() TERN(HAS_TEMP_ADC_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1)
#define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1)
#define GET_BOARD_ADC() TERN(HAS_TEMP_ADC_BOARD, PIN_TO_ADC(TEMP_BOARD_PIN), -1)
#define GET_SOC_ADC() TERN(HAS_TEMP_ADC_SOC, PIN_TO_ADC(TEMP_SOC_PIN), -1)
#define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1)
#define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1)
#define GET_JOY_ADC_X() TERN(HAS_JOY_ADC_X, PIN_TO_ADC(JOY_X_PIN), -1)
#define GET_JOY_ADC_Y() TERN(HAS_JOY_ADC_Y, PIN_TO_ADC(JOY_Y_PIN), -1)
#define GET_JOY_ADC_Z() TERN(HAS_JOY_ADC_Z, PIN_TO_ADC(JOY_Z_PIN), -1)
#define GET_POWERMON_ADC_CURRENT() TERN(POWER_MONITOR_CURRENT, PIN_TO_ADC(POWER_MONITOR_CURRENT_PIN), -1)
#define GET_POWERMON_ADC_VOLTS() TERN(POWER_MONITOR_VOLTAGE, PIN_TO_ADC(POWER_MONITOR_VOLTAGE_PIN), -1)
#define IS_ADC_REQUIRED(n) ( \
GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
@ -73,10 +76,11 @@
|| GET_CHAMBER_ADC() == n \
|| GET_PROBE_ADC() == n \
|| GET_COOLER_ADC() == n \
|| GET_BOARD_ADC() == n \
|| GET_BOARD_ADC() == n || GET_SOC_ADC() == n \
|| GET_FILAMENT_WIDTH_ADC() == n \
|| GET_BUTTONS_ADC() == n \
|| GET_JOY_ADC_X() == n || GET_JOY_ADC_Y() == n || GET_JOY_ADC_Z() == n \
|| GET_POWERMON_ADC_CURRENT() == n || GET_POWERMON_ADC_VOLTS() == n \
)
#if IS_ADC_REQUIRED(0)
@ -136,6 +140,9 @@ enum ADCIndex {
#if GET_BOARD_ADC() == 0
TEMP_BOARD,
#endif
#if GET_SOC_ADC() == 0
TEMP_SOC,
#endif
#if GET_FILAMENT_WIDTH_ADC() == 0
FILWIDTH,
#endif
@ -151,6 +158,15 @@ enum ADCIndex {
#if GET_JOY_ADC_Z() == 0
JOY_Z,
#endif
#if GET_POWERMON_ADC_CURRENT() == 0
POWERMON_CURRENT,
#endif
#if GET_POWERMON_ADC_VOLTS() == 0
POWERMON_VOLTS,
#endif
// Use later indexes for ADC index 1
#if GET_TEMP_0_ADC() == 1
TEMP_0,
#endif
@ -190,6 +206,9 @@ enum ADCIndex {
#if GET_BOARD_ADC() == 1
TEMP_BOARD,
#endif
#if GET_SOC_ADC() == 1
TEMP_SOC,
#endif
#if GET_FILAMENT_WIDTH_ADC() == 1
FILWIDTH,
#endif
@ -205,6 +224,13 @@ enum ADCIndex {
#if GET_JOY_ADC_Z() == 1
JOY_Z,
#endif
#if GET_POWERMON_ADC_CURRENT() == 1
POWERMON_CURRENT,
#endif
#if GET_POWERMON_ADC_VOLTS() == 1
POWERMON_VOLTS,
#endif
ADC_COUNT
};
@ -303,6 +329,9 @@ enum ADCIndex {
#if GET_BOARD_ADC() == 0
TEMP_BOARD_PIN,
#endif
#if GET_SOC_ADC() == 0
TEMP_SOC_PIN,
#endif
#if GET_FILAMENT_WIDTH_ADC() == 0
FILWIDTH_PIN,
#endif
@ -318,7 +347,15 @@ enum ADCIndex {
#if GET_JOY_ADC_Z() == 0
JOY_Z_PIN,
#endif
#if GET_POWERMON_ADC_CURRENT() == 0
POWER_MONITOR_CURRENT_PIN,
#endif
#if GET_POWERMON_ADC_VOLTS() == 0
POWER_MONITOR_VOLTS_PIN,
#endif
// ADC1 pins
#if GET_TEMP_0_ADC() == 1
TEMP_0_PIN,
#endif
@ -358,6 +395,9 @@ enum ADCIndex {
#if GET_BOARD_ADC() == 1
TEMP_BOARD_PIN,
#endif
#if GET_SOC_ADC() == 1
TEMP_SOC_PIN,
#endif
#if GET_FILAMENT_WIDTH_ADC() == 1
FILWIDTH_PIN,
#endif
@ -373,6 +413,12 @@ enum ADCIndex {
#if GET_JOY_ADC_Z() == 1
JOY_Z_PIN,
#endif
#if GET_POWERMON_ADC_CURRENT() == 1
POWER_MONITOR_CURRENT_PIN,
#endif
#if GET_POWERMON_ADC_VOLTS() == 1
POWER_MONITOR_VOLTS_PIN,
#endif
};
static uint16_t adc_results[ADC_COUNT];
@ -420,6 +466,9 @@ enum ADCIndex {
#if GET_BOARD_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) },
#endif
#if GET_SOC_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_SOC_PIN) },
#endif
#if GET_FILAMENT_WIDTH_ADC() == 0
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
#endif
@ -435,6 +484,12 @@ enum ADCIndex {
#if GET_JOY_ADC_Z() == 0
{ PIN_TO_INPUTCTRL(JOY_Z_PIN) },
#endif
#if GET_POWERMON_ADC_CURRENT() == 0
{ PIN_TO_INPUTCTRL(POWER_MONITOR_CURRENT_PIN) },
#endif
#if GET_POWERMON_ADC_VOLTS() == 0
{ PIN_TO_INPUTCTRL(POWER_MONITOR_VOLTS_PIN) },
#endif
};
#define ADC0_AINCOUNT COUNT(adc0_dma_regs_list)
@ -483,6 +538,9 @@ enum ADCIndex {
#if GET_BOARD_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) },
#endif
#if GET_SOC_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_SOC_PIN) },
#endif
#if GET_FILAMENT_WIDTH_ADC() == 1
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
#endif
@ -498,6 +556,12 @@ enum ADCIndex {
#if GET_JOY_ADC_Z() == 1
{ PIN_TO_INPUTCTRL(JOY_Z_PIN) },
#endif
#if GET_POWERMON_ADC_CURRENT() == 1
{ PIN_TO_INPUTCTRL(POWER_MONITOR_CURRENT_PIN) },
#endif
#if GET_POWERMON_ADC_VOLTS() == 1
{ PIN_TO_INPUTCTRL(POWER_MONITOR_VOLTS_PIN) },
#endif
};
#define ADC1_AINCOUNT COUNT(adc1_dma_regs_list)