74hc165串口转并口输入

来源:互联网 发布:php 大端小端 转换 编辑:程序博客网 时间:2024/06/05 03:13

74hc165.h

#ifndef _74H165_H_#define _74H165_H_#include<reg51.h>#include<intrins.h>#define GPIO_LED P0sbit IN_PL = P1^6;sbit IN_Data = P1^7;sbit SCK = P3^6;#ifndef uchar #define uchar unsigned char#endif#ifndef uint #define uint unsigned int#endifuchar read74H165();#endif

74hc165.c

#include<74H165.h>uchar read74H165(){    uchar i;    uchar indata;    //将数据并行输入    IN_PL = 0;           _nop_();    IN_PL = 1;    _nop_();    indata = 0;     //保存的数据清零    for(i = 0; i < 8; i++)    {        indata = indata << 1;        SCK = 0;        _nop_();        indata |= IN_Data;        SCK = 1;    }    return indata;}
0 0
原创粉丝点击