這次要測(cè)試的是驅(qū)動(dòng)OLED12864顯示屏。OLED12864模塊使用的是IIC接口,SDA接RF4引腳,SCL接RF5引腳,電源為3.3V。IIC時(shí)序使用軟件模擬,采用強(qiáng)制讀寫模式。
1.iic.h文件
#ifndef __IIC_H
#define __IIC_H
#include
#include "system_config.h"
#define IIC_SCL(status)? ? ? if(status)
PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_5);
else? ? ? ?
PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_5)?
#define IIC_SDA_OUT(status)? if(status)
PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_4);
else? ? ? ?
PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_4)
#define DELAY_US? ? ? ? ? ? ?asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
asm("nop");asm("nop");asm("nop");? ? ? ? asm("nop");
評(píng)論
查看更多