Caiou
Dependents: LCD_Proj LCD_imagetest LCD_Proj_rtc
Fork of DmTftLibrary by
dm_platform.h@3:02c19cbc707c, 2014-05-21 (annotated)
- Committer:
- displaymodule
- Date:
- Wed May 21 14:43:08 2014 +0000
- Revision:
- 3:02c19cbc707c
- Parent:
- 2:59be7fca4581
- Child:
- 4:92d019216e28
Fixed bug in Touch.cpp. Added delays in the pulse_* macros to lower the clock frequency in the simulated SPI communication.
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 | 0:d6ff5fa503e8 | 63 | #define constrain(amt,low,high) ((amt)<=(low)?(low):((amt)>(high)?(high):(amt))) |
displaymodule | 0:d6ff5fa503e8 | 64 | #define delay(ms) wait_ms(ms) |
embeddedartists | 2:59be7fca4581 | 65 | |
displaymodule | 3:02c19cbc707c | 66 | // On Arduino no extra delay is needed, but on faster platforms the simulated |
displaymodule | 3:02c19cbc707c | 67 | // SPI bus may get a too high frequency so a delay here will lower it. This |
displaymodule | 3:02c19cbc707c | 68 | // delay should ideally be configurable per platform but for now it will have |
displaymodule | 3:02c19cbc707c | 69 | // to be ok to lower the frequency to 500KHz |
displaymodule | 3:02c19cbc707c | 70 | #define pulse_delay() wait_us(1) |
displaymodule | 3:02c19cbc707c | 71 | #define pulse_high(reg, _bitmask) do {\ |
displaymodule | 3:02c19cbc707c | 72 | *(reg) = 1; \ |
displaymodule | 3:02c19cbc707c | 73 | pulse_delay(); \ |
displaymodule | 3:02c19cbc707c | 74 | *(reg) = 0; \ |
displaymodule | 3:02c19cbc707c | 75 | pulse_delay(); \ |
displaymodule | 3:02c19cbc707c | 76 | } while(0) |
displaymodule | 3:02c19cbc707c | 77 | #define pulse_low(reg, _bitmask) do {\ |
displaymodule | 3:02c19cbc707c | 78 | *(reg) = 0; \ |
displaymodule | 3:02c19cbc707c | 79 | pulse_delay(); \ |
displaymodule | 3:02c19cbc707c | 80 | *(reg) = 1; \ |
displaymodule | 3:02c19cbc707c | 81 | pulse_delay(); \ |
displaymodule | 3:02c19cbc707c | 82 | } while(0) |
displaymodule | 3:02c19cbc707c | 83 | |
displaymodule | 0:d6ff5fa503e8 | 84 | // Map of mandatory pin names, from Arduino names to D* and A* |
displaymodule | 0:d6ff5fa503e8 | 85 | #if defined(__LPC407x_8x_177x_8x_H__) |
displaymodule | 0:d6ff5fa503e8 | 86 | #define D0 p10 |
displaymodule | 0:d6ff5fa503e8 | 87 | #define D1 p9 |
displaymodule | 0:d6ff5fa503e8 | 88 | #define D2 p31 |
displaymodule | 0:d6ff5fa503e8 | 89 | #define D3 p32 |
displaymodule | 0:d6ff5fa503e8 | 90 | #define D4 p33 |
displaymodule | 0:d6ff5fa503e8 | 91 | #define D5 p37 |
displaymodule | 0:d6ff5fa503e8 | 92 | #define D6 p38 |
displaymodule | 0:d6ff5fa503e8 | 93 | #define D7 p34 |
displaymodule | 0:d6ff5fa503e8 | 94 | #define D8 p8 |
displaymodule | 0:d6ff5fa503e8 | 95 | #define D9 p39 |
displaymodule | 0:d6ff5fa503e8 | 96 | #define D10 p14 |
displaymodule | 0:d6ff5fa503e8 | 97 | #define D11 p11 |
displaymodule | 0:d6ff5fa503e8 | 98 | #define D12 p12 |
displaymodule | 0:d6ff5fa503e8 | 99 | #define D13 p13 |
embeddedartists | 2:59be7fca4581 | 100 | |
displaymodule | 0:d6ff5fa503e8 | 101 | #define A0 p15 |
displaymodule | 0:d6ff5fa503e8 | 102 | #define A1 p16 |
displaymodule | 0:d6ff5fa503e8 | 103 | #define A2 p17 |
displaymodule | 0:d6ff5fa503e8 | 104 | #define A3 p18 |
displaymodule | 0:d6ff5fa503e8 | 105 | #define A4 p19 |
displaymodule | 0:d6ff5fa503e8 | 106 | #define A5 p20 |
displaymodule | 0:d6ff5fa503e8 | 107 | #endif |
embeddedartists | 2:59be7fca4581 | 108 | |
embeddedartists | 2:59be7fca4581 | 109 | // Special handling for the LPC1549 LPCXpresso board with solder bump |
embeddedartists | 2:59be7fca4581 | 110 | #ifdef LPC15XX_H |
embeddedartists | 2:59be7fca4581 | 111 | #define SPECIAL_D5 P0_11 |
embeddedartists | 2:59be7fca4581 | 112 | #else |
embeddedartists | 2:59be7fca4581 | 113 | #define SPECIAL_D5 D5 |
embeddedartists | 2:59be7fca4581 | 114 | #endif |
displaymodule | 0:d6ff5fa503e8 | 115 | #endif |
displaymodule | 0:d6ff5fa503e8 | 116 | |
displaymodule | 0:d6ff5fa503e8 | 117 | #endif /* DM_PLATFORM_h */ |
displaymodule | 0:d6ff5fa503e8 | 118 |