bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
Guys,
I want to port from AVR to STM32CubeMx...
Please correct me if I'm wrong
Thanks
I want to port from AVR to STM32CubeMx...
Please correct me if I'm wrong
Code:
STM32 :
/* Exchange a byte */
static
BYTE xchg_spi ( /* Returns received data */
BYTE dat[1] /* Data to be sent */
)
{
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
HAL_SPI_Receive(&hspi2,dat,1,100);
return dat[1];
}
AVR :
/* Exchange a byte */
static
BYTE xchg_spi ( /* Returns received data */
BYTE dat /* Data to be sent */
)
{
SPDR = dat;
loop_until_bit_is_set(SPSR, SPIF);
return SPDR;
}
Thanks