/****************************************************/
/*                                                  */
/* This is an example of use of the rockfifo module */
/*                                                  */
/* Some parts are missing, so do not compile it!    */
/*                                                  */
/****************************************************/

#include <Error.h>
#include <rockfifo.h>

/* read a frame */

inc main()
{
 ROCK_id rock_id;
 ROCK_FIFO_id fifo_id;
 int err;
 ROCK_FIFO_RAW raw;
 ROCK_FIFO_FRAME frame;

 /* open the rock */
 
 err = rock_open(0x50010000,0x100000,0x09,0,&rock_id);
 if (err!=ROCK_ERROR_OK)
   {
     printf("Error opening ROCK!: %s",ErrorGetMessage());
     return 1;
   }

 /* open the FIFO */
 err = rock_fifo_open_efifo(rock_id,ROCK_FIFO_CACHE_OFF,&fifo_id);
                                    /* read only the strict minimum */
 if (err!=ROCK_ERROR_OK)
   {
     printf("Error opening FIFO!: %s",ErrorGetMessage());
     return 1;
   }

 /* read a frame */
 err = rock_fifo_read(fifo_id,&frame);
 if ((err!=ROCK_ERROR_OK)&&(err!=ROCK_ERROR_FIFO_FRAME_PARITY))
   {
     if (err==ROCK_ERROR_FIFO_EMPTY)
       printf("FIFO empty!\n");
     else
       pritnf("Error reading a frame: %s\n",ErrorGetMessage());
   }
 else
   {
     if (err==ROCK_ERROR_FIFO_FRAME_PARITY)
       printf("Parity error.\n");

     /* here use the data as needed */
   }

 /* close the FIFO */
 rock_fifo_close(fifo_id,&raw);
        /* discard cache data */

 /* close the rock */
 rock_close(rock_id);
}