2023-08-15 06:55 AM
Hi everyone! i am work with stm32l010c6t6 for comunicate llcc68 Lora module using spi, i find the standard peripheral library and not have, i don´t want use hal because i need maior control. i am using the example but this is using stm32f103c8t6 and need the configuration for stm32l010c6t6, i view the reference manual and the code example is:
uint8_t HALSpi1InOut(uint8_t data){
uint32_t retry=0;
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET){//¼ì²éÖ¸¶¨µÄSPI±ê־λÉèÖÃÓë·ñ:·¢ËÍ»º´æ¿Õ±ê־λ(»º³åÇø¿ÕÁ˾ͿÉÒÔ¿½±´Êý¾ÝÁË)
if((retry++)>2000){
//³¬Ê±ÁË
return 0xff;
}
}
SPI_I2S_SendData(SPI1, data); //ͨ¹ýÍâÉèSPIx·¢ËÍÒ»¸öÊý¾Ý
retry=0;
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET){ //¼ì²éÖ¸¶¨µÄSPI±ê־λÉèÖÃÓë·ñ:½ÓÊÜ»º´æ·Ç¿Õ±ê־루·Ç¿ÕÁ˾ͱíʾ½ÓÊÕÊý¾ÝÍê³ÉÁË£©
if((retry++)>2000){
//³¬Ê±ÁË
return 0xff;
}
}
return SPI_I2S_ReceiveData(SPI1); //·µ»Øͨ¹ýSPIx×î½ü½ÓÊÕµÄÊý¾Ý
}
and i am make: