hi there, i have struct with the problem.I'm writing a code for DS12887,And typedef two structures in the header file.It is normal before writing a function. But now the error C141. I am more confused. Ask for The help Header file:
#include <stdio.h> #include <absacc.h> typedef struct { ...... }stTimeStr; typedef struct { ...... }stDsStatus; void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime); void SetClkTime(stTimeStr* stClkTime); void SetAlmTime(stTimeStr* stAlmTime); void GetDSStatus(stDsStatus* stStat);
C Source file:
#include <stdio.h> #include <absacc.h> #include "DS12887.h" void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime) { ...... } void SetClkTime(stTimeStr* stClkTime) { ...... } void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime) { ...... } void GetDSStatus(stDsStatus* stStat) { ...... } void GetDSStatus(stDsStatus* stStat) { ...... }
Sorry,Here is the complete source code: ds12887.h
#include <stdio.h> #include <absacc.h> #include "ComUnit.h" #define RDADDR XBYTE[0xfb04] #define WR1ADDR XBYTE[0xfb01] #define WR0ADDR XBYTE[0xfb00] /************** definitions unique to high-speed micros **************/ //sfr CKCON = 0x8e; /***************************** Defines ********************************/ #define CLK_SECS XBYTE[0xfb00] /* time, date & alarm regs */ #define CLK_SECS_ALM XBYTE[0xfb01] #define CLK_MINS XBYTE[0xfb02] #define CLK_MINS_ALM XBYTE[0xfb03] #define CLK_HRS XBYTE[0xfb04] #define CLK_HRS_ALM XBYTE[0xfb05] #define CLK_DOW XBYTE[0xfb06] #define CLK_DOM XBYTE[0xfb07] #define CLK_MON XBYTE[0xfb08] #define CLK_YR XBYTE[0xfb09] #define REGA XBYTE[0xfb0a] #define REGB XBYTE[0xfb0b] #define REGC XBYTE[0xfb0c] #define REGD XBYTE[0xfb0d] #define CLK_CENTTURY XBYTE[0xfb32] //#define REG4A XBYTE[0xfb4a] //#define REG4B XBYTE[0xfb4b] #define RS2 0x0f #define RS4 0x0e #define RS8 0x0d #define RS16 0x0c #define RS32 0x0b #define RS64 0x0a #define RS128 0x09 #define RS256 0x08 #define RS512 0x07 #define RS1024 0x06 #define RS2048 0x05 #define RS4096 0x04 #define RS8192 0x03 #define VRT 0x80 #define E32K 0x40 #define DVX 0x01 #define C887 0x02 #define VRT_SET 0x04 #define VRT2_SET 0x08 #define VLDMDL 0x10 #define CRCSEROK 0x20 typedef struct { byte_1 ucSECS; byte_1 ucMINS; byte_1 ucHRS; byte_1 ucWEEK; byte_1 ucDAY; byte_1 ucMON; byte_1 ucYR; byte_1 ucCENT; }stTimeStr; typedef struct { byte_1 ucStatsBit; byte_1 ucSeletWord; }stDsStatus; void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime); void SetClockTime(stTimeStr* stClkTime); void SetAlarmTime(stTimeStr* stAlmTime); void GetDSStatus(stDsStatus* stStat);
ds12887.c
#include <stdio.h> /* Prototypes for I/O functions */ #include <absacc.h> /* needed to define xdata addresses */ #include "DS12887.h" #include "ComUnit.h" //Initialization DS12C887 void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime) { REGA = 0xad; REGB = 0xa6; if(stClkTime->ucSECS > 0x80) return; else SetClkTime(stClkTime); if(stAlmTime->ucSECS > 0x80) return; else SetAlmTime(stAlmTime); } //Set Clock Time void SetClkTime(stTimeStr* stClkTime) { } //Set Alarm Time void SetAlmTime(stTimeStr* stAlmTime) { } //Get DS12C887 Status WORD & BIT/ void GetDSStatus(stDsStatus* stStat) { byte_1 uStatus = 0x00; byte_1 ucTemp = 0x00; //Read Select Switch ucTemp = REGA; ucTemp = ucTemp & 0x7f; stStat->ucSeletWord = ucTemp; //Read Status Bit On REG B ucTemp = ucTemp | ((REGB& 0x07)<<1); stStat->ucStatsBit = stStat->ucStatsBit | ucTemp; ucTemp = REGC & 0xf0; //Read Status Bit On REG C stStat->ucStatsBit = ucTemp; }
error C141: syntax error near 'stTimeStr' error C141: syntax error near 'stDsStatus' is there:
typedef struct { byte_1 ucSECS; byte_1 ucMINS; byte_1 ucHRS; byte_1 ucWEEK; byte_1 ucDAY; byte_1 ucMON; byte_1 ucYR; byte_1 ucCENT; }stTimeStr; typedef struct { byte_1 ucStatsBit; byte_1 ucSeletWord; }stDsStatus;