master1.c
来自「ADuC系列芯片的源代码事例」· C语言 代码 · 共 54 行
C
54 行
/*********************************************************************
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 + =
减小字号Ctrl + -
显示快捷键?