slave.c
来自「ADI公司的ARM7的功能模块的源码」· C语言 代码 · 共 39 行
C
39 行
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Dec. 2005
File : slave.c
Hardware : Applicable to ADuC702x rev H or I silicon
Currently targetting ADuC7026.
Description : SPI slave is to use with master.c or master1.c
the slaves receives values from the master and
keeps transmitting '0' as it is the default value at reset.
*********************************************************************/
#include<ADuC7026.h>
int main(void) {
char i;
char received_data[30];
GP1CON = 0x22220000; // configure SPI on SPM
SPICON = 0x1409; // enable SPI slave mode
for (i=0; i <30; i++) {
while (!(SPISTA & 0x08)) ; // wait for data in the RX MMR
received_data[i] = SPIRX; // read data and clear bit 4 of SPISTA
}
while (1) {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?