//-----------------------------------------------------------------------------
//
// Copyright (C) 2004, Motorola Inc. All Rights Reserved
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// File: bsppwm.c
//
// This file implements the BSP specific functions for PWM.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include "bsp.h"
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------
// This will define the choice of clock source in PWMCR register
#define PWM_CLKSRC_VAL PWM_PWMCR_CLKSRC_IPG_CLK_32K
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: BSPSetClockSource
//
// This function returns the BSP-specific clock
// source selection value for the PWM.
//
// Parameters:
// None
//
// Returns:
// The clock source for the PWM.
//
//------------------------------------------------------------------------------
UINT32 BSPSetPWMClockSource(void)
{
return PWM_CLKSRC_VAL;
}
//------------------------------------------------------------------------------
//
// Function: BSPPwmSetClockGatingMode
//
// This function enable or disable CRM clock for PWM.
//
// Parameters:
// startClocks
// [in] boolean variable to enable or disable CRM clock
//
// Returns:
// Return TRUE.
//
//------------------------------------------------------------------------------
BOOL BSPPwmSetClockGatingMode(BOOL startClocks)
{
BOOL rc;
if (startClocks)
{
rc = DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_PWM,
DDK_CLOCK_GATE_MODE_ENABLED_ALL);
}
else
{
rc = DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_PWM,
DDK_CLOCK_GATE_MODE_DISABLED);
}
return rc;
}
//------------------------------------------------------------------------------
//
// Function: BSPPwmGetClockGatingMode
//
// This function reads the value of CRM clock for PWM.
//
// Parameters:
// None
//
// Returns:
// Return TRUE if clock is not disabled, else return FALSE.
//
//------------------------------------------------------------------------------
BOOL BSPPwmGetClockGatingMode()
{
DDK_CLOCK_GATE_MODE ClockState;
DDKClockGetGatingMode(DDK_CLOCK_GATE_INDEX_PWM, &ClockState);
if (ClockState != DDK_CLOCK_GATE_MODE_DISABLED)
{
return TRUE;
}
else
{
return FALSE;
}
}
//------------------------------------------------------------------------------
//
// Function: BSPPwmIomuxSetPin
//
// This function configures the IOMUX pin for PWM.
//
// Parameters:
// None
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void BSPPwmIomuxSetPin(void)
{
DDKIomuxSetPinMux(DDK_IOMUX_PIN_PWMO, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
}