📄 master1.c
字号:
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Dec. 2005
File : master1.c
Hardware : Applicable to ADuC702x rev H or I silicon
Currently targetting ADuC7026.
Description : SPI master to demonstrate with slave.c or slave1.c
*********************************************************************/
#include<ADuC7026.h>
void My_IRQ_Function(void); // IRQ Funtion Prototype
int i = 0;
int main(void) {
IRQ = My_IRQ_Function;
GP4DAT = 0x04000000; // P4.2 configured as an output. LED is turned on
IRQEN = SPI_MASTER_BIT;
GP1CON = 0x22220000; // configure SPI on SPM
SPIDIV = 0xCC; // set SPI clock 40960000/(2x(1+SPIDIV))
// 0xCC = 100kHz
SPICON = 0x104B; // enable SPI master in continuous transfer mode
// slave select will stay low during the all transmission
while (1){
}
}
/********************************************************************/
/* */
/* Interrupt Service Rountine */
/* */
/********************************************************************/
void My_IRQ_Function() {
GP4DAT ^= 0x00040000; // Complement P4.2
if ((IRQSTA & SPI_MASTER_BIT) != 0) {
SPITX = i;
i++;
if (i==30) IRQCLR = SPI_MASTER_BIT;
}
return ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -