📄 u08main.c
字号:
//============================================================================
// File: U08MAIN.C
// Func: Main Module for USB08 Demo Application
// Ver.: 1.01
// Auth: (C)2000,2001 by Oliver Thamm, MCT Elektronikladen GbR
// http://hc08web.de/usb08
// Make: Build the project using U08MAIN.C, U08KEY.C, U08ADC.C and VECJB8.C
// Rem.: View/Edit this File with TAB-Size=4
// Jan 02 : Adapted for CodeWarrior by Isabelle GIRAUD, Metrowerks Europe
//============================================================================
//-- Includes ----------------------------------------------------------------
#include "hc08jb8.h" // HC908JB8 Register and Bitmap Definitions
#include "u08key.h" // Keyboard Module Header File
#include "u08led.h" // LED Module Header File (just Macros)
#include "u08adc.h" // Soft ADC Module Header File
//-- some Assembly Level Stuff -----------------------------------------------
#define cli() asm cli
#define nop() asm nop
//-- Data Type Definitions ---------------------------------------------------
typedef unsigned char uchar;
//-- Code Starts here --------------------------------------------------------
#include "u08usb.c" // use USB implementation
//----------------------------------------------------------------------------
// Dummy Interrupt Handler
// Place a Breakpoint here in case you are looking for spurious Interrupts
//
interrupt void isrDummy() {
nop(); // just for Debugging
}
//----------------------------------------------------------------------------
void main() {
uchar n, a;
uchar io_buffer[8];
uchar adc[3];
#if USB_COMMUNICATION==1 // Defined in the compiler commandline, 1 by default
initUSB(); // init RS232 or USB Pipe
#endif
initLED(); // init LED Output
initKey(); // init Key Input
initSADC(); // init Soft ADC
cli();
a = 0;
for(;;) {
// update ADC results (1 out of 3 at one time)
adc[a] = getSADC(a+1);
if(++a==3) a=0;
// get data from input pipe
#if USB_COMMUNICATION==1
n=0;
do {
io_buffer[n++] = getUSB();
} while(n<8);
#endif
// process input data
if(io_buffer[0]==0) offLED(1);
else onLED(1);
if(io_buffer[1]==0) offLED(2);
else onLED(2);
if(io_buffer[2]==0) offLED(3);
else onLED(3);
// send data to output pipe
io_buffer[0] = getKey(1);
io_buffer[1] = getKey(2);
io_buffer[2] = getKey(3);
io_buffer[3] = adc[0];
io_buffer[4] = adc[1];
io_buffer[5] = adc[2];
#if USB_COMMUNICATION==1
n=0;
do {
putUSB(io_buffer[n++]);
} while(n<8);
#endif
}
}
//============================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -