port_pin.h
#ifndef __PORT_PIN_H__
#define __PORT_PIN_H__
typedef enum
{
IO_PORT_A = ((uint16_t)0), /* IO Port A Selected */
IO_PORT_B = ((uint16_t)1), /* IO Port B Selected */
IO_PORT_NONE = ((uint16_t)0xFF) /* No IO Port Selected */
}PortName_t;
/* IO Driver GPIO Pin Numbers */
typedef enum
{
IO_PIN_0 = ((uint16_t)0), /* Pin 0 selected */
IO_PIN_1 = ((uint16_t)1), /* Pin 1 selected */
IO_PIN_2 = ((uint16_t)2), /* Pin 2 selected */
IO_PIN_3 = ((uint16_t)3), /* Pin 3 selected */
}PinNumber_t;
hal_io.h
#ifndef __HAL_IO_H__
#define __HAL_IO_H__
#ifdef DEF_HAL_IO
#define EXTERN_HAL_IO
#else
#define EXTERN_HAL_IO extern
#endif
EXTERN_HAL_IO void HalIo_fct(PortName_t, PinNumber_t);
#endif
drv_io.h
#ifndef __DRV_IO_H__
#define __DRV_IO_H__
#ifdef DEF_DRV_IO
#define EXTERN_DRV_IO
#else
#define EXTERN_DRV_IO extern
#endif
EXTERN_DRV_IO Status_t DDrvIOPinSet_fct(const BoardCfgPortPin_t *pointer);
#endif
board_cfg.h
#ifndef __BOARD_CFG_H__
#define __BOARD_CFG_H__
#ifdef DEF_BOARD_CFG
#define EXTERN_BOARD_CFG
#else
#define EXTERN_BOARD_CFG extern
#endif
/* IO driver Gpio Port and Pin Configuration */
typedef struct
{
PortName_t Name_en; /* Specifies the IO Port module */
/* This parameter can be a value of @ref */
/* GpioPort_t */
PinNumber_t PinNo_en; /* Specifies the IO Pin number */
/* This parameter can be a value of @ref */
/* PinNumber_t */
}BoardCfgPortPin_t;
EXTERN_BOARD_CFG const BoardCfgPortPin_t BoardCfgPortPin_sta[4];
EXTERN_BOARD_CFG void BoardCfg_fct();
#endif
main.c
#include <stdio.h>
#include "common.h"
#include "port_pin.h"
#include "board_cfg.h"
#include "drv_io.h"
int main()
{
BoardCfg_fct();
printf("\n\n");
return 0;
}
hal_io.c
#define DEF_HAL_IO
#include <stdio.h>
#include "common.h"
#include "port_pin.h"
#include "hal_io.h"
void HalIo_fct(PortName_t PortName_en, PinNumber_t PinNo_en)
{
printf("\nIN HAL\n");
printf("PORTNAME : %d, PIN NUMBER : %d", PortName_en, PinNo_en);
}
drv_io.c
#define DEF_DRV_IO
#include <stdio.h>
#include "common.h"
#include "port_pin.h"
#include "hal_io.h"
#include "board_cfg.h"
#include "drv_io.h"
Status_t DDrvIOPinSet_fct(const BoardCfgPortPin_t *pointer)
{
printf("\nin DRV IO \n");
HalIo_fct(pointer->Name_en, pointer->PinNo_en);
return (PASS);
}
board_cfg.c
#define DEF_BOARD_CFG
#include <stdio.h>
#include "common.h"
#include "port_pin.h"
#include "drv_io.h"
#include "board_cfg.h"
const BoardCfgPortPin_t BoardCfgPortPin_sta[4] =
{
{ IO_PORT_B, IO_PIN_0 }, /* SENSE_INV_TEMP */
{ IO_PORT_B, IO_PIN_1 }, /* SENSE_INV_AC */
{ IO_PORT_B, IO_PIN_2 }, /* BUZZER */
{ IO_PORT_B, IO_PIN_3 }, /* STAUS_230V_AC */
};
void BoardCfg_fct()
{
DDrvIOPinSet_fct(&BoardCfgPortPin_sta[0]);
DDrvIOPinSet_fct(&BoardCfgPortPin_sta[1]);
DDrvIOPinSet_fct(&BoardCfgPortPin_sta[2]);
DDrvIOPinSet_fct(&BoardCfgPortPin_sta[3]);
}
Regarding the above files, when I try to compile the code I am getting the following errors:
drv_io.h(10): error C2143: syntax error : missing ')' before '*'
drv_io.h(10): error C2143: syntax error : missing '{' before '*'
drv_io.h(10): error C2059: syntax error : ')'
If I comment the code in board_cfg.h
/* IO driver Gpio Port and Pin Configuration */
typedef struct
{
PortName_t Name_en; /* Specifies the IO Port module */
/* This parameter can be a value of @ref */
/* GpioPort_t */
PinNumber_t PinNo_en; /* Specifies the IO Pin number */
/* This parameter can be a value of @ref */
/* PinNumber_t */
}BoardCfgPortPin_t;
and add it to port_pin.h, I could compile the code successfully.
But I need to have the struct in board_cfg.h only
Why am I getting this error?