Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for teensy 3.x, 4.x #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 63 additions & 5 deletions cppsrc/Ucglib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,15 @@ void Ucglib3Wire9bitHWSPI::begin(uint8_t is_transparent)
/*=========================================================================*/
/* 8 Bit Parallel */


#if defined(__PIC32MX) || defined(__arm__) || defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266) || defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP32)
#if defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
/* Teensy3 */
static volatile uint8_t *u8g_data_port[9];
static uint8_t u8g_data_mask[9];
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
/* Teensy4 */
static volatile uint32_t *u8g_data_port[9];
static uint32_t u8g_data_mask[9];
#elif (defined(__PIC32MX) || defined(__arm__) || defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266) || defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP32))
/* CHIPKIT PIC32 */
static volatile uint32_t *u8g_data_port[9];
static uint32_t u8g_data_mask[9];
Expand Down Expand Up @@ -830,7 +837,24 @@ static void ucg_com_arduino_init_8bit(ucg_t *ucg)
static void ucg_com_arduino_send_8bit(ucg_t *ucg, uint8_t data)
{
int i;
#if defined(__arm__)
#if defined(__MK20DX256__) || defined( __MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__) || defined(__IMXRT1062__)
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
#elif defined(__arm__)
__NOP;
__NOP;
__NOP;
Expand Down Expand Up @@ -860,7 +884,24 @@ static void ucg_com_arduino_send_8bit(ucg_t *ucg, uint8_t data)
data >>= 1;
}

#if defined(__arm__)
#if defined(__MK20DX256__) || defined( __MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__) || defined(__IMXRT1062__)
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
#elif defined(__arm__)
__NOP;
__NOP;
__NOP;
Expand All @@ -885,7 +926,24 @@ static void ucg_com_arduino_send_8bit(ucg_t *ucg, uint8_t data)

*u8g_data_port[8] &= ~u8g_data_mask[8];

#if defined(__arm__)
#if defined(__MK20DX256__) || defined( __MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__) || defined(__IMXRT1062__)
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
__asm__ __volatile__("NOP");
#elif defined(__arm__)
__NOP;
__NOP;
__NOP;
Expand Down
7 changes: 7 additions & 0 deletions csrc/ucg.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ typedef uint8_t PROGMEM ucg_pgm_uint8_t;
typedef uint8_t ucg_fntpgm_uint8_t;
#define ucg_pgm_read(adr) pgm_read_byte_near(adr)
#define UCG_PSTR(s) ((ucg_pgm_uint8_t *)PSTR(s))
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
/* Teensy4 */
#undef PROGMEM
typedef uint8_t ucg_pgm_uint8_t;
typedef uint8_t ucg_fntpgm_uint8_t;
#define ucg_pgm_read(adr) (*(const uint8_t *)(adr))
#define UCG_PSTR(s) ((uint8_t *)(s))
#else
#define UCG_PROGMEM
#define PROGMEM
Expand Down