main.c
来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 64 行
C
64 行
#include <stdio.h>
#include <string.h>
#include <intrinsics.h>
#include "timer.h"
#include "tms470.h"
#ifdef R1VFA384
#include <TexasInstruments/iotms470r1a384.h>
#else
#include <TexasInstruments/iotms470r1a256.h>
#endif
// LED moving pattern codes.
static int led_table[] = {
0x1818, 0x3c3c, 0x7e7e, 0xffff, 0xe7e7, 0xc3c3, 0x8181, 0x4242, 0x2424, -1
};
int main(void)
{
// Set up peripheral registers.
// First disable interrupts.
__disable_interrupt();
// Setup system.
TMS470SystemInit();
// Setup ports.
TMS470InitPIO();
// Setup interrupt controller.
TMS470InitInterrupt(TimerBeat);
// Periodic timer initialization.
TMS470InitTimer();
// Enable interrupts.
__enable_interrupt();
// Start periodic timer.
TMS470StartTimer();
// Initial LED pattern.
TMS470LedSet(0x18);
// Display pattern for 1 second.
Sleep(1000);
// Next LED pattern.
TMS470LedSet(0xc3);
// Display pattern for 1 second.
Sleep(1000);
// Loop forever.
for (;;)
{
int *ip;
// Loop over all LED patterns in table.
for (ip = led_table; *ip != -1; ip++)
{
// Update LEDs.
TMS470LedSet(*ip);
// Wait 75 ms to show pattern for some time.
Sleep(75);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?