我在uart.h中遇到错误,因为标识符字符串是未定义的,请更正 [英] I am getting errors in uart.h as identifier string is undefined can one please correct it

查看:133
本文介绍了我在uart.h中遇到错误,因为标识符字符串是未定义的,请更正的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <lpc21xx.h>
#include <stdio.h>
#include "lcd.h"
#include "uart.h"
void getstring(unsigned char *);

void status_ok(void);
void main(void)
{
	int i,j,k;
 unsigned int cnt=0x80,m;
 char xx , msg[50];
 Serial_Init();
 delay(50);
uart0_init();
initLCD();
 while(1)
 {
 uart0_tx("AT\r"); // AT COMMAND FOR INITIALING
 status_ok();
 uart0_tx("AT+IPR=9600\r"); // AT COMMAND FOR BAUD RATE
 status_ok();
 uart0_tx("AT+CMGR=2\r"); // Reading the message detail
// at Index 1 with phone number, data and time
 status_ok();
 delay(250);
for(i=0;i<50;)
{
msg[i++]= uart0_rx(); // receieving the message and storing it in the array.
}
msg[i]= '\0';

for( i=0,k=j;i<16;i++)
	{
		LCD_Cmd(0x80+i);
		LCD_WriteString(msg);
		
		if(i+j>16)
		{
			k--;
			LCD_Cmd(0x80);
			LCD_WriteString(msg + k);
		}
		delay(1000);
		LCD_Cmd(0x01);
		
	}
}
}

void getstring(unsigned char *array)
{
 unsigned char temp=0, i=0;
 do
 {
 temp = getchar();
 *array++ = temp;
 }
 while((temp != '\r') && (temp != '\n'));
 *array = '\0';

}
void status_ok(void)
{
	unsigned char *y;
	 char *pointr;
 getstring(y);
 while(!(strstr(y,"OK"))) getstring(y);
* pointr = strstr(y,"OK");
 LCD_Cmd(0xc0);
 LCD_WriteString(pointr++);
 LCD_WriteString(pointr);
 delay(500);
 LCD_Cmd(0x01);

}


---------------------------------------------------------------------------------------------------------------------------------

//lcd.h program//
--------------------

#include <lpc214x.h>
//#include <delay.h>

/*
 Connections from LPC2148 to LCD Module:
 P0.0 to P0.7 used as Data bits.
 P1.16 connected to pin4 i.e. RS	- Command / Data
 P1.17 connected to pin6 i.e. E - Enable
 Pin5 of LCD Module i.e. 'R/W' connected to ground
*/	

void initLCD(void);
void enable(void);
void LCD_WriteChar(char c);
void LCD_WriteString(char * string);
void LCD_Cmd(unsigned int cmd);

void initLCD(void)
{
	IO0DIR = 0xFF; //P0.0 to P0.7 configured as Output - Using 8 Bit mode
	IO1DIR |= (1<<16) | (1<<17); //P1.16 and P1.17 configured as Output - Control Pins
	IO0PIN = 0x0; //Reset Port0 to 0.	
	IO1PIN = 0x0; //Reset Port1 to 0 - Which also makes RS and Enable LOW.

	//LCD Initialization Sequence Now starts
  delay(50);//Initial Delay
	LCD_Cmd(0x3C); //Function Set Command : 8 Bit Mode , 2 Rows , 5x10 Font Style
	LCD_Cmd(0x0F); //Display Switch Command : Display on , Cursor on , Blink on
	LCD_Cmd(0x06); //Input Set : Increment Mode 
	LCD_Cmd(0x01); //Screen Clear Command , Cursor at Home
	LCD_Cmd(0x80); //Not required the 1st time but needed to reposition the cursor at home after Clearing Screen 
	//Done!
}

void enable(void)
{
	delay(50);
	IO1PIN |=  (1<<17);//Enable=High
	delay(50);
	IO1PIN &= ~(1<<17);//Enable=Low
	delay(50);
}

void LCD_WriteChar(char c)
{
	IO1PIN |= (1<<16); //Switch to Data Mode
	IO0PIN = (int) c; //Supply Character Code
	enable(); //Pulse Enable to process it
}

void LCD_WriteString(char *str)
{
	int c=0;
	while (str[c]!='\0')
	{
		LCD_WriteChar(str[c]);
		c++;
	}
}
		
void LCD_Cmd(unsigned int cmd)
{
	IO1PIN = 0x0; //Enter Instruction Mode
	IO0PIN = cmd; //Supply Instruction/Command Code
	enable(); //Pulse Enable to process it
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------

//delay.h program//

------------------------



void delay(unsigned int n)
{
 unsigned int i,j;
 for(i=0;i<n;i++)
 {
 for(j=0;j<12000;j++)
 {;}
 }
}



-------------------------------------------------------------------------------------------------------------------------------------------------


//uart.h program//
---------------------



unsigned char uart_rx()
{
unsigned char str;
while(!(U0LSR&0x20));//wait till kbr contains valid data
str=U0RBR;

	return str;
}
void uart0_tx(string a)----------//error identifier 'string' is undefined//
{
U0THR=a;
while(!(U0LSR & 0x26));
}
void uart_string(char*str)
{
while(*str)
uart0_tx(*str++);
}
uart0_init()
{
U0LSR=0x83;
U0DLL=0x61;
U0DLM=0x00;
U0LCR=0x03;
}





我的尝试:



尝试纠正错误。请帮助我们。



What I have tried:

tried correcting errors.please help us.

推荐答案

void uart0_tx(string a)----------//error identifier 'string' is undefined//

字符串不是标准C类型,并且在您的代码中未定义。



看起来这个函数正在传输一个字符。然后

string is not a standard C type and has been nowhere defined in your code.

It looks like the function is transmitting a single character. Then

void uart0_tx(unsigned char a)

应该完成这项工作。


这篇关于我在uart.h中遇到错误,因为标识符字符串是未定义的,请更正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆