Skip to content

stm32: Add DAC feature for STM32G0. #17763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/stm32/boards/NUCLEO_G0B1RE/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_ENABLE_RNG (0)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_DAC (0)
#define MICROPY_HW_ENABLE_DAC (1)
#define MICROPY_HW_ENABLE_USB (0) // can be enabled if USB cable connected to PA11/PA12
#define MICROPY_PY_PYB_LEGACY (0)

Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static uint32_t TIMx_Config(mp_obj_t timer) {
// work out the trigger channel (only certain ones are supported)
if (tim->Instance == TIM2) {
return DAC_TRIGGER_T2_TRGO;
#if defined(TIM4)
#if defined(TIM4) && defined(DAC_TRIGGER_T4_TRGO) // G0B1 doesn't have this
} else if (tim->Instance == TIM4) {
return DAC_TRIGGER_T4_TRGO;
#endif
Expand Down
6 changes: 3 additions & 3 deletions ports/stm32/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ static void dma_idle_handler(uint32_t tick) {
}
#endif

#if defined(STM32F0) || defined(STM32G4) || defined(STM32L0) || defined(STM32L1) || defined(STM32L4)
#if defined(STM32F0) || defined(STM32G0) || defined(STM32G4) || defined(STM32L0) || defined(STM32L1) || defined(STM32L4)

void dma_nohal_init(const dma_descr_t *descr, uint32_t config) {
DMA_Channel_TypeDef *dma = descr->instance;
Expand All @@ -1680,7 +1680,7 @@ void dma_nohal_init(const dma_descr_t *descr, uint32_t config) {
} else {
__HAL_DMA2_REMAP(descr->sub_instance);
}
#elif defined(STM32G4)
#elif defined(STM32G0) || defined(STM32G4)
uint32_t *dmamux_ctrl = (void *)(DMAMUX1_Channel0_BASE + 0x04 * descr->id);
*dmamux_ctrl = (*dmamux_ctrl & ~(0x7f)) | descr->sub_instance;
#elif defined(STM32L1)
Expand Down Expand Up @@ -1807,7 +1807,7 @@ void dma_nohal_start(const dma_descr_t *descr, uint32_t src_addr, uint32_t dst_a
dma->CCR |= DMA_CCR_EN;
}

#elif defined(STM32G0) || defined(STM32N6) || defined(STM32WB) || defined(STM32WL)
#elif defined(STM32N6) || defined(STM32WB) || defined(STM32WL)

// These functions are currently not implemented or needed for this MCU.

Expand Down
Loading