/*
 * SharedMemDataSynch.h
 *
 *  Created on: Nov 11, 2025
 *      Author: tummalanr
 */

#ifndef SHAREDMEMDATASYNCH_H_
#define SHAREDMEMDATASYNCH_H_

#include <kernel/dpl/SemaphoreP.h>
#include "FreeRTOS.h"
#include "event_groups.h"
#include "queue.h"

/**
 * SPIN LOCK base Address.
 */
#define SPINLOCK_BASE_ADDR                              (CSL_SPINLOCK0_BASE)


/**
 * IO Modules Shared Memory Data Write Request Message Queue.
 */
QueueHandle_t  io_shmdataupdwrqueue;

/**
 * IO Modules Event Group for Processing Cyclic/Acyclic data.
 */
EventGroupHandle_t xCyclicEventGroup_IOModules;
EventGroupHandle_t xACyclicEventGroup_IOModules;

/**
 * PZx Modules Event Group for Processing Cyclic/Acyclic data.
 */
EventGroupHandle_t xCyclicEventGrp_PZx;
EventGroupHandle_t xACyclicEventGrp_PZxModules;


/**
 * Pressure Zone Modules Shared Memory Data Write Request Message Queue.
 */
QueueHandle_t  pzx_shmdataupdwrqueue;


/**
 * Semaphore for System Discovery Info Details shared Memory Lock
 */
SemaphoreP_Object   System_Info_mutexObj;

/**
 * Semaphore for Access to IO Modules Cyclic / ACyclic shared Memory Data SPIN Lock.
 */
SemaphoreP_Object   Cyclic_IOModules_mutexObj;
SemaphoreP_Object   ACyclic_IOModules_mutexObj;

/**
 * Semaphore for Access to PressureZone Modules Cyclic / ACyclic shared Memory Data SPIN Lock.
 */
SemaphoreP_Object   Cyclic_PZx_mutexObj;
SemaphoreP_Object   ACyclic_PZx_mutexObj;

/**
 * SpinLock Base Address.
 */
uint32_t            spinlockBaseAddr;
/**
 * Flag to indicate System Configuration is updated to Shared Memory.
 */
uint8_t     systemconfig_updated = 0u;


/**
 *  SystemInfo process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define SystemInfo_TASK_PRI  (configMAX_PRIORITIES-19)
/**
*  SystemInfo process Task Stack size and Stack Buffer
*/
#define SystemInfo_TASK_SIZE (16384u/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gSystemInfoTaskStack[SystemInfo_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  SystemInfo process Task Object.
*/
StaticTask_t gSystemInfoTaskObj;
/**
*  SystemInfo process Task Handle.
*/
TaskHandle_t gSystemInfoTask;

/**
 *  IO Module Cyclic process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define IOModulesCyclic_TASK_PRI  (configMAX_PRIORITIES-19)
/**
*  IO Module Cyclic process Task Stack size and Stack Buffer
*/
#define IOModules_TASK_SIZE (16384u/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gIOModulesCyclicTaskStack[IOModules_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  IO Module Cyclic process Task Object.
*/
StaticTask_t gIOModulesCyclicTaskObj;
/**
*  IO Module Cyclic process Task Handle.
*/
TaskHandle_t gIOModulesCyclicTask;

/**
 *  IO Module ACyclic process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define IOModulesACyclic_TASK_PRI  (configMAX_PRIORITIES-21)
/**
*  IO Module ACyclic process Task Stack size and Stack Buffer
*/
#define IOModulesAcyclic_TASK_SIZE (( 16384u)/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gIOModulesACyclicTaskStack[IOModulesAcyclic_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  IO Module ACyclic process Task Object.
*/
StaticTask_t gIOModulesACyclicTaskObj;
/**
*  IO Module ACyclic process Task Handle.
*/
TaskHandle_t gIOModulesACyclicTask;


/**
 *  IO Module ACyclic ACyclicPrmUpdate process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define IOModuleACyclicPrmUpdt_TASK_PRI  (configMAX_PRIORITIES-21)
/**
*  IO Module PrmUpdate ACyclic process Task Stack size and Stack Buffer
*/
#define IOModulePrmUpdtAcyclc_TASK_SIZE (( 16384u)/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gIOMdlesACyclicPrmUpdtTaskStack[IOModulesAcyclic_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  IO Module PrmUpdate ACyclic process Task Object.
*/
StaticTask_t  gIOModulesACyclicPrmUpdtTaskObj;
/**
*  IO Module PrmUpdate ACyclic process Task Handle.
*/
TaskHandle_t gIOModulesACyclicPrmUpdateTask;


/**
 *  PZx Modules Cyclic process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define PZxCyclic_TASK_PRI  (configMAX_PRIORITIES-19)
/**
*  PZx Module  Cyclic process Task Stack size and Stack Buffer
*/
#define  PZxCyclic_TASK_SIZE    (16384u/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gPZxCyclicTaskStack[PZxCyclic_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  PZx Module Cyclic process Task Object.
*/
StaticTask_t    gPZxCyclicTaskObj;
/**
 *  PZx Module Cyclic process Task Handle.
*/
TaskHandle_t    gPZxCyclicTask;

/**
 *  PZx Modules ACyclic process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define PZxModulesACyclic_TASK_PRI  (configMAX_PRIORITIES-20)
/**
*  PZx Module  ACyclic process Task Stack size and Stack Buffer
*/
#define  gPZxModulesAcyclic_TASK_SIZE    ((16384u)/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gPZxModulesACyclicTaskStack[gPZxModulesAcyclic_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  PZx Module ACyclic process Task Object.
*/
StaticTask_t gPZxModulesACyclicTaskObj;
/**
 *  PZx Module ACyclic process Task Handle.
*/
TaskHandle_t gPZxModulesACyclicTask;

/**
 *  IO / PZx Modules CyclicFetch  process Task Priority.
 *  task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest
 */
#define CyclicFetch_TASK_PRI  (configMAX_PRIORITIES-19)
/**
*  IO / PZx ModuleS  CyclicFetch process Task Stack size and Stack Buffer
*/
#define  CyclicFetch_TASK_SIZE    ((16384u)/sizeof(configSTACK_DEPTH_TYPE))
StackType_t gCyclicFetchTaskStack[CyclicFetch_TASK_SIZE] __attribute__((aligned(32)));
/**
 *  IO / PZx Module CyclicFetch process Task Object.
*/
StaticTask_t    gCyclicFetchTaskObj;
/**
 *  IO / PZx Module CyclicFetch process Task Handle.
*/
TaskHandle_t    gCyclicDataFetchTask;



/**
*  IO Module ACyclic Read Request Process Flag.
*/
uint8_t  IOAcyclicRDReqProcess = 0u;
/**
*  IO Module ACyclic Write Request Process Flag.
*/
uint8_t  IOAcyclicWRReqProcess = 0u;
/**
*  PZx Module ACyclic Read Request Process Flag.
*/
uint8_t  PZxAcyclicRDReqProcess = 0u;
/**
*  PZx Module ACyclic Write Request Process Flag.
*/
uint8_t  PZxAcyclicWRReqProcess = 0u;

#endif /* SHAREDMEMDATASYNCH_H_ */
