how to switch the configuration for the PINs when the code is running

2 posts / 0 new
Last post
liuluan002
Offline
Last seen:4 months 3 weeks ago
Joined:2015-11-27 14:24
how to switch the configuration for the PINs when the code is running

how to switch the configuration for the DA14583 SPI interface from one setting into another setting.

For example, I want to use the configuration with the following setting of the SPI interface to talk with the pressure sensor through the SPI interface.
#define SPI_EN_GPIO_PORT GPIO_PORT_0
#define SPI_EN_GPIO_PIN GPIO_PIN_3

#define SPI_CLK_GPIO_PORT GPIO_PORT_0
#define SPI_CLK_GPIO_PIN GPIO_PIN_0

#定义SPI_DO_GPIO_PORT GPIO_PORT_0
#定义SPI_DO_GPIO_PIN GPIO_PIN_6

#define SPI_DI_GPIO_PORT GPIO_PORT_0
#define SPI_DI_GPIO_PIN GPIO_PIN_5

Latterly, I want to change the SPI setting into another one talk with the inside the SPI memory. How to do it? Does it means I need to change the setting and run the system_init(); and
periph_init(); again?

#define SPI_EN_GPIO_PORT GPIO_PORT_2
#define SPI_EN_GPIO_PIN GPIO_PIN_3

#define SPI_CLK_GPIO_PORT GPIO_PORT_2
#define SPI_CLK_GPIO_PIN GPIO_PIN_0

#定义SPI_DO_GPIO_PORT GPIO_PORT_2
#定义SPI_DO_GPIO_PIN GPIO_PIN_9

#define SPI_DI_GPIO_PORT GPIO_PORT_2
#define SPI_DI_GPIO_PIN GPIO_PIN_4

Device:
MT_dialog
Offline
Last seen:1 month 1 week ago
Staff
Joined:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

You can just reconfigure your pins by invoking GPIO_ConfigurePin() function with the pins that you would like to change as parameters, you dont have to invoke those functions in the periph_init() function, but remember that every time that your device goes into sleep you will have to reconfigure your pins to the functionallity you want if you want to use that pins as SPI pins. You can have a look at the IoT reference design that uses a 583 and initializes the internal flash every time he wants to interact with it.

Thanks MT_dialog