0

私はコードをコンパイルしようとしています。私は XC8 コンパイラを初めて使用します。次のコードがあります。

main.c

void main()
{
   bmp280_t bmp280;
   ...
   bmp280.dev_addr = 0x77;
   init_check = bmp280_init(&bmp280);
   ....
}

bmp280.h

...
typedef struct {
    struct bmp280_calib_param_t calib_param;/**<calibration data*/

    uint8_t chip_id;/**< chip id of the sensor*/
    uint8_t dev_addr;/**< device address of the sensor*/

    uint8_t oversamp_temperature;/**< temperature over sampling*/
    uint8_t oversamp_pressure;/**< pressure over sampling*/

    BMP280_WR_FUNC_PTR;/**< bus write function pointer*/
    BMP280_RD_FUNC_PTR;/**< bus read function pointer*/
}bmp280_t;

BMP280_RETURN_FUNCTION_TYPE bmp280_init(bmp280_t *temp_bmp280);
...

bmp280.c

static bmp280_t *p_bmp280;
BMP280_RETURN_FUNCTION_TYPE bmp280_init(bmp280_t *temp_bmp280)
{
    /* variable used to return communication result*/
    BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
    uint8_t v_data_u8 = BMP280_INIT_VALUE;

    p_bmp280 = temp_bmp280;/* assign BMP280 ptr */
    /* read chip id */
    com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->dev_addr,
    BMP280_CHIP_ID_REG, &v_data_u8,
    BMP280_GEN_READ_WRITE_DATA_LENGTH);/* read Chip Id */
    p_bmp280->chip_id = v_data_u8;
    /* readout bmp280 calibparam structure */
    com_rslt += bmp280_get_calib_param();
    return com_rslt;
}
...

このコードを実行した後、次のようなエラーが発生します

":0: error: (499) undefined symbol:
    _bmp280_init(dist/default/production\FTS_basic.X.production.obj) 
(908) exit status = 1
nbproject/Makefile-default.mk:279: recipe for target 'dist/default/production/FTS_basic.X.production.hex' failed
make[2]: Leaving directory 'C:/Users/Abhi/MPLABXProjects/FTS_basic.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/Abhi/MPLABXProjects/FTS_basic.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/FTS_basic.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 10s)
"

ご覧のとおり、タイプミスはありません。ネーミングは正しい。また、構造が正しく渡されることを願っています。

XC8 コンパイラで注意する必要がある新しいことはありますか?

これはpic16f1618マイクロコントローラ用です。

Makefile-impl.mk

SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}


# Project Name
PROJECTNAME=FTS_basic.X

# Active Configuration
DEFAULTCONF=default
CONF=${DEFAULTCONF}

# All Configurations
ALLCONFS=default 


# build
.build-impl: .build-pre
    ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf


# clean
.clean-impl: .clean-pre
    ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf

# clobber
.clobber-impl: .clobber-pre .depcheck-impl
        ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean



# all
.all-impl: .all-pre .depcheck-impl
        ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build



# dependency checking support
.depcheck-impl:
#   @echo "# This code depends on make tool being used" >.dep.inc
#   @if [ -n "${MAKE_VERSION}" ]; then \
#       echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
#       echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
#       echo "include \$${DEPFILES}" >>.dep.inc; \
#       echo "endif" >>.dep.inc; \
#   else \
#       echo ".KEEP_STATE:" >>.dep.inc; \
#       echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
#   fi
4

0 に答える 0