ioctrl.c

来自「TI DSP系列读下CF卡程序,可用做图象存储产品的开发」· C语言 代码 · 共 51 行

C
51
字号
#include <io.h>
#include <sys/hyrtk.h>
#include "ioctrl.h"
#include "devctrl.h"


void SetLEDState(LEDControl LEDsOn, LEDControl LEDsOff)
{
  LEDsOff  &= LatchReg;
  LatchReg |=  LEDsOn;
  LatchReg &= ~LEDsOff;

  outpw(LATCH_ADDR, LatchReg);
}


UINT32 GetKeyState(UINT32 Keys)
{
  return (((~inpw(LATCH_ADDR)) & Keys) == Keys);
}

UINT32 ReadLatch(UINT32 Keys)
{
  return ((~inpw(LATCH_ADDR)) & Keys);
}

void WaitForKeyChange(UINT32 Keys)
{
  int keys = ReadLatch(Keys);

  while (keys == ReadLatch(Keys))
    DelayBy(1000);
}



UINT32 GetGPInput(UINT32 GPInputs)
{
  return (((~inpw(LATCH_ADDR)) & GPInputs) == GPInputs);
}


void SetGPOutput(GPOutputControl GPOutOn, GPOutputControl GPOutOff)
{
  GPOutOff &= LatchReg;
  LatchReg |=  GPOutOn;
  LatchReg &= ~GPOutOff;

  outpw(LATCH_ADDR, LatchReg);
}

⌨️ 快捷键说明

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