text: /* ###################################################################
  **     This component module is generated by Processor Expert. Do not modify it.
  **     Filename    : SYNCINT.c
  **     Project     : WobblerV2
  **     Processor   : MKL02Z32VFM4
  **     Component   : ExtInt_LDD
  **     Version     : Component 02.156, Driver 01.02, CPU db: 3.00.000
  **     Repository  : Kinetis
  **     Compiler    : GNU C Compiler
  **     Date/Time   : 2017-10-01, 21:49, # CodeGen: 10
  **     Abstract    :
  **         This component, "ExtInt_LDD", provide a low level API 
  **         for unified access of external interrupts handling
  **         across various device designs.
  **         The component uses one pin which generates interrupt on 
  **         selected edge.
  **     Settings    :
  **          Component name                                 : SYNCINT
  **          Pin                                            : ADC0_SE5/CMP0_IN3/PTB1/IRQ_6/UART0_TX/UART0_RX
  **          Pin signal                                     : 
  **          Generate interrupt on                          : falling edge
  **          Interrupt                                      : INT_PORTB
  **          Interrupt priority                             : medium priority
  **          Initialization                                 : 
  **            Enabled in init. code                        : yes
  **            Auto initialization                          : yes
  **     Contents    :
  **         Init   - LDD_TDeviceData* SYNCINT_Init(LDD_TUserData *UserDataPtr);
  **         GetVal - bool SYNCINT_GetVal(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 SYNCINT.c
  ** @version 01.02
  ** @brief
  **         This component, "ExtInt_LDD", provide a low level API 
  **         for unified access of external interrupts handling
  **         across various device designs.
  **         The component uses one pin which generates interrupt on 
  **         selected edge.
  */         
  /*!
  **  @addtogroup SYNCINT_module SYNCINT module documentation
  **  @{
  */         
  
  /* MODULE SYNCINT. */
  
  #include "Events.h"
  #include "SYNCINT.h"
  /* {Default RTOS Adapter} No RTOS includes */
  
  #ifdef __cplusplus
  extern "C" {
  #endif 
  
  typedef struct {
    LDD_TUserData *UserData;             /* RTOS device data structure */
  } SYNCINT_TDeviceData, *SYNCINT_TDeviceDataPtr; /* Device data structure type */
  
  /* {Default RTOS Adapter} Static object used for simulation of dynamic driver memory allocation */
  static SYNCINT_TDeviceData DeviceDataPrv__DEFAULT_RTOS_ALLOC;
  /* {Default RTOS Adapter} Global variable used for passing a parameter into ISR */
  static SYNCINT_TDeviceData * INT_PORTB__DEFAULT_RTOS_ISRPARAM;
  
  /*
  ** ===================================================================
  **     Method      :  SYNCINT_Init (component ExtInt_LDD)
  */
  /*!
  **     @brief
  **         This method initializes the associated peripheral(s) and the
  **         component internal variables. The method is called
  **         automatically as a part of the application initialization
  **         code.
  **     @param
  **         UserDataPtr     - Pointer to the RTOS device
  **                           structure. This pointer will be passed to
  **                           all events as parameter.
  **     @return
  **                         - Pointer to the dynamically allocated private
  **                           structure or NULL if there was an error.
  */
  /* ===================================================================*/
  LDD_TDeviceData* SYNCINT_Init(LDD_TUserData *UserDataPtr)
  {
    /* Allocate LDD device structure */
    SYNCINT_TDeviceData *DeviceDataPrv;
  
    /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
    DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC;
    /* Store the UserData pointer */
    DeviceDataPrv->UserData = UserDataPtr;
    /* Interrupt vector(s) allocation */
    /* {Default RTOS Adapter} Set interrupt vector: IVT is static, ISR parameter is passed by the global variable */
    INT_PORTB__DEFAULT_RTOS_ISRPARAM = DeviceDataPrv;
    /* Initialization of Port Control registers */
    /* PORTB_PCR1: ISF=0,MUX=1 */
    PORTB_PCR1 = (uint32_t)((PORTB_PCR1 & (uint32_t)~(uint32_t)(
                  PORT_PCR_ISF_MASK |
                  PORT_PCR_MUX(0x06)
                 )) | (uint32_t)(
                  PORT_PCR_MUX(0x01)
                 ));
    /* PORTB_PCR1: ISF=1,IRQC=0x0A */
    PORTB_PCR1 = (uint32_t)((PORTB_PCR1 & (uint32_t)~(uint32_t)(
                  PORT_PCR_IRQC(0x05)
                 )) | (uint32_t)(
                  PORT_PCR_ISF_MASK |
                  PORT_PCR_IRQC(0x0A)
                 ));
    /* NVIC_IPR7: PRI_31=0x80 */
    NVIC_IPR7 = (uint32_t)((NVIC_IPR7 & (uint32_t)~(uint32_t)(
                 NVIC_IP_PRI_31(0x7F)
                )) | (uint32_t)(
                 NVIC_IP_PRI_31(0x80)
                ));
    /* NVIC_ISER: SETENA|=0x80000000 */
    NVIC_ISER |= NVIC_ISER_SETENA(0x80000000);
    /* Registration of the device structure */
    PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_SYNCINT_ID,DeviceDataPrv);
    return ((LDD_TDeviceData *)DeviceDataPrv);
  }
  
  /*
  ** ===================================================================
  **     Method      :  SYNCINT_Interrupt (component ExtInt_LDD)
  **
  **     Description :
  **         The method services the interrupt of the selected peripheral(s)
  **         and eventually invokes event(s) of the component.
  **         This method is internal. It is used by Processor Expert only.
  ** ===================================================================
  */
  void SYNCINT_Interrupt(void)
  {
    /* {Default RTOS Adapter} ISR parameter is passed through the global variable */
    SYNCINT_TDeviceDataPtr DeviceDataPrv = INT_PORTB__DEFAULT_RTOS_ISRPARAM;
  
    /* Check the pin interrupt flag of the shared interrupt */
    if (PORT_PDD_GetPinInterruptFlag(PORTB_BASE_PTR, SYNCINT_PIN_INDEX)) {
      /* Clear the interrupt flag */
      PORT_PDD_ClearPinInterruptFlag(PORTB_BASE_PTR, SYNCINT_PIN_INDEX);
      /* Call OnInterrupt event */
      SYNCINT_OnInterrupt(DeviceDataPrv->UserData);
    }
  }
  
  /*
  ** ===================================================================
  **     Method      :  SYNCINT_GetVal (component ExtInt_LDD)
  */
  /*!
  **     @brief
  **         Returns the actual value of the input pin of the component.
  **     @param
  **         DeviceDataPtr   - Device data structure
  **                           pointer returned by <Init> method.
  **     @return
  **                         - Returned input value. Possible values:
  **                           <false> - logical "0" (Low level) <true> -
  **                           logical "1" (High level)
  */
  /* ===================================================================*/
  bool SYNCINT_GetVal(LDD_TDeviceData *DeviceDataPtr)
  {
    (void)DeviceDataPtr;                 /* Parameter is not used, suppress unused argument warning */
    if ((GPIO_PDD_GetPortDataInput(PTB_BASE_PTR) & SYNCINT_PIN_MASK) != 0U) {
      return TRUE;
    } else {
      return FALSE;
    }
  }
  
  /* END SYNCINT. */
  
  #ifdef __cplusplus
  }  /* extern "C" */
  #endif 
  
  /*!
  ** @}
  */
  /*
  ** ###################################################################
  **
  **     This file was created by Processor Expert 10.5 [05.21]
  **     for the Freescale Kinetis series of microcontrollers.
  **
  ** ###################################################################
  */
  