//********************************************************************** //■■■インクルード■■■ #include "lib_terminal.h" //********************************************************************** //■■■マクロ定義■■■ #define LED1 GPIO.F5 #define LED2 GPIO.F4 //********************************************************************** //■■■メイン関数■■■ void main() { char rd, buf[6]; double ad; // OSCCON = 0b01110000; // クロックは8Mhz CMCON0 = 0b00000111; // コンパレータは使用しない。 ANSEL = 0b00000011; // AN0、AN1を使用する。 TRISIO = 0b00001011; // LED1 = 0; LED2 = 0; // Soft_UART_Init(&GPIO, 3, 2, 9600, 0); // while (1) { rd = terminal_get_char(); switch (rd) { case 'A': ad = Adc_Read(0); ad = ad * 4.8828125; WordToStr(ad, buf); terminal_put_str(1, 1, buf); terminal_put_str(1, 6, "mV"); break; case 'B': ad = Adc_Read(1); ad = ad * 4.8828125; WordToStr(ad, buf); terminal_put_str(2, 1, buf); terminal_put_str(2, 6, "mV"); break; case 'C': LED1 = ~LED1; break; case 'D': LED2 = ~LED2; break; case '*': terminal_cmd(_LCD_CLEAR); break; } } } //********************************************************************** char terminal_stub_get_char() { char rd, error; // while (1) { rd = Soft_UART_Read(&error); if (error == 0) return(rd); } } void terminal_stub_put_char(char c) { Soft_UART_Write(c); } //**********************************************************************