Caiou
Dependents: LCD_Proj LCD_imagetest LCD_Proj_rtc
Fork of DmTftLibrary by
dm_platform.h@6:fde03297017b, 2014-05-23 (annotated)
- Committer:
- displaymodule
- Date:
- Fri May 23 08:10:09 2014 +0000
- Revision:
- 6:fde03297017b
- Parent:
- 4:92d019216e28
Lowered the pulsing time for bit banged SPI on the LPC4088 QSB to make it more responsive.
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 | 6:fde03297017b | 73 | //#define slow_pulse_delay() wait_us(1) |
displaymodule | 6:fde03297017b | 74 | #define slow_pulse_delay() do {\ |
displaymodule | 6:fde03297017b | 75 | volatile unsigned _xyz = 10; \ |
displaymodule | 6:fde03297017b | 76 | for (; _xyz > 0; _xyz--); \ |
displaymodule | 6:fde03297017b | 77 | } while(0) |
displaymodule | 4:92d019216e28 | 78 | #else |
displaymodule | 4:92d019216e28 | 79 | #define slow_pulse_delay() |
displaymodule | 4:92d019216e28 | 80 | #endif |
displaymodule | 4:92d019216e28 | 81 | #define slow_pulse_high(reg, _bitmask) do {\ |
displaymodule | 3:02c19cbc707c | 82 | *(reg) = 1; \ |
displaymodule | 4:92d019216e28 | 83 | slow_pulse_delay(); \ |
displaymodule | 3:02c19cbc707c | 84 | *(reg) = 0; \ |
displaymodule | 4:92d019216e28 | 85 | slow_pulse_delay(); \ |
displaymodule | 3:02c19cbc707c | 86 | } while(0) |
displaymodule | 4:92d019216e28 | 87 | #define slow_pulse_low(reg, _bitmask) do {\ |
displaymodule | 4:92d019216e28 | 88 | *(reg) = 0; \ |
displaymodule | 4:92d019216e28 | 89 | slow_pulse_delay(); \ |
displaymodule | 4:92d019216e28 | 90 | *(reg) = 1; \ |
displaymodule | 4:92d019216e28 | 91 | slow_pulse_delay(); \ |
displaymodule | 4:92d019216e28 | 92 | } while(0) |
embeddedartists | 2:59be7fca4581 | 93 | |
embeddedartists | 2:59be7fca4581 | 94 | // Special handling for the LPC1549 LPCXpresso board with solder bump |
embeddedartists | 2:59be7fca4581 | 95 | #ifdef LPC15XX_H |
embeddedartists | 2:59be7fca4581 | 96 | #define SPECIAL_D5 P0_11 |
embeddedartists | 2:59be7fca4581 | 97 | #else |
embeddedartists | 2:59be7fca4581 | 98 | #define SPECIAL_D5 D5 |
embeddedartists | 2:59be7fca4581 | 99 | #endif |
displaymodule | 0:d6ff5fa503e8 | 100 | #endif |
displaymodule | 0:d6ff5fa503e8 | 101 | |
displaymodule | 0:d6ff5fa503e8 | 102 | #endif /* DM_PLATFORM_h */ |
displaymodule | 0:d6ff5fa503e8 | 103 |