Driver Library for our displays
Dependents: dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more
dm_platform.h
00001 #ifndef DM_PLATFORM_h 00002 #define DM_PLATFORM_h 00003 00004 // Determine type of system 00005 #if defined (__AVR__) 00006 #define DM_TOOLCHAIN_ARDUINO 00007 #elif defined(TOOLCHAIN_ARM) || defined(TOOLCHAIN_ARM_MICRO) 00008 #define DM_TOOLCHAIN_MBED 00009 #else 00010 #error Only Arduino and Mbed toolchains are supported 00011 #endif 00012 00013 // Arduino 00014 #if defined (DM_TOOLCHAIN_ARDUINO) 00015 00016 // Mandatory includes for Arduino 00017 #include <Arduino.h> 00018 #include <avr/pgmspace.h> 00019 #include <SPI.h> 00020 00021 // Clear bit, Set bit, High pulse and Low pulse macros 00022 #define cbi(reg, _bitmask) *reg &= ~_bitmask 00023 #define sbi(reg, _bitmask) *reg |= _bitmask 00024 #define pulse_high(reg, _bitmask) sbi(reg, _bitmask); cbi(reg, _bitmask); 00025 #define pulse_low(reg, _bitmask) cbi(reg, _bitmask); sbi(reg, _bitmask); 00026 00027 // Map of mandatory pin names, from Arduino names to D* and A* 00028 #define D2 2 00029 #define D3 3 00030 #define D4 4 00031 #define D5 5 00032 #define D6 6 00033 #define D9 9 00034 #define D10 10 00035 #define A2 16 00036 #define A3 17 00037 #define A4 18 00038 #define A5 19 00039 00040 // Needed typedefs, not normally present in the Arduino environment 00041 #ifndef uint8_t 00042 #define uint8_t unsigned char 00043 #endif 00044 #ifndef int8_t 00045 #define int8_t signed char 00046 #endif 00047 #ifndef uint16_t 00048 #define uint16_t unsigned short 00049 #endif 00050 #ifndef uint32_t 00051 #define uint32_t unsigned long 00052 #endif 00053 00054 // Mbed 00055 #elif defined(DM_TOOLCHAIN_MBED) 00056 00057 // Mandatory includes for Mbed 00058 #include "mbed.h" 00059 00060 // Clear bit, Set bit, High pulse, Low pulse, Boundary limits and Delay macros 00061 #define sbi(reg, _bitmask) (*(reg) = 1) 00062 #define cbi(reg, _bitmask) (*(reg) = 0) 00063 #define pulse_high(reg, _bitmask) do { *(reg) = 1; *(reg) = 0; } while(0) 00064 #define pulse_low(reg, _bitmask) do { *(reg) = 0; *(reg) = 1; } while(0) 00065 #define constrain(amt,low,high) ((amt)<=(low)?(low):((amt)>(high)?(high):(amt))) 00066 #define delay(ms) wait_ms(ms) 00067 00068 // On Arduino no extra delay is needed, but on faster platforms the simulated 00069 // SPI bus may get a too high frequency so a delay here will lower it. This 00070 // delay should ideally be configurable per platform but for now it will have 00071 // to be ok to lower the frequency to 500KHz 00072 #if defined(__LPC407x_8x_177x_8x_H__) 00073 //#define slow_pulse_delay() wait_us(1) 00074 #define slow_pulse_delay() do {\ 00075 volatile unsigned _xyz = 10; \ 00076 for (; _xyz > 0; _xyz--); \ 00077 } while(0) 00078 #else 00079 #define slow_pulse_delay() 00080 #endif 00081 #define slow_pulse_high(reg, _bitmask) do {\ 00082 *(reg) = 1; \ 00083 slow_pulse_delay(); \ 00084 *(reg) = 0; \ 00085 slow_pulse_delay(); \ 00086 } while(0) 00087 #define slow_pulse_low(reg, _bitmask) do {\ 00088 *(reg) = 0; \ 00089 slow_pulse_delay(); \ 00090 *(reg) = 1; \ 00091 slow_pulse_delay(); \ 00092 } while(0) 00093 00094 // Special handling for the LPC1549 LPCXpresso board with solder bump 00095 #ifdef LPC15XX_H 00096 #define SPECIAL_D5 P0_11 00097 #else 00098 #define SPECIAL_D5 D5 00099 #endif 00100 #endif 00101 00102 #endif /* DM_PLATFORM_h */ 00103
Generated on Wed Jul 13 2022 04:21:40 by 1.7.2