无法向LCD发送信息

时间:2015-07-09 17:53:55

标签: avr atmel avrdude atmelstudio

我在其中一个youtube教程中学习了这段代码,我无法向LCD发送信息,程序显示错误,我一直得到的错误是

Initializing argument 1 of 'void Send_A_String(char*)' [-fpermissive]
initializing argument 3 of 'void Send_An_IntegerToMrLCD(uint8_t, uint8_t, int, char)' [-fpermissive]
invalid conversion from 'char' to 'char*' [-fpermissive]
invalid conversion from 'char*' to 'int' [-fpermissive]

以下是LCD的头文件 - MrLCD.h

#ifndef MrLCD
#define MrLCD

#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>

#define MrLCDsCrib PORTB
#define DataDir_MrLCDsCrib DDRB
#define MrLCDsControl PORTD
#define DataDir_MrLCDsControl DDRD
#define LightSwitch 5
#define ReadWrite 7
#define BiPolarMood 2

char firstColumnPositionsForMrLCD[4] = {0, 64, 20, 84};

void Check_IF_MrLCD_isBusy(void);
void Peek_A_Boo(void);
void Send_A_Command(unsigned char command);
void Send_A_Character(unsigned char character);
void Send_A_String(char *StringOfCharacters);
void initializeMrLCD(void);
void GotoMrLCDsLocation(uint8_t x, uint8_t y);
void Send_A_StringToMrLCDWithLocation(uint8_t x, uint8_t y, char *StringOfCharacters);
void Send_An_IntegerToMrLCD(uint8_t x, uint8_t y, int IntegerToDisplay, char NumberOfDigits);


void Check_IF_MrLCD_isBusy()
{
    DataDir_MrLCDsCrib = 0;
    MrLCDsControl |= 1<<ReadWrite;
    MrLCDsControl &= ~1<<BiPolarMood;

    while (MrLCDsCrib >= 0x80)
    {
        Peek_A_Boo();
    }

    DataDir_MrLCDsCrib = 0xFF;
}
void Peek_A_Boo()
{
    MrLCDsControl |= 1<<LightSwitch;
    asm volatile ("nop");
    asm volatile ("nop");
    MrLCDsControl &= ~1<<LightSwitch;
}

void Send_A_Command(unsigned char command)
{
    Check_IF_MrLCD_isBusy();
    MrLCDsCrib = command;
    MrLCDsControl &= ~ ((1<<ReadWrite)|(1<<BiPolarMood));
    Peek_A_Boo();
    MrLCDsCrib = 0;
}

void Send_A_Character(unsigned char character)
{
    Check_IF_MrLCD_isBusy();
    MrLCDsCrib = character;
    MrLCDsControl &= ~ (1<<ReadWrite);
    MrLCDsControl |= 1<<BiPolarMood;
    Peek_A_Boo();
    MrLCDsCrib = 0;
}

void Send_A_String(char *StringOfCharacters)
{
    while(*StringOfCharacters > 0)
    {
        Send_A_Character(*StringOfCharacters++);
    }
}

void initializeMrLCD()
{
    DataDir_MrLCDsControl |= 1<<LightSwitch | 1<<ReadWrite | 1<<BiPolarMood;
    _delay_ms(15);

    Send_A_Command(0x01); //Clear Screen 0x01 = 00000001
    _delay_ms(2);
    Send_A_Command(0x38);
    _delay_us(50);
    Send_A_Command(0b00001110);
    _delay_us(50);
}

void GotoMrLCDsLocation(uint8_t x, uint8_t y)
{
    Send_A_Command(0x80 + firstColumnPositionsForMrLCD[y-1] + (x-1));
}

void Send_A_StringToMrLCDWithLocation(uint8_t x, uint8_t y, char *StringOfCharacters)
{
    GotoMrLCDsLocation(x, y);
    Send_A_String(*StringOfCharacters);
}

void Send_An_IntegerToMrLCD(uint8_t x, uint8_t y, int IntegerToDisplay, char NumberOfDigits)
{
    char StringToDisplay[NumberOfDigits];
    itoa(IntegerToDisplay, StringToDisplay, 10);
    Send_A_StringToMrLCDWithLocation(x, y, StringToDisplay); 
    Send_A_String(" ");
}

#endif

在主文件中最简单的程序中,如果我尝试在头文件中调用这些函数,如Send_A_StringToMrLCDWithLocation或Send_An_IntegerToMrLCD ......程序显示错误......

2 个答案:

答案 0 :(得分:0)

您需要将所有这些代码移动到C文件中,即MrLCD.c,因为这是代码实例化的地方。

答案 1 :(得分:0)

您没有将.c文件包含在您调用这些函数的位置,但是错误似乎表明您正在使用错误类型的变量调用函数。

您使用void Send_A_String(char*)而不是指向字符串的指针调用char

您使用char指针(字符串)而不是第三个参数中的int调用void Send_An_IntegerToMrLCD(uint8_t, uint8_t, int, char)