SmartOS/Drivers/74HC165Monitor.h

40 lines
900 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _74HC165MOR_H_
#define _74HC165MOR_H_
#include "Port.h"
#include "Power.h"
/* 备注
调用构造函数后 需要Open()一下
如果不Open() 在Read 里面也会Open 但第一次读取不对
*/
class IC74HC165MOR
{
private:
InputPort _PL;
InputPort _SCK;
InputPort _In;
ByteArray _Bs; // 内部缓冲区
byte _irqCount; // 记录pl信号后第几位数据
bool _sckHighSpeed;
public:
bool Opened;
// pl采集cp时钟Q7输出 bufsize 是级联个数highSpeed 是否是高速clk ms以下算高速
IC74HC165MOR(Pin pl, Pin sck, Pin in, byte bufSize = 0,bool highSpeed = true);
bool Open();
bool Close();
// 内部中断委托函数
void Trigger();
void ReaBit();
// 级联读取 buf,数据放置位置count级联ic数
byte Read(byte *buf, byte count);
// 读一个IC 的数据
byte Read();
};
#endif