Skip to main content
antonius
Associate III
February 2, 2016
Question

#167: argument of type ''const BYTE *'' is incompatible with parameter of type ''uint8_t *''??

  • February 2, 2016
  • 2 replies
  • 1878 views
Posted on February 02, 2016 at 15:34

Guys,

Is there anyway to convert Byte to uint8_t ?

I got this error :

..\Src\user_diskio.c(171): error: #167: argument of type ''const BYTE *'' is incompatible with parameter of type ''uint8_t *''

static

void xmit_spi_multi (

const BYTE *p, /* Data block to be sent */

UINT cnt

)

{

while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);

HAL_SPI_Transmit(&hspi2,p,cnt,100);

}

thanks

    This topic has been closed for replies.

    2 replies

    hbarta2
    Associate III
    February 2, 2016
    Posted on February 02, 2016 at 16:10

    Is the problem BYTE vs. uint8_t or const?

    HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);

    HAL_SPI_Transmit() does not expect a pointer to const data. IMO this is a bug in the library and I really hope thatHAL_SPI_Transmit() does not modify the data that pData points to.

    I would just cast away constness:

    HAL_SPI_Transmit(&hspi2,(BYTE*)p,cnt,100); or

     

    HAL_SPI_Transmit(&hspi2,(uint8_t *)p,cnt,100);

     

    Hope this works and hope this helps.

    antonius
    antoniusAuthor
    Associate III
    February 2, 2016
    Posted on February 02, 2016 at 21:47

    It does the job....hopefully the code will run...

    it can be compiled, but I will see if it's running or not...

    I'll keep posting

    Thanks