Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more
dm_platform.h@4:92d019216e28, 2014-05-22 (annotated)
- Committer:
- displaymodule
- Date:
- Thu May 22 09:14:49 2014 +0000
- Revision:
- 4:92d019216e28
- Parent:
- 3:02c19cbc707c
- Child:
- 6:fde03297017b
Restored the pulse_high/pulse_low functions and added slow_* versions of them for faster platforms. Put the SPECIAL_D5 define into use as that was the reason behind DM_TFT_101 not working
Who changed what in which revision?
| User | Revision | Line number | New 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 | |
| displaymodule | 3:02c19cbc707c | 68 | // On Arduino no extra delay is needed, but on faster platforms the simulated |
| displaymodule | 3:02c19cbc707c | 69 | // SPI bus may get a too high frequency so a delay here will lower it. This |
| displaymodule | 3:02c19cbc707c | 70 | // delay should ideally be configurable per platform but for now it will have |
| displaymodule | 3:02c19cbc707c | 71 | // to be ok to lower the frequency to 500KHz |
| displaymodule | 4:92d019216e28 | 72 | #if defined(__LPC407x_8x_177x_8x_H__) |
| displaymodule | 4:92d019216e28 | 73 | #define slow_pulse_delay() wait_us(1) |
| displaymodule | 4:92d019216e28 | 74 | #else |
| displaymodule | 4:92d019216e28 | 75 | #define slow_pulse_delay() |
| displaymodule | 4:92d019216e28 | 76 | #endif |
| displaymodule | 4:92d019216e28 | 77 | #define slow_pulse_high(reg, _bitmask) do {\ |
| displaymodule | 3:02c19cbc707c | 78 | *(reg) = 1; \ |
| displaymodule | 4:92d019216e28 | 79 | slow_pulse_delay(); \ |
| displaymodule | 3:02c19cbc707c | 80 | *(reg) = 0; \ |
| displaymodule | 4:92d019216e28 | 81 | slow_pulse_delay(); \ |
| displaymodule | 3:02c19cbc707c | 82 | } while(0) |
| displaymodule | 4:92d019216e28 | 83 | #define slow_pulse_low(reg, _bitmask) do {\ |
| displaymodule | 4:92d019216e28 | 84 | *(reg) = 0; \ |
| displaymodule | 4:92d019216e28 | 85 | slow_pulse_delay(); \ |
| displaymodule | 4:92d019216e28 | 86 | *(reg) = 1; \ |
| displaymodule | 4:92d019216e28 | 87 | slow_pulse_delay(); \ |
| displaymodule | 4:92d019216e28 | 88 | } while(0) |
| embeddedartists | 2:59be7fca4581 | 89 | |
| embeddedartists | 2:59be7fca4581 | 90 | // Special handling for the LPC1549 LPCXpresso board with solder bump |
| embeddedartists | 2:59be7fca4581 | 91 | #ifdef LPC15XX_H |
| embeddedartists | 2:59be7fca4581 | 92 | #define SPECIAL_D5 P0_11 |
| embeddedartists | 2:59be7fca4581 | 93 | #else |
| embeddedartists | 2:59be7fca4581 | 94 | #define SPECIAL_D5 D5 |
| embeddedartists | 2:59be7fca4581 | 95 | #endif |
| displaymodule | 0:d6ff5fa503e8 | 96 | #endif |
| displaymodule | 0:d6ff5fa503e8 | 97 | |
| displaymodule | 0:d6ff5fa503e8 | 98 | #endif /* DM_PLATFORM_h */ |
| displaymodule | 0:d6ff5fa503e8 | 99 |
DisplayModule 1.8" TFT with SPI Interface
DisplayModule 2.2" TFT with 8-bit interface
DisplayModule 2.8" 240x320 Touch TFT with 8-bit Interface
DisplayModule 2.4" 240x320 Touch TFT with 8-bit Interface
DisplayModule 2.8" 240x320 TFT LCD With Resistive Touch - SPI, 4MB Flash
DisplayModule 3.5" 320x240 TFT LCD With Resistive Touch - SPI, 4MB Flash
DisplayModule 4.3" 480x272 Arduino TFT Shield With Touch And SPI Interface
DisplayModule 5.0" 800x480 Arduino TFT Shield With Touch And SPI Interface
DisplayModule 2.8" 240x320 TFT With Capacitive Touch