/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    spi.h
  * @brief   This file contains all the function prototypes for
  *          the spi.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SPI_H__
#define __SPI_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

#define EEPROM_SPI_PORT     &hspi1
#define EEPROM_SPI_CS_Pin   GPIO_PIN_12
#define EEPROM_SPI_CS_Port  GPIOF

#define EEPROM_PAGE_SIZE    16
#define EEPROM_MAX_SIZE     1024    //8Kbit = 1Kbyte

/* USER CODE END Includes */

extern SPI_HandleTypeDef hspi1;

extern SPI_HandleTypeDef hspi4;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_SPI1_Init(void);
void MX_SPI4_Init(void);

/* USER CODE BEGIN Prototypes */
//EEPROM(Microchip 25LC080A) by SPI
uint8_t EEPROM_ReadByte (uint16_t address);
uint8_t EEPROM_ReadPage (uint16_t address, uint8_t data[], uint8_t size);
void	  EEPROM_WriteByte(uint16_t address, uint8_t data);
void	  EEPROM_WritePage(uint16_t address, uint8_t data[], uint8_t size);

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __SPI_H__ */

