/*
 * EepromAccessExtern.h
 *
 *  Created on: Jun 2, 2025
 *      Author: tummalanr
 */

#ifndef USER_ADDONS_EEPROMTEMPERATURE_USERSPACE_EEPROMACCESSEXTERN_H_
#define USER_ADDONS_EEPROMTEMPERATURE_USERSPACE_EEPROMACCESSEXTERN_H_

#include <kernel/dpl/EventP.h>
#include <kernel/dpl/SemaphoreP.h>
#include "AppSharedMemory.h"

/*
 *      Module Discovery info       CAN <-> CIP  EEPROM
 *      Module Identification Info  CAN <-> CIP  EEPROM
 *      MBN   Identification Info   MAIN CORE  <-> CIP  EEPROM      - READ DONE
 *      Protocol type               CIP -> EEPROM.                  -   READ /WRITE DONE
 *      IP DETAILS                  MAIN CORE -> CIP EEPROM.        -   READ /WRITE DONE
 *      MAC DETAILS                 MAIN CORE -> CIP EEPROM.        -   READ /WRITE DONE
 *      PIN                         MAIN CORE -> CIP EEPROM.        -   READ /WRITE DONE
 *      PSWD                        MAIN CORE -> CIP EEPROM.        -   READ /WRITE DONE
 *      MODE OF OPERATION           MAIN CORE -> CIP EEPROM.        -   READ /WRITE DONE
 *      SHORT CODE                  MAIN CORE -> CIP EEPROM.        -   READ / DONE
 *      FIRMWARE CRC CHECK          MAIN CORE -> CIP EEPROM.
 *      PROTOCOL CONFIG             CIP -> EEPROM.
 *
 */

#define             VALIDRECORDHEADER       0xEEu

#define             EEPROM_MODULEDISCOVERY             0x00000001u
#define             EEPROM_MAINCOREIPADDR              0x00000002u
#define             EEPROM_CIP1IPADDR                  0x00000004u
#define             EEPROM_CIP2IPADDR                  0x00000008u
#define             EEPROM_MAINCOREMACADDR             0x00000010u
#define             EEPROM_CIP1MACADDR                 0x00000020u
#define             EEPROM_CIP2MACADDR                 0x00000040u
#define             EEPROM_MBNIDENTIFICATION           0x00000080u
#define             EEPROM_CIPPROTOCOLTYPE             0x00000100u
#define             EEPROM_MBNOPRMODE                  0x00000200u
#define             EEPROM_MBNPIN                      0x00000400u
#define             EEPROM_MBNPSWD                     0x00000800u
#define             EEPROM_MBNSHORTCODE                0x00001000u

#define             EEPROM_WRITE_EVENT_BIT            (0x000001u)
#define             EEPROM_READ_EVENT_BIT             (0x000002u)

#define             TEMPERATURE_READ_EVENT_BIT        (0x000004u)

extern SemaphoreP_Object gEepromAccessReqSynch;
extern EventP_Object gEepromAccessSynchEvent;
extern volatile    uint32_t    eeprom_write_flag;

extern volatile    uint32_t    eeprom_write_flag;
extern volatile    uint32_t    eeprom_read_flag;

extern uint32_t    CIP_IPAddress[2u];
extern uint32_t    MAINCore_IPAddress;



extern uint16_t    MAINCORE_DEFAULT_PIN;
extern uint64_t    MAINCORE_DEFAULT_PSWD;

extern AppRET_T    App_EepromTemp_TaskInit(void);
extern AppRET_T    Get_SystemDetails_Eeprom(void);
extern AppRET_T    Get_EepromAccess(void);
extern AppRET_T    EepromWrite_ModuleDiscoveryInfo(void);
extern AppRET_T    Get_EepromAccess(void);
extern AppRET_T    Release_EepromAccess(void);
extern AppRET_T    EepromWrite_MBNIdentification(void);

extern volatile    uint32_t    eeprom_write_flag;

#endif /* USER_ADDONS_EEPROMTEMPERATURE_USERSPACE_EEPROMACCESSEXTERN_H_ */
