eris2010

Documentation: http://frombelow.net/projects/eris2010/
Clone: git clone https://git.frombelow.net/eris2010.git
Log | Files | Refs | Submodules | README | LICENSE

blink.c (766B)


      1 /*
      2  * Copyright 2021 Gerd Beuster (gerd@frombelow.net). This is free
      3  * software under the GNU GPL v3 license or any later version. See
      4  * COPYING in the root directory for details.
      5  */
      6 
      7 #include <conio.h>
      8 #include "../cc65_eris/os.h"
      9 
     10 void main(void){
     11   unsigned char ddra;
     12   unsigned int delay;
     13   unsigned char blink;
     14   cputs("Hit a key.\r\n");
     15   cgetc();
     16   cputs("Bliniking LED.\r\n");
     17   // Set PA4 as output
     18   ddra = PEEK(VIA_DDRA);
     19   ddra |= 0x10;
     20   POKE(VIA_DDRA, ddra);
     21   for (;;) {
     22     // Toggle LED on every
     23     // counter overflow.
     24     if (++delay == 0) {
     25       blink = PEEK(VIA_RA);
     26       blink ^= 0x10;
     27       POKE(VIA_RA, blink);
     28     }
     29     if (kbhit()) {
     30 	// Key has been pressed.
     31 	// Exit if it is 'q'
     32 	if (cgetc() == 'q') {
     33 	  break;
     34 	}
     35       }
     36 
     37   }
     38 }