Assigning SPI1 pins (STM32F103RBT6), to an external SPI device (ADS1220)
Hi !
i'm trying to write a driver, to interface the "ADS1220" device with STM32F103RBT6, using SPI,
i would like to assign each pin of the MCU SPI (PA4, PA5, PA6, PA7) with its corresponding pin of ADS1220 like this : using macros
#define ADS_CS PA4 // or the adress of PA4 of MCU
#define ADS_CLK PA5 // or Address of PA5 of MCU
and so on...
i have received some suggestion about using structure pointer method
i have made a sketch as follow :
#include "stm32f10x.h" // Device header
typedef struct ADS_PIN{
uint32_t CS; // CS PIN of ADS1220 device
uint32_t CLK; // CLK PIN of ADS1220 device
uint32_t DOUT; // DOUT PIN of ADS1220 device
uint32_t DIN; // DIN PIN of ADS1220 device
} ADS_PIN;
ADS_PIN *pointer;
ADS_PIN.CS = GPIOA->BSRR|= (1<<4) // PA4 MCU
ADS_PIN.CLK = GPIOA->BSRR| = (1<<5) // PA5 MCU
ADS_PIN.DIN = GPIOA->BSRR| = (1<<6) // PA6 MCU
ADS_PIN.DOUT = GPIOA->BSRR| = (1<<7) // PA7 MCU
but, i'm confused, it may be sound silly , but i'm trying to understand how to specify that CS / CLK / DIN and DOUT pins correspond to PA / PA5 etc...;
if you could give me a suggestion
Thank you !