Project

Committer:
bcostm
Date:
Wed Oct 07 15:53:06 2015 +0000
Revision:
0:fe0cf5e2960f
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:fe0cf5e2960f 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
bcostm 0:fe0cf5e2960f 2 *
bcostm 0:fe0cf5e2960f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcostm 0:fe0cf5e2960f 4 * and associated documentation files (the "Software"), to deal in the Software without
bcostm 0:fe0cf5e2960f 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
bcostm 0:fe0cf5e2960f 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
bcostm 0:fe0cf5e2960f 7 * Software is furnished to do so, subject to the following conditions:
bcostm 0:fe0cf5e2960f 8 *
bcostm 0:fe0cf5e2960f 9 * The above copyright notice and this permission notice shall be included in all copies or
bcostm 0:fe0cf5e2960f 10 * substantial portions of the Software.
bcostm 0:fe0cf5e2960f 11 *
bcostm 0:fe0cf5e2960f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcostm 0:fe0cf5e2960f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcostm 0:fe0cf5e2960f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcostm 0:fe0cf5e2960f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcostm 0:fe0cf5e2960f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcostm 0:fe0cf5e2960f 17 */
bcostm 0:fe0cf5e2960f 18
bcostm 0:fe0cf5e2960f 19 #ifndef __TS_DISCO_F746NG_H
bcostm 0:fe0cf5e2960f 20 #define __TS_DISCO_F746NG_H
bcostm 0:fe0cf5e2960f 21
bcostm 0:fe0cf5e2960f 22 #ifdef TARGET_DISCO_F746NG
bcostm 0:fe0cf5e2960f 23
bcostm 0:fe0cf5e2960f 24 #include "mbed.h"
bcostm 0:fe0cf5e2960f 25 #include "stm32746g_discovery_ts.h"
bcostm 0:fe0cf5e2960f 26
bcostm 0:fe0cf5e2960f 27 /*
bcostm 0:fe0cf5e2960f 28 This class drives the touch screen module (FT5336 device) of the LCD display
bcostm 0:fe0cf5e2960f 29 present on DISCO_F746NG board.
bcostm 0:fe0cf5e2960f 30
bcostm 0:fe0cf5e2960f 31 Usage:
bcostm 0:fe0cf5e2960f 32
bcostm 0:fe0cf5e2960f 33 #include "mbed.h"
bcostm 0:fe0cf5e2960f 34 #include "TS_DISCO_F746NG.h"
bcostm 0:fe0cf5e2960f 35
bcostm 0:fe0cf5e2960f 36 TS_DISCO_F746NG ts;
bcostm 0:fe0cf5e2960f 37
bcostm 0:fe0cf5e2960f 38 DigitalOut led1(LED1);
bcostm 0:fe0cf5e2960f 39
bcostm 0:fe0cf5e2960f 40 int main()
bcostm 0:fe0cf5e2960f 41 {
bcostm 0:fe0cf5e2960f 42 TS_StateTypeDef TS_State;
bcostm 0:fe0cf5e2960f 43
bcostm 0:fe0cf5e2960f 44 ts.Init(420, 272);
bcostm 0:fe0cf5e2960f 45
bcostm 0:fe0cf5e2960f 46 while(1)
bcostm 0:fe0cf5e2960f 47 {
bcostm 0:fe0cf5e2960f 48 ts.GetState(&TS_State);
bcostm 0:fe0cf5e2960f 49 if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240))
bcostm 0:fe0cf5e2960f 50 {
bcostm 0:fe0cf5e2960f 51 led1 = 1;
bcostm 0:fe0cf5e2960f 52 }
bcostm 0:fe0cf5e2960f 53 else
bcostm 0:fe0cf5e2960f 54 {
bcostm 0:fe0cf5e2960f 55 led1 = 0;
bcostm 0:fe0cf5e2960f 56 }
bcostm 0:fe0cf5e2960f 57 }
bcostm 0:fe0cf5e2960f 58 }
bcostm 0:fe0cf5e2960f 59 */
bcostm 0:fe0cf5e2960f 60 class TS_DISCO_F746NG
bcostm 0:fe0cf5e2960f 61 {
bcostm 0:fe0cf5e2960f 62
bcostm 0:fe0cf5e2960f 63 public:
bcostm 0:fe0cf5e2960f 64 //! Constructor
bcostm 0:fe0cf5e2960f 65 TS_DISCO_F746NG();
bcostm 0:fe0cf5e2960f 66
bcostm 0:fe0cf5e2960f 67 //! Destructor
bcostm 0:fe0cf5e2960f 68 ~TS_DISCO_F746NG();
bcostm 0:fe0cf5e2960f 69
bcostm 0:fe0cf5e2960f 70 /**
bcostm 0:fe0cf5e2960f 71 * @brief Initializes and configures the touch screen functionalities and
bcostm 0:fe0cf5e2960f 72 * configures all necessary hardware resources (GPIOs, I2C, clocks..);.
bcostm 0:fe0cf5e2960f 73 * @param ts_SizeX: Maximum X size of the TS area on LCD
bcostm 0:fe0cf5e2960f 74 * @param ts_SizeY: Maximum Y size of the TS area on LCD
bcostm 0:fe0cf5e2960f 75 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:fe0cf5e2960f 76 */
bcostm 0:fe0cf5e2960f 77 uint8_t Init(uint16_t ts_SizeX, uint16_t ts_SizeY);
bcostm 0:fe0cf5e2960f 78
bcostm 0:fe0cf5e2960f 79 /**
bcostm 0:fe0cf5e2960f 80 * @brief DeInitializes the TouchScreen.
bcostm 0:fe0cf5e2960f 81 * @retval TS state
bcostm 0:fe0cf5e2960f 82 */
bcostm 0:fe0cf5e2960f 83 uint8_t DeInit(void);
bcostm 0:fe0cf5e2960f 84
bcostm 0:fe0cf5e2960f 85 /**
bcostm 0:fe0cf5e2960f 86 * @brief Configures and enables the touch screen interrupts.
bcostm 0:fe0cf5e2960f 87 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:fe0cf5e2960f 88 */
bcostm 0:fe0cf5e2960f 89 uint8_t ITConfig(void);
bcostm 0:fe0cf5e2960f 90
bcostm 0:fe0cf5e2960f 91 /**
bcostm 0:fe0cf5e2960f 92 * @brief Gets the touch screen interrupt status.
bcostm 0:fe0cf5e2960f 93 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:fe0cf5e2960f 94 */
bcostm 0:fe0cf5e2960f 95 uint8_t ITGetStatus(void);
bcostm 0:fe0cf5e2960f 96
bcostm 0:fe0cf5e2960f 97 /**
bcostm 0:fe0cf5e2960f 98 * @brief Returns status and positions of the touch screen.
bcostm 0:fe0cf5e2960f 99 * @param TS_State: Pointer to touch screen current state structure
bcostm 0:fe0cf5e2960f 100 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:fe0cf5e2960f 101 */
bcostm 0:fe0cf5e2960f 102 uint8_t GetState(TS_StateTypeDef *TS_State);
bcostm 0:fe0cf5e2960f 103
bcostm 0:fe0cf5e2960f 104 /**
bcostm 0:fe0cf5e2960f 105 * @brief Update gesture Id following a touch detected.
bcostm 0:fe0cf5e2960f 106 * @param TS_State: Pointer to touch screen current state structure
bcostm 0:fe0cf5e2960f 107 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:fe0cf5e2960f 108 */
bcostm 0:fe0cf5e2960f 109 uint8_t Get_GestureId(TS_StateTypeDef *TS_State);
bcostm 0:fe0cf5e2960f 110
bcostm 0:fe0cf5e2960f 111 /**
bcostm 0:fe0cf5e2960f 112 * @brief Clears all touch screen interrupts.
bcostm 0:fe0cf5e2960f 113 */
bcostm 0:fe0cf5e2960f 114 void ITClear(void);
bcostm 0:fe0cf5e2960f 115
bcostm 0:fe0cf5e2960f 116 /**
bcostm 0:fe0cf5e2960f 117 * @brief Function used to reset all touch data before a new acquisition
bcostm 0:fe0cf5e2960f 118 * of touch information.
bcostm 0:fe0cf5e2960f 119 * @param TS_State: Pointer to touch screen current state structure
bcostm 0:fe0cf5e2960f 120 * @retval TS_OK if OK, TE_ERROR if problem found.
bcostm 0:fe0cf5e2960f 121 */
bcostm 0:fe0cf5e2960f 122 uint8_t ResetTouchData(TS_StateTypeDef *TS_State);
bcostm 0:fe0cf5e2960f 123
bcostm 0:fe0cf5e2960f 124 private:
bcostm 0:fe0cf5e2960f 125
bcostm 0:fe0cf5e2960f 126 };
bcostm 0:fe0cf5e2960f 127
bcostm 0:fe0cf5e2960f 128 #else
bcostm 0:fe0cf5e2960f 129 #error "This class must be used with DISCO_F746NG board only."
bcostm 0:fe0cf5e2960f 130 #endif // TARGET_DISCO_F746NG
bcostm 0:fe0cf5e2960f 131
bcostm 0:fe0cf5e2960f 132 #endif