/*!
* @file     Usart_Hw.h
*
* @version  1.0.0
*
* @brief    Usart driver header file
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_01-Otc-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

#ifndef USART_HW_H
#define USART_HW_H

#ifdef __cplusplus
extern "C" {
#endif

#include "Mcal.h"
 
#include "StdRegMacros.h"
#include "CDD_Usart.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup USART_Driver
  @{
*/

/** @defgroup USART_Macros
  @{
*/
/*******************************************************************************
                    VENDOR ID & AUTOSAR VERSION INFO
*******************************************************************************/
/* Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define USART_HW_H_VENDOR_ID                     0x00C1U
/* Module ID of this module, as defined in the BSW Module List. */
#define USART_HW_H_MODULE_ID                     0x00FFU
/* Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define USART_HW_H_AR_RELEASE_MAJOR_VERSION      0x04U
/* Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define USART_HW_H_AR_RELEASE_MINOR_VERSION      0x04U
/* Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define USART_HW_H_AR_RELEASE_REVISION_VERSION   0x00U
/* Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define USART_HW_H_SW_MAJOR_VERSION              0x01U
/* Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define USART_HW_H_SW_MINOR_VERSION              0x00U
/* Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define USART_HW_H_SW_PATCH_VERSION              0x00U

/**@} end of group USART_Macros */
/*******************************************************************************
                            FUNCTION DECLARATIONS
*******************************************************************************/                                             
/** @defgroup USART_Fuctions
  @{
*/

/* USART peripheral Reset and Configuration */
FUNC(void, USART_CODE) Usart_Hw_Config(Usart_UsartIdType usartId, const Usart_ConfigType * configStruct);
FUNC(void, USART_CODE) Usart_Hw_Operation(Usart_UsartIdType usartId, uint32 status);
FUNC(void, USART_CODE) Usart_Hw_OperationDirectionMode(Usart_UsartIdType usartId, Usart_DirectionType mode, uint32 status);
                                            
/* Transmit and receive */
FUNC(void, USART_CODE) Usart_Hw_TxData(Usart_UsartIdType usartId, const uint8 * data);
FUNC(uint16, USART_CODE) Usart_Hw_RxData(Usart_UsartIdType usartId);

/* DMA */
FUNC(void, USART_CODE) Usart_Hw_OperationDma(Usart_UsartIdType usartId, Usart_DmaRequestType direction, uint32 status);
FUNC(void, USART_CODE) Usart_Hw_ConfigDMAReceptionError(Usart_UsartIdType usartId, Usart_DmaRxerrType error);

/* Interrupt */
FUNC(void, USART_CODE) Usart_Hw_OperationInterrupt(Usart_UsartIdType usartId, Usart_IntType interrupt, uint32 status);
FUNC(uint8, USART_CODE) Usart_Hw_ReadIntFlag(Usart_UsartIdType usartId, Usart_IntFlagType flag);
FUNC(void, USART_CODE) Usart_Hw_ClearIntFlag(Usart_UsartIdType usartId, uint32 flag);

/* Flag */
FUNC(uint8, USART_CODE) Usart_Hw_ReadStatusFlag(Usart_UsartIdType usartId, Usart_FlagType flag);
FUNC(void, USART_CODE) Usart_Hw_ClearStatusFlag(Usart_UsartIdType usartId, uint32 flag);
FUNC(boolean, USART_CODE) Usart_Hw_GetUsartState(Usart_UsartIdType usartId);


FUNC(void, USART_CODE) Usart_Hw_OperationHalfDuplex(Usart_UsartIdType usartId, uint32 status);
FUNC(void, USART_CODE) Usart_Hw_OperationSynchronousMode(Usart_UsartIdType usartId, uint32 status);
FUNC(void, USART_CODE) Usart_Hw_OperationCPolHigh(Usart_UsartIdType usartId, Usart_ClockPolType enable);
FUNC(void, USART_CODE) Usart_Hw_OperationCPhaTwo(Usart_UsartIdType usartId, Usart_ClockPhaType edge2);
FUNC(void, USART_CODE) Usart_Hw_OperationLastBitOutput(Usart_UsartIdType usartId, boolean status);
/**@} end of group USART_Fuctions */

#ifdef __cplusplus
}
#endif

#endif /* __USART_DRV_H */

/**@} end of group USART_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
