我正在使用gcc編譯器爲STM32編寫C代碼,我嘗試了一些建議。 我通過i2c.h definiton從i2c.c調用函數。可能是我在那裏犯錯了。 感謝您的意見。從'uint8_t * {aka unsigned char *}'無效轉換爲'const char *'[-fpermissive]
(i2c.h中)
#define Chip_TxBurst(wREG, wCNT, pbDATA) \
I2C_TxBurst((0xC0) | (((wREG) >> 7) & 0x1E), (wREG), (wCNT), (pbDATA))
(i2c.c)
void I2C_TxBurst (
uint16_t bSLA, /* I2C slave address */
uint16_t bREG, /* I2C sub-address */
uint16_t bCNT, /* The number of data which will be transmitted */
uint8_t *pbDATA /* Point to the first DATA item */
)
{
uint8_t bIdx;
for (bIdx = 0; bIdx < bCNT; bIdx++)
{
I2C_TxData(pbDATA[bIdx]);
} /* for */
} /* I2C_TxBurst */
(osd.c)
void OSD0_TEXT(uint8_t *TEXT,
uint8_t FONT_SIZE_X,
......
)
{
Chip_TxBurst(0x400, FONT_SIZE_X, TEXT);
}
(主)
main{
OSD0_TEXT("STAY FOLISH",11);
}
# #
(老問題代碼)
void OSD0_TEXT ( uint8_t *TEXT)
{
.....
TxBurst(0x400, strlen(TEXT), TEXT);
.....
}
main{
OSD0_TEXT("STAY FOLISH");
}
你傳遞'炭[N]'給需要'uint8_t'和你傳遞'uint8_t'給一個函數('OS0_TEXT')一個函數('strlen')需要'const char *'。 –