I'm currently working on writing a driver for an external SPI ADC (AD7980), and would like to reuse the hal_adc, hal_spi, and hal_pwm to make it portable. See below:
Code: Select all
+---------------+
| hal_adc.c |
+---------------+
|
+-------|-------+
| ad7980.c |
+-------|-------+
|
|---------------------|------------------|
+-------|-------+ +-------|-------+ +-------|-------+
| hal_pwm.c | | hal_spi.c | | stm32_dma.c |
+---------------+ +---------------+ +-------+-------+
There are a couple of issues I've discovered so far, and probably more. I think the HAL - or at least the STM32 implementation should be updated to at the very least allow this sort of usage.
The spi driver doesn't expose the half transfer interrupt. It also disables the interrupts after the dma transfer is complete, thus not supporting 'continuous' mode. A couple of other changes probably need to happen as well to have the rights hooks to be able to use the SPI driver as part of a more complex composite device driver.
Have anyone of you already done this? Any idea for how to do this cleanly?