2024-01-31 04:14 PM
Hi,
I go my own hardware, that connects the ST25R3916b-aq chip to a nRF52840 Bluetooth Module and its SPI bus. (and the I2C bus, just in case).
Im using the Segger Embedded Studio with the nRF5 SDK for programming.
Because and the communication is quite complex for the SPI, I want to use the RFAL library.
If I just import it to my project, its missing the platform.h file. That file includes the "stm32f4xx_hal.h" and that can't work for my nRF52840. Where do i go from here?
I know the basics of C coding, but im new to nRF and would really apreciate some help to get me in the right direction.
Thank you!
Solved! Go to Solution.
2024-02-01 02:57 AM
@pososos wrote:Does anyone know if that has been done before?
Probably the Nordic forum would be the best place to ask that - that's where you'll find the people working with nRF devices!
2024-01-31 04:32 PM
@pososos wrote:I know the basics of C coding, but I'm new to nRF and would really apreciate some help to get me in the right direction.
Are you familiar with working on STM32? or any other microcontroller?
Perhaps it would be easier for you to start by getting this to work with an STM32?
Then you'd have a known-working setup as reference from which to start your port to nRF...
2024-01-31 11:45 PM
Hi pososos,
please see the documentation. stsw-st25rfal002 references the UM2890RF/NFC abstraction layer (RFAL) and contained in the package is also an rfal.chm file both detailing the porting.
(rfal_)platform.h is the central file which you will need to adapt for configuring rfal and the interface to the host MCU.
Ulysses
2024-02-01 02:16 AM
Ok thank you, i found the mandatory functions that i need to provide:
RFAL (RF Abstraction Layer)
Interfaces to the user specific platform hardware driver (MCU HAL)
A few interfaces for the HW drivers must be provided:
This is how I use the SPI from the nRF SDK:
#include "nrf_drv_spi.h"
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(ST25R3916B_SPI_INSTANCE);
static volatile bool spi_xfer_done = false;
void spi_event_handler(nrf_drv_spi_evt_t const * p_event, void * p_context)
{
spi_xfer_done = true;
}
void configure_spi(void)
{
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = NRF_GPIO_PIN_MAP(0,27);
spi_config.miso_pin = NRF_GPIO_PIN_MAP(0,5);
spi_config.mosi_pin = NRF_GPIO_PIN_MAP(0,26);;
spi_config.sck_pin = NRF_GPIO_PIN_MAP(0,6);
spi_config.irq_priority = APP_IRQ_PRIORITY_HIGH;
spi_config.mode = NRF_DRV_SPI_MODE_0;
spi_config.frequency = NRF_DRV_SPI_FREQ_1M;
spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
}
uint8_t st25r3916b_read_register(uint8_t reg)
{
uint8_t read_cmd = 0x00 | (reg << 1);
uint8_t data;
nrf_drv_spi_transfer(&spi, &read_cmd, 1, &data, 1);
return data;
}
void st25r3916b_write_register(uint8_t reg, uint8_t value)
{
uint8_t write_cmd = 0x01 | (reg << 1);
nrf_drv_spi_transfer(&spi, &write_cmd, 1, NULL, 0);
nrf_drv_spi_transfer(&spi, &value, 1, NULL, 0);
}
For Example
#define platformGpioSet( port, pin ) HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET) /*!< Turns the given GPIO High */
I would try to change that to my nRF functions.
This is how i set GPIO pins.
nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(1,8) );
nrf_gpio_pin_write(NRF_GPIO_PIN_MAP(1,8) , 0);
Does anyone know if that has been done before?
Or may can help me with further information, how i can achieve that?
Thank You!
2024-02-01 02:57 AM
@pososos wrote:Does anyone know if that has been done before?
Probably the Nordic forum would be the best place to ask that - that's where you'll find the people working with nRF devices!