Skip to content
Snippets Groups Projects

ADC driver:

Merged Clément Foucher requested to merge cfoucher/core:adc_rework into main
9 files
+ 52
46
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -51,14 +51,10 @@ static bool enable_dma[NUMBER_OF_ADCS] = {false};
@@ -51,14 +51,10 @@ static bool enable_dma[NUMBER_OF_ADCS] = {false};
static uint32_t enabled_channels[NUMBER_OF_ADCS][NUMBER_OF_CHANNELS_PER_ADC] = {0};
static uint32_t enabled_channels[NUMBER_OF_ADCS][NUMBER_OF_CHANNELS_PER_ADC] = {0};
 
/////
/////
// Public API
// Public API
void adc_init()
{
adc_core_init();
}
void adc_configure_trigger_source(uint8_t adc_number, adc_ev_src_t trigger_source)
void adc_configure_trigger_source(uint8_t adc_number, adc_ev_src_t trigger_source)
{
{
if ( (adc_number == 0) || (adc_number > NUMBER_OF_ADCS) )
if ( (adc_number == 0) || (adc_number > NUMBER_OF_ADCS) )
@@ -125,7 +121,30 @@ void adc_configure_use_dma(uint8_t adc_number, bool use_dma)
@@ -125,7 +121,30 @@ void adc_configure_use_dma(uint8_t adc_number, bool use_dma)
void adc_start()
void adc_start()
{
{
/////
/////
// Configure ADCs
// Initialize ADCs
 
 
adc_core_init();
 
 
/////
 
// Pre-enable configuration
 
 
// Nothing here for now.
 
 
// If some channels have to be set as differential,
 
// or ADCs have to be set as dual mode,
 
// this shoud be done here.
 
 
/////
 
// Enable ADCs
 
 
for (int i = 1 ; i <= NUMBER_OF_ADCS ; i++)
 
{
 
adc_core_enable(i);
 
}
 
 
/////
 
// Post-enable configuration
 
for (uint8_t adc_num = 1 ; adc_num <= NUMBER_OF_ADCS ; adc_num++)
for (uint8_t adc_num = 1 ; adc_num <= NUMBER_OF_ADCS ; adc_num++)
{
{
uint8_t adc_index = adc_num-1;
uint8_t adc_index = adc_num-1;
@@ -215,7 +234,7 @@ void adc_stop()
@@ -215,7 +234,7 @@ void adc_stop()
}
}
}
}
void adc_software_trigger_conversion(uint8_t adc_number)
void adc_trigger_software_conversion(uint8_t adc_number)
{
{
adc_core_start(adc_number, 1);
adc_core_start(adc_number, 1);
}
}
Loading