//#############################################################################
// $Copyright:
// Copyright (C) 2017-2023 Texas Instruments Incorporated - http://www.ti.com/
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
//   Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
//
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the
//   distribution.
//
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################


//! \file   \solutions\tidm_02010_dmpfc\f280013x\drivers\include\hal_obj.h
//! \brief  Defines the structures for the HAL object
//!
//!

#ifndef HAL_OBJ_H
#define HAL_OBJ_H

// drivers
#include "device.h"

#include "pwmdac.h"

// modules
#include "hal_data.h"

// platforms

//!
//!
//! \defgroup HAL_OBJ HAL_OBJ
//!
//@{


#ifdef __cplusplus
extern "C" {
#endif


//! \brief      Defines the HAL object
//!
typedef struct _HAL_MTR_Obj_
{
  bool          flagEnablePWM;      //<! the pwm enable flag
  MotorNum_e    motorNum;

  uint16_t      numCurrentSensors;  //!< the number of current sensors
  uint16_t      numVoltageSensors;  //!< the number of voltage sensors

  uint32_t      pwmHandle[3];       //<! the PWM handles
  uint32_t      cmpssHandle[3];     //!< the CMPSS handle

#ifdef QEP_ENABLE
  uint32_t      qepHandle;           //!< the QEP handle
#endif  // QEP_ENABLE

  uint32_t      gateEnableGPIO;
} HAL_MTR_Obj;

//! \brief      Defines the HAL_MTR handle
//! \details    The HAL_MTR handle is a pointer to a HAL_MTR object.  In all
//!             HAL_MTR functions, the HAL_MTR handle is passed so that the
//!             function knows what peripherals are to be accessed.
//!
typedef struct _HAL_MTR_Obj_ *HAL_MTR_Handle;


//! \brief      Defines the HAL object
//!
typedef struct _HAL_PFC_Obj_
{
  bool          flagEnablePWM;      //<! the pwm enable flag

  uint32_t      pwmHandle;          //<! the PWM handles

#if defined(DMCPFC_REV3P2) || defined(DMCPFC_REV3P1)
  uint32_t      cmpssHandle[2];     //!< the CMPSS handle
#else
  uint32_t      cmpssHandle[1];     //!< the CMPSS handle
    // DMHCVS_REV1P
#endif  // DMHCVS_REV1P1
} HAL_PFC_Obj;


//! \brief      Defines the HAL_MTR handle
//! \details    The HAL_MTR handle is a pointer to a HAL_MTR object.  In all
//!             HAL_MTR functions, the HAL_MTR handle is passed so that the
//!             function knows what peripherals are to be accessed.
//!
typedef struct _HAL_PFC_Obj_ *HAL_PFC_Handle;

//! \brief      Defines the hardware abstraction layer (HAL) data
//! \details    The HAL object contains all handles to peripherals.  When accessing a
//!             peripheral on a processor, use a HAL function along with the HAL handle
//!             for that processor to access its peripherals.
//!
typedef struct _HAL_Obj_
{
  uint32_t       adcHandle[2];      //!< the ADC handles
  uint32_t       adcResult[2];      //!< the ADC results

  uint32_t       timerHandle[3];    //<! the timer handles

  uint32_t       sciHandle[3];      //!< the SCI handle
  uint32_t       i2cHandle;         //!< the I2C handle

  uint32_t       spiHandle;         //!< the SPI handle

#if defined(EPWMDAC_MODE)
  uint32_t       pwmDACHandle[4];   //<! the PWMDAC handles
#endif  // EPWMDAC_MODE

  HAL_MTR_Handle mtrHandle[2];      //!< the motor control interface handle

  HAL_PFC_Handle pfcHandle;         //!< the pfc control interface handle
} HAL_Obj;

//! \brief      Defines the HAL handle
//! \details    The HAL handle is a pointer to a HAL object.  In all HAL functions
//!             the HAL handle is passed so that the function knows what peripherals
//!             are to be accessed.
//!
typedef struct _HAL_Obj_ *HAL_Handle;


#ifdef __cplusplus
}
#endif // extern "C"

//@} // ingroup
#endif // end of HAL_OBJ_ALL_H definition

