本帖最后由 hello18 于 2018-9-21 09:50 编辑
位操作例程
主函数
*/
#include "holychip_define.h"
#include "user_define.h"
IMPLEMENT_BITS8(BITS8)//也可以定义在user_src.c文件中
void main()
{
// SET_BITS8(BITS8, 0)
Init();
while (1)
{
HCFLAG0 = 0;
HCFLAG1 = 1;
HCFLAG2 = 0;
HCFLAG3 = 1;
HCFLAG4 = 0;
HCFLAG5 = 1;
HCFLAG6 = 0;
HCFLAG7 = 1;
}
定义头文件
#define DECLARE_BITS8(a) \
extern bits8 a;
#define IMPLEMENT_BITS8(a) \
bits8 a;
#define DECLARE_BITS16(a) \
extern bits16 a;
#define IMPLEMENT_BITS16(a) \
bits16 a;
#define BITS(a, i) (a.bit##i)
#define SET_BITS8(a, b) \
a.bit0 = ((b)>>0x00)&0x01; \
a.bit1 = ((b)>>0x01)&0x01; \
a.bit2 = ((b)>>0x02)&0x01; \
a.bit3 = ((b)>>0x03)&0x01; \
a.bit4 = ((b)>>0x04)&0x01; \
a.bit5 = ((b)>>0x05)&0x01; \
a.bit6 = ((b)>>0x06)&0x01; \
a.bit7 = ((b)>>0x07)&0x01;
位操作例程_DemoCode_Ver1.0.1.0.zip
(41.41 KB)
|