text: /* ###################################################################
  **     This component module is generated by Processor Expert. Do not modify it.
  **     Filename    : CODEC_PDN.c
  **     Project     : eurocodec
  **     Processor   : MK22FN512VLH12
  **     Component   : BitIO_LDD
  **     Version     : Component 01.033, Driver 01.03, CPU db: 3.00.000
  **     Repository  : Kinetis
  **     Compiler    : GNU C Compiler
  **     Date/Time   : 2015-12-05, 11:41, # CodeGen: 0
  **     Abstract    :
  **         The HAL BitIO component provides a low level API for unified
  **         access to general purpose digital input/output pins across
  **         various device designs.
  **
  **         RTOS drivers using HAL BitIO API are simpler and more
  **         portable to various microprocessors.
  **     Settings    :
  **          Component name                                 : CODEC_PDN
  **          Pin for I/O                                    : PTB19/FTM2_CH1/I2S0_TX_FS/FBa_OE_b/FTM2_QD_PHB
  **          Direction                                      : Input/Output
  **          Initialization                                 : 
  **            Init. direction                              : Output
  **            Init. value                                  : 0
  **            Auto initialization                          : yes
  **          Safe mode                                      : no
  **     Contents    :
  **         Init     - LDD_TDeviceData* CODEC_PDN_Init(LDD_TUserData *UserDataPtr);
  **         SetDir   - void CODEC_PDN_SetDir(LDD_TDeviceData *DeviceDataPtr, bool Dir);
  **         SetInput - void CODEC_PDN_SetInput(LDD_TDeviceData *DeviceDataPtr);
  **         GetVal   - bool CODEC_PDN_GetVal(LDD_TDeviceData *DeviceDataPtr);
  **         PutVal   - void CODEC_PDN_PutVal(LDD_TDeviceData *DeviceDataPtr, bool Val);
  **         ClrVal   - void CODEC_PDN_ClrVal(LDD_TDeviceData *DeviceDataPtr);
  **         SetVal   - void CODEC_PDN_SetVal(LDD_TDeviceData *DeviceDataPtr);
  **
  **     Copyright : 1997 - 2015 Freescale Semiconductor, Inc. 
  **     All Rights Reserved.
  **     
  **     Redistribution and use in source and binary forms, with or without modification,
  **     are permitted provided that the following conditions are met:
  **     
  **     o Redistributions of source code must retain the above copyright notice, this list
  **       of conditions and the following disclaimer.
  **     
  **     o 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.
  **     
  **     o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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.
  **     
  **     http: www.freescale.com
  **     mail: support@freescale.com
  ** ###################################################################*/
  /*!
  ** @file CODEC_PDN.c
  ** @version 01.03
  ** @brief
  **         The HAL BitIO component provides a low level API for unified
  **         access to general purpose digital input/output pins across
  **         various device designs.
  **
  **         RTOS drivers using HAL BitIO API are simpler and more
  **         portable to various microprocessors.
  */         
  /*!
  **  @addtogroup CODEC_PDN_module CODEC_PDN module documentation
  **  @{
  */         
  
  /* MODULE CODEC_PDN. */
  
  /* {Default RTOS Adapter} No RTOS includes */
  #include "CODEC_PDN.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif 
  
  typedef struct {
    LDD_TUserData *UserDataPtr;          /* Pointer to user data */
  } CODEC_PDN_TDeviceData;               /* Device data structure type */
  
  typedef CODEC_PDN_TDeviceData *CODEC_PDN_TDeviceDataPtr ; /* Pointer to the device data structure. */
  
  /* {Default RTOS Adapter} Static object used for simulation of dynamic driver memory allocation */
  static CODEC_PDN_TDeviceData DeviceDataPrv__DEFAULT_RTOS_ALLOC;
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_Init (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         Initializes the device. Allocates memory for the device data
  **         structure, allocates interrupt vectors and sets interrupt
  **         priority, sets pin routing, sets timing, etc. If the "Enable
  **         in init. code" is set to "yes" value then the device is also
  **         enabled(see the description of the Enable() method). In this
  **         case the Enable() method is not necessary and needn't to be
  **         generated. 
  **     @param
  **         UserDataPtr     - Pointer to the user or
  **                           RTOS specific data. This pointer will be
  **                           passed as an event or callback parameter.
  **     @return
  **                         - Pointer to the dynamically allocated private
  **                           structure or NULL if there was an error.
  */
  /* ===================================================================*/
  LDD_TDeviceData* CODEC_PDN_Init(LDD_TUserData *UserDataPtr)
  {
    /* Allocate device structure */
    CODEC_PDN_TDeviceDataPtr DeviceDataPrv;
  
    /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
    DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC;
    DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */
    /* Enable device clock gate */
    /* SIM_SCGC5: PORTB=1 */
    SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
    /* Configure pin as output */
    /* GPIOB_PDDR: PDD|=0x00080000 */
    GPIOB_PDDR |= GPIO_PDDR_PDD(0x00080000);
    /* Set initialization value */
    /* GPIOB_PDOR: PDO&=~0x00080000 */
    GPIOB_PDOR &= (uint32_t)~(uint32_t)(GPIO_PDOR_PDO(0x00080000));
    /* Initialization of pin routing */
    /* PORTB_PCR19: ISF=0,MUX=1 */
    PORTB_PCR19 = (uint32_t)((PORTB_PCR19 & (uint32_t)~(uint32_t)(
                   PORT_PCR_ISF_MASK |
                   PORT_PCR_MUX(0x06)
                  )) | (uint32_t)(
                   PORT_PCR_MUX(0x01)
                  ));
    /* Registration of the device structure */
    PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_CODEC_PDN_ID,DeviceDataPrv);
    return ((LDD_TDeviceData *)DeviceDataPrv);
  }
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_SetDir (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         Sets a pin direction (available only if the direction =
  **         _[input/output]_).
  **     @param
  **         DeviceDataPtr   - Device data structure
  **                           pointer returned by <Init> method.
  **     @param
  **         Dir             - Direction to set. Possible values:
  **                           <false> - Input
  **                           <true> - Output
  */
  /* ===================================================================*/
  void CODEC_PDN_SetDir(LDD_TDeviceData *DeviceDataPtr, bool Dir)
  {
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    if (Dir) {
      /* Output */
      GPIO_PDD_SetPortOutputDirectionMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
    } else {
      /* Input */
      GPIO_PDD_SetPortInputDirectionMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
    }
  }
  
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_SetInput (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         Sets a pin direction to input (available only if the
  **         direction = _[input/output]_).
  **     @param
  **         DeviceDataPtr   - Device data structure
  **                           pointer returned by <Init> method.
  */
  /* ===================================================================*/
  void CODEC_PDN_SetInput(LDD_TDeviceData *DeviceDataPtr)
  {
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    GPIO_PDD_SetPortInputDirectionMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
  }
  
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_GetVal (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         Returns the input/output value. If the direction is [input]
  **         then the input value of the pin is read and returned. If the
  **         direction is [output] then the last written value is read
  **         and returned (see <Safe mode> property for limitations).
  **         This method cannot be disabled if direction is [input].
  **     @param
  **         DeviceDataPtr   - Device data structure
  **                           pointer returned by <Init> method.
  **     @return
  **                         - Input or output value. Possible values:
  **                           <false> - logical "0" (Low level)
  **                           <true> - logical "1" (High level)
  */
  /* ===================================================================*/
  bool CODEC_PDN_GetVal(LDD_TDeviceData *DeviceDataPtr)
  {
    uint32_t PortData;                   /* Port data masked according to the bit used */
  
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    if ((GPIO_PDD_GetPortDirection(CODEC_PDN_MODULE_BASE_ADDRESS) & CODEC_PDN_PORT_MASK) == 0U) {
      /* Port is configured as input */
      PortData = GPIO_PDD_GetPortDataInput(CODEC_PDN_MODULE_BASE_ADDRESS) & CODEC_PDN_PORT_MASK;
    } else {
      /* Port is configured as output */
      PortData = GPIO_PDD_GetPortDataOutput(CODEC_PDN_MODULE_BASE_ADDRESS) & CODEC_PDN_PORT_MASK;
    }
    return (PortData != 0U) ? (bool)TRUE : (bool)FALSE;
  }
  
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_PutVal (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         The specified output value is set. If the direction is <b>
  **         input</b>, the component saves the value to a memory or a
  **         register and this value will be written to the pin after
  **         switching to the output mode (using <tt>SetDir(TRUE)</tt>;
  **         see <a href="BitIOProperties.html#SafeMode">Safe mode</a>
  **         property for limitations). If the direction is <b>output</b>,
  **         it writes the value to the pin. (Method is available only if
  **         the direction = <u><tt>output</tt></u> or <u><tt>
  **         input/output</tt></u>).
  **     @param
  **         DeviceDataPtr   - Device data structure
  **                           pointer returned by <Init> method.
  **     @param
  **         Val             - Output value. Possible values:
  **                           <false> - logical "0" (Low level)
  **                           <true> - logical "1" (High level)
  */
  /* ===================================================================*/
  void CODEC_PDN_PutVal(LDD_TDeviceData *DeviceDataPtr, bool Val)
  {
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    if (Val) {
      GPIO_PDD_SetPortDataOutputMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
    } else { /* !Val */
      GPIO_PDD_ClearPortDataOutputMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
    } /* !Val */
  }
  
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_ClrVal (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         Clears (set to zero) the output value. It is equivalent to
  **         the [PutVal(FALSE)]. This method is available only if the
  **         direction = _[output]_ or _[input/output]_.
  **     @param
  **         DeviceDataPtr   - Pointer to device data
  **                           structure returned by <Init> method.
  */
  /* ===================================================================*/
  void CODEC_PDN_ClrVal(LDD_TDeviceData *DeviceDataPtr)
  {
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    GPIO_PDD_ClearPortDataOutputMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
  }
  
  /*
  ** ===================================================================
  **     Method      :  CODEC_PDN_SetVal (component BitIO_LDD)
  */
  /*!
  **     @brief
  **         Sets (to one) the output value. It is equivalent to the
  **         [PutVal(TRUE)]. This method is available only if the
  **         direction = _[output]_ or _[input/output]_.
  **     @param
  **         DeviceDataPtr   - Pointer to device data
  **                           structure returned by <Init> method.
  */
  /* ===================================================================*/
  void CODEC_PDN_SetVal(LDD_TDeviceData *DeviceDataPtr)
  {
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    GPIO_PDD_SetPortDataOutputMask(CODEC_PDN_MODULE_BASE_ADDRESS, CODEC_PDN_PORT_MASK);
  }
  
  /* END CODEC_PDN. */
  
  #ifdef __cplusplus
  }  /* extern "C" */
  #endif 
  
  /*!
  ** @}
  */
  /*
  ** ###################################################################
  **
  **     This file was created by Processor Expert 10.5 [05.21]
  **     for the Freescale Kinetis series of microcontrollers.
  **
  ** ###################################################################
  */
  