Beispiel #1
0
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac)
{
    GPIO_InitTypeDef gpio_init;
    static DMA_HandleTypeDef  hdma_dac;
    GPIO_INIT(DACx_GPIO, DACx_PIN, GPIO_MODE_ANALOG, GPIO_NOPULL, 0, 0);
    DACx_CLK_ENABLE();
    DAC_DMAx_CLK_ENABLE();
    DAC_TIMx_CLK_ENABLE();

    hdma_dac.Instance = DAC_DMAx_STREAM;

    hdma_dac.Init.Channel  = DAC_DMAx_CHANNEL;

    hdma_dac.Init.Direction = DMA_MEMORY_TO_PERIPH;
    hdma_dac.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_dac.Init.MemInc = DMA_MINC_ENABLE;
    hdma_dac.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_dac.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    hdma_dac.Init.Mode = DMA_CIRCULAR;
    hdma_dac.Init.Priority = DMA_PRIORITY_MEDIUM;

    HAL_DMA_Init(&hdma_dac);

#if DAC_OUTn == 1
    __HAL_LINKDMA(hdac, DMA_Handle1, hdma_dac);
#endif

#if DAC_OUTn == 2
    __HAL_LINKDMA(hdac, DMA_Handle2, hdma_dac);
#endif
}
Beispiel #2
0
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
#ifdef TIMn
    if(htim->Instance == TIMx)
    {
        TIMx_CLK_ENABLE();
        HAL_NVIC_SetPriority(TIMx_IRQn, 0xF, 0);
        HAL_NVIC_EnableIRQ(TIMx_IRQn);
    }
#endif
#ifdef ADC_TIMx
    if(htim->Instance == ADC_TIMx)
    {
        ADC_TIMx_CLK_ENABLE();
        HAL_NVIC_SetPriority(ADC_TIMx_IRQn, 0xF, 0);
        HAL_NVIC_EnableIRQ(ADC_TIMx_IRQn);
    }
#endif
#ifdef DAC_TIMx
    if(htim->Instance == DAC_TIMx)
    {
        DAC_TIMx_CLK_ENABLE();
        HAL_NVIC_SetPriority(DAC_TIMx_IRQn, 0xF, 0);
        HAL_NVIC_EnableIRQ(DAC_TIMx_IRQn);
    }
#endif
#ifdef PTP_TIMx
    if(htim->Instance == PTP_TIMx)
    {
        PTP_TIMx_CLK_ENABLE();
        HAL_NVIC_SetPriority(PTP_TIMx_IRQn, 0xF, 0);
        HAL_NVIC_EnableIRQ(PTP_TIMx_IRQn);
    }
#endif
#ifdef DISP_TIMx
    if(htim->Instance == DISP_TIMx)
    {
        DISP_TIMx_CLK_ENABLE();
        HAL_NVIC_SetPriority(DISP_TIMx_IRQn, 0xF, 0);
        HAL_NVIC_EnableIRQ(DISP_TIMx_IRQn);
    }
#endif
#ifdef USB_TIMx
    if(htim->Instance == USB_TIMx)
    {
        USB_TIMx_CLK_ENABLE();
        HAL_NVIC_SetPriority(USB_TIMx_IRQn, 0x5, 0);
        HAL_NVIC_EnableIRQ(USB_TIMx_IRQn);
    }
#endif
}