eris2010

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

blink.c (579B)


      1 #include <conio.h>
      2 #include "../cc65_eris/os.h"
      3 
      4 void main(void){
      5   unsigned char ddra;
      6   unsigned int delay;
      7   unsigned char blink;
      8   cputs("Hit a key.\r\n");
      9   cgetc();
     10   cputs("Bliniking LED.\r\n");
     11   // Set PA4 as output
     12   ddra = PEEK(VIA_DDRA);
     13   ddra |= 0x10;
     14   POKE(VIA_DDRA, ddra);
     15   for (;;) {
     16     // Toggle LED on every
     17     // counter overflow.
     18     if (++delay == 0) {
     19       blink = PEEK(VIA_RA);
     20       blink ^= 0x10;
     21       POKE(VIA_RA, blink);
     22     }
     23     if (kbhit()) {
     24 	// Key has been pressed.
     25 	// Exit if it is 'q'
     26 	if (cgetc() == 'q') {
     27 	  break;
     28 	}
     29       }
     30 
     31   }
     32 }