📄 8016a.c
字号:
/****************************************Copyright (c)*****************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:
** Last modified Date:
** Last Version: 1.0
** Descriptions: MiniISA-8016A功能函数
**
**------------------------------------------------------------------------------------------------------
** Created by:
** Created date:
** Version:
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
**********************************************************************************************************/
#include "config.h"
/**********************************************************************************************************
** Function name: void Wirte8016A(const uint8 *cmd, uint8 base)
** Descriptions: 8016A写命令数组
** Input: cmd 命令数组(3字节) cmd[0] 命令参数低字节
** cmd[1] 命令参数高字节
** cmd[2] 命令码 命令代码参看《MiniISA-8016A用户手册》
** base 板卡基址
** Output: 无
***********************************************************************************************************
*/
void Write8016A(const uint8 *cmd, uint8 base)
{
WriteBus(cmd, base, 3);
}
/**********************************************************************************************************
** Function name: void Wirte8016A(const uint8 *cmd, uint8 base)
** Descriptions: 8016A 读命令状态
** Input: info 状态数组(4字节) info[0] 命令返回值低字节
** info[1] 命令返回值高字节
** info[2] 命令回显
** info[3] IDI状态
** Output: base 板卡基址
**********************************************************************************************************/
void Read8016A(uint8 *info, uint8 base)
{
ReadBus(info, base, 4);
}
/**********************************************************************************************************
** Function name: void Wreg8016A(uint8 data, uint8 base, uint8 reg)
** Descriptions: 写8016A 寄存器
** Input: data 写入数据
** base 基址
** reg 目标寄存器 OMB0 ~ OMB3
** Output: 无
**********************************************************************************************************/
void Wreg8016A(uint8 data, uint8 base, uint8 reg)
{
*(volatile unsigned char *)(MISA_BASE_ADDR + base + reg) = data;
}
/**********************************************************************************************************
** Function name: uint8 Rreg8016A(uint8 base, uint8 reg)
** Descriptions: 读8016A 寄存器
** Input: base 基址
** reg 目标寄存器 IMB0~IMB3
** Output: 目标寄存器值
**********************************************************************************************************/
uint8 Rreg8016A(uint8 base, uint8 reg)
{
return ( *(volatile unsigned char *)(MISA_BASE_ADDR + base + reg) );
}
/**********************************************************************************************************
** Function name: void Wirte8016A(uint8 *cmd, uint8 base)
** Descriptions: 8016A命令操作
** Input: cmd 命令数组(3字节) cmd[0] 命令参数低字节
** cmd[1] 命令参数高字节
** cmd[2] 命令码 命令代码参看《MiniISA-8016A用户手册》
** base 板卡基址
** Output: 命令回显值
**********************************************************************************************************/
void WriteCmd8016A(uint8 *cmd, uint8 base)
{
Write8016A(cmd, base);
OSTimeDly(1); /* 简单化的等待命令操作方式 */
Read8016A(cmd, base);
}
/**********************************************************************************************************
** Function name: void Int8016A(void)
** Descriptions: 8016A中断函数
** Input: 无
** Output: 无
**********************************************************************************************************/
void Int8016A(void)
{
uint8 cmd[4], tmp, i;
cmd[2] = 0x60; /* 读中断标志寄存器 */
WriteCmd8016A(cmd, BoardB0);
tmp = cmd[0];
if ( (tmp & 0x01) == 0x01) {
/* 输入状态匹配中断处理 */
}
if ( (tmp & 0x02) == 0x02) {
cmd[2] = 0x61;
WriteCmd8016A(cmd, BoardB0); /* 读状态中断 */
}
if ( (tmp & 0x04) == 0x04) {
cmd[2] = 0x62;
WriteCmd8016A(cmd, BoardB0); /* 读取计数中断 */
if (cmd[0] != 0) { /* 匹配中断处理 */
cmd[2] = 0x29;
cmd[0] = 0x01;
WriteCmd8016A(cmd, BoardB0); /* 复位IDI0计数值 */
cmd[0] = 0xff;
cmd[2] = 1;
for (i=0; i<7; i++) { /* 继电器闪烁3次 */
cmd[0] = ~cmd[0];
Write8016A(cmd, BoardB0);
OSTimeDly(OS_TICKS_PER_SEC / 2);
}
}
if (cmd[1] != 0) { /* 溢出中断处理 */
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -