Globalstar ST150 User Manual page 25

Table of Contents

Advertisement

9150-0125-01 R-4
The basic steps in setting up an additional SPI instance is as follows:
o
You will need 4 pins for MOSI, MISO, CLK and CS. If you plan to drive multiple SPI Slave devices off of the same
master device instance, you will need an additional pin for each additional CS line, and your HAL will be more
complex than the example in the Globalstar ST150 SDK.
o
Remove the 4 (or more) pins you plan to use from the GPIO list in UAPI_GPIO_list.c. Note that the pin definition
constants that you are setting below will reserve those pins for your SPI port via the GPIO library when the
initialization function for your new library is called, if the initialization function retains the lines of code that reserve
the pins from the original template.
o
Make a copy the source file "GSTAR_HAL_spi_1.c" and add the new file to the project. A recommended name is
"GSTAR_HAL_spi_n.c" where "n" is the instance number that you are using.
o
Edit the new file to change the instance number to the one desired (e. g. "2").
o
In "GSTAR_HAL_spi.h" copy the block below:
#define SPI_1_CLK_PIN
#define SPI_1_MOSI_PIN
#define SPI_1_MISO_PIN
#define SPI_1_CS_PIN
#define SPI_1_FREQUENCY
#define SPI_1_MODE
#define SPI_1_BIT_ORDER
#define SPI_1_IRQ_PRIORITY
o
And make it look something like this:
#define SPI_2_CLK_PIN
#define SPI_2_MOSI_PIN
#define SPI_2_MISO_PIN
#define SPI_2_CS_PIN
#define SPI_2_FREQUENCY
#define SPI_2_MODE
#define SPI_2_BIT_ORDER
#define SPI_2_IRQ_PRIORITY
as above.
o
Create the following struct in your new HAL source file:
static nrf_drv_spi_config_t m_spi2Config =
{
.sck_pin
.mosi_pin
.miso_pin
.ss_pin
.irq_priority
.orc
.frequency
.mode
.bit_order
};
o
Modify the remaining functions in the HAL to point to your new instance of SPI Master port.
Adding a SPI Slave port:
The Nordic nRF52840 can support one SPI slave port. Configuring such a port allows a host processor that may be on your
carrier board to send instructions to the Nordic on the ST150M board as a master.
o
You will need to remove the 4 pins you wish to use for the SPI Slave port from the GPIO list as in the sections
above.
o
You will need to write a custom HAL for the SPI Slave device.
o
The HAL for the SPI Master device in the Globalstar ST150M SDK should be useful as a template for this
HAL. However, you will need to consult the Nordic SDK documentation as a reference how to link your new HAL into
the SPI Slave control functions.
ST150M User Manual
12 //28
NRF_GPIO_PIN_MAP(1,9) //29
NRF_GPIO_PIN_MAP(1,8) //30
11 //NRF_DRV_SPI_PIN_NOT_USED
NRF_DRV_SPI_FREQ_125K
NRF_DRV_SPI_MODE_0
NRF_DRV_SPI_BIT_ORDER_MSB_FIRST
NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY
<your clock pin>
<your MOSI pin>
<your MISO pin>
<your CS pin>
<your selection of standard NRF SPI frequencies>
<your SPI mode>
<your devices bit order> Note: MSB first is by far the most common for SPI
<your desired IRQ priority> Note: For most cases, the "default" is most appropriate,
= SPI_2_CLK_PIN,
= SPI_2_MOSI_PIN,
= SPI_2_MISO_PIN,
= SPI_2_CS_PIN,
= SPI_2_IRQ_PRIORITY,
= 0xFF,
= SPI_2_FREQUENCY,
= SPI_2_MODE,
= SPI_2_BIT_ORDER
Confidential & Proprietary Information
25

Advertisement

Table of Contents
loading

This manual is also suitable for:

St150m-devkit

Table of Contents