cancel
Showing results for 
Search instead for 
Did you mean: 

How to use SPI in other .c

JJoao.1
Associate III

Hi everybody,

 

Actually I start a new project with a ST7567 driver for LCD 128x64.

 

I have create my project with CubeIDE . CubeIDE generate my code in the main.c  like this :

 

 

 

 

/* Private variables ---------------------------------------------------------*/
RTC_HandleTypeDef hrtc;

SPI_HandleTypeDef hspi1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_RTC_Init(void);
static void MX_SPI1_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

 

 

 

 

 

It's ok .

 

Now to drive my screen I would like to create files like st7567_driver.h and a st7567_driver.c file.

This way I could create my functions relating to the driver in these files. Functions such as "draw pixel", "send command", "send data", etc....

But to communicate with the driver I have to use SPI1 create in my main.c.

So I get an error when I try to use the HAL_SPI_Transmit function in st7567_driver.c

I don't know how to declare to my st7567_driver.c file as I use the SPI1 declare in my main.c

Thank you for your help

 

10 REPLIES 10
JJoao.1
Associate III

Thank you so much for your reactivity. I can continue my learning and my code

 

Best regards