Added SPI burst mode to spi 8 bit.

Dependents:   Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG

Fork of UniGraphic by GraphicsDisplay

Added SPI burst mode to this graphics driver. If whoever wants this rolled in to repository let me know. I replaced _spi.write(); with fastWrite(); and clearRX();

SPI8.cpp

// need to re-create SPI firmware to access SPI handle
static SPI_HandleTypeDef SpiHandle;

void SPI8::fastWrite(int data) {
    
      SpiHandle.Instance = SPI1;
    // Check if data is transmitted
    while ((SpiHandle.Instance->SR & SPI_SR_TXE) == 0);
    SpiHandle.Instance->DR = data;
}
    
void SPI8::clearRX( void ) {
        SpiHandle.Instance = SPI1;
    //Check if the RX buffer is busy
    //While busy, keep checking
    while (SpiHandle.Instance->SR & SPI_SR_BSY){   
        // Check RX buffer readable
        while ((SpiHandle.Instance->SR & SPI_SR_RXNE) == 0);
        int dummy = SpiHandle.Instance->DR;
    }
}      
Revision:
0:75ec1b3cde17
Child:
4:12ba0ecc2c1f
diff -r 000000000000 -r 75ec1b3cde17 Graphics/TextDisplay.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Graphics/TextDisplay.h	Thu Feb 12 22:22:47 2015 +0000
@@ -0,0 +1,106 @@
+/* mbed TextDisplay Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A common base class for Text displays
+ * To port a new display, derive from this class and implement
+ * the constructor (setup the display), character (put a character
+ * at a location), rows and columns (number of rows/cols) functions.
+ * Everything else (locate, printf, putc, cls) will come for free
+ *
+ * The model is the display will wrap at the right and bottom, so you can
+ * keep writing and will always get valid characters. The location is 
+ * maintained internally to the class to make this easy
+ */
+
+#ifndef MBED_TEXTDISPLAY_H
+#define MBED_TEXTDISPLAY_H
+
+#include "mbed.h"
+
+/** A common base class for Text displays
+*/
+class TextDisplay : public Stream {
+public:
+
+    // functions needing implementation in derived implementation class
+    // ----------------------------------------------------------------
+    /** Create a TextDisplay interface
+    * @param name The name used in the path to access the strean through the filesystem
+    */
+    TextDisplay(const char *name = NULL);
+
+    /** output a character at the given position
+    *
+    * @param column column where charater must be written
+    * @param  row where character must be written
+    * @param c the character to be written to the TextDisplay
+    * @note this method may be overridden in a derived class.
+    */
+    virtual void character(int column, int row, int c) = 0;
+
+    /** return number of rows on TextDisplay
+    * @result number of rows
+    * @note this method must be supported in the derived class.
+    */
+    virtual int rows() = 0;
+
+    /** return number of columns on TextDisplay
+    * @result number of columns
+    * @note this method must be supported in the derived class.
+    */
+    virtual int columns() = 0;
+    
+    // functions that come for free, but can be overwritten
+    // ----------------------------------------------------
+    /** redirect output from a stream (stoud, sterr) to  display
+    * @param stream stream that shall be redirected to the TextDisplay
+    * @note this method may be overridden in a derived class.
+    * @returns true if the claim succeeded.
+    */
+    virtual bool claim (FILE *stream);
+
+    /** clear the entire screen
+    * @note this method may be overridden in a derived class.
+    */
+    virtual void cls();
+
+    /** locate the cursor at a character position.
+    * Based on the currently active font, locate the cursor on screen.
+    * @note this method may be overridden in a derived class.
+    * @param column is the horizontal offset from the left side.
+    * @param row is the vertical offset from the top.
+    */
+    virtual void locate(int column, int row);
+
+    /** set the foreground color
+    * @note this method may be overridden in a derived class.
+    * @param color is color to use for foreground drawing.
+    */
+    virtual void foreground(uint16_t colour);
+
+    /** set the background color
+    * @note this method may be overridden in a derived class.
+    * @param color is color to use for background drawing.
+    */
+    virtual void background(uint16_t colour);
+
+    // putc (from Stream)
+    // printf (from Stream)
+    
+protected:
+
+    virtual int _putc(int value);
+    virtual int _getc();
+
+    // character location
+    int _column;
+    int _row;
+
+    // colours
+    uint16_t _foreground;
+    uint16_t _background;
+    char *_path;
+};
+
+#endif