📄 cpld_read.c
字号:
#include "Cpld_Read.h"
#include <macros.h>
int Cpld_Read(unsigned char Address)
{
unsigned char temp;
int Result;
CLI();
if(Address) //Address select
PORTB|=BIT(A0);
else
PORTB&=~BIT(A0);
PORTB|=BIT(LoadL); //LoadL set low
NOP();
NOP();
PORTB&=~BIT(LoadL);
NOP();
NOP();
NOP();
temp=CpldRead; //Read Data low byte
temp=CpldRead;
PORTB|=BIT(LoadL); //Set LoadL high
PORTB|=BIT(LoadH); //LoadH set low
NOP();
NOP();
PORTB&=~BIT(LoadH);
NOP();
NOP();
NOP();
Result=CpldRead; //Read Data low byte
Result=CpldRead;
PORTB|=BIT(LoadH); //LoadH set high
Result=(Result<<8)+temp;
SEI();
return Result;
}
void Cpld_Set(void)
{
CLI(); //Set all the counters reset
PORTB|=BIT(Set); //Zero
NOP();
NOP();
PORTB&=~BIT(Set);
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
PORTB|=BIT(Set);
SEI();
}
void Cpld_Init(void)
{
PORTB|=BIT(Set); //Set All Control signal high
PORTB|=BIT(LoadL);
PORTB|=BIT(LoadH);
PORTB&=~BIT(LoadL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -