/************************************************************************** * * Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file PAL.c * * @author (last) Vinayakam Mani * @date (last) 07-Aug-2024 * * @author (original) Vinayakam Mani * @date (original) 07-Aug-2024 * ***************************************************************************/ #include "mibspi.h" #include "reg_system.h" #include "reg_crc.h" #include "PAL.h" /** * @addtogroup PAL * @{ */ // ********** private definitions ********** #define SAFETY_SPI1_PORT_MASK 0x00000010 ///< Safety shutdown GPIO port mask (CS[4] - re-purposed as output GPIO). #define SET_SAFETY_SHUTDOWN() {mibspiREG1->PC3 |= SAFETY_SPI1_PORT_MASK;} ///< Set safety shutdown GPIO macro. #define CLR_SAFETY_SHUTDOWN() {mibspiREG1->PC3 &= ~SAFETY_SPI1_PORT_MASK;} ///< Clear safety shutdown GPIO macro. /*********************************************************************//** * @brief * The setSystemREG1_SYSECR function sets the SYSECR register to a given value. * @details \b Inputs: none * @details \b Outputs: SYSECR register set to given value * @return none *************************************************************************/ void setSystemREG1_SYSECR( U32 regval ) { systemREG1->SYSECR = regval; } /*********************************************************************//** * @brief * The getSystemREG1_SYSECR function gets the current value of the SYSECR register. * @details \b Inputs: SYSECR register * @details \b Outputs: none * @return Value of the SYSECR register *************************************************************************/ U32 getSystemREG1_SYSECR( void ) { return systemREG1->SYSECR; } /*********************************************************************//** * @brief * The setCrcREG_PSA_SIGREGL1 function sets the CRC PSA_SIGREGL1 register * to a given value. * @details \b Inputs: none * @details \b Outputs: PSA_SIGREGL1 register set to given value * @return none *************************************************************************/ void setCrcREG_PSA_SIGREGL1( U32 regval ) { crcREG->PSA_SIGREGL1 = regval; } /*********************************************************************//** * @brief * The getCrcREG_PSA_SIGREGL1 function gets the current value of the CRC * PSA_SIGREGL1 register. * @details \b Inputs: PSA_SIGREGL1 register * @details \b Outputs: none * @return Value of the PSA_SIGREGL1 register *************************************************************************/ U32 getCrcREG_PSA_SIGREGL1( void ) { return crcREG->PSA_SIGREGL1; } /*********************************************************************//** * @brief * The set_saftey_shutdown function sets the GPIO to disable 24v supply. * @details \b Inputs: none * @details \b Outputs: mibspiREG1->PC3 * @return Value none *************************************************************************/ void set_safety_shutdown( void ) { SET_SAFETY_SHUTDOWN(); } /*********************************************************************//** * @brief * The clear_saftety_shutdown function clears the GPIO to enable 24v supply. * @details \b Inputs: none * @details \b Outputs: mibspiREG1->PC3 * @return Value none *************************************************************************/ void clear_saftety_shutdown( void ) { CLR_SAFETY_SHUTDOWN(); } /**@}*/