?? led.c
字號:
// Copyright (c) David Vescovi. All rights reserved.
// Part of Project DrumStix
// Windows Embedded Developers Interest Group (WE-DIG) community project.
// http://www.we-dig.org
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
// File: led.c
//
// This module implements the Debug LED.
//
//------------------------------------------------------------------------------
#include "bsp.h"
#include <nkintr.h>
//------------------------------------------------------------------------------
// Defines
//
//------------------------------------------------------------------------------
// Externs
//
//------------------------------------------------------------------------------
// Global Variables
static BOOL g_debugLedState;
//------------------------------------------------------------------------------
// Local Variables
//
//------------------------------------------------------------------------------
// Local Functions
//
//------------------------------------------------------------------------------
//
// Function: OEMInitLED
//
// Configure GPIO for LED output.
//
//------------------------------------------------------------------------------
BOOL OEMInitLED(void)
{
volatile GPIO_REG_T *pGPIORegs = NULL;
pGPIORegs = (volatile GPIO_REG_T *) OALPAtoVA(PXA255_BASE_REG_PA_GPIO, FALSE);
pGPIORegs->GPDR2 |= DEBUG_LED_GPIO;
OEMWriteDebugLED(0, 0);
g_debugLedState = FALSE;
return (TRUE);
}
//------------------------------------------------------------------------------
//
// Function: OEMInitDebugLED
//
// Configure GPIO for LED output.
//
//------------------------------------------------------------------------------
void OEMInitDebugLED(void)
{
volatile GPIO_REG_T *pGPIORegs = NULL;
pGPIORegs = (volatile GPIO_REG_T *) OALPAtoVA(PXA255_BASE_REG_PA_GPIO, FALSE);
#ifdef USE_DEBUG_LED
pGPIORegs->GPDR2 |= DEBUG_LED_GPIO;
#endif
OEMWriteDebugLED(0, 0);
g_debugLedState = FALSE;
}
//------------------------------------------------------------------------------
//
// Function: OEMWriteDebugLED
//
// Writes to debug LED.
// Turns off LED if Pattern 0
// Turns on LED if Pattern 1
// Toggle LED if Pattern 2
// Index not used.
//
//------------------------------------------------------------------------------
void OEMWriteDebugLED(UINT16 Index, DWORD Pattern)
{
volatile GPIO_REG_T *pGPIORegs = NULL;
pGPIORegs = (volatile GPIO_REG_T *) OALPAtoVA(PXA255_BASE_REG_PA_GPIO, FALSE);
if (Pattern == 2)
{ // toggle
g_debugLedState ? (pGPIORegs->GPSR2 = DEBUG_LED_GPIO) : (pGPIORegs->GPCR2 = DEBUG_LED_GPIO);
g_debugLedState = !g_debugLedState;
}
else
{ // ON or OFF
Pattern ? (pGPIORegs->GPCR2 = DEBUG_LED_GPIO) : (pGPIORegs->GPSR2 = DEBUG_LED_GPIO);
g_debugLedState = (BOOL)Pattern;
}
}
//------------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -