📄 hello_world.c
字号:
/*
* C Code for a simple application
*
* This code prints a user specified message using the embedded uart
* as stdin / stdout.
* When combined with the appropriate pld files, this software is
* programmed into flash using the JTAG and flash interface.
*
* It tests the UART by outputting information
* over the UART at a baud rate of 38400 with 8 bits per
* character no parity and one stop bit, with no flow control.
* You must connect a serial terminal to the board to control this.
*
* It tests the address and data lines of the flash memory
* For this simple application, no logic exists in the PLD.
*
* Using the associated make_hello.bat file validates the
* embedded software tool chain for compiling, linking and creating
* flash downloadable images.
*
* Copyright (c) Altera Corporation 2001.
* All rights reserved.
*/
#include <stdio.h>
#include "uartcomm.h"
#include "stripe.h"
#include "flash.h"
void EnableIRQ(void);
void Scroll_PLD(void);
void delay(unsigned int);
volatile unsigned int * LED;
int main(void)
{
LED = (volatile unsigned int*) EXC_PLD_BLOCK0_BASE;
uart_init();
EnableIRQ(); // Enable processor interrupts
write_flash_value((unsigned short*)EXC_EBI_BLOCK0_BASE, 0xFFFF);//Writes to flash to reset the boot parameters.
//The websever will run after the board is reset
printf("\r\nAltera Excalibur Development Board\r\n");
printf("Look for scrolling LEDs\r\n");
while (1)
Scroll_PLD();
}
void Scroll_PLD(void)
{
int i;
*LED = 0x00;
for(i = 0; i < 8; i++)
{
*LED = 0x01 << i;
delay(1000000);
printf("LED = 0x%x\r\n", *LED);
}
*LED = 0x00;
for(i = 0; i < 8; i++)
{
*LED = 0x80 >> i;
delay(1000000);
printf("LED = 0x%x\r\n", *LED);
}
*LED = 0x00;
}
void delay(unsigned int time)
{
volatile int i;
for(i = 0; i < time; i++);
}
void CAbtHandler(void)
{
printf("Data abort\r\n");
}
void CPabtHandler(void)
{
printf("Error prefetch abort\r\n");
}
void CDabtHandler(void)
{
printf("Error data abort\r\n");
}
void CSwiHandler(void)
{
printf("Error swi\r\n");
}
void CUdefHandler(void)
{
printf("Error undefined instruction\r\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -