Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <system.h>
- #include <stdio.h>
- #include <io.h>
- #define SW0 0x00000001
- #define SW1 0x00000002
- #define SW2 0x00000004
- #define SW3 0x00000008
- #define SW4 0x00000010
- #define SW5 0x00000020
- #define L_NULL 0x00000000
- #define LED0 0x00000001
- #define LED1 0x00000002
- #define LED2 0x00000004
- #define LED3 0x00000008
- #define LED4 0x00000010
- #define LED5 0x00000020
- #define LED6 0x00000040
- #define SEGA 0x00001
- #define SEGB 0x00002
- #define SEGC 0x00004
- #define SEGD 0x00008
- #define SEGE 0x00010
- #define SEGF 0x00020
- #define SEGG 0x00040
- #define H_NULL 0x00000000
- #define ONE SEGB | SEGC
- #define TWO SEGA | SEGB | SEGD | SEGE | SEGG
- #define THREE SEGA | SEGB | SEGC | SEGD | SEGG
- #define FOUR SEGB | SEGC | SEGF | SEGG
- #define FIVE SEGA | SEGC | SEGD | SEGF | SEGG
- #define SIX SEGA | SEGC | SEGD | SEGE | SEGF | SEGG
- #define CHAR_E SEGA | SEGD | SEGE | SEGF | SEGG
- #define CHAR_R SEGE | SEGG
- int main() {
- int sw, sw0, sw1, sw2, sw3, sw4, sw5;
- short state = 0;
- IOWR(HEX_BASE, 0, 0);
- IOWR(HEX_BASE, 1, 0);
- IOWR(HEX_BASE, 2, 0);
- IOWR(HEX_BASE, 3, 0);
- IOWR(HEX_BASE, 4, 0);
- IOWR(HEX_BASE, 5, 0);
- while (1){
- sw = IORD(SW_SLIDERS_BASE, 0);
- if ((sw & sw0) && !(sw & (sw1 | sw2 | sw3 | sw4 | sw5))) {
- IOWR(LEDS_BASE, 0, LED0);
- IOWR(HEX_BASE, 0, ONE);
- }else if ((sw & sw1) && !(sw & (sw0 | sw2 | sw3 | sw4 | sw5))) {
- IOWR(LEDS_BASE, 0, LED1);
- IOWR(HEX_BASE, 0, TWO);
- }else if ((sw & sw2) && !(sw & (sw1 | sw0 | sw3 | sw4 | sw5))) {
- IOWR(LEDS_BASE, 0, LED2);
- IOWR(HEX_BASE, 0, THREE);
- }else if ((sw & sw3) && !(sw & (sw1 | sw2 | sw0 | sw4 | sw5))) {
- IOWR(LEDS_BASE, 0, LED3);
- IOWR(HEX_BASE, 0, FOUR);
- }else if ((sw & sw4) && !(sw & (sw1 | sw2 | sw3 | sw0 | sw5))) {
- IOWR(LEDS_BASE, 0, LED4);
- IOWR(HEX_BASE, 0, FIVE);
- }else if ((sw & sw5) && !(sw & (sw1 | sw2 | sw3 | sw4 | sw0))) {
- IOWR(LEDS_BASE, 0, LED5);
- IOWR(HEX_BASE, 0, SIX);
- }else if (!(sw & (sw0 | sw1 | sw2 | sw3 | sw4 | sw5))){
- IOWR(LEDS_BASE, 0, L_NULL);
- IOWR(HEX_BASE, 0, H_NULL);
- }else {
- IOWR(LEDS_BASE, 0, LED6);
- IOWR(HEX_BASE, 0, CHAR_R);
- IOWR(HEX_BASE, 1, CHAR_R);
- IOWR(HEX_BASE, 2, CHAR_E);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement