igtaba
Newbie level 2
Hello people, I'm in need of help with SPI for a university project. Please bear in mind that I am a complete newbie to programming MCU and SPI, and sorry for my bad English (Spanish speaker) .
I'm trying to port a library for the nRF24L01 module to use with a STM32F103C8 (blue pill module) programming in uVision 5 using HAL Libraries, but I have tried a lot of libraries that did not work for my MCU or HAL or are to hard to port; Since I found Lonely Wolf's library in GitHub and I'm trying to port it because is well documented and separates the hardware dependent of the non-hardware dependent parts of code in a clear way, the problem I face is the changing of the SPI (He uses ST STD Peripheral Lib) to Hal libraries. I need to do this because most of my code is base around the HAL libraries, but I cant to use the 2 at the same time.
The librarie uses the next function to send the data from the MCU to the RF module:
and this is the function that I'm trying to replace it with
Is this implementation of the HAL function ok? would actually work?
The other problem I have is how to use this actual library to make a working transceiver between 2 MCU and a pair of RF module, but first I need help to make the library work
Thanks in advance
I'm trying to port a library for the nRF24L01 module to use with a STM32F103C8 (blue pill module) programming in uVision 5 using HAL Libraries, but I have tried a lot of libraries that did not work for my MCU or HAL or are to hard to port; Since I found Lonely Wolf's library in GitHub and I'm trying to port it because is well documented and separates the hardware dependent of the non-hardware dependent parts of code in a clear way, the problem I face is the changing of the SPI (He uses ST STD Peripheral Lib) to Hal libraries. I need to do this because most of my code is base around the HAL libraries, but I cant to use the 2 at the same time.
The librarie uses the next function to send the data from the MCU to the RF module:
HTML:
// Low level SPI transmit/receive function (hardware depended)
// input:
// data - value to transmit via SPI
// return: value received from SPI
uint8_t nRF24_LL_RW(uint8_t data) {/*
// Wait until TX buffer is empty
while (SPI_I2S_GetFlagStatus(nRF24_SPI_PORT, SPI_I2S_FLAG_TXE) == RESET);
// Send byte to SPI (TXE cleared)
SPI_I2S_SendData(nRF24_SPI_PORT, data);
// Wait while receive buffer is empty
while (SPI_I2S_GetFlagStatus(nRF24_SPI_PORT, SPI_I2S_FLAG_RXNE) == RESET);
// Return received byte
return (uint8_t)SPI_I2S_ReceiveData(nRF24_SPI_PORT);*/
}
and this is the function that I'm trying to replace it with
HTML:
extern hspi1; //This is done at the top of the .c file and I understand that this make possible to call
//the hspi1 generated with the CubeMX in the main.c with the Init values for the SPI ports
// Low level SPI transmit/receive function (hardware depended)
// input:
// data - value to transmit via SPI
// return: value received from SPI
uint8_t nRF24_LL_RW(uint8_t dataIn) {
uint8_t dataOut;
HAL_SPI_TransmitReceive(&hspi1, &dataIn, &dataOut, 1,1000 );
return dataOut;
}
Is this implementation of the HAL function ok? would actually work?
The other problem I have is how to use this actual library to make a working transceiver between 2 MCU and a pair of RF module, but first I need help to make the library work
Thanks in advance