mayo20102012 发表于 2013-11-7 15:55:39

NIOSii 软件设计碰到一个问题

额 这是第一次接触这个,我按照网上的教程配置了一个CPU点亮LED,以下是程序:
/*
* "Hello World" example.
*
* This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
* the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
* designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
* device in your system's hardware.
* The memory footprint of this hosted application is ~69 kbytes by default
* using the standard reference design.
*
* For a reduced footprint version of this template, and an explanation of how
* to reduce the memory footprint for a given application, see the
* "small_hello_world" template.
*
*/
#include "stdio.h"
#include "unistd.h"
#include "system.h"

#define _LED 1

typedef struct
{
    unsigned long int DATA;
    unsigned long int DIRECTION;
    unsigned long int INTERRUPT_MASK;
    unsigned long int EDGE_CAPTURE;
}PIO_STR;

#ifdef _LED
#define LED((PIO_STR *)PIO_LED_BASE)
#endif

int main()
{
    int i;
    while(1)
    {
      for(i=0;i<8;i++){
            LED->DATA=1<<i;
            usleep(50000);
      }
    }
    return 0;
}

但在编译时 提示 LED没有定义?求高手解答!

mitchell 发表于 2013-11-7 16:08:03

“#define LED((PIO_STR *)PIO_LED_BASE)”中,“#define LED"和”((PIO_STR *)PIO_LED_BASE)“之间没有空格吗?
像这样:#define LED ((PIO_STR *)PIO_LED_BASE)

mayo20102012 发表于 2013-11-8 08:45:15

mitchell 发表于 2013-11-7 16:08 static/image/common/back.gif
“#define LED((PIO_STR *)PIO_LED_BASE)”中,“#define LED"和”((PIO_STR *)PIO_LED_BASE)“之间没有空 ...

额。谢谢你啊了,笔误啊。,。。。

zwham 发表于 2013-12-15 10:21:28

我也遇到了同样的问题!都是新手啊{:lol:}
页: [1]
查看完整版本: NIOSii 软件设计碰到一个问题