Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Revision:
68:ab08efabfc88
Parent:
66:468a11f05580
Child:
71:dcac8efd842d
--- a/RA8875.h	Sun Aug 31 14:47:59 2014 +0000
+++ b/RA8875.h	Sun Aug 31 15:52:39 2014 +0000
@@ -8,7 +8,7 @@
 
 // Define this to enable code that monitors the performance of various
 // graphics commands.
-#define PERF_METRICS
+//#define PERF_METRICS
 
 // What better place for some test code than in here and the companion
 // .cpp file. See also the bottom of this file.
@@ -1204,7 +1204,8 @@
     /// than a read can be performed. The frequency set by this API
     /// is for the SPI writes. It will automatically reduce the SPI
     /// clock rate when a read is performed, and restore it for the 
-    /// next write.
+    /// next write. Alternately, the 2nd parameters permits setting
+    /// the read speed rather than letting it compute it automatically.
     ///
     /// @note The primary effect of this is to recover more CPU cycles
     ///     for your application code. Keep in mind that when more than
@@ -1216,9 +1217,11 @@
     ///     range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
     ///     outside this range will be accepted, but operation may
     ///     be unreliable.
+    /// @param Hz2 is an optional parameter and will set the read
+    ///     speed independently of the write speed.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ);
+    RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ, unsigned long Hz2 = 0);
     
 
 #ifdef PERF_METRICS
@@ -1365,6 +1368,17 @@
     ///
     bool _WaitWhileReg(uint8_t reg, uint8_t mask);
 
+    /// set the spi port to either the write or the read speed.
+    ///
+    /// This is a private API used to toggle between the write
+    /// and the read speed for the SPI port to the RA8875, since
+    /// it can accept writes faster than reads.
+    ///
+    /// @param writeSpeed when true selects the write frequency,
+    ///     and when false it selects the read frequency.
+    ///
+    void _setWriteSpeed(bool writeSpeed);
+
     /// The most primitive - to write a data value to the SPI interface.
     ///
     /// @param data is the value to write.
@@ -1384,7 +1398,8 @@
     unsigned char spiread();
     
     SPI spi;                        ///< spi port
-    unsigned long spiwritefreq;          ///< saved write freq
+    bool spiWriteSpeed;             ///< indicates if the current mode is write or read
+    unsigned long spiwritefreq;     ///< saved write freq
     unsigned long spireadfreq;      ///< saved read freq
     DigitalOut cs;                  ///< chip select pin, assumed active low
     DigitalOut res;                 ///< reset pin, assumed active low