TEST

Dependencies:   max32630fthr Adafruit_FeatherOLED USBDevice

Committer:
gmehmet
Date:
Wed Apr 10 14:56:25 2019 +0300
Revision:
1:f60eafbf009a
upload from local

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gmehmet 1:f60eafbf009a 1 /***************************************************************************//**
gmehmet 1:f60eafbf009a 2 * @file LS013B7DH03.h
gmehmet 1:f60eafbf009a 3 * @brief Driver class for the Sharp LS013B7DH03 memory LCD on some kits.
gmehmet 1:f60eafbf009a 4 *******************************************************************************
gmehmet 1:f60eafbf009a 5 * @section License
gmehmet 1:f60eafbf009a 6 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
gmehmet 1:f60eafbf009a 7 *******************************************************************************
gmehmet 1:f60eafbf009a 8 *
gmehmet 1:f60eafbf009a 9 * Permission is granted to anyone to use this software for any purpose,
gmehmet 1:f60eafbf009a 10 * including commercial applications, and to alter it and redistribute it
gmehmet 1:f60eafbf009a 11 * freely, subject to the following restrictions:
gmehmet 1:f60eafbf009a 12 *
gmehmet 1:f60eafbf009a 13 * 1. The origin of this software must not be misrepresented; you must not
gmehmet 1:f60eafbf009a 14 * claim that you wrote the original software.
gmehmet 1:f60eafbf009a 15 * 2. Altered source versions must be plainly marked as such, and must not be
gmehmet 1:f60eafbf009a 16 * misrepresented as being the original software.
gmehmet 1:f60eafbf009a 17 * 3. This notice may not be removed or altered from any source distribution.
gmehmet 1:f60eafbf009a 18 *
gmehmet 1:f60eafbf009a 19 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
gmehmet 1:f60eafbf009a 20 * obligation to support this Software. Silicon Labs is providing the
gmehmet 1:f60eafbf009a 21 * Software "AS IS", with no express or implied warranties of any kind,
gmehmet 1:f60eafbf009a 22 * including, but not limited to, any implied warranties of merchantability
gmehmet 1:f60eafbf009a 23 * or fitness for any particular purpose or warranties against infringement
gmehmet 1:f60eafbf009a 24 * of any proprietary rights of a third party.
gmehmet 1:f60eafbf009a 25 *
gmehmet 1:f60eafbf009a 26 * Silicon Labs will not be liable for any consequential, incidental, or
gmehmet 1:f60eafbf009a 27 * special damages, or any other relief, or for any claim by any third party,
gmehmet 1:f60eafbf009a 28 * arising from your use of this Software.
gmehmet 1:f60eafbf009a 29 *
gmehmet 1:f60eafbf009a 30 ******************************************************************************/
gmehmet 1:f60eafbf009a 31
gmehmet 1:f60eafbf009a 32 #ifndef SILABS_LS013B7DH03_H
gmehmet 1:f60eafbf009a 33 #define SILABS_LS013B7DH03_H
gmehmet 1:f60eafbf009a 34
gmehmet 1:f60eafbf009a 35 #include "platform.h"
gmehmet 1:f60eafbf009a 36 #include <mbed.h>
gmehmet 1:f60eafbf009a 37 #include "LCDSettings.h"
gmehmet 1:f60eafbf009a 38 #include "BufferedDisplay.h"
gmehmet 1:f60eafbf009a 39 #include "Peripherals.h"
gmehmet 1:f60eafbf009a 40
gmehmet 1:f60eafbf009a 41 typedef void (*cbptr_t)(void);
gmehmet 1:f60eafbf009a 42
gmehmet 1:f60eafbf009a 43 #define LS013B7DH03_ERROR_BUSY -1
gmehmet 1:f60eafbf009a 44 #define LS013B7DH03_ERROR_SPI_BUSY -2
gmehmet 1:f60eafbf009a 45 #define LS013B7DH03_NO_ACTION -3
gmehmet 1:f60eafbf009a 46 #define LS013B7DH03_ERROR_ARGUMENT -4
gmehmet 1:f60eafbf009a 47 #define LS013B7DH03_OK 0
gmehmet 1:f60eafbf009a 48
gmehmet 1:f60eafbf009a 49 typedef enum {
gmehmet 1:f60eafbf009a 50 IDLE, // No operation currently ongoing
gmehmet 1:f60eafbf009a 51 CLEARING, // In the process of clearing the display
gmehmet 1:f60eafbf009a 52 WRITING, // In the process of sending a display update
gmehmet 1:f60eafbf009a 53 WAIT_CLEAR, // Going to clear after CS pin timeout
gmehmet 1:f60eafbf009a 54 WAIT_WRITE, // Going to write after CS pin timeout
gmehmet 1:f60eafbf009a 55 TRANSFERS_DONE, // Last transfer in progress
gmehmet 1:f60eafbf009a 56 DONE // Done with transmission, waiting for CS pin to become high
gmehmet 1:f60eafbf009a 57 } LS013B7DH03_state_t;
gmehmet 1:f60eafbf009a 58
gmehmet 1:f60eafbf009a 59 namespace silabs {
gmehmet 1:f60eafbf009a 60 class LS013B7DH03 : public BufferedDisplay {
gmehmet 1:f60eafbf009a 61
gmehmet 1:f60eafbf009a 62 public:
gmehmet 1:f60eafbf009a 63
gmehmet 1:f60eafbf009a 64 LS013B7DH03(SPI * spi, DigitalOut * CS, const char *name=NULL);
gmehmet 1:f60eafbf009a 65
gmehmet 1:f60eafbf009a 66 /**
gmehmet 1:f60eafbf009a 67 * Call this function to push all changes to the display
gmehmet 1:f60eafbf009a 68 */
gmehmet 1:f60eafbf009a 69 int update( cbptr_t callback = NULL );
gmehmet 1:f60eafbf009a 70
gmehmet 1:f60eafbf009a 71 /**
gmehmet 1:f60eafbf009a 72 * Immediately clear the display: set pixel buffer to zero and clear out the display.
gmehmet 1:f60eafbf009a 73 */
gmehmet 1:f60eafbf009a 74 int clearImmediate( cbptr_t callback = NULL );
gmehmet 1:f60eafbf009a 75
gmehmet 1:f60eafbf009a 76 /**
gmehmet 1:f60eafbf009a 77 * Function to test display buffer
gmehmet 1:f60eafbf009a 78 */
gmehmet 1:f60eafbf009a 79 int showDemo();
gmehmet 1:f60eafbf009a 80
gmehmet 1:f60eafbf009a 81
gmehmet 1:f60eafbf009a 82
gmehmet 1:f60eafbf009a 83 /**
gmehmet 1:f60eafbf009a 84 * Function to get internal refresh counter
gmehmet 1:f60eafbf009a 85 */
gmehmet 1:f60eafbf009a 86 uint32_t getRefreshTicks();
gmehmet 1:f60eafbf009a 87
gmehmet 1:f60eafbf009a 88 /**
gmehmet 1:f60eafbf009a 89 * Function to get internal refresh counter
gmehmet 1:f60eafbf009a 90 */
gmehmet 1:f60eafbf009a 91 int executeOnceLCD();
gmehmet 1:f60eafbf009a 92
gmehmet 1:f60eafbf009a 93
gmehmet 1:f60eafbf009a 94 protected:
gmehmet 1:f60eafbf009a 95 mbed::SPI *_spi;
gmehmet 1:f60eafbf009a 96 //mbed::DigitalOut *_EXTCOM;
gmehmet 1:f60eafbf009a 97 mbed::DigitalOut *_CS;
gmehmet 1:f60eafbf009a 98
gmehmet 1:f60eafbf009a 99 mbed::Ticker _displayToggler;
gmehmet 1:f60eafbf009a 100 mbed::Timeout _csTimeout;
gmehmet 1:f60eafbf009a 101
gmehmet 1:f60eafbf009a 102 event_callback_t _internalEventCallback;
gmehmet 1:f60eafbf009a 103 volatile uint32_t _refreshCount;
gmehmet 1:f60eafbf009a 104 uint8_t _lcdPolarity;
gmehmet 1:f60eafbf009a 105 LS013B7DH03_state_t _state;
gmehmet 1:f60eafbf009a 106 cbptr_t _completionCallbackPtr;
gmehmet 1:f60eafbf009a 107 volatile uint32_t _rowCount;
gmehmet 1:f60eafbf009a 108 uint8_t _cmd[2 + (DISPLAY_WIDTH / DISPLAY_BUFFER_TYPE_SIZE * sizeof(DISPLAY_BUFFER_TYPE))];
gmehmet 1:f60eafbf009a 109
gmehmet 1:f60eafbf009a 110 /**
gmehmet 1:f60eafbf009a 111 * Callback handler for internal SPI transfers.
gmehmet 1:f60eafbf009a 112 */
gmehmet 1:f60eafbf009a 113 void _cbHandler( int event );
gmehmet 1:f60eafbf009a 114
gmehmet 1:f60eafbf009a 115 /**
gmehmet 1:f60eafbf009a 116 * Callback handler for internal SPI transfers triggered by timeout.
gmehmet 1:f60eafbf009a 117 */
gmehmet 1:f60eafbf009a 118 void _cbHandlerTimeout( void );
gmehmet 1:f60eafbf009a 119
gmehmet 1:f60eafbf009a 120 /**
gmehmet 1:f60eafbf009a 121 * Call this function at 55 ~ 65 Hz to keep the display from losing contrast.
gmehmet 1:f60eafbf009a 122 */
gmehmet 1:f60eafbf009a 123 void toggle();
gmehmet 1:f60eafbf009a 124
gmehmet 1:f60eafbf009a 125 /**
gmehmet 1:f60eafbf009a 126 *
gmehmet 1:f60eafbf009a 127 */
gmehmet 1:f60eafbf009a 128 bool interrupt_received;
gmehmet 1:f60eafbf009a 129 };
gmehmet 1:f60eafbf009a 130
gmehmet 1:f60eafbf009a 131 } // namespace silabs
gmehmet 1:f60eafbf009a 132
gmehmet 1:f60eafbf009a 133 #endif //SILABS_LS013B7DH03_H