Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Using ST RFAL Library within nRF SDK5 SPI communication to ST25R3916b

Hi,

I go my own hardware, that connects the nRF52840 Module to an ST25R3916b-aq chip with SPI bus.
The I2C bus is also available by using some 0R resistors, just in case.

Im using the Segger Embedded Studio with the nRF5 SDK for programming.

Because and the communication is quite complex for the ST25R3916b NFC SPI, I want to use the RFAL library.
https://www.st.com/en/embedded-software/stsw-st25rfal002.html

Therefore i need to modify the rfal_platform.h and change it to the nRF HAL functions. There is some porting required.
This is some example code of the platform.h file:

#include "stm32f4xx_hal.h"  ///> include HAL_PLATFORM_NRF52840 ?
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>

#include "main.h"
#ifdef RFAL_USE_I2C
#include "i2c.h"
#else

//#include "spi.h"
#include "nrf_drv_spi.h"  //is that okay?


#endif
#include "timer.h"` // use nrf_systick?
#include "logger.h" // use nrf_log?

/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
#define ST25R_SS_PIN             SPI1_CS_Pin              /*!< GPIO pin used for ST25R SPI SS                */
#define ST25R_SS_PORT            SPI1_CS_GPIO_Port        /*!< GPIO port used for ST25R SPI SS port          */

#define ST25R_INT_PIN            ST25R_IRQ_Pin            /*!< GPIO pin used for ST25R External Interrupt    */
#define ST25R_INT_PORT           ST25R_IRQ_GPIO_Port      /*!< GPIO port used for ST25R External Interrupt   */

/*
******************************************************************************
* GLOBAL MACROS
******************************************************************************
*/
#define platformProtectST25RComm()                    do{ globalCommProtectCnt++; __DSB();NVIC_DisableIRQ(EXTI0_IRQn);__DSB();__ISB();}while(0)
#define platformUnprotectST25RComm()                  do{ if (--globalCommProtectCnt==0) {NVIC_EnableIRQ(EXTI0_IRQn);} }while(0) 
#define platformGpioSet( port, pin )                  HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET)
#define platformGpioClear( port, pin )                HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET)
#define platformGpioToggle( port, pin )               HAL_GPIO_TogglePin(port, pin)                 /*!< Toggles the given GPIO                      */
#define platformGpioIsHigh( port, pin )               (HAL_GPIO_ReadPin(port, pin) == GPIO_PIN_SET) /*!< Checks if the given LED is High             */
#define platformGpioIsLow( port, pin )                (!platformGpioIsHigh(port, pin))

Can somebody give me some advice or any suggestions how i can achieve that?
Thank You!

Related