A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Fri Jan 23 17:31:56 2015 +0100
Revision:
28:8ae20cb0b943
Parent:
26:a65fbb4bde5c
Child:
31:d47cffcb0a3e
- BIOS API up to 0.2.0
- Moved I2C0 interrupt handling from BiosTouch to BiosLoader
- Added (or prepared for) ethernet MAC address reading from BIOS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 22:1a58a518435c 1 /*
embeddedartists 22:1a58a518435c 2 * Copyright 2014 Embedded Artists AB
embeddedartists 22:1a58a518435c 3 *
embeddedartists 22:1a58a518435c 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 22:1a58a518435c 5 * you may not use this file except in compliance with the License.
embeddedartists 22:1a58a518435c 6 * You may obtain a copy of the License at
embeddedartists 22:1a58a518435c 7 *
embeddedartists 22:1a58a518435c 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 22:1a58a518435c 9 *
embeddedartists 22:1a58a518435c 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 22:1a58a518435c 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 22:1a58a518435c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 22:1a58a518435c 13 * See the License for the specific language governing permissions and
embeddedartists 22:1a58a518435c 14 * limitations under the License.
embeddedartists 22:1a58a518435c 15 */
embeddedartists 22:1a58a518435c 16
embeddedartists 22:1a58a518435c 17 #include "mbed.h"
embeddedartists 22:1a58a518435c 18 #include "BiosTouch.h"
embeddedartists 22:1a58a518435c 19 #include "BiosLoader.h"
embeddedartists 22:1a58a518435c 20 #include "DMBoard.h"
embeddedartists 22:1a58a518435c 21 #include "bios.h"
embeddedartists 22:1a58a518435c 22 #include "meas.h"
embeddedartists 22:1a58a518435c 23
embeddedartists 22:1a58a518435c 24 /******************************************************************************
embeddedartists 22:1a58a518435c 25 * Defines and typedefs
embeddedartists 22:1a58a518435c 26 *****************************************************************************/
embeddedartists 22:1a58a518435c 27
embeddedartists 26:a65fbb4bde5c 28 #define NUM_COORDS 5
embeddedartists 26:a65fbb4bde5c 29 #define NUM_MAILS 10
embeddedartists 26:a65fbb4bde5c 30 typedef struct {
embeddedartists 26:a65fbb4bde5c 31 touch_coordinate_t touch[NUM_COORDS];
embeddedartists 26:a65fbb4bde5c 32 int num;
embeddedartists 26:a65fbb4bde5c 33 } touch_mail_t;
embeddedartists 26:a65fbb4bde5c 34
embeddedartists 22:1a58a518435c 35 #define SIG_NEW_DATA 0x1
embeddedartists 22:1a58a518435c 36 class TouchHandler {
embeddedartists 22:1a58a518435c 37 public:
embeddedartists 22:1a58a518435c 38 TouchHandler(bios_header_t* bios, void* biosData, int num) :
embeddedartists 22:1a58a518435c 39 _latest(NULL), _touchIRQ(P2_25), _bios(bios),
embeddedartists 26:a65fbb4bde5c 40 _biosData(biosData), _points(num),
embeddedartists 26:a65fbb4bde5c 41 _listener(NULL), _lostData(0),
embeddedartists 26:a65fbb4bde5c 42 _dbgAdded(0), _dbgRemoved(0) {}
embeddedartists 22:1a58a518435c 43 void handleTouchInterrupt();
embeddedartists 26:a65fbb4bde5c 44 void handleNewData(touch_coordinate_t* coord, int num);
embeddedartists 28:8ae20cb0b943 45 void changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger);
embeddedartists 22:1a58a518435c 46 TouchPanel::TouchError read(touch_coordinate_t* coord, int num);
embeddedartists 22:1a58a518435c 47 void run();
embeddedartists 22:1a58a518435c 48 FunctionPointer* setListener(FunctionPointer* listener);
embeddedartists 22:1a58a518435c 49 private:
embeddedartists 26:a65fbb4bde5c 50 Mail<touch_mail_t, NUM_MAILS> _mailbox;
embeddedartists 22:1a58a518435c 51 Mutex _mutex;
embeddedartists 22:1a58a518435c 52 touch_coordinate_t* _latest;
embeddedartists 22:1a58a518435c 53 InterruptIn _touchIRQ;
embeddedartists 22:1a58a518435c 54 bios_header_t* _bios;
embeddedartists 22:1a58a518435c 55 void* _biosData;
embeddedartists 22:1a58a518435c 56 int _points;
embeddedartists 22:1a58a518435c 57 FunctionPointer* _listener;
embeddedartists 26:a65fbb4bde5c 58 uint32_t _lostData;
embeddedartists 26:a65fbb4bde5c 59 uint32_t _dbgAdded;
embeddedartists 26:a65fbb4bde5c 60 uint32_t _dbgRemoved;
embeddedartists 22:1a58a518435c 61 };
embeddedartists 22:1a58a518435c 62
embeddedartists 22:1a58a518435c 63 /******************************************************************************
embeddedartists 22:1a58a518435c 64 * Local variables
embeddedartists 22:1a58a518435c 65 *****************************************************************************/
embeddedartists 22:1a58a518435c 66
embeddedartists 22:1a58a518435c 67 /******************************************************************************
embeddedartists 22:1a58a518435c 68 * Private Functions
embeddedartists 22:1a58a518435c 69 *****************************************************************************/
embeddedartists 22:1a58a518435c 70
embeddedartists 22:1a58a518435c 71 BiosTouch::BiosTouch() :
embeddedartists 22:1a58a518435c 72 _initialized(false),
embeddedartists 22:1a58a518435c 73 _haveInfo(false),
embeddedartists 22:1a58a518435c 74 _poweredOn(false),
embeddedartists 22:1a58a518435c 75 //_touchIRQ(P2_25),
embeddedartists 22:1a58a518435c 76 _bios(NULL),
embeddedartists 22:1a58a518435c 77 _biosData(NULL),
embeddedartists 22:1a58a518435c 78 _handlerThread(NULL),
embeddedartists 22:1a58a518435c 79 _handler(NULL),
embeddedartists 22:1a58a518435c 80 _supportsTouch(false)
embeddedartists 22:1a58a518435c 81 {
embeddedartists 22:1a58a518435c 82 }
embeddedartists 22:1a58a518435c 83
embeddedartists 22:1a58a518435c 84 BiosTouch::~BiosTouch()
embeddedartists 22:1a58a518435c 85 {
embeddedartists 22:1a58a518435c 86 // _bios and _biosData are deallocated by BiosLoader
embeddedartists 22:1a58a518435c 87
embeddedartists 22:1a58a518435c 88 if (_handlerThread != NULL) {
embeddedartists 22:1a58a518435c 89 delete _handlerThread;
embeddedartists 22:1a58a518435c 90 _handlerThread = NULL;
embeddedartists 22:1a58a518435c 91 }
embeddedartists 22:1a58a518435c 92 if (_handler != NULL) {
embeddedartists 22:1a58a518435c 93 delete _handler;
embeddedartists 22:1a58a518435c 94 _handler = NULL;
embeddedartists 22:1a58a518435c 95 }
embeddedartists 22:1a58a518435c 96 }
embeddedartists 22:1a58a518435c 97
embeddedartists 22:1a58a518435c 98 // Function called from the BIOS
embeddedartists 28:8ae20cb0b943 99 static void touchIrqEnabler(uint32_t arg, bool enable, touch_irq_trigger_t trigger)
embeddedartists 22:1a58a518435c 100 {
embeddedartists 28:8ae20cb0b943 101 ((TouchHandler*)arg)->changeTouchInterrupt(enable, trigger);
embeddedartists 26:a65fbb4bde5c 102 }
embeddedartists 26:a65fbb4bde5c 103
embeddedartists 26:a65fbb4bde5c 104 // Function called from the BIOS
embeddedartists 26:a65fbb4bde5c 105 static void touchNewData(uint32_t arg, touch_coordinate_t* coords, int num)
embeddedartists 26:a65fbb4bde5c 106 {
embeddedartists 26:a65fbb4bde5c 107 ((TouchHandler*)arg)->handleNewData(coords, num);
embeddedartists 22:1a58a518435c 108 }
embeddedartists 22:1a58a518435c 109
embeddedartists 22:1a58a518435c 110 static void touchTask(void const* args)
embeddedartists 22:1a58a518435c 111 {
embeddedartists 22:1a58a518435c 112 ((TouchHandler*)args)->run();
embeddedartists 22:1a58a518435c 113 }
embeddedartists 22:1a58a518435c 114
embeddedartists 22:1a58a518435c 115
embeddedartists 22:1a58a518435c 116 void TouchHandler::run()
embeddedartists 22:1a58a518435c 117 {
embeddedartists 22:1a58a518435c 118 RtosLog* log = DMBoard::instance().logger();
embeddedartists 26:a65fbb4bde5c 119
embeddedartists 22:1a58a518435c 120 _latest = (touch_coordinate_t*)malloc(_points*sizeof(touch_coordinate_t));
embeddedartists 22:1a58a518435c 121 if (_latest == NULL) {
embeddedartists 22:1a58a518435c 122 log->printf("Failed to allocate memory for touch events\n");
embeddedartists 22:1a58a518435c 123 mbed_die();
embeddedartists 22:1a58a518435c 124 }
embeddedartists 22:1a58a518435c 125 memset(_latest, 0, _points*sizeof(touch_coordinate_t));
embeddedartists 22:1a58a518435c 126 while(true) {
embeddedartists 26:a65fbb4bde5c 127 SET_MEAS_PIN_1();
embeddedartists 26:a65fbb4bde5c 128 osEvent evt = _mailbox.get(osWaitForever);
embeddedartists 26:a65fbb4bde5c 129 CLR_MEAS_PIN_1();
embeddedartists 26:a65fbb4bde5c 130 if (evt.status == osEventMail) {
embeddedartists 26:a65fbb4bde5c 131 touch_mail_t* mail = (touch_mail_t*)evt.value.p;
embeddedartists 26:a65fbb4bde5c 132 memcpy(_latest, mail->touch, mail->num * sizeof(touch_coordinate_t));
embeddedartists 26:a65fbb4bde5c 133 _mailbox.free(mail);
embeddedartists 26:a65fbb4bde5c 134 _dbgRemoved++;
embeddedartists 26:a65fbb4bde5c 135 if (_points == 1) {
embeddedartists 26:a65fbb4bde5c 136 log->printf("{%3d,%3d,%d} at %u/%u, with %u lost\n",
embeddedartists 26:a65fbb4bde5c 137 _latest[0].x,
embeddedartists 26:a65fbb4bde5c 138 _latest[0].y,
embeddedartists 26:a65fbb4bde5c 139 _latest[0].z,
embeddedartists 26:a65fbb4bde5c 140 _dbgRemoved, _dbgAdded,
embeddedartists 26:a65fbb4bde5c 141 _lostData);
embeddedartists 24:9a677afc86f1 142 } else {
embeddedartists 26:a65fbb4bde5c 143 log->printf("{%d,%d,%d,%d,%d} at %u/%u, with %u lost\n",
embeddedartists 26:a65fbb4bde5c 144 _latest[0].z,
embeddedartists 26:a65fbb4bde5c 145 _latest[1].z,
embeddedartists 26:a65fbb4bde5c 146 _latest[2].z,
embeddedartists 26:a65fbb4bde5c 147 _latest[3].z,
embeddedartists 26:a65fbb4bde5c 148 _latest[4].z,
embeddedartists 26:a65fbb4bde5c 149 _dbgRemoved, _dbgAdded,
embeddedartists 26:a65fbb4bde5c 150 _lostData);
embeddedartists 24:9a677afc86f1 151 }
embeddedartists 26:a65fbb4bde5c 152 } else {
embeddedartists 26:a65fbb4bde5c 153 log->printf("got non-mail event: 0x%x\n", evt.status);
embeddedartists 26:a65fbb4bde5c 154 continue;
embeddedartists 26:a65fbb4bde5c 155 }
embeddedartists 26:a65fbb4bde5c 156 _mutex.lock();
embeddedartists 26:a65fbb4bde5c 157 FunctionPointer* fp = _listener;
embeddedartists 26:a65fbb4bde5c 158 _mutex.unlock();
embeddedartists 26:a65fbb4bde5c 159
embeddedartists 26:a65fbb4bde5c 160 if (fp != NULL) {
embeddedartists 26:a65fbb4bde5c 161 fp->call();
embeddedartists 26:a65fbb4bde5c 162 }
embeddedartists 22:1a58a518435c 163 }
embeddedartists 22:1a58a518435c 164 }
embeddedartists 22:1a58a518435c 165
embeddedartists 22:1a58a518435c 166 TouchPanel::TouchError TouchHandler::read(touch_coordinate_t* coord, int num)
embeddedartists 22:1a58a518435c 167 {
embeddedartists 22:1a58a518435c 168 if (num > _points || num < 1) {
embeddedartists 22:1a58a518435c 169 return TouchPanel::TouchError_InvalidParam;
embeddedartists 22:1a58a518435c 170 }
embeddedartists 22:1a58a518435c 171 _mutex.lock();
embeddedartists 22:1a58a518435c 172 memcpy(coord, _latest, num*sizeof(touch_coordinate_t));
embeddedartists 22:1a58a518435c 173 _mutex.unlock();
embeddedartists 22:1a58a518435c 174
embeddedartists 22:1a58a518435c 175 return TouchPanel::TouchError_Ok;
embeddedartists 22:1a58a518435c 176 }
embeddedartists 22:1a58a518435c 177
embeddedartists 22:1a58a518435c 178 void TouchHandler::handleTouchInterrupt()
embeddedartists 22:1a58a518435c 179 {
embeddedartists 22:1a58a518435c 180 SET_MEAS_PIN_2();
embeddedartists 26:a65fbb4bde5c 181 _bios->touchIrqHandler(_biosData);
embeddedartists 26:a65fbb4bde5c 182 CLR_MEAS_PIN_2();
embeddedartists 26:a65fbb4bde5c 183 }
embeddedartists 26:a65fbb4bde5c 184
embeddedartists 26:a65fbb4bde5c 185 void TouchHandler::handleNewData(touch_coordinate_t* coord, int num)
embeddedartists 26:a65fbb4bde5c 186 {
embeddedartists 26:a65fbb4bde5c 187 SET_MEAS_PIN_4();
embeddedartists 26:a65fbb4bde5c 188 touch_mail_t* mail = _mailbox.alloc(0);
embeddedartists 26:a65fbb4bde5c 189 if (mail == NULL) {
embeddedartists 26:a65fbb4bde5c 190 //DMBoard::instance().logger()->printf("Lost touch event\n");
embeddedartists 26:a65fbb4bde5c 191 _lostData++;
embeddedartists 26:a65fbb4bde5c 192 } else {
embeddedartists 26:a65fbb4bde5c 193 _dbgAdded++;
embeddedartists 26:a65fbb4bde5c 194 mail->num = (num < NUM_COORDS) ? num : NUM_COORDS;
embeddedartists 26:a65fbb4bde5c 195 memcpy(&mail->touch, coord, mail->num*sizeof(touch_coordinate_t));
embeddedartists 26:a65fbb4bde5c 196 _mailbox.put(mail);
embeddedartists 22:1a58a518435c 197 }
embeddedartists 26:a65fbb4bde5c 198 CLR_MEAS_PIN_4();
embeddedartists 22:1a58a518435c 199 }
embeddedartists 22:1a58a518435c 200
embeddedartists 28:8ae20cb0b943 201 void TouchHandler::changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger)
embeddedartists 22:1a58a518435c 202 {
embeddedartists 28:8ae20cb0b943 203 switch (trigger) {
embeddedartists 28:8ae20cb0b943 204 case TOUCH_IRQ_RISING_EDGE:
embeddedartists 28:8ae20cb0b943 205 if (enable) {
embeddedartists 28:8ae20cb0b943 206 _touchIRQ.rise(this, &TouchHandler::handleTouchInterrupt);
embeddedartists 28:8ae20cb0b943 207 } else {
embeddedartists 28:8ae20cb0b943 208 _touchIRQ.rise(NULL);
embeddedartists 28:8ae20cb0b943 209 }
embeddedartists 28:8ae20cb0b943 210 break;
embeddedartists 28:8ae20cb0b943 211
embeddedartists 28:8ae20cb0b943 212 case TOUCH_IRQ_FALLING_EDGE:
embeddedartists 28:8ae20cb0b943 213 if (enable) {
embeddedartists 28:8ae20cb0b943 214 _touchIRQ.fall(this, &TouchHandler::handleTouchInterrupt);
embeddedartists 28:8ae20cb0b943 215 } else {
embeddedartists 28:8ae20cb0b943 216 _touchIRQ.fall(NULL);
embeddedartists 28:8ae20cb0b943 217 }
embeddedartists 28:8ae20cb0b943 218 break;
embeddedartists 28:8ae20cb0b943 219
embeddedartists 28:8ae20cb0b943 220 case TOUCH_IRQ_HIGH_LEVEL:
embeddedartists 28:8ae20cb0b943 221 case TOUCH_IRQ_LOW_LEVEL:
embeddedartists 28:8ae20cb0b943 222 default:
embeddedartists 28:8ae20cb0b943 223 DMBoard::instance().logger()->printf("BIOS requests unknown trigger type %d\n", trigger);
embeddedartists 28:8ae20cb0b943 224 break;
embeddedartists 22:1a58a518435c 225 }
embeddedartists 22:1a58a518435c 226 }
embeddedartists 22:1a58a518435c 227
embeddedartists 22:1a58a518435c 228 FunctionPointer* TouchHandler::setListener(FunctionPointer* listener)
embeddedartists 22:1a58a518435c 229 {
embeddedartists 22:1a58a518435c 230 _mutex.lock();
embeddedartists 22:1a58a518435c 231 FunctionPointer* old = _listener;
embeddedartists 22:1a58a518435c 232 _listener = listener;
embeddedartists 22:1a58a518435c 233 _mutex.unlock();
embeddedartists 22:1a58a518435c 234 return old;
embeddedartists 22:1a58a518435c 235 }
embeddedartists 22:1a58a518435c 236
embeddedartists 22:1a58a518435c 237
embeddedartists 22:1a58a518435c 238 /******************************************************************************
embeddedartists 22:1a58a518435c 239 * Public Functions
embeddedartists 22:1a58a518435c 240 *****************************************************************************/
embeddedartists 22:1a58a518435c 241
embeddedartists 22:1a58a518435c 242 BiosTouch::TouchError BiosTouch::init()
embeddedartists 22:1a58a518435c 243 {
embeddedartists 22:1a58a518435c 244 TouchError result = TouchError_Ok;
embeddedartists 22:1a58a518435c 245 if (!_initialized) {
embeddedartists 22:1a58a518435c 246 do {
embeddedartists 22:1a58a518435c 247 if (BiosLoader::instance().params(&_bios, &_biosData) != DMBoard::Ok) {
embeddedartists 22:1a58a518435c 248 result = TouchError_ConfigError;
embeddedartists 22:1a58a518435c 249 break;
embeddedartists 22:1a58a518435c 250 }
embeddedartists 22:1a58a518435c 251
embeddedartists 28:8ae20cb0b943 252 result = (TouchError)_bios->touchInformation(_biosData, &_supportsTouch, &_supportsTouchCalibration, &_touchNumFingers);
embeddedartists 22:1a58a518435c 253 if (result != TouchError_Ok) {
embeddedartists 22:1a58a518435c 254 break;
embeddedartists 22:1a58a518435c 255 }
embeddedartists 22:1a58a518435c 256 _haveInfo = true;
embeddedartists 22:1a58a518435c 257
embeddedartists 22:1a58a518435c 258 // is it supported at all?
embeddedartists 22:1a58a518435c 259 if (!_supportsTouch) {
embeddedartists 22:1a58a518435c 260 result = TouchError_TouchNotSupported;
embeddedartists 22:1a58a518435c 261 break;
embeddedartists 22:1a58a518435c 262 }
embeddedartists 22:1a58a518435c 263
embeddedartists 28:8ae20cb0b943 264 _handler = new TouchHandler(_bios, _biosData, _touchNumFingers);
embeddedartists 22:1a58a518435c 265
embeddedartists 26:a65fbb4bde5c 266 result = (TouchError)_bios->touchInit(_biosData, touchIrqEnabler, (uint32_t)_handler, touchNewData, (uint32_t)_handler);
embeddedartists 22:1a58a518435c 267 if (result != TouchError_Ok) {
embeddedartists 22:1a58a518435c 268 break;
embeddedartists 22:1a58a518435c 269 }
embeddedartists 22:1a58a518435c 270
embeddedartists 22:1a58a518435c 271 result = (TouchError)_bios->touchPowerUp(_biosData);
embeddedartists 22:1a58a518435c 272 if (result != TouchError_Ok) {
embeddedartists 22:1a58a518435c 273 break;
embeddedartists 22:1a58a518435c 274 }
embeddedartists 22:1a58a518435c 275
embeddedartists 22:1a58a518435c 276 _handlerThread = new Thread(touchTask, _handler);
embeddedartists 22:1a58a518435c 277
embeddedartists 22:1a58a518435c 278 _initialized = true;
embeddedartists 22:1a58a518435c 279 } while(0);
embeddedartists 22:1a58a518435c 280
embeddedartists 22:1a58a518435c 281 if (!_initialized) {
embeddedartists 22:1a58a518435c 282 if (_handler != NULL) {
embeddedartists 22:1a58a518435c 283 delete _handler;
embeddedartists 22:1a58a518435c 284 _handler = NULL;
embeddedartists 22:1a58a518435c 285 }
embeddedartists 22:1a58a518435c 286 }
embeddedartists 22:1a58a518435c 287 }
embeddedartists 22:1a58a518435c 288 return result;
embeddedartists 22:1a58a518435c 289 }
embeddedartists 22:1a58a518435c 290
embeddedartists 22:1a58a518435c 291 BiosTouch::TouchError BiosTouch::read(touch_coordinate_t &coord)
embeddedartists 22:1a58a518435c 292 {
embeddedartists 22:1a58a518435c 293 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 294 if (!_initialized) {
embeddedartists 22:1a58a518435c 295 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 296 } else {
embeddedartists 22:1a58a518435c 297 err = _handler->read(&coord, 1);
embeddedartists 22:1a58a518435c 298 }
embeddedartists 22:1a58a518435c 299 return err;
embeddedartists 22:1a58a518435c 300 }
embeddedartists 22:1a58a518435c 301
embeddedartists 22:1a58a518435c 302 BiosTouch::TouchError BiosTouch::read(touch_coordinate_t* coord, int num)
embeddedartists 22:1a58a518435c 303 {
embeddedartists 22:1a58a518435c 304 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 305 if (!_initialized) {
embeddedartists 22:1a58a518435c 306 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 307 } else {
embeddedartists 22:1a58a518435c 308 err = _handler->read(coord, num);
embeddedartists 22:1a58a518435c 309 }
embeddedartists 22:1a58a518435c 310 return err;
embeddedartists 22:1a58a518435c 311 }
embeddedartists 22:1a58a518435c 312
embeddedartists 22:1a58a518435c 313 BiosTouch::TouchError BiosTouch::info(bool* resistive, int* maxPoints, bool* calibrated)
embeddedartists 22:1a58a518435c 314 {
embeddedartists 22:1a58a518435c 315 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 316 if (!_haveInfo) {
embeddedartists 22:1a58a518435c 317 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 318 } else {
embeddedartists 22:1a58a518435c 319 *maxPoints = _touchNumFingers;
embeddedartists 22:1a58a518435c 320 *calibrated = _supportsTouchCalibration;
embeddedartists 22:1a58a518435c 321 }
embeddedartists 22:1a58a518435c 322 return err;
embeddedartists 22:1a58a518435c 323 }
embeddedartists 22:1a58a518435c 324
embeddedartists 22:1a58a518435c 325 bool BiosTouch::isTouchSupported()
embeddedartists 22:1a58a518435c 326 {
embeddedartists 22:1a58a518435c 327 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 22:1a58a518435c 328 if (_haveInfo) {
embeddedartists 22:1a58a518435c 329 return _supportsTouch;
embeddedartists 22:1a58a518435c 330 }
embeddedartists 22:1a58a518435c 331 #endif
embeddedartists 22:1a58a518435c 332 return false;
embeddedartists 22:1a58a518435c 333 }
embeddedartists 22:1a58a518435c 334
embeddedartists 22:1a58a518435c 335 BiosTouch::TouchError BiosTouch::calibrateStart()
embeddedartists 22:1a58a518435c 336 {
embeddedartists 22:1a58a518435c 337 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 338 if (!_initialized) {
embeddedartists 22:1a58a518435c 339 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 340 } else {
embeddedartists 22:1a58a518435c 341 err = (TouchError)_bios->touchCalibrateStart(_biosData);
embeddedartists 22:1a58a518435c 342 }
embeddedartists 22:1a58a518435c 343 return err;
embeddedartists 22:1a58a518435c 344 }
embeddedartists 22:1a58a518435c 345
embeddedartists 22:1a58a518435c 346 BiosTouch::TouchError BiosTouch::getNextCalibratePoint(uint16_t* x, uint16_t* y, bool* last)
embeddedartists 22:1a58a518435c 347 {
embeddedartists 22:1a58a518435c 348 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 349 if (!_initialized) {
embeddedartists 22:1a58a518435c 350 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 351 } else {
embeddedartists 22:1a58a518435c 352 err = (TouchError)_bios->touchGetNextCalibPoint(_biosData, x, y, last);
embeddedartists 22:1a58a518435c 353 }
embeddedartists 22:1a58a518435c 354 return err;
embeddedartists 22:1a58a518435c 355 }
embeddedartists 22:1a58a518435c 356
embeddedartists 22:1a58a518435c 357 BiosTouch::TouchError BiosTouch::waitForCalibratePoint(bool* morePoints, uint32_t timeout)
embeddedartists 22:1a58a518435c 358 {
embeddedartists 22:1a58a518435c 359 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 360 if (!_initialized) {
embeddedartists 22:1a58a518435c 361 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 362 } else {
embeddedartists 22:1a58a518435c 363 err = (TouchError)_bios->touchWaitForCalibratePoint(_biosData, morePoints, timeout);
embeddedartists 22:1a58a518435c 364 }
embeddedartists 22:1a58a518435c 365 return err;
embeddedartists 22:1a58a518435c 366 }
embeddedartists 22:1a58a518435c 367
embeddedartists 22:1a58a518435c 368 FunctionPointer* BiosTouch::setListener(FunctionPointer* listener)
embeddedartists 22:1a58a518435c 369 {
embeddedartists 22:1a58a518435c 370 if (_initialized) {
embeddedartists 22:1a58a518435c 371 return _handler->setListener(listener);
embeddedartists 22:1a58a518435c 372 }
embeddedartists 22:1a58a518435c 373 return NULL;
embeddedartists 22:1a58a518435c 374 }