cancel
Showing results for 
Search instead for 
Did you mean: 

SPI_RxFIFOThresholdConfig is not defined

RBair.3
Associate II

I'm using the L4xx HAL library and trying to set my SPI RX threshold value to 1/4 so I can receive a single byte response. From my research there should be a HAL function called SPI_RxFIFOThresholdConfig that will do this. When I put it into my SPI initialization function though, I get an error undeclared identifier. Presumably then this version of the HAL doesn't define this method. What is the right way to do this manually?

Here is my init code

  hspi3.Instance = SPI3;
  hspi3.Init.Mode = SPI_MODE_MASTER;
  hspi3.Init.Direction = SPI_DIRECTION_2LINES;
  hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi3.Init.NSS = SPI_NSS_SOFT;
  hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
  hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi3.Init.CRCPolynomial = 7;
  hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
  hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
  SPI_RxFIFOThresholdConfig(SPI3, SPI_RxFIFOThreshold_QF); // compile error
  if (HAL_SPI_Init(&hspi3) != HAL_OK)
  {
    Error_Handler();
  }

2 REPLIES 2

Which STM32?

Cube is open source, so you can check presence/absence of any functionality there yourself.

You always can simply ditch Cube and program SPI according to your needs normally.

However, note, that Cube is designed to work as a whole, for the "usual usage cases", as decided by Cube authors, so tinkering with it may cause unexpected results. So, by "ditch Cube" I mean replace it entirely by your own code, of which you take compleate ownership.

In this case, CubeL4 appears to set FRXTH in a particular way in the initialization code and rest of Cube may be written with this particular setting in mind, so changing it may result in you being frustrated by "Cube ain't work" later.

JW

Piranha
Chief II

SPI_RxFIFOThresholdConfig() is not a HAL function, but is from the legacy SPL library.