Hi Guys,
I mainly write C programs for embedded applications, a few months back with some help from you I wrote a Usart communications program for the NXP LPC1443 that worked quite well.
I am now working with a new uProcessor and using a different IDE/compiler and when porting the program I am getting some errors that I did not get before. I tried to look at the issues but can not understand the errors that the compiler is throwing at me, Hence I need your help. I am sure this is because I am missing some C knowledge so please fell free to send me some links related to the subject.
Here is the header file that is giving me the errors:
Code:
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BUFFERSTORE_H
#define __BUFFERSTORE_H
#define NUMBEROFBUFFERS 20
/*MultiBuffer Definition
* This is the work horse of this program. it defines
* storage for either data for processing, packet for
* transmission or just received and also the raw data for
* physical medium
* These definition by using the union construct will allow
* for easier data manipulation.
*/
typedef volatile union
{
struct
{
/* For data storage can be used for everything (TX or RX) */
char processNumber; /* will probably id the task that needs the data */
//char pNumberB; /* Packet number binary (one byte) */
char dataSize; /* number of bytes(max 10) */
char data[10]; /* Data bytes */
}dataS; /* Data structure */
struct
{
/* For Packet Storage can be used for RX or TX
All values have been translated to Hex ASCII
Hence the need for Two bytes in most cases. */
char pStartChar; //Start char normally (
char pTypeChar; //Packet Type 1 to F
char pNumberH[2]; //packet number in Hex 00 to FF
char pDSize[2]; //packet size in Hex
char pChecksum[2]; //packet checksum
char pData[20]; //packet Data
char pEndChar; //End char normally )
char pSize;
}packetS; // Packet structure
struct
{
//for Packet Storage after Hex Ascii to binary conversion
// may not be needed can be used for RX or TX
//All values have been translated to Binary values
char pStartChar; //Start char normally (
char pTypeChar; //Packet Type 1 to F
char pNumber; //packet number in Hex 00 to 255
char pDSize; //packet size
char pChecksum; //packet checksum 00 to FF
char pData[10]; //packet Data
char pEndChar; //End char normally )
//for raw hex data
char rBuffer[30]; // this buffer is defined for ease of use by the UART
}MultiBuffer;
/* --------------------------------------------------------------------------- */
/* Queue Handling */
/* The Element as two parts, the payload or data part
and a pointer to the next Element, hence it can be used to
implement a linked list. */
typedef volatile struct Element Element; /* This is required to let the compiler know
that the struct Element is te same as the Element
or it will generate an "incomplete" definition error. */
struct Element
{
MultiBuffer *payload;
volatile struct Element *nextElement;
};
/* To implement a queue de only thing you need really is to know where the Head of
the Queue and its tail is. By then accessing the elements they will let you know
where the others are. */
volatile typedef struct
{
volatile Element *head;
volatile Element *tail;
}Queue;
/* ------------------------------------------------------------------------------------*/
volatile Queue *createQueue(void);
void createQueues(void);
volatile Queue *addElementToQueue(volatile Queue *queue, volatile MultiBuffer *bufferPrt);
volatile MultiBuffer *getElementFromQueue(volatile Queue *queue);
#endif /* __BUFFERSTORE_H */
On this line...
Code:
/* The Element as two parts, the payload or data part and a pointer to the next Element, hence it can be used to implement a linked list. */ typedef volatile struct Element Element; /* This is required to let the compiler know that the struct Element is the same as the Element or it will generate an "incomplete" definition error. */
I get errors:
.\inc\bufferStore.h(98): error: #70: incomplete type is not allowed
and
.\inc\bufferStore.h(98): error: #80: a storage class may not be specified here
On this part of the code:
Code:
struct Element
{ MultiBuffer *payload;
volatile struct Element *nextElement;
};
I get erros:
.\inc\bufferStore.h(104): error: #20: identifier "MultiBuffer" is undefined
and
.\inc\bufferStore.h(106): warning: #40-D: expected an identifier
The other errors are similar, if can find out what the problem is I can fix the rest.
Thank you in advance for any help.
Best Regards
Luis