首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

SPI 源码解决思路

2012-03-26 
SPI 源码急求获得摩托罗拉serial peripheral interface(SPI)DEMO源码的方法,谢谢在线等啊[解决办法]这个看

SPI 源码
急求获得摩托罗拉serial peripheral interface(SPI)DEMO源码的方法,谢谢
在线等啊

[解决办法]
这个看你用得着么

#include "mc9s08gt32.h"

/******************************************************************************
 * Function: SpiInit
 *
 * PreCondition: None .
 *
 * Input: None .
 *
 * Output: None . 
 *
 * Side Effects: None
 *
 * Overview: SpiInit initialized the SPI bus . 
 *
 * Note: None
 *****************************************************************************/
void SpiInit(void)
{
SPI1C1_CPHA = 0;
SPI1C1_MSTR = 1;
SPI1C1_SPE = 1; //Enable SPI bus .

SPI1BR = 0x00;
}

/******************************************************************************
 * Function: SpiTransfer
 *
 * PreCondition: SPI bus must be initialized .
 *
 * Input: The Byte will be transferred .
 *
 * Output: The Byte Received simultaneous . 
 *
 * Side Effects: None
 *
 * Overview: SpiTransfer is a basic SPI operation ,it transfer a Byte and 
 * Receive a Byte simultanous.
 *
 * Note: None
 *****************************************************************************/
unsigned char SpiTransfer(unsigned char C)
{
while(SPI1S_SPTEF == 0);
SPI1D = C;
while(SPI1S_SPRF == 0);
return SPI1D;
}


[解决办法]
在对应芯片的SPEC里面都会有讲怎么访问的呀.

热点排行