stm32/dac: Add support for H7 MCUs.

Includes a fix for H7 DAC DMA requests.
This commit is contained in:
iabdalkader 2018-04-06 01:04:08 +02:00 committed by Damien George
parent cbf981f330
commit 90bb98e83d
2 changed files with 12 additions and 2 deletions

View File

@ -65,6 +65,10 @@
#if defined(MICROPY_HW_ENABLE_DAC) && MICROPY_HW_ENABLE_DAC
#if defined(STM32H7)
#define DAC DAC1
#endif
STATIC DAC_HandleTypeDef DAC_Handle;
void dac_init(void) {
@ -160,6 +164,8 @@ STATIC mp_obj_t pyb_dac_init_helper(pyb_dac_obj_t *self, size_t n_args, const mp
// DAC peripheral clock
#if defined(STM32F4) || defined(STM32F7)
__DAC_CLK_ENABLE();
#elif defined(STM32H7)
__HAL_RCC_DAC12_CLK_ENABLE();
#elif defined(STM32L4)
__HAL_RCC_DAC1_CLK_ENABLE();
#else
@ -256,10 +262,14 @@ STATIC mp_obj_t pyb_dac_deinit(mp_obj_t self_in) {
pyb_dac_obj_t *self = self_in;
if (self->dac_channel == DAC_CHANNEL_1) {
DAC_Handle.Instance->CR &= ~DAC_CR_EN1;
#ifndef STM32H7
DAC_Handle.Instance->CR |= DAC_CR_BOFF1;
#endif
} else {
DAC_Handle.Instance->CR &= ~DAC_CR_EN2;
#ifndef STM32H7
DAC_Handle.Instance->CR |= DAC_CR_BOFF2;
#endif
}
return mp_const_none;
}

View File

@ -336,8 +336,8 @@ const dma_descr_t dma_SPI_2_TX = { DMA1_Stream4, DMA_REQUEST_SPI2_TX, DMA_MEMORY
const dma_descr_t dma_I2C_3_TX = { DMA1_Stream4, DMA_REQUEST_I2C3_TX, DMA_MEMORY_TO_PERIPH, dma_id_4, &dma_init_struct_spi_i2c };
const dma_descr_t dma_I2C_4_TX = { DMA1_Stream5, BDMA_REQUEST_I2C4_TX, DMA_MEMORY_TO_PERIPH, dma_id_5, &dma_init_struct_spi_i2c };
#if defined(MICROPY_HW_ENABLE_DAC) && MICROPY_HW_ENABLE_DAC
const dma_descr_t dma_DAC_1_TX = { DMA1_Stream5, DMA_REQUEST_DAC1_TX, DMA_MEMORY_TO_PERIPH, dma_id_5, &dma_init_struct_dac };
const dma_descr_t dma_DAC_2_TX = { DMA1_Stream6, DMA_REQUEST_DAC2_TX, DMA_MEMORY_TO_PERIPH, dma_id_6, &dma_init_struct_dac };
const dma_descr_t dma_DAC_1_TX = { DMA1_Stream5, DMA_REQUEST_DAC1_CH1, DMA_MEMORY_TO_PERIPH, dma_id_5, &dma_init_struct_dac };
const dma_descr_t dma_DAC_2_TX = { DMA1_Stream6, DMA_REQUEST_DAC1_CH2, DMA_MEMORY_TO_PERIPH, dma_id_6, &dma_init_struct_dac };
#endif
const dma_descr_t dma_SPI_3_TX = { DMA1_Stream7, DMA_REQUEST_SPI3_TX, DMA_MEMORY_TO_PERIPH, dma_id_7, &dma_init_struct_spi_i2c };
const dma_descr_t dma_I2C_1_TX = { DMA1_Stream7, DMA_REQUEST_I2C1_TX, DMA_MEMORY_TO_PERIPH, dma_id_7, &dma_init_struct_spi_i2c };