Utility library for HSP SPo2 HR demo including user interface, board support adn accelerometer.

Committer:
gmehmet
Date:
Mon Dec 17 13:58:56 2018 +0300
Revision:
0:a12d6976d64c
create and put source to HSP demo utility repo

Who changed what in which revision?

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