+/*
+ * The voltage divider has 1M5 and 300K resistors (i.e. it measures 1/6th of
+ * the real voltage), ADC uses 1.1V internal reference.
+ * Macro to calculate upper eight bits of the ADC running-averaged value
+ * from the voltage in milivolts.
+ */
+#define ADC_1100MV_VALUE 1071 // measured, not exactly 1100
+#define MV_TO_ADC8(mV) ((unsigned char)(((uint32_t)(1UL << ADC_RUNAVG_SHIFT) \
+ * (1024UL * (mV)) \
+ / (6UL * ADC_1100MV_VALUE)) >> 8))
+#define BATT_N_LEVELS 3
+static unsigned char batt_levels[BATT_N_LEVELS] = {
+ MV_TO_ADC8(3500),
+ MV_TO_ADC8(3700),
+ MV_TO_ADC8(3900),
+};
+