📄 ledblinker.cpp
字号:
/*
* LEDBlinker.CPP: An simple LED Blinker in EC++
*/
#include <stdio.h> // for printf
#include <XC167.h> // special function register definitions
#include "LEDBlinker.h" // LED Blinker header file
LEDBlinker* LEDBlinker::m_pInstance = 0;
// Get the only existing instance of this class
LEDBlinker* LEDBlinker::GetInst() {
if (m_pInstance == 0) {
m_pInstance = new LEDBlinker;
}
return m_pInstance;
}
// Constructor
LEDBlinker::LEDBlinker() {
}
// Destructor
LEDBlinker::~LEDBlinker() {
}
void LEDBlinker::DeleteInstance() {
if (0 != m_pInstance) {
delete m_pInstance;
m_pInstance = 0;
}
}
void LEDBlinker::Initialise() {
DP2 = 0xff00; // Set top 8 bits as output
}
void LEDBlinker::Delay() {
unsigned long tmp;
for (tmp = 0; tmp < 260000; tmp++);
}
void LEDBlinker::RunLights() {
unsigned int idx;
while(1) {
printf("Hello World!\n"); // Test Output
for (idx = 0x100; idx; idx <<= 1) {
P2 = ~idx;
Delay ();
}
for (idx = 0x8000; idx > 0xff; idx >>= 1) {
P2 = ~idx;
Delay ();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -