/*
 * FRAM_MB85RC256.h
 *
 *  Created on: Sep 24, 2019
 *      Author: nxa07657
 */

#ifndef FRAM_MB85RC256_H_
#define FRAM_MB85RC256_H_

#include "Mcal.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Dio_Ip.h"
#include "Lpi2c_Ip.h"

//#include "StandardTypes.h"

/*PTF2 is used for MB85RC256 write protection, active high*/
#define MB85RC256_WP_GPIO_PORT (PTF_L_HALF)
#define MB85RC256_WP_GPIO_PIN  2

#define FRAM_MB85RC256_WP_Enable()   Siul2_Dio_Ip_WritePin(FRAM_WP_PORT, FRAM_WP_PIN, 1)
#define FRAM_MB85RC256_WP_Disable()  Siul2_Dio_Ip_WritePin(FRAM_WP_PORT, FRAM_WP_PIN, 0)

#define FRAM_I2C_INST 0  /* use LPI2C0 for FRAM */

#define FRAM_I2C_MasterConfig	(I2c_Lpi2cMasterChannel0_BOARD_InitPeripherals)

#define MB85RC256_DEVIC_Addr 0x57

Std_ReturnType FRAM_MB85RC256_Init(void);
void FRAM_MB85RC256_DeInit(void);
Std_ReturnType FRAM_MB85RC256_ByteWrite(uint32_t address, uint8_t data);
Std_ReturnType FRAM_MB85RC256_PageWrite(uint32_t address, uint8_t *data, uint16_t length);
Std_ReturnType FRAM_MB85RC256_ReadByte(uint32_t address, uint8_t *data);
Std_ReturnType FRAM_MB85RC256_ReadMultiByte(uint32_t address, uint8_t *data, uint16_t length);

Std_ReturnType FRAM_MB85RC256_Test(void);

#endif /* FRAM_MB85RC256_H_ */
