diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-09-02 14:45:40 -0400 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-09-02 14:45:40 -0400 |
| commit | e3a880051ccf1ba9a16fd9cf031b7386b2533bf1 (patch) | |
| tree | 96a096b2a668bf7b7929385ebb54c1a3cbd1b9d2 /project/Core/Src/dac.c | |
| parent | 0ff718e7cd7159c30636aa323a666ac1af684f63 (diff) | |
| download | 340-repo-Sowgro-e3a880051ccf1ba9a16fd9cf031b7386b2533bf1.tar.gz 340-repo-Sowgro-e3a880051ccf1ba9a16fd9cf031b7386b2533bf1.tar.bz2 340-repo-Sowgro-e3a880051ccf1ba9a16fd9cf031b7386b2533bf1.zip | |
Organized project
Diffstat (limited to 'project/Core/Src/dac.c')
| -rw-r--r-- | project/Core/Src/dac.c | 83 |
1 files changed, 0 insertions, 83 deletions
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); -} |
