Modified version of the DmTftLibrary, optimized for the LPC4088 Experiment Base Board

Dependents:   lpc4088_ebb_dm_calc lpc4088_ebb_dm_bubbles

Fork of DmTftLibrary by Display Module

Committer:
embeddedartists
Date:
Thu Sep 11 14:28:32 2014 +0000
Revision:
12:eb97ccfe7c3f
Parent:
11:8b441dd1d470
Tweaked to get better/stable touch events

Who changed what in which revision?

UserRevisionLine numberNew contents of line
displaymodule 0:d6ff5fa503e8 1 #ifndef DM_PLATFORM_h
displaymodule 0:d6ff5fa503e8 2 #define DM_PLATFORM_h
displaymodule 0:d6ff5fa503e8 3
displaymodule 0:d6ff5fa503e8 4 // Determine type of system
displaymodule 0:d6ff5fa503e8 5 #if defined (__AVR__)
displaymodule 0:d6ff5fa503e8 6 #define DM_TOOLCHAIN_ARDUINO
displaymodule 0:d6ff5fa503e8 7 #elif defined(TOOLCHAIN_ARM) || defined(TOOLCHAIN_ARM_MICRO)
displaymodule 0:d6ff5fa503e8 8 #define DM_TOOLCHAIN_MBED
displaymodule 0:d6ff5fa503e8 9 #else
displaymodule 0:d6ff5fa503e8 10 #error Only Arduino and Mbed toolchains are supported
displaymodule 0:d6ff5fa503e8 11 #endif
displaymodule 0:d6ff5fa503e8 12
displaymodule 0:d6ff5fa503e8 13 // Arduino
displaymodule 0:d6ff5fa503e8 14 #if defined (DM_TOOLCHAIN_ARDUINO)
embeddedartists 2:59be7fca4581 15
displaymodule 0:d6ff5fa503e8 16 // Mandatory includes for Arduino
displaymodule 0:d6ff5fa503e8 17 #include <Arduino.h>
displaymodule 0:d6ff5fa503e8 18 #include <avr/pgmspace.h>
displaymodule 0:d6ff5fa503e8 19 #include <SPI.h>
embeddedartists 2:59be7fca4581 20
displaymodule 0:d6ff5fa503e8 21 // Clear bit, Set bit, High pulse and Low pulse macros
displaymodule 0:d6ff5fa503e8 22 #define cbi(reg, _bitmask) *reg &= ~_bitmask
displaymodule 0:d6ff5fa503e8 23 #define sbi(reg, _bitmask) *reg |= _bitmask
displaymodule 0:d6ff5fa503e8 24 #define pulse_high(reg, _bitmask) sbi(reg, _bitmask); cbi(reg, _bitmask);
displaymodule 0:d6ff5fa503e8 25 #define pulse_low(reg, _bitmask) cbi(reg, _bitmask); sbi(reg, _bitmask);
displaymodule 0:d6ff5fa503e8 26
displaymodule 0:d6ff5fa503e8 27 // Map of mandatory pin names, from Arduino names to D* and A*
displaymodule 0:d6ff5fa503e8 28 #define D2 2
displaymodule 0:d6ff5fa503e8 29 #define D3 3
displaymodule 0:d6ff5fa503e8 30 #define D4 4
displaymodule 0:d6ff5fa503e8 31 #define D5 5
displaymodule 0:d6ff5fa503e8 32 #define D6 6
displaymodule 0:d6ff5fa503e8 33 #define D9 9
displaymodule 0:d6ff5fa503e8 34 #define D10 10
displaymodule 0:d6ff5fa503e8 35 #define A2 16
displaymodule 0:d6ff5fa503e8 36 #define A3 17
displaymodule 0:d6ff5fa503e8 37 #define A4 18
displaymodule 0:d6ff5fa503e8 38 #define A5 19
embeddedartists 2:59be7fca4581 39
displaymodule 0:d6ff5fa503e8 40 // Needed typedefs, not normally present in the Arduino environment
displaymodule 0:d6ff5fa503e8 41 #ifndef uint8_t
displaymodule 0:d6ff5fa503e8 42 #define uint8_t unsigned char
displaymodule 0:d6ff5fa503e8 43 #endif
displaymodule 0:d6ff5fa503e8 44 #ifndef int8_t
displaymodule 0:d6ff5fa503e8 45 #define int8_t signed char
displaymodule 0:d6ff5fa503e8 46 #endif
displaymodule 0:d6ff5fa503e8 47 #ifndef uint16_t
displaymodule 0:d6ff5fa503e8 48 #define uint16_t unsigned short
displaymodule 0:d6ff5fa503e8 49 #endif
displaymodule 0:d6ff5fa503e8 50 #ifndef uint32_t
displaymodule 0:d6ff5fa503e8 51 #define uint32_t unsigned long
displaymodule 0:d6ff5fa503e8 52 #endif
displaymodule 0:d6ff5fa503e8 53
displaymodule 0:d6ff5fa503e8 54 // Mbed
displaymodule 0:d6ff5fa503e8 55 #elif defined(DM_TOOLCHAIN_MBED)
displaymodule 0:d6ff5fa503e8 56
displaymodule 0:d6ff5fa503e8 57 // Mandatory includes for Mbed
displaymodule 0:d6ff5fa503e8 58 #include "mbed.h"
displaymodule 0:d6ff5fa503e8 59
displaymodule 0:d6ff5fa503e8 60 // Clear bit, Set bit, High pulse, Low pulse, Boundary limits and Delay macros
displaymodule 0:d6ff5fa503e8 61 #define sbi(reg, _bitmask) (*(reg) = 1)
displaymodule 0:d6ff5fa503e8 62 #define cbi(reg, _bitmask) (*(reg) = 0)
displaymodule 4:92d019216e28 63 #define pulse_high(reg, _bitmask) do { *(reg) = 1; *(reg) = 0; } while(0)
displaymodule 4:92d019216e28 64 #define pulse_low(reg, _bitmask) do { *(reg) = 0; *(reg) = 1; } while(0)
displaymodule 0:d6ff5fa503e8 65 #define constrain(amt,low,high) ((amt)<=(low)?(low):((amt)>(high)?(high):(amt)))
displaymodule 0:d6ff5fa503e8 66 #define delay(ms) wait_ms(ms)
embeddedartists 2:59be7fca4581 67
embeddedartists 11:8b441dd1d470 68 // Change pinning for LPC4088 Experiment Base Board as it is different compared
embeddedartists 11:8b441dd1d470 69 // to the LPC4088 QSB Base Board (i.e. D2<->D8 and D5<->D9)
embeddedartists 11:8b441dd1d470 70 #undef D2
embeddedartists 11:8b441dd1d470 71 #define D2 p8
embeddedartists 11:8b441dd1d470 72 #undef D5
embeddedartists 11:8b441dd1d470 73 #define D5 p39
embeddedartists 11:8b441dd1d470 74 #undef D8
embeddedartists 11:8b441dd1d470 75 #define D8 p31
embeddedartists 11:8b441dd1d470 76 #undef D9
embeddedartists 11:8b441dd1d470 77 #define D9 p37
embeddedartists 11:8b441dd1d470 78
embeddedartists 11:8b441dd1d470 79
displaymodule 3:02c19cbc707c 80 // On Arduino no extra delay is needed, but on faster platforms the simulated
displaymodule 3:02c19cbc707c 81 // SPI bus may get a too high frequency so a delay here will lower it. This
displaymodule 3:02c19cbc707c 82 // delay should ideally be configurable per platform but for now it will have
displaymodule 3:02c19cbc707c 83 // to be ok to lower the frequency to 500KHz
displaymodule 4:92d019216e28 84 #if defined(__LPC407x_8x_177x_8x_H__)
displaymodule 6:fde03297017b 85 //#define slow_pulse_delay() wait_us(1)
displaymodule 6:fde03297017b 86 #define slow_pulse_delay() do {\
displaymodule 6:fde03297017b 87 volatile unsigned _xyz = 10; \
displaymodule 6:fde03297017b 88 for (; _xyz > 0; _xyz--); \
displaymodule 6:fde03297017b 89 } while(0)
embeddedartists 11:8b441dd1d470 90 //#define slow_pulse_delay()
displaymodule 4:92d019216e28 91 #else
displaymodule 4:92d019216e28 92 #define slow_pulse_delay()
displaymodule 4:92d019216e28 93 #endif
displaymodule 4:92d019216e28 94 #define slow_pulse_high(reg, _bitmask) do {\
displaymodule 3:02c19cbc707c 95 *(reg) = 1; \
displaymodule 4:92d019216e28 96 slow_pulse_delay(); \
displaymodule 3:02c19cbc707c 97 *(reg) = 0; \
displaymodule 4:92d019216e28 98 slow_pulse_delay(); \
displaymodule 3:02c19cbc707c 99 } while(0)
displaymodule 4:92d019216e28 100 #define slow_pulse_low(reg, _bitmask) do {\
displaymodule 4:92d019216e28 101 *(reg) = 0; \
displaymodule 4:92d019216e28 102 slow_pulse_delay(); \
displaymodule 4:92d019216e28 103 *(reg) = 1; \
displaymodule 4:92d019216e28 104 slow_pulse_delay(); \
displaymodule 4:92d019216e28 105 } while(0)
embeddedartists 2:59be7fca4581 106
embeddedartists 2:59be7fca4581 107 // Special handling for the LPC1549 LPCXpresso board with solder bump
embeddedartists 2:59be7fca4581 108 #ifdef LPC15XX_H
embeddedartists 2:59be7fca4581 109 #define SPECIAL_D5 P0_11
embeddedartists 2:59be7fca4581 110 #else
embeddedartists 2:59be7fca4581 111 #define SPECIAL_D5 D5
embeddedartists 2:59be7fca4581 112 #endif
displaymodule 0:d6ff5fa503e8 113 #endif
displaymodule 0:d6ff5fa503e8 114
displaymodule 0:d6ff5fa503e8 115 #endif /* DM_PLATFORM_h */
displaymodule 0:d6ff5fa503e8 116