本想做出点东西来后再发表的,不过现实总是残酷的,都一周了还没做出来,没作品分享,就只能分享些资料了。(无奈一下~呵呵)
注:以下隐藏内容为本人废话,为了方便下载资料的朋友,就直接隐藏了~
void MMAWriteByte(uchar Value)
{
uchar i;
MMA_CS=0;
for(i=8;i;--i)
{
MMA_CLK=0;
MMA_IN=Value>>7;
Value<<=1;
MMA_CLK=1;
}
MMA_CS=1;
}uchar MMAReadByte()
{
uchar i,Value;
MMA_CS=0;
for(i=8;i;--i)
{
MMA_CLK=0;
Value<<=1;
MMA_CLK=1;
Value|=MMA_OUT;
}
MMA_CS=1;
return Value;
}uchar MMAReadRegister(uchar Addr)
{
MMAWriteByte((Addr&0x3f)<<1); //Write in the register address with the read command
return MMAReadByte();
}void MMAWriteRegister(uchar Addr, uchar Value)
{
MMAWriteByte((Addr<<1)|0x80); //Write in the register address with the write command
MMAWriteByte(Value);
}void MMAInit()
{
MMA_CS=1;
MMA_CLK=0;
MMAWriteRegister(MMA_MODE_CONTROL,0x05); //4 Wire Mode Set up in the Accelerometer
}
一不小心就写到现在,赶紧睡了,明早还有课~点名概率87%的课哦!
PS:本来帖子命名为“玩MMA7455一周有感(附部分资料)”,写完了却发现还是倒过来比较合适~哈哈!