main.c
来自「easyarm2103开发板资料」· C语言 代码 · 共 95 行
C
95 行
/***********************************************Copyright (c)*********************************************
** Guangzou ZLG-MCU Development Co.,LTD.
**
** http://www.zlgmcu.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2007-09-20
** Last Version: 1.0
** Descriptions: The main() function example template
**
**--------------------------------------------------------------------------------------------------------
** Created by:
** Created date:
** Version:
** Descriptions:
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
#include "config.h"
/*********************************************************************************************************
** Function name: main
** Descriptions: 用户主函数,用户写程序需要注意以下几个步骤
** 1.用户要对自己操作的管脚进行管脚功能设置,设置文件为pinConfig.h
** 2.如果用户代码需要中断,需要打开内核中断,函数为:IRQEnable(); FIQEnable();
** 3.用户有中断,需要设置VIC,设置函数请参考IRQManage.h
** 4.其他功能实现用户可参考相关驱动的头文件或使用说明文档
** Input parameters: NONE
** Output parameters: NONE
** Returned value: NONE
*********************************************************************************************************/
void timeDlyUs (uint32 uiDly)
{
uint32 i;
uint32 j;
for(i = 0; i < uiDly; i++) {
for(j = 0; j < 10000; j++);
}
}
/*********************************************************************************************************
** Function name: main
** Descriptions: 用户主函数,用户写程序需要注意以下几个步骤
** 1.用户要对自己操作的管脚进行管脚功能设置,设置文件为pinConfig.h
** 2.如果用户代码需要中断,需要打开内核中断,函数为:IRQEnable(); FIQEnable();
** 3.用户有中断,需要设置VIC,设置函数请参考IRQManage.h
** 4.其他功能实现用户可参考相关驱动的头文件或使用说明文档
** Input parameters: NONE
** Output parameters: NONE
** Returned value: NONE
*********************************************************************************************************/
int main (void)
{
uint8 uctemp[20];
uint32 i;
uint32 j;
IRQEnable(); /* 开中断 */
memset( uctemp, 0, 20);
spiInit(0, "Spiclk=100000 Cpha=0 Cpol=1 Lsbf=0", NULL); /* 初始化SPI */
spiSetCs(0, P0_07);
irqVicSet(SPI0_VIC, 5, spi0Isr); /* 设置SPI的VIC中断 */
spiWrite(0, (uint8*)"123456789", 9, SPI_SAVE_BACK);
/* 写入数据 */
while (spiGetFlag(0, SPI_GET_STATE) == SPI_WRITE); /* 等待SPI写完成 */
spiRead(0, uctemp, 11); /* 在该处设断点监视数据 */
for (i = 0; i < 8; i++) {
spiWrite(0, &uctemp[i+1], 1, SPI_NOSAVE_BACK); /* 使用LED灯测试SPI输出 */
for (j = 0; j < 500000; j++);
}
spiReadStart(0, 10, 0x33);
while (spiGetFlag(0, SPI_GET_STATE) == SPI_READ);
spiRead(0, uctemp, 11); /* 在该处设断点监视数据 */
while (1) {
}
return 0;
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?