int main(int argc, char const *argv[]) { unsigned destination = 0; unsigned flit_number = 0; unsigned flit; unsigned packet_counter = 0; setup_uart(CPU_SPEED, UART_BAUDRATE); uart_puts("UART TEST: If you can read this, then UART output works!\n"); while(1){ if ((ni_read_flags() & NI_READ_MASK) == 0) { flit = ni_read(); }else if((ni_read_flags() & NI_WRITE_MASK) == 0 && packet_counter < 100) { flit_number ++; if (flit_number == 1){ ni_write(build_header(destination, 3)); destination ++; if (destination == MY_ADDR){ destination ++; } if (destination == 4){ destination = 0; } }else if (flit_number == 3){ ni_write(0); flit_number = 0; packet_counter ++; }else{ ni_write(0b1111111111111111111111111111); } } if (packet_counter >= 100){ while ((ni_read_flags() & NI_READ_MASK) == 0){ flit = ni_read(); } uart_puts("finished sending packets!\n"); break; } } /* Run CPU test */ test_plasma_funcitons(); return 0; }
ni_status ni2_copydir(void *srcdomain, ni_id *srcdir, void*dstdomain, ni_id *dstdir , bool recursive) { ni_status ret; ni_idlist children; int i, len; ni_proplist p; ni_id dir; NI_INIT(&p); /* get proplist from src dir */ ret = ni_read(srcdomain, srcdir, &p); if (ret != NI_OK) { return ret; } /* write the property list to the dst dir */ ret = ni_write(dstdomain, dstdir, p); if (ret != NI_OK) { ni_proplist_free(&p); return ret; } ni_proplist_free(&p); if (recursive) { NI_INIT(&children); /* get list of children */ ret = ni_children(srcdomain, srcdir, &children); if (ret != NI_OK) { return ret; } len = children.ni_idlist_len; for (i = 0; i < len; i++) { dir.nii_object = children.ni_idlist_val[i]; ret = ni_self(srcdomain, &dir); if (ret != NI_OK) { ni_idlist_free(&children); return ret; } ret = ni2_copydirtoparentdir(srcdomain,&dir,dstdomain,dstdir,recursive); } ni_idlist_free(&children); } return NI_OK; }
int main() { int i; //ni_write(0b00010000000000110000000000000000); //for(i = 0; i<1000; i++){} while (1) { ni_write(0b00010000000011110000000000000000); asm("nop"); asm("nop"); } return 0; }
int main(int argc, char const *argv[]) { unsigned flit; unsigned flit_type; unsigned payload; unsigned packet_counter = 1; /* Test UART */ setup_uart(CPU_SPEED, UART_BAUDRATE); uart_puts("UART TEST: If you can read this, then UART output works!\n"); #if (UART_IN_TEST == 1) uart_puts("Please press letter 'b' on the UART terminal:\n"); char uart_in = uart_getch(); if (uart_in == 'b') { uart_puts("UART INPUT TEST PASSED!\n\n"); } else { uart_puts("UART INPUT TEST FAILED!\n"); uart_puts("Received following letter: {ASCII:HEX}\n"); uart_putchar(uart_in); uart_putchar(':'); uart_print_hex(uart_in); uart_puts("\n\n"); } #endif #if (GPIO_TEST == 1) /* Test GPIO */ unsigned gpio_in = memory_read(GPIOA_IN); memory_write(GPIO0_SET, gpio_in); #endif uart_puts("\n\nBeginning communication test\n\n"); ni_write(build_header(DST_ADDR, 3)); ni_write(0b1111111111111111111111111111); ni_write(0); while (packet_counter <= SEND_PACKET_COUNT) { if ((ni_read_flags() & NI_READ_MASK) == 0) { flit = ni_read(); flit_type = get_flit_type(flit); if (flit_type == FLIT_TYPE_HEADER) { uart_puts("Sending packet number "); uart_print_num(packet_counter, 10, 0); uart_putchar('\n'); ni_write(build_header(DST_ADDR, 3)); packet_counter++; } else { payload = get_flit_payload(flit); ni_write(payload); } } } /* Run CPU test */ test_plasma_funcitons(); return 0; }