#include "dinkusr.h" #include "support.h" #define getchar get_char #define getkb get_KEYBOARD #define putchar write_char #define printf dink_printf void blink_leds(int addr, int i); main() { set_up_transfer_base(); int decimal_no; char LED; do { printf ("\nSelect the LED you want to blink:\n"); printf ("\tS - Press S for the Status LED\n"); printf ("\tE - Press E for the Error LED\n"); printf ("\tQ - Press Q to Quit\n"); LED = getchar(getkb()); /* Read typed Character */ if (LED == 'E' || LED == 'e') { printf ("\nEnter the number of times to blink the Error LED: "); scanf("%d", &decimal_no); blink_leds(0x40600000, decimal_no); } else if (LED == 'S' || LED == 's') { printf ("\nEnter the number of times to blink the Status LED: "); scanf("%d", &decimal_no); blink_leds(0x40200000, decimal_no); } } while ( LED != 'Q' && LED != 'q' ); /* X or x */ return 0; } void blink_leds(int addr, int i) { unsigned long count; int loop; for (loop = 0 ; loop < i; loop++) { *(char *) (addr) = 0x00; //turn on selected LED for(count = 0; count <= 0xfff00; count ++){}; *(char *) (addr) = 0x08; //turn off selected LED for(count = 0; count <= 0xfff00; count ++){}; } *(char *) (0x40600000) = 0x08; }