📄 main.c
字号:
#include "init.h" // included by C-Wiz#include "delay.h"#include "serial.h"#include <htc.h>#include <pic16f87.h>unsigned char delayus_variable;const unsigned char vec[] = {'z','Z','i','I','f','F','l','L'};unsigned char ms_getch(void){#define MS_EN RA4#define MS_CLK RB1#define MS_DATA RB0 unsigned char rdin=0x00, rdif=0x00, rdic=0x00; rdin = 0x00; rdif = 0x00; rdic = 0x00; while (MS_EN) { rdif = 0x1; if (MS_CLK){ rdin = rdin >> 1; if (MS_DATA) rdin |= 0x80; else rdin &= 0x7F; putch('0'+MS_DATA); while(MS_CLK); rdic++; } } if (rdif) { putlf; putchdec(rdin); putlf; rdif = 0x00; } return rdin;}#define PASSO 10voidmain(void){ unsigned char getch_timeout_temp,pass; unsigned char ch = 0x00; unsigned int i; unsigned char c; int passo = PASSO; init(); // Function call inserted by C-Wiz PORTA=0x00; ANSEL=0x00; TRISA=0x10; PORTB=0x00; // RB5 Input RX TRISB=0x07; //OPTION=0xFF; CLRWDT(); serial_setup(); while (1){ // now loop forever, taking input when ready //putch('.'); //do_foreground_process(); //ch = getch(); ch = ms_getch(); switch (ch) { case 'I': RB3 = 1; for(i=0; i < passo; i++) DelayMs(250); RB3 = 0; break; case 'i': RB4 = 1; for(i=0; i < passo; i++) DelayMs(250); RB4 = 0; break; case 'Z': RB6 = 1; for(i=0; i < passo; i++) DelayMs(250); RB6 = 0; break; case 'z': RB7 = 1; for(i=0; i < passo; i++) DelayMs(250); RB7 = 0; break; case 'f': RA0 = 1; for(i=0; i < passo; i++) DelayMs(250); RA0 = 0; break; case 'F': RA1 = 1; for(i=0; i < passo; i++) DelayMs(250); RA1 = 0; break; case 'l': RA3 = 0; break; case 'L': RA3 = 1; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': passo = 1 * (ch-'0'); break; }/* // 1 Sec isteresi for (i=0; i < 4; i++) { DelayMs(250); }*/ /* putst("INTCON: 0x"); putchhex(INTCON); putlf; putst("OSCCON: 0x"); putchhex(OSCCON); putlf;*/ } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -