Search
lxdream.org :: lxdream/src/sh4/scif.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/scif.c
changeset 22:f0703013049f
prev21:fda269b432a7
next23:1ec3acd0594d
author nkeynes
date Thu Dec 22 13:57:26 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Add basic save/load state methods
file annotate diff log raw
1.1 --- a/src/sh4/scif.c Thu Dec 22 13:52:02 2005 +0000
1.2 +++ b/src/sh4/scif.c Thu Dec 22 13:57:26 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: scif.c,v 1.2 2005-12-22 13:52:02 nkeynes Exp $
1.6 + * $Id: scif.c,v 1.3 2005-12-22 13:57:26 nkeynes Exp $
1.7 * SCIF (Serial Communication Interface with FIFO) implementation - part of the
1.8 * SH4 standard on-chip peripheral set. The SCIF is hooked up to the DCs
1.9 * external serial port
1.10 @@ -159,23 +159,35 @@
1.11 uint8_t data[FIFO_ARR_LENGTH];
1.12 };
1.13
1.14 +int SCIF_recvq_triggers[4] = {1, 4, 8, 14};
1.15 +struct SCIF_fifo SCIF_recvq = {0,0,1};
1.16 +
1.17 +int SCIF_sendq_triggers[4] = {8, 4, 2, 1};
1.18 +struct SCIF_fifo SCIF_sendq = {0,0,8};
1.19 +
1.20 +/**
1.21 + * Flag to indicate if data was received (ie added to the receive queue)
1.22 + * during the last SCIF clock tick. Used to determine when to set the DR
1.23 + * flag.
1.24 + */
1.25 +gboolean SCIF_rcvd_last_tick = FALSE;
1.26 +
1.27 void SCIF_save_state( FILE *f )
1.28 {
1.29 -
1.30 + fwrite( &SCIF_recvq, sizeof(SCIF_recvq), 1, f );
1.31 + fwrite( &SCIF_sendq, sizeof(SCIF_sendq), 1, f );
1.32 + fwrite( &SCIF_rcvd_last_tick, sizeof(gboolean), 1, f );
1.33
1.34 }
1.35
1.36 int SCIF_load_state( FILE *f )
1.37 {
1.38 + fread( &SCIF_recvq, sizeof(SCIF_recvq), 1, f );
1.39 + fread( &SCIF_sendq, sizeof(SCIF_sendq), 1, f );
1.40 + fread( &SCIF_rcvd_last_tick, sizeof(gboolean), 1, f );
1.41 return 0;
1.42 }
1.43
1.44 -int SCIF_recvq_triggers[4] = {1, 4, 8, 14};
1.45 -struct SCIF_fifo SCIF_recvq = {0,0,1};
1.46 -
1.47 -int SCIF_sendq_triggers[4] = {8, 4, 2, 1};
1.48 -struct SCIF_fifo SCIF_sendq = {0,0,8};
1.49 -
1.50 static inline uint8_t SCIF_recvq_size( )
1.51 {
1.52 int val = SCIF_recvq.tail - SCIF_recvq.head;
1.53 @@ -543,13 +555,6 @@
1.54 }
1.55
1.56 /**
1.57 - * Flag to indicate if data was received (ie added to the receive queue)
1.58 - * during the last SCIF clock tick. Used to determine when to set the DR
1.59 - * flag.
1.60 - */
1.61 -gboolean SCIF_rcvd_last_tick = FALSE;
1.62 -
1.63 -/**
1.64 * Actions for a single tick of the serial clock, defined as the transmission
1.65 * time of a single frame.
1.66 *
.