The wait in mci_WaitForEvent will delay all card transactions.

Dependencies:   FATFileSystem

Fork of EALib by EmbeddedArtists AB

Committer:
dreschpe
Date:
Sun Dec 15 21:58:56 2013 +0000
Revision:
9:da373a015d07
Parent:
5:3290d7b766d5
the wait in mci_WaitForEvent will delay all card transactions.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:0fdadbc3d852 1
embeddedartists 0:0fdadbc3d852 2 #ifndef TSC2046_H
embeddedartists 0:0fdadbc3d852 3 #define TSC2046_H
embeddedartists 0:0fdadbc3d852 4
embeddedartists 4:b32cf4ef45c5 5 #include "TouchPanel.h"
embeddedartists 4:b32cf4ef45c5 6
embeddedartists 4:b32cf4ef45c5 7 #define TSC2046_NUM_CALIB_POINTS (3)
embeddedartists 0:0fdadbc3d852 8
embeddedartists 0:0fdadbc3d852 9 /**
embeddedartists 0:0fdadbc3d852 10 * Texas Instruments Touch Screen Controller (TSC2046).
embeddedartists 0:0fdadbc3d852 11 */
embeddedartists 4:b32cf4ef45c5 12 class TSC2046 : public TouchPanel {
embeddedartists 0:0fdadbc3d852 13 public:
embeddedartists 0:0fdadbc3d852 14
embeddedartists 0:0fdadbc3d852 15
embeddedartists 0:0fdadbc3d852 16 /**
embeddedartists 0:0fdadbc3d852 17 * Constructor
embeddedartists 0:0fdadbc3d852 18 *
embeddedartists 0:0fdadbc3d852 19 * @param mosi SPI MOSI pin
embeddedartists 0:0fdadbc3d852 20 * @param miso SPI MISO pin
embeddedartists 0:0fdadbc3d852 21 * @param sck SPI SCK pin
embeddedartists 0:0fdadbc3d852 22 * @param cs chip-select pin
embeddedartists 0:0fdadbc3d852 23 */
embeddedartists 0:0fdadbc3d852 24 TSC2046(PinName mosi, PinName miso, PinName sck, PinName cs);
embeddedartists 0:0fdadbc3d852 25
embeddedartists 5:3290d7b766d5 26 virtual bool init(uint16_t width, uint16_t height);
embeddedartists 4:b32cf4ef45c5 27
embeddedartists 5:3290d7b766d5 28 virtual bool read(touchCoordinate_t &coord);
embeddedartists 5:3290d7b766d5 29 virtual bool calibrateStart();
embeddedartists 5:3290d7b766d5 30 virtual bool getNextCalibratePoint(uint16_t* x, uint16_t* y);
embeddedartists 5:3290d7b766d5 31 virtual bool waitForCalibratePoint(bool* morePoints, uint32_t timeout);
embeddedartists 0:0fdadbc3d852 32
embeddedartists 0:0fdadbc3d852 33 /**
embeddedartists 4:b32cf4ef45c5 34 * Calibrate the touch panel with already gathered calibration values.
embeddedartists 4:b32cf4ef45c5 35 * The list with calibration points must at one point have been retrieved
embeddedartists 4:b32cf4ef45c5 36 * by calling getCalibrationValues;
embeddedartists 4:b32cf4ef45c5 37 *
embeddedartists 4:b32cf4ef45c5 38 * @param values list with calibration values
embeddedartists 4:b32cf4ef45c5 39 * @param numValues the size of the list must match the number of
embeddedartists 4:b32cf4ef45c5 40 * calibration points needed for this touch panel (TSC2046_NUM_CALIB_POINTS)
embeddedartists 4:b32cf4ef45c5 41 *
embeddedartists 4:b32cf4ef45c5 42 * @return true if the request was successful; otherwise false
embeddedartists 0:0fdadbc3d852 43 */
embeddedartists 4:b32cf4ef45c5 44 bool calibrate(touchCoordinate_t* values, int numValues);
embeddedartists 0:0fdadbc3d852 45
embeddedartists 0:0fdadbc3d852 46 /**
embeddedartists 4:b32cf4ef45c5 47 * Get calibration values for the calibration points used by this touch
embeddedartists 4:b32cf4ef45c5 48 * panel. This method may only be called after a successful calibration
embeddedartists 4:b32cf4ef45c5 49 * has been performed.
embeddedartists 4:b32cf4ef45c5 50 *
embeddedartists 4:b32cf4ef45c5 51 * The list with values can be written to persistent storage and used
embeddedartists 4:b32cf4ef45c5 52 * to calibrate the display without involving the user.
embeddedartists 4:b32cf4ef45c5 53 *
embeddedartists 4:b32cf4ef45c5 54 * @param values calibration values will be written to this list
embeddedartists 4:b32cf4ef45c5 55 * @param numValues the size of the list must match the number of
embeddedartists 4:b32cf4ef45c5 56 * calibration points needed for this touch panel (TSC2046_NUM_CALIB_POINTS)
embeddedartists 4:b32cf4ef45c5 57 *
embeddedartists 4:b32cf4ef45c5 58 * @return true if the request was successful; otherwise false
embeddedartists 0:0fdadbc3d852 59 */
embeddedartists 4:b32cf4ef45c5 60 bool getCalibrationValues(touchCoordinate_t* values, int numValues);
embeddedartists 0:0fdadbc3d852 61
embeddedartists 0:0fdadbc3d852 62
embeddedartists 0:0fdadbc3d852 63 private:
embeddedartists 0:0fdadbc3d852 64
embeddedartists 0:0fdadbc3d852 65 typedef struct {
embeddedartists 0:0fdadbc3d852 66 int64_t x;
embeddedartists 0:0fdadbc3d852 67 int64_t y;
embeddedartists 0:0fdadbc3d852 68 } calibPoint_t;
embeddedartists 0:0fdadbc3d852 69
embeddedartists 0:0fdadbc3d852 70 typedef struct {
embeddedartists 0:0fdadbc3d852 71 int64_t An;
embeddedartists 0:0fdadbc3d852 72 int64_t Bn;
embeddedartists 0:0fdadbc3d852 73 int64_t Cn;
embeddedartists 0:0fdadbc3d852 74 int64_t Dn;
embeddedartists 0:0fdadbc3d852 75 int64_t En;
embeddedartists 0:0fdadbc3d852 76 int64_t Fn;
embeddedartists 0:0fdadbc3d852 77 int64_t Divider;
embeddedartists 0:0fdadbc3d852 78 } calibMatrix_t;
embeddedartists 0:0fdadbc3d852 79
embeddedartists 0:0fdadbc3d852 80 SPI _spi;
embeddedartists 0:0fdadbc3d852 81 DigitalOut _cs;
embeddedartists 0:0fdadbc3d852 82 bool _calibrated;
embeddedartists 0:0fdadbc3d852 83 bool _initialized;
embeddedartists 0:0fdadbc3d852 84 calibMatrix_t _calibMatrix;
embeddedartists 0:0fdadbc3d852 85
embeddedartists 4:b32cf4ef45c5 86 uint16_t _width;
embeddedartists 4:b32cf4ef45c5 87 uint16_t _height;
embeddedartists 4:b32cf4ef45c5 88 int _calibPoint;
embeddedartists 4:b32cf4ef45c5 89 int _insetPx;
embeddedartists 4:b32cf4ef45c5 90
embeddedartists 4:b32cf4ef45c5 91 touchCoordinate_t _calibrateValues[TSC2046_NUM_CALIB_POINTS][2];
embeddedartists 4:b32cf4ef45c5 92
embeddedartists 0:0fdadbc3d852 93 void readAndFilter(touchCoordinate_t &coord);
embeddedartists 0:0fdadbc3d852 94 int32_t getFilteredValue(int cmd);
embeddedartists 0:0fdadbc3d852 95 uint16_t spiTransfer(uint8_t cmd);
embeddedartists 0:0fdadbc3d852 96
embeddedartists 4:b32cf4ef45c5 97 void calibrate(touchCoordinate_t &ref1,
embeddedartists 4:b32cf4ef45c5 98 touchCoordinate_t &ref2,
embeddedartists 4:b32cf4ef45c5 99 touchCoordinate_t &ref3,
embeddedartists 4:b32cf4ef45c5 100 touchCoordinate_t &scr1,
embeddedartists 4:b32cf4ef45c5 101 touchCoordinate_t &scr2,
embeddedartists 4:b32cf4ef45c5 102 touchCoordinate_t &scr3);
embeddedartists 4:b32cf4ef45c5 103
embeddedartists 4:b32cf4ef45c5 104 void getCalibratePoint(int pointNum, int32_t* x, int32_t *y);
embeddedartists 4:b32cf4ef45c5 105 int waitForTouch(int32_t* x, int32_t* y, uint32_t timeout);
embeddedartists 4:b32cf4ef45c5 106
embeddedartists 0:0fdadbc3d852 107
embeddedartists 0:0fdadbc3d852 108
embeddedartists 0:0fdadbc3d852 109 int setCalibrationMatrix( calibPoint_t * displayPtr,
embeddedartists 0:0fdadbc3d852 110 calibPoint_t * screenPtr,
embeddedartists 0:0fdadbc3d852 111 calibMatrix_t * matrixPtr);
embeddedartists 0:0fdadbc3d852 112 int getDisplayPoint( calibPoint_t * displayPtr,
embeddedartists 0:0fdadbc3d852 113 calibPoint_t * screenPtr,
embeddedartists 0:0fdadbc3d852 114 calibMatrix_t * matrixPtr );
embeddedartists 0:0fdadbc3d852 115
embeddedartists 4:b32cf4ef45c5 116
embeddedartists 4:b32cf4ef45c5 117
embeddedartists 0:0fdadbc3d852 118 };
embeddedartists 0:0fdadbc3d852 119
embeddedartists 0:0fdadbc3d852 120 #endif