資源簡(jiǎn)介
利用STM32F103和CS1238實(shí)現(xiàn)4~20mA電流采樣,使用芯海官方提供的驅(qū)動(dòng)結(jié)合STM32的HAL庫設(shè)計(jì),驗(yàn)證可靠運(yùn)行,MCU運(yùn)行72M,兩線IO操作,使用掃描方式檢測(cè),Cs1238使用外部2.5V基準(zhǔn)電壓,pga=1
代碼片段和文件信息
#define?_C_ExtAD
#include?“AppDef.h“
#include?“ExtAD.h“
//輸出:dir?=?1??輸入:dir=0
void?AD_DAT_MODE(u16?dir)
{
??GPIO_InitTypeDef?GPIO_InitStruct?=?{0};
??switch(dir)
??{
??case?0:
????{
??????
???????GPIO_InitStruct.Pin?=?GPIO_PIN_7;
??????GPIO_InitStruct.Mode?=?GPIO_MODE_INPUT;
??????GPIO_InitStruct.Pull?=?GPIO_NOPULL;
??????HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);
??????
??????/*
??????GPIO_InitStruct.Pin?=?GPIO_PIN_7;
??????GPIO_InitStruct.Mode?=?GPIO_MODE_IT_FALLING;
??????GPIO_InitStruct.Pull?=?GPIO_NOPULL;
??????HAL_GPIO_Init(GPIOA?&GPIO_InitStruct);
??????*/
????}
????break;
??case?1:
????{
??????GPIO_InitStruct.Pin?=?GPIO_PIN_7;
??????GPIO_InitStruct.Mode?=?GPIO_MODE_OUTPUT_PP;
??????GPIO_InitStruct.Pull?=?GPIO_NOPULL;
??????GPIO_InitStruct.Speed?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????7195??2020-01-25?19:01??ExtAD.c
?????文件????????1340??2020-01-25?18:45??ExtAD.h
評(píng)論
共有 條評(píng)論