Globalstar ST150M User Manual page 25

Hide thumbs Also See for ST150M:
Table of Contents

Advertisement

9150-0125-01 R-1
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.
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.
Edit the new file to change the instance number to the one desired (e. g. "2").
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
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
<your SPI mode>
#define SPI_2_BIT_ORDER
#define SPI_2_IRQ_PRIORITY
NOTE: For most cases, the "default" is most appropriate, as above.
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
};
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.
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.
You will need to write a custom HAL for the SPI Slave device.
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> #define SPI_2_MODE
<your devices bit order> Note: MSB first is by far the most common for SPI
<your desired IRQ priority>
= 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
17

Advertisement

Table of Contents
loading

Table of Contents