From e3a880051ccf1ba9a16fd9cf031b7386b2533bf1 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 2 Sep 2025 14:45:40 -0400 Subject: Organized project --- project/Core/Src/dac.c | 83 -------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 project/Core/Src/dac.c (limited to 'project/Core/Src/dac.c') diff --git a/project/Core/Src/dac.c b/project/Core/Src/dac.c deleted file mode 100644 index e03f9ce..0000000 --- a/project/Core/Src/dac.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * dac.c - * - * Created on: Apr 13, 2022 - * Author: bruce - */ - -#include "dac.h" -#include "main.h" -#include "stm32l4xx.h" - -DAC_HandleTypeDef hdac1; - -/** -* @brief DAC MSP Initialization -* This function configures the hardware resources used in this example -* @param hdac: DAC handle pointer -* @retval None -*/ -void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hdac->Instance==DAC1) - { - __HAL_RCC_DAC1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - GPIO_InitStruct.Pin = GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - } - -} - -/** -* @brief DAC MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hdac: DAC handle pointer -* @retval None -*/ -void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) -{ - if(hdac->Instance==DAC1) - { - __HAL_RCC_DAC1_CLK_DISABLE(); - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4); - } - -} - -void DAC_Init () { - DAC_ChannelConfTypeDef sConfig = {0}; - - /** DAC Initialization - */ - hdac1.Instance = DAC1; - if (HAL_DAC_Init(&hdac1) != HAL_OK) - { - Error_Handler(); - } - - /** DAC channel OUT1 config - */ - sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; - sConfig.DAC_Trigger = DAC_TRIGGER_NONE; - sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; - sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; - sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; - - if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) - { - Error_Handler(); - } -} - -void DAC_Start () { - HAL_DAC_Start (&hdac1, DAC_CHANNEL_1); -} - -void DAC_Set_Value (uint32_t value) { - HAL_DAC_SetValue (&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, value); -} -- cgit v1.2.3