找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 614|回复: 1
打印 上一主题 下一主题
收起左侧

warning C206: 'DELAY_MS': missing function-prototype

[复制链接]
跳转到指定楼层
楼主
ID:1081248 发表于 2023-5-31 23:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示这个错误怎么办?
#include <reg51.h>

#define DISP_PORT P1     // ???????
#define DISP_DATA P2     // ???????

#define NORTH_GREEN_TIME 54  // ??????
#define NORTH_YELLOW_TIME 3  // ??????
#define NORTH_RED_TIME 40    // ??????
#define EAST_GREEN_TIME 34   // ??????
#define EAST_YELLOW_TIME 3   // ??????
#define EAST_RED_TIME 60     // ??????
#define EMERGENCY_TIME 99    // ??????
sbit NORTH_GREEN_LED = P0^0;   // ????
sbit NORTH_YELLOW_LED = P0^1;  // ????
sbit NORTH_RED_LED = P0^2;     // ????
sbit EAST_GREEN_LED = P0^3;    // ????
sbit EAST_YELLOW_LED = P0^4;   // ????
sbit EAST_RED_LED = P0^5;      // ????
sbit KEY1 = P3^0;              // ??????
sbit KEY2 = P3^1;              // ??????

unsigned char north_time_left = 60;  // ????????
unsigned char east_time_left = 40;   // ????????
unsigned char emergency_time_left = EMERGENCY_TIME;  // ????????
unsigned char disp_buf[2];   // ???????,????????

// ???????
void display(unsigned char num)
{
    unsigned char i;
    DISP_PORT = 0xFE;   // ???????
    for (i = 0; i < 8; i++) {
        DISP_DATA = num % 10;   // ???
        num /= 10;              // ???
        DISP_PORT = DISP_PORT << 1;  // ??
        DELAY_MS(1);            // ??????
    }
}

// ????????,?????
void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    for (i = 0; i < ms; i++) {
        for (j = 0; j < 114; j++) {}  // ??????,??1ms
    }
}

// ??????????
void north_green()
{
    north_time_left = NORTH_GREEN_TIME;
    while (north_time_left > 0) {
        if (north_time_left <= 3) {
            // ??????
            NORTH_GREEN_LED = ~NORTH_GREEN_LED;
            delay_ms(500);
            NORTH_GREEN_LED = 1;
            delay_ms(500);
        } else {
            // ??????
            NORTH_GREEN_LED = 1;
            delay_ms(1000);
        }
        north_time_left--;
    }
}

// ??????????
void north_red()
{
    north_time_left = NORTH_RED_TIME;
    NORTH_GREEN_LED = 0;
    NORTH_YELLOW_LED = 0;
    NORTH_RED_LED = 1;
    delay_ms(NORTH_YELLOW_TIME * 1000);
    NORTH_RED_LED = 0;
    NORTH_YELLOW_LED = 1;
    delay_ms(NORTH_YELLOW_TIME * 1000);
    NORTH_YELLOW_LED = 0;
    while (north_time_left > 0) {
        NORTH_RED_LED = 1;
        delay_ms(1000);
        north_time_left--;
    }
}

// ??????????
void east_green()
{
    east_time_left = EAST_GREEN_TIME;
    while (east_time_left > 0) {
        if (east_time_left <= 3) {
            // ??????
            EAST_GREEN_LED = ~EAST_GREEN_LED;
            delay_ms(500);
            EAST_GREEN_LED = 1;
            delay_ms(500);
        } else {
            // ??????
            EAST_GREEN_LED = 1;
            delay_ms(1000);
        }
        east_time_left--;
    }
}

// ??????????
void east_red()
{
    east_time_left = EAST_RED_TIME;
    EAST_GREEN_LED = 0;
    EAST_YELLOW_LED = 0;
    EAST_RED_LED = 1;
    delay_ms(EAST_YELLOW_TIME * 1000);
    EAST_RED_LED = 0;
    EAST_YELLOW_LED = 1;
    delay_ms(EAST_YELLOW_TIME * 1000);
    EAST_YELLOW_LED = 0;
    while (east_time_left > 0) {
        EAST_RED_LED = 1;
        delay_ms(1000);
        east_time_left--;
    }
}

// ????????
void emergency()
{
    north_time_left = 0;
    east_time_left = 0;
    emergency_time_left = EMERGENCY_TIME;
    display(99);  // ??????"99"
    while (emergency_time_left > 0) {
        if (emergency_time_left <= 3) {
            // ??????
            EAST_GREEN_LED = ~EAST_GREEN_LED;
            delay_ms(500);
            EAST_GREEN_LED = 1;
            delay_ms(500);
        } else {
            // ??????
            EAST_GREEN_LED = 1;
            delay_ms(1000);
        }
        emergency_time_left--;
    }
    EAST_GREEN_LED = 0;
    EAST_YELLOW_LED = 0;
    EAST_RED_LED = 1;
    delay_ms(EAST_YELLOW_TIME * 1000);
    EAST_RED_LED = 0;
    EAST_YELLOW_LED = 1;
    delay_ms(EAST_YELLOW_TIME * 1000);
    EAST_YELLOW_LED = 0;
}

int main()
{
    while (1) {
        // ??????
        north_green();
        north_red();

        // ??????
        east_red();
        east_green();

        // ??????
        if (KEY1 == 0) {
            emergency();
        }
        if (KEY2 == 0) {
            north_time_left = 60;
            east_time_left = 40;
        }

        // ??????
        disp_buf[0] = north_time_left / 10;
        disp_buf[1] = north_time_left % 10;
        display(disp_buf[0] * 10 + disp_buf[1]);  // ????????
        delay_ms(1000);

        disp_buf[0] = east_time_left / 10;
        disp_buf[1] = east_time_left % 10;
        display(disp_buf[0] * 10 + disp_buf[1]);  // ????????
        delay_ms(1000);
    }
    return 0;
}


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:213173 发表于 2023-6-1 05:52 | 只看该作者
DELAY_MS函数名大小写不一致,void delay_ms函数要放在void display函数上面。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表