WXK
2025-02-11 e328ebef585cea2351b37117b2d5ac4978ecd3c0
keil/include/drivers/mk_adc.c
@@ -104,6 +104,7 @@
        /* If the external reference voltage driving capability is insufficient */
        /* It is recommended to enable this configuration */
        // val |= (9 << 1) | (1 << 4);
        val |= (1 << 9) | (7 << 5) | (1 << 4);
    }
    REG_WRITE(0x4000062C, val);
@@ -405,17 +406,12 @@
    adc_close();
}
static void adc_continue_callback(void *data, uint32_t number)
{
    LOG_INFO(TRACE_MODULE_APP, "Chip adc callback %d degree\r\n", data);
}
int16_t battery_monitor_get(void)
{
#define NUM_SAMPLES (3)
    uint32_t sample[NUM_SAMPLES];
    adc_get(&sample[0], NUM_SAMPLES, adc_continue_callback);
    adc_get(&sample[0], NUM_SAMPLES, NULL);
    int32_t sum = 0;
    for (int i = 0; i < NUM_SAMPLES; i++)