📄 bspowire.c
字号:
//------------------------------------------------------------------------------
//
// Copyright (C) 2006, 2007 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: bspowire.c
//
// Provides BSP-specific configuration routines for the OWIRE peripheral.
//
//------------------------------------------------------------------------------
#include <windows.h>
#include "owire_priv.h"
#include "bsp.h"
//------------------------------------------------------------------------------
// External Functions
//------------------------------------------------------------------------------
// External Variables
//------------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: BSPGetDivider
//
// Determine the appropriate time divider value for the one-wire module.
// The divider value is chosen based on the clock so as to arrive at
// a divided clock closest to 1MHz.
//
// Parameters:
// None.
//
// Returns:
// The value to go into the OWIRE time divider register.
//
//------------------------------------------------------------------------------
UINT16 BSPGetDivider()
{
UINT16 div, rem;
UINT32 freq;
DDKClockGetFreq(DDK_CLOCK_SIGNAL_PER, &freq);
div = freq / 1000000;
rem = (UINT16)(freq % 1000000);
if (rem >= 500000)
div++;
return div;
}
//------------------------------------------------------------------------------
//
// Function: BSPOwireCrmSetClockGatingMode
//
// This function calls to the CRM module to
// set the clock gating mode, turning on or off
// clocks to the OWIRE.
//
// Parameters:
// startClocks
// [in] If TRUE, turn clocks to OWIRE on.
// If FALSE, turn clocks to OWIRE off
//
// Returns:
// TRUE if success.
// FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL BSPOwireSetClockGatingMode(BOOL startClocks)
{
if (startClocks)
{
// Turn OWIRE clocks on
if (!DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_OWIRE,
DDK_CLOCK_GATE_MODE_ENABLED_ALL))
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Failed to set CRM clock gating mode!\r\n"), __WFUNCTION__));
return FALSE;
}
}
else
{
// Turn OWIRE clocks off
if (!DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_OWIRE,
DDK_CLOCK_GATE_MODE_DISABLED))
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Failed to set CRM clock gating mode!\r\n"), __WFUNCTION__));
return FALSE;
}
}
return TRUE;
}
void BSPOwireIomuxSetPin(void)
{
DDKIomuxSetPinMux(DDK_IOMUX_PIN_BATT_LINE, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -