Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <main.h>
- #include <flex_lcd.c>
- // Ad hoc programming, only for testing purpose (demo).
- // Needs to be revised before using.
- #INT_EXT
- void external (){
- delay_ms(50);
- if ( ! input(PIN_B0) ){
- printf("This is a message triggered by an external interrupt! ");
- }
- }
- void main (){
- lcd_init();
- setup_uart(9600);
- port_b_pullups(true);
- int ctprint;
- int ctcmd;
- int ctbyte;
- int posit = 1;
- int eeptmp;
- int eeadd;
- short cline = 0;
- printf(lcd_putc, "Hello World!\nPress button.");
- while( input(PIN_B0) );
- lcd_gotoxy(1,1);
- lcd_init();
- lcd_gotoxy(0,1);
- printf("Hello World! ");
- delay_ms(100);
- enable_interrupts(GLOBAL);
- enable_interrupts(INT_EXT);
- ext_int_edge (H_TO_L);
- while(true){
- ctprint=getc();
- if ( ctprint == 0x09 ){
- output_high(PIN_A0);
- ctcmd=getc();
- switch (ctcmd){
- case 0x42:
- case 0x62:
- output_high(PIN_A1);
- ctbyte=getc();
- lcd_send_byte(0,ctbyte);
- output_low(PIN_A1);
- break;
- case 0x52:
- case 0x72:
- lcd_init();
- posit = 1;
- cline = 0;
- break;
- case 0x45:
- case 0x65:
- output_high(PIN_A2);
- eeadd=getc();
- eeptmp=read_eeprom(eeadd);
- printf("%c", eeptmp);
- output_low(PIN_A2);
- break;
- case 0x57:
- case 0x77:
- output_high(PIN_A2);
- output_high(PIN_A1);
- eeadd=getc();
- output_low(PIN_A0);
- ctbyte=getc();
- write_eeprom(eeadd,ctbyte);
- delay_ms(8);
- output_low(PIN_A1);
- output_low(PIN_A2);
- break;
- case 0x43:
- case 0x63:
- output_low(PIN_A0);
- output_high(PIN_A2);
- int i;
- for(i=0;i<128;i++){
- write_eeprom(i,0xFF);
- }
- output_low(PIN_A2);
- break;
- case 0x46:
- case 0x66:
- output_low(PIN_A0);
- output_high(PIN_A2);
- for( i=0;i<127;i++ ){
- eeptmp=read_eeprom(i);
- printf("%c", eeptmp);
- }
- output_low(PIN_A2);
- break;
- case 0x09:
- break;
- }
- output_low(PIN_A0);
- }
- else if ( !( posit == 16 && cline == 1 ) && posit != 17 && ctprint != 0x08 && ctprint != 0x0A ){
- lcd_putc(ctprint);
- posit++;
- }
- else if ( !( posit == 1 && cline == 0 ) && ctprint == 0x08 ){
- lcd_putc(0x08);
- lcd_putc(0x20);
- lcd_putc(0x08);
- posit--;
- if ( posit == 0 ){
- lcd_gotoxy(17,1);
- posit=17;
- cline=0;
- }
- }
- else if ( posit == 17 && cline == 0 && ctprint != 0x0A ){
- lcd_gotoxy(1,0);
- cline=1;
- lcd_putc(ctprint);
- posit=1;
- }
- else if ( ctprint == 0x0A && cline == 0 ){
- lcd_putc(ctprint);
- posit=1;
- cline=1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement