diff --git a/src/ADC/ADC.c b/src/ADC/ADC.c index 78cd81c..5991362 100644 --- a/src/ADC/ADC.c +++ b/src/ADC/ADC.c @@ -1,13 +1,13 @@ /* - * Author: Jake Goodwin + * Author: Jake Goodwin * Date: 2025 * filename: ADC.c - * description: + * description: */ /*DEVNOTES: - * The CH32v003 micro-controllers have 8channels for the ADC that are - * external and 2 internal channels. + * The CH32v003 micro-controllers have 8channels for the ADC that are + * external and 2 internal channels. * * The channels/inputs are labeled as AIN0-AIN7 */ @@ -20,15 +20,15 @@ * A4 --> PD3 * A5 --> PD5 * A6 --> PD6 - * A7 --> PD4 + * A7 --> PD4 * - * Because they don't exactly match up, I'll need to write up my own + * Because they don't exactly match up, I'll need to write up my own * way to do the mapping. */ #include "ADC.h" #include "RegEdit.h" -#include "ch32fun.h" +#include "ch32v003hw.h" #define MAX_PIN_NUM 7 @@ -45,6 +45,11 @@ void ADC_Setup(void) { } +void ADC_PowerOn(void) +{ + RegEdit_SetBit((void *)&ADC1->CTLR2, ADC_ADON); +} + void ADC_Init(uint8_t pin_num) { if (IsInvalidPin(pin_num)) diff --git a/src/ADC/ADC.h b/src/ADC/ADC.h index 7791664..5428d4c 100644 --- a/src/ADC/ADC.h +++ b/src/ADC/ADC.h @@ -27,6 +27,11 @@ */ void ADC_Init(uint8_t pin_num); +/** + * @brief Enables the ADC + */ +void ADC_PowerOn(void); + /** * @brief Enables the ADC */