cancel
Showing results for 
Search instead for 
Did you mean: 

Mixing HAL and LL for STM32F446

Cezar Chirila
Associate II
Posted on April 22, 2018 at 14:39

Hi there!

I have a bit of code, which was initialized using CubeMX and now I want to use a mix of HAL and LL (use LL for transmitting, use HAL for everything else). 

Currently I have tried to generate CubeMX code and just add manually the stm32f4xx_ll_spi.c/h files, then I include the header where I need. I want to replace this function:

void spi_write(uint8_t data) {

   HAL_SPI_Transmit(SPI_PORT,&data,1,HAL_MAX_DELAY);

}

With this one:

void ST7735_write(uint8_t data) {

   LL_SPI_TransmitData8 (&hspi2, data);

   while (!LL_SPI_IsActiveFlag_TXE(&hspi2))

   {

      ;

   }

}

But it does not work. I also get an error regarding hspi2, because it is of type 'SPI_HandleTypeDef' and not 'SPI_TypeDef'. Does anyone have any idea what I am missing? Thank you!

#ll #spi #hal
1 REPLY 1
Cezar Chirila
Associate II
Posted on April 22, 2018 at 14:52

I managed to get rid of the error by using (&hspi2)->Instance instead of simple hspi2. But I still cannot transmit data. 

I have also tried to leave the LL drivers and work directly on the registers, but it does not work.  

(&hspi2)->Instance->DR = data;

while (!((&hspi2)->Instance->SR & ((uint16_t)0x0002))); //Check TXE flag

while ((&hspi2)->Instance->SR & ((uint16_t)0x0080)); // Check busy flag