The GPT can be started as follows (as first test, it's toggling an LED at 10 Hz):
Code: Select all
void gpt_adc_trigger (GPTDriver*) {
palTogglePad(GPIOA, GPIOA_LED_GREEN);
}
static GPTConfig gpt_adc_config = {
10000, // timer clock: 10 KHz
gpt_adc_trigger, // timer callback function
0, 0
};
int main () {
...
gptStart(&GPTD1, &gpt_adc_config);
gptStartContinuous(&GPTD1, 1000);
...
The next step will be to start the ADC, but if done from in software gpt_adc_trigger(), then I would think that this can only be done as one-shot, and repeated again the next time gpt_adc_trigger() gets called. Each timeout then starts the ADC on 4 channels and then it stops again, right?
What I'm after though, ideally, is to have this all take place through DMA, i.e.use EXTSEL (external event select) to drive the ADC scans from the timer, at 10 KHz, and on each trigger have the ADC scan-and-save the next 4 readings to a circular buffer, using DMA. By then using the half-full and full interrupts, that would allow processing entire bursts of readings, as long as the reader thread can process half the buffer in time before the next interrupt.
While still working my way through the ChibiOS and STM32F1 docs, my question is: is the above approach feasible, and how far can it be integrated into what ChibiOS already does (which is quite a lot, including all the DMA setup).
-jcw