/*
 * "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 <io.h>
#include <system.h>
#include <stdio.h>

#define IOWR_XY_DATA(base, offset, data) \
    IOWR_16DIRECT(base, (offset) * 2, data)
#define IORD_XY_DATA(base, offset) \
    IORD_16DIRECT(base, (offset) *2) 
    
int main()
{
  unsigned int x1, y1, x2, y2, x3, y3;
  
  for(;;){
    x1 = IORD_XY_DATA(XY_POS_BASE, 1);
    y1 = IORD_XY_DATA(XY_POS_BASE, 2);
    x2 = IORD_XY_DATA(XY_POS_BASE, 3);
    y2 = IORD_XY_DATA(XY_POS_BASE, 4);
    x3 = IORD_XY_DATA(XY_POS_BASE, 5);
    y3 = IORD_XY_DATA(XY_POS_BASE, 6);
    
    printf("x1 = %u, y1= %u, x2 = %u, y2 = %u, x3 = %u and y3 = %u\n", x1, y1, x2, y2, x3, y3);
  }

  return 0;
}
