生活随笔
收集整理的這篇文章主要介紹了
DAC8812驱动
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
DAC8812驅(qū)動(dòng)
#include "dac8812.h"
#include "delay.h"
#include "includes.h"
#include "sys.h"
void DAC8812_Init(void)
{GPIO_InitTypeDef GPIO_Initure
;__HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_Initure
.Pin
= GPIO_PIN_10
| GPIO_PIN_11
| GPIO_PIN_12
| GPIO_PIN_13
| GPIO_PIN_15
; GPIO_Initure
.Mode
= GPIO_MODE_OUTPUT_PP
; GPIO_Initure
.Pull
= GPIO_PULLUP
; GPIO_Initure
.Speed
= GPIO_SPEED_FREQ_HIGH
; HAL_GPIO_Init(GPIOB
, &GPIO_Initure
);HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_10
| GPIO_PIN_12
, GPIO_PIN_SET
); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_11
, GPIO_PIN_RESET
);
}void DAC8812_UpdateOutput(uint32_t TxData
)
{OS_CPU_SR cpu_sr
= 0;uint8_t i
= 0;OS_ENTER_CRITICAL(); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_10
| GPIO_PIN_11
, GPIO_PIN_SET
); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_12
, GPIO_PIN_RESET
); for (i
= 0; i
< 18; i
++){HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_13
, GPIO_PIN_RESET
); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_15
, (GPIO_PinState
)((TxData
>> (17 - i
)) & GPIO_PIN_SET
)); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_13
, GPIO_PIN_SET
); }HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_13
, GPIO_PIN_RESET
); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_12
, GPIO_PIN_SET
); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_10
, GPIO_PIN_RESET
); HAL_GPIO_WritePin(GPIOB
, GPIO_PIN_10
, GPIO_PIN_SET
); OS_EXIT_CRITICAL();
}
#ifndef __ADC8812_H__
#define __ADC8812_H__
#include "sys.h"
void DAC8812_Init(void);
void DAC8812_UpdateOutput(uint32_t TxData
);#endif
總結(jié)
以上是生活随笔為你收集整理的DAC8812驱动的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。