Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * "Hello World" example.
- *
- * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
- * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
- * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
- * device in your system's hardware.
- * The memory footprint of this hosted application is ~69 kbytes by default
- * using the standard reference design.
- *
- * For a reduced footprint version of this template, and an explanation of how
- * to reduce the memory footprint for a given application, see the
- * "small_hello_world" template.
- *
- */
- #include <stdio.h>
- #include <system.h>
- #include <io.h>
- // leds
- #define LED0 0x00000001
- #define LED1 0x00000002
- #define LED2 0x00000004
- #define LED3 0x00000008
- #define LED4 0x00000010
- #define LED5 0x00000020
- #define LED6 0x00000040
- #define LED7 0x00000080
- #define LED8 0x00000100
- #define LED9 0x00000200
- // hex
- #define SEGA 0x00001
- #define SEGB 0x00002
- #define SEGC 0x00004
- #define SEGD 0x00008
- #define SEGE 0x00010
- #define SEGF 0x00020
- #define SEGG 0x00040
- // hex - numbers
- #define ZERO SEGA | SEGB | SEGC | SEGD |SEGE | SEGF
- #define ONE SEGB | SEGC
- #define TWO SEGA | SEGB | SEGG | SEGE | SEGD
- #define THREE SEGA | SEGB | SEGC | SEGD | SEGG
- #define FOUR SEGG | SEGF | SEGB | SEGC
- #define FIVE SEGA | SEGE | SEGG | SEGC | SEGD
- #define E SEGA | SEGD | SEGE | SEGF | SEGG
- #define R SEGE | SEGG
- int main()
- {
- int i=0;
- int read;
- while (1)
- {
- read = IORD(SHAREDMEMORY_BASE, 0); //read shared memory
- if(read=6){
- while(1){
- if(i % 2 == 0){
- IOWR(LEDS_BASE, 0, LED1); // 1 zolte
- IOWR(LEDS_BASE, 0, LED6);// 2 Zolte
- IOWR(SKRZYZOWANIE_0_BASE, 0, 4); // -- LED1(3): ON LED2(4): on LED3(8): on LED4(9): ON
- for(int k=0; k<50000000 ; k++){ // opoznienie procesore 2 mhz o 1 sek
- }
- }
- else{
- IOWR(LEDS_BASE, 0, 0x0);
- IOWR(SKRZYZOWANIE_0_BASE, 0, 3);// -- LED1(3): off LED2(4): off LED3(8): off LED4(9): off
- for(int k=0; k<50000000 ; k++){ // opoznienie procesore 2 mhz o 1 sek
- }
- }
- i++;
- }
- }
- else break;
- OSTimeDlyHMSM(0, 0, 0, 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement