diff options
author | inmarket <andrewh@inmarket.com.au> | 2015-04-01 00:30:12 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2015-04-01 00:30:12 +1000 |
commit | 9f38cbc445e95162ad583d55dbcd36b6381fe5a0 (patch) | |
tree | 6c457ed37403a5c2b3f0d44b9b392f6edcbb0db6 /boards/addons/gdisp | |
parent | 8e18cc30e240293a9bb7024a5e0d75232ce81dab (diff) | |
download | uGFX-9f38cbc445e95162ad583d55dbcd36b6381fe5a0.tar.gz uGFX-9f38cbc445e95162ad583d55dbcd36b6381fe5a0.tar.bz2 uGFX-9f38cbc445e95162ad583d55dbcd36b6381fe5a0.zip |
Example board file and cpp file for the Auduino teensy and the SSD1351 driver
Diffstat (limited to 'boards/addons/gdisp')
-rw-r--r-- | boards/addons/gdisp/board_SSD1351_teensy.cpp | 60 | ||||
-rw-r--r-- | boards/addons/gdisp/board_SSD1351_teensy.h | 35 |
2 files changed, 95 insertions, 0 deletions
diff --git a/boards/addons/gdisp/board_SSD1351_teensy.cpp b/boards/addons/gdisp/board_SSD1351_teensy.cpp new file mode 100644 index 00000000..b652bc21 --- /dev/null +++ b/boards/addons/gdisp/board_SSD1351_teensy.cpp @@ -0,0 +1,60 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#include <Arduino.h> +#include <SPI.h> + +// pin numbers +#define SSD1351_DC 14 +#define SSD1351_R 15 +#define SSD1351_CS 16 + +// Predefine the routine with "C" prototypes +extern "C" void ssd1351_init_board(void); +extern "C" void ssd1351_setpin_reset(int state); +extern "C" void ssd1351_acquire_bus(void); +extern "C" void ssd1351_release_bus(void); +extern "C" void ssd1351_write_cmd(unsigned char index); +extern "C" void ssd1351_write_data(unsigned char data); + +static SPISettings settings(12000000, MSBFIRST, SPI_MODE0); + +void ssd1351_init_board(void) { + pinMode(SSD1351_R, OUTPUT); + pinMode(SSD1351_CS, OUTPUT); + pinMode(SSD1351_DC, OUTPUT); + digitalWriteFast(SSD1351_R, 1); + digitalWriteFast(SSD1351_CS, 1); + digitalWriteFast(SSD1351_D, 1); +} + +void ssd1351_setpin_reset(int state) { + if (state) + digitalWriteFast(SSD1351_R, 0); + else + digitalWriteFast(SSD1351_R, 1); +} + +void ssd1351_acquire_bus(void) { + SPI.beginTransaction(settings); + digitalWriteFast(SSD1351_CS, 0); +} + +void ssd1351_release_bus(void) { + digitalWriteFast(SSD1351_CS, 1); + SPI.endTransaction(); +} + +void ssd1351_write_cmd(unsigned char index) { + digitalWriteFast(SSD1351_DC, 0); + SPI.transfer(index); + digitalWriteFast(SSD1351_DC, 1); +} + +void ssd1351_write_data(unsigned char data) { + SPI.transfer(data); +} diff --git a/boards/addons/gdisp/board_SSD1351_teensy.h b/boards/addons/gdisp/board_SSD1351_teensy.h new file mode 100644 index 00000000..92a8ba4f --- /dev/null +++ b/boards/addons/gdisp/board_SSD1351_teensy.h @@ -0,0 +1,35 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +extern void ssd1351_init_board(void); +extern void ssd1351_setpin_reset(int state); +extern void ssd1351_acquire_bus(void); +extern void ssd1351_release_bus(void); +extern void ssd1351_write_cmd(unsigned char index); +extern void ssd1351_write_data(unsigned char data); + +#define init_board(g) ssd1351_init_board() +#define post_init_board(g) +#define setpin_reset(g, s) ssd1351_setpin_reset(s) +#define set_backlight(g, p) +#define acquire_bus(g) ssd1351_acquire_bus() +#define release_bus(g) ssd1351_release_bus() +#define write_cmd(g, i) ssd1351_write_cmd(i) +#define write_data(g, d) ssd1351_write_cmd(d) + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif /* _GDISP_LLD_BOARD_H */ |