⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ir.c

📁 Cirrus Logic EP7312处理器部分控制程序。
💻 C
字号:
//****************************************************************************
//
// IR.C - Routines for enabling the IR port and sending/receiving data via it
//
// Copyright (c) 1998-2001 Cirrus Logic, Inc.
//
//****************************************************************************
#include "ep7312.h"
#include "lib7312.h"

//****************************************************************************
//
// IREnable will configure the IR port and enable it for operation.
//
//****************************************************************************
long
IREnable(long lDataRate)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwBaseAddress;
    long lRates[5] = { 115200, 57600, 38400, 19200, 9600 };
    long lIdx;

    //
    // Make sure the data rate is valid.
    //
    for(lIdx = 0; lIdx < 5; lIdx++)
    {
        if(lRates[lIdx] == lDataRate)
        {
            break;
        }
    }
    if(lIdx == 5)
    {
        return(0);
    }

    //
    // Configure the UART.
    //
    if(UARTEnable(1, lDataRate, 8, 1, 0, 0) == 0)
    {
        return(0);
    }

    //
    // Enable the SIR encoder.
    //
    pulPtr[HwControl >> 2] |= HwControlUartSirEnable;

    //
    // Success.
    //
    return(1);
}

//****************************************************************************
//
// IRDisable will power off the IR port.
//
//****************************************************************************
void
IRDisable(void)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwBaseAddress;

    //
    // Disable the UART.
    //
    UARTDisable(1);

    //
    // Turn off the SIR encoder.
    //
    pulPtr[HwControl >> 2] &= ~HwControlUartSirEnable;
}

//****************************************************************************
//
// IRSendChar sends a character to the IR port.
//
//****************************************************************************
void
IRSendChar(char cChar)
{
    //
    // The IR port is simply a backend on UART1, so use the UART routine to
    // send this character.
    //
    UARTSendChar(1, cChar);
}

//****************************************************************************
//
// IRReceiveChar receives a character from the IR port.
//
//****************************************************************************
char
IRReceiveChar(void)
{
    //
    // The IR port is simply a backend on UART1, so use the UART routine to
    // receive a character.
    //
    return(UARTReceiveChar(1));
}

//****************************************************************************
//
// IRCharReady determines if there is a character ready to be read from the
// IR port.
//
//****************************************************************************
long
IRCharReady(void)
{
    //
    // The IR port is simply a backend on UART1, so use the UART routine to
    // determine if there is a character available.
    //
    return(UARTCharReady(1));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -