NIOS II错误:整数常量后缀无效

时间:2014-12-05 17:35:57

标签: c audio sd-card nios

所以我一直在DE2-155主板上制作SD卡音乐播放器。我终于完成了硬件并且已经进入C编码以完成它。但是,在我构建项目之前,我不断收到错误:"无效后缀" 0b00100000"在整数常量上。"

这是我的C代码:

#include <io.h>
#include <system.h>

#include "altera_up_avalon_audio_and_video_config.h"
#include "altera_up_avalon_audio.h"

#define SD_CARD_OFFSET_RXTX 0
#define SD_CARD_OFFSET_CMD  560
#define SD_CARD_OFFSET_CMD_ARG  556
#define SD_CARD_OFFSET_ASR  564

#define SD_CONNECTED        0x02
#define SD_COMPLETE     0x04
#define SD_BLOCK_SIZE       512
#define SD_CMD_READ     0x11

int main()
{
    int *sd_asr = (int *)(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_BASE + SD_CARD_OFFSET_ASR);
    short int sd_status;
    int res;
    int sector_count, byte_count;
    unsigned int l_buff,r_buff;

alt_up_av_config_dev* cfg_dev;
alt_up_audio_dev* audio_dev;

/* Wait for SD-Card */

printf("Wait for SD-Card to be connected...\n");

do{
    sd_status=(short int)IORD_16DIRECT(sd_asr,0);
}while((sd_status & SD_CONNECTED) == 0);

printf("SD-Card connected.\n");

/* Initialize CFG/Audio Device */

cfg_dev=alt_up_av_config_open_dev("/dev/audio_and_video_config_0");

if(cfg_dev == NULL){
    printf("Config device not found.\n");
}else{
    printf("Config device opened for configuration.\n");
}

printf("Resetting config device and peripherals...\n");

res = alt_up_av_config_reset(cfg_dev);

alt_up_av_config_write_audio_cfg_register(cfg_dev,0x08,0b00100000);

if(res == 0){
    printf("Reset successful.\n");
}else{
    printf("Reset failed.\n");
}

/* Play Music */

audio_dev = alt_up_audio_open_dev("/dev/audio_0");

if(audio_dev == NULL){
    printf("Failed to open audio device.\n");
}else{
    printf("Audio device opened.\n");
}

printf("Starting playback!\n");

sector_count=0;
while(1)
{
    /* Read 512B sector from SD-Card */
    IOWR_32DIRECT(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_BASE,SD_CARD_OFFSET_CMD_ARG,sector_count*512);
    IOWR_16DIRECT(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_BASE,SD_CARD_OFFSET_CMD,SD_CMD_READ);
    do{
        sd_status=(short int)IORD_16DIRECT(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_BASE,SD_CARD_OFFSET_ASR);
    }while((sd_status & SD_COMPLETE) != 0);

    byte_count=0;
    while(byte_count < 512){
        l_buff = (unsigned int)IORD_16DIRECT(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_BASE,SD_CARD_OFFSET_RXTX+byte_count);
        r_buff = (unsigned int)IORD_16DIRECT(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_BASE,SD_CARD_OFFSET_RXTX+(byte_count+2));
        byte_count+=4;
        while(alt_up_audio_write_fifo_space(audio_dev,ALT_UP_AUDIO_RIGHT) < 4){ asm("NOP"); }
            alt_up_audio_write_fifo (audio_dev, &(r_buff), 1, ALT_UP_AUDIO_RIGHT);
            alt_up_audio_write_fifo (audio_dev, &(l_buff), 1, ALT_UP_AUDIO_LEFT);
        }

        sector_count++;
    }

    return 0;
}

1 个答案:

答案 0 :(得分:1)

错误在线

alt_up_av_config_write_audio_cfg_register(cfg_dev,0x08,0b00100000);

0b00100000 是整数值。如果整数值以 0 开头,则下一个字符必须是 x 才能将整数表示为十六进制数,或者它将被解释为{{3} }。八进制数只能有0到7的数字。

0b00100000 是二进制,十进制 32 或十六进制 0x20

另见octal number

只有具有已启用GCC扩展名的GCC才支持 0b00100000 等二进制表示法。