aboutsummaryrefslogtreecommitdiff
path: root/KSDK_1.2.0/platform/drivers/src/aoi
diff options
context:
space:
mode:
Diffstat (limited to 'KSDK_1.2.0/platform/drivers/src/aoi')
-rwxr-xr-xKSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_common.c46
-rwxr-xr-xKSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_driver.c156
-rwxr-xr-xKSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_lpm_callback.c103
3 files changed, 305 insertions, 0 deletions
diff --git a/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_common.c b/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_common.c
new file mode 100755
index 0000000..7dc09c2
--- /dev/null
+++ b/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_common.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 - 2014, 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.
+ */
+
+#include "fsl_device_registers.h"
+
+#if FSL_FEATURE_SOC_AOI_COUNT
+
+/*******************************************************************************
+ * Variables
+ ******************************************************************************/
+
+/*! @brief Table of base addresses for AOI instances. */
+AOI_Type* const g_aoiBase[] = AOI_BASE_PTRS;
+
+#endif /* FSL_FEATURE_SOC_AOI_COUNT */
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/
+
diff --git a/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_driver.c b/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_driver.c
new file mode 100755
index 0000000..730a91a
--- /dev/null
+++ b/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_driver.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013 - 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.
+ */
+#include "fsl_aoi_driver.h"
+#include "fsl_clock_manager.h"
+
+#if FSL_FEATURE_SOC_AOI_COUNT
+
+/*FUNCTION*********************************************************************
+ *
+ * Function Name : AOI_DRV_Init
+ * Description : Initialize the AOI module to the reset state.
+ * This API should be called before any operation of the AOI module.
+ *
+ *END*************************************************************************/
+aoi_status_t AOI_DRV_Init(uint32_t instance)
+{
+ AOI_Type* base = g_aoiBase[instance];
+
+ /* Enable the clock gate from clock manager. */
+ bool mEnable = CLOCK_SYS_GetAoiGateCmd(0);
+ if (!mEnable)
+ {
+ CLOCK_SYS_EnableAoiClock(0);
+ }
+
+ /* Init registers of the AOI module to the reset state. */
+ AOI_HAL_Init(base);
+
+ return kStatus_AOI_Success;
+}
+
+/*FUNCTION*********************************************************************
+ *
+ * Function Name : AOI_DRV_Deinit
+ * Description : De-initialize the AOI module. It shuts down the AOI module
+ * clock to reduce the power consumption and resets the registers configuration.
+ *
+ *END*************************************************************************/
+aoi_status_t AOI_DRV_Deinit(uint32_t instance)
+{
+ AOI_Type* base = g_aoiBase[instance];
+
+ /*Get module to the reset state - clears all configurations*/
+ AOI_HAL_Init(base);
+
+ /*Disable clock to the AOI module*/
+ CLOCK_SYS_DisableAoiClock(0);
+
+ return kStatus_AOI_Success;
+}
+
+/*FUNCTION*********************************************************************
+ *
+ * Function Name : AOI_DRV_ConfigEventLogic
+ * Description : Configures selected event output of the AOI module. It will configure
+ * the event output of the AOI module itself according the eventConfig structure.
+ * This function configures all of the inputs (A, B, C, and D)
+ * of all of the product terms (0, 1, 2, and 3) of a desired event.
+ *
+ *END*************************************************************************/
+aoi_status_t AOI_DRV_ConfigEventLogic(uint32_t instance,
+ aoi_event_index_t event,
+ const aoi_event_config_t * eventConfigPtr)
+{
+ AOI_Type* base = g_aoiBase[instance];
+
+ if(!eventConfigPtr)
+ {
+ return kStatus_AOI_InvalidArgument;
+ }
+
+ /* Set the selected AOI module event registers according eventConfigPtr target structure */
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm0, kAoiInputA, eventConfigPtr->PT0AC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm0, kAoiInputB, eventConfigPtr->PT0BC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm0, kAoiInputC, eventConfigPtr->PT0CC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm0, kAoiInputD, eventConfigPtr->PT0DC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm1, kAoiInputA, eventConfigPtr->PT1AC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm1, kAoiInputB, eventConfigPtr->PT1BC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm1, kAoiInputC, eventConfigPtr->PT1CC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm1, kAoiInputD, eventConfigPtr->PT1DC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm2, kAoiInputA, eventConfigPtr->PT2AC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm2, kAoiInputB, eventConfigPtr->PT2BC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm2, kAoiInputC, eventConfigPtr->PT2CC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm2, kAoiInputD, eventConfigPtr->PT2DC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm3, kAoiInputA, eventConfigPtr->PT3AC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm3, kAoiInputB, eventConfigPtr->PT3BC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm3, kAoiInputC, eventConfigPtr->PT3CC);
+ AOI_HAL_SetSignalLogicUnit(base, event, kAoiTerm3, kAoiInputD, eventConfigPtr->PT3DC);
+
+ return kStatus_AOI_Success;
+}
+
+/*FUNCTION*********************************************************************
+ *
+ * Function Name : AOI_DRV_ConfigProductTermLogic
+ * Description : Configuration of one of the AOI module product term in a specific event.
+ * This function configures one of the AOI module product terms for a specific event. The user has
+ * to select the event and the product term which will be configured and fill the
+ * AoiProductTermConfig configuration structure.
+ *
+ *END*************************************************************************/
+aoi_status_t AOI_DRV_ConfigProductTermLogic(uint32_t instance,
+ aoi_event_index_t event,
+ aoi_product_term_t productTerm,
+ const aoi_product_term_config_t * productTermConfigPtr)
+{
+ AOI_Type* base = g_aoiBase[instance];
+
+ if(!productTermConfigPtr)
+ {
+ return kStatus_AOI_InvalidArgument;
+ }
+
+ /* Set the selected AOI module event product term registers according eventConfigPtr target
+ * structure
+ */
+ AOI_HAL_SetSignalLogicUnit(base, event, productTerm, kAoiInputA, productTermConfigPtr->PTAC);
+ AOI_HAL_SetSignalLogicUnit(base, event, productTerm, kAoiInputB, productTermConfigPtr->PTBC);
+ AOI_HAL_SetSignalLogicUnit(base, event, productTerm, kAoiInputC, productTermConfigPtr->PTCC);
+ AOI_HAL_SetSignalLogicUnit(base, event, productTerm, kAoiInputD, productTermConfigPtr->PTDC);
+
+ return kStatus_AOI_Success;
+}
+
+#endif /* FSL_FEATURE_SOC_AOI_COUNT */
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/
+
diff --git a/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_lpm_callback.c b/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_lpm_callback.c
new file mode 100755
index 0000000..ed93b32
--- /dev/null
+++ b/KSDK_1.2.0/platform/drivers/src/aoi/fsl_aoi_lpm_callback.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+// Includes
+///////////////////////////////////////////////////////////////////////////////
+
+// Standard C Included Files
+#include <stdio.h>
+#include <stdint.h>
+
+// SDK Included Files
+#include "fsl_power_manager.h"
+#include "fsl_clock_manager.h"
+#if FSL_FEATURE_SOC_AOI_COUNT
+
+power_manager_error_code_t aoi_pm_callback(power_manager_notify_struct_t * notify,
+ power_manager_callback_data_t * dataPtr)
+{
+ power_manager_error_code_t result = kPowerManagerSuccess;
+
+ switch (notify->notifyType)
+ {
+ case kPowerManagerNotifyRecover:
+ /* TODO */
+ /* Add code here. */
+ break;
+
+ case kPowerManagerNotifyBefore:
+ /* TODO */
+ /* Add code here. */
+ break;
+
+ case kPowerManagerNotifyAfter:
+ /* TODO */
+ /* Add code here. */
+ break;
+
+ default:
+ result = kPowerManagerError;
+ break;
+ }
+
+ return result;
+}
+
+clock_manager_error_code_t aoi_cm_callback(clock_notify_struct_t *notify,
+ void* dataPtr)
+{
+ clock_manager_error_code_t result = kClockManagerSuccess;
+
+ switch (notify->notifyType)
+ {
+ case kClockManagerNotifyBefore:
+ /* TODO */
+ /* Add code here. */
+ break;
+
+ case kClockManagerNotifyRecover:
+ /* TODO */
+ /* Add code here. */
+ break;
+
+ case kClockManagerNotifyAfter:
+ /* TODO */
+ /* Add code here. */
+ break;
+
+ default:
+ result = kClockManagerError;
+ break;
+ }
+ return result;
+}
+#endif
+