Commits

Dennis Muhlestein  committed f5540e4

Change gpif_single_read/write to gpif_single_read16/write16

  • Participants
  • Parent commits 1a70b5e

Comments (0)

Files changed (2)

File include/gpif.h

 void gpif_set_tc(DWORD tc);
 
 /**
- * Use the gpif to read a single byte at a time.
- * Read len bytes and store in res
+ * Use the gpif to read a single word at a time.
+ * Read len words and store in res
  *
- * This is coded to use 16 bit data bus.  Len
- * Should be multiple of 2.  Should this function
- * be coded to be smart enough for 8 bit bus and 16 both
- * or should there be a different function?
+ * At least one EPxFIFOCFG has to have wordwide=1 or this
+ * functions won't transfer both bytes.
+ **/
+
+void gpif_single_read16( WORD* res , WORD len);
+
+/**
+ * Use the gpif to write a single word at a time.
+ * Write len words from data
  *
- * At least one EPxFIFOCFG has to have wordwide=1 or these
- * functions won't transfer both bytes right
+ * At leat one EPxFIFOCFG has to have wordwide=1 or this
+ * function won't transfer both bytes.
  **/
-void gpif_single_read( BYTE* res , WORD len);
-void gpif_single_write( BYTE* data, WORD len);
+void gpif_single_write16( WORD* data, WORD len);
 
 void gpif_fifo_read ( GPIF_EP_NUM ep_num );
 
     GPIFTCB0 = LSB(LSW(tc));
 }
 
-void gpif_single_read( BYTE* res, WORD len ){
-    BYTE c;
+void gpif_single_read16( WORD* res, WORD len ){
+    BYTE c;    
     while (!(GPIFTRIG & 0x80)); // wait done
     // dummy read to trigger real read
     res[0] = XGPIFSGLDATLX;
-    for (c=0;c<len;c+=2) {
+    for (c=0;c<len;++c) {
      while ( !(GPIFTRIG & 0x80) ); // wait done
      // real read
-     res[c] = GPIFSGLDATH;
-     // whether or not to do another transfer
-     res[c+1] = c==len-2 ? GPIFSGLDATLNOX : GPIFSGLDATLX;
+     // whether or not to do another transfer is controlled by GPIFSGLDATLNOX or ..DATLX
+     res[c] = MAKEWORD(GPIFSGLDATH, c==len-1 ? GPIFSGLDATLNOX : GPIFSGLDATLX );
     }
 }
 
-void gpif_single_write( BYTE* dat, WORD len) {
+void gpif_single_write16( WORD* dat, WORD len) {
    BYTE c;
-   for (c=0;c<len;c+=2) {
+   for (c=0;c<len;++c) {
     while (!(GPIFTRIG & 0x80) );
-    XGPIFSGLDATH = dat[c];
-    XGPIFSGLDATLX = dat[c+1];
+    XGPIFSGLDATH = MSB(dat[c]);
+    XGPIFSGLDATLX = LSB(dat[c]);
    }
 }