Peter Drescher's library for the Embedded Artists E-paper display, but modified to also support the LPC4088 QuickStart Board

Dependents:   app_epaper

Fork of EaEpaper by Peter Drescher

Files at this revision

API Documentation at this revision

Comitter:
embeddedartists
Date:
Wed Dec 04 12:51:40 2013 +0000
Parent:
2:1f3672176ca3
Commit message:
Added support for the LPC4088 QuickStart Board and more specifically the LPC4088 QSB Base Board

Changed in this revision

EPD.cpp Show annotated file Show diff for this revision Revisions of this file
EPD.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1f3672176ca3 -r 6fb3e296a6fd EPD.cpp
--- a/EPD.cpp	Sun Nov 10 19:32:53 2013 +0000
+++ b/EPD.cpp	Wed Dec 04 12:51:40 2013 +0000
@@ -18,7 +18,10 @@
 
 #include "EPD.h"
 #include "mbed.h"
+
+#if !defined(TARGET_LPC4088)
 #include "BurstSPI.h"
+#endif
 
 
 // delays - more consistent naming
@@ -39,13 +42,6 @@
 #define millis_start() _time.start()
 
 
-//static void PWM_start(int pin);
-//static void PWM_stop(int pin);
-
-//static void SPI_put(uint8_t c);
-//static void SPI_put_wait(uint8_t c, int busy_pin);
-//static void SPI_send(uint8_t cs_pin, const uint8_t *buffer, uint16_t length);
-
 
 EPD_Class::EPD_Class(EPD_size size,
              PinName panel_on_pin,
@@ -139,8 +135,7 @@
     digitalWrite(this->EPD_Pin_BORDER, LOW);
     digitalWrite(this->EPD_Pin_EPD_CS, LOW);
 
-    //PWM_start(this->EPD_Pin_PWM);
-    EPD_Pin_PWM = 0.5;
+    PWM_start();
     Delay_ms(5);
     digitalWrite(this->EPD_Pin_PANEL_ON, HIGH);
     Delay_ms(10);
@@ -221,8 +216,7 @@
 
     // final delay before PWM off
     Delay_ms(30);
-    //PWM_stop(this->EPD_Pin_PWM);
-    EPD_Pin_PWM = 0.0;
+    PWM_stop();
 
     // charge pump negative voltage on
     Delay_us(10);
@@ -594,20 +588,41 @@
 
     // send all data
     for (uint16_t i = 0; i < length; ++i) {
+#if defined(TARGET_LPC4088)
+        spi_.write(*buffer++);
+#elif
         spi_.fastWrite(*buffer++);
         spi_.clearRX();
+#endif    
     }
 
     // CS high
     digitalWrite(cs_pin, HIGH);
 }
 
+#if defined(TARGET_LPC4088)
+void EPD_Class::PWM_flip() {
+    EPD_Pin_PWM = !EPD_Pin_PWM;
+}
+#endif
 
-//static void PWM_start(int pin) {
-//    analogWrite(pin, 128);  // 50% duty cycle
-//}
+void EPD_Class::PWM_start() {
+#if defined(TARGET_LPC4088) 
+    pwmTicker.attach_us(this, &EPD_Class::PWM_flip, 5);
+#elif
+    // we need at least a 100kHz signal -> 10us period
+    EPD_Pin_PWM.period_us(10);
 
+    // 50% duty cycle
+    EPD_Pin_PWM = 0.5;
+#endif
+}
 
-//static void PWM_stop(int pin) {
-//    analogWrite(pin, 0);
-//}
+void EPD_Class::PWM_stop() {
+#if defined(TARGET_LPC4088) 
+    pwmTicker.detach();
+#elif
+    EPD_Pin_PWM = 0;
+#endif
+}
+
diff -r 1f3672176ca3 -r 6fb3e296a6fd EPD.h
--- a/EPD.h	Sun Nov 10 19:32:53 2013 +0000
+++ b/EPD.h	Wed Dec 04 12:51:40 2013 +0000
@@ -16,7 +16,7 @@
 #define EPD_H
 
 #include "mbed.h"
-#include "BurstSPI.h"
+//#include "BurstSPI.h"
 
 #define PROGMEM
 
@@ -41,12 +41,21 @@
     DigitalOut EPD_Pin_PANEL_ON;
     DigitalOut EPD_Pin_BORDER;
     DigitalOut EPD_Pin_DISCHARGE;
+#if defined(TARGET_LPC4088)
+    DigitalOut EPD_Pin_PWM;
+#elif    
     PwmOut EPD_Pin_PWM;
+#endif    
     DigitalOut EPD_Pin_RESET;
     DigitalIn EPD_Pin_BUSY;
     DigitalOut EPD_Pin_EPD_CS;
+#if defined(TARGET_LPC4088)
+    SPI spi_;
+    Ticker pwmTicker;
+#elif
     BurstSPI spi_;    
-
+#endif    
+    
     EPD_size size;
     uint16_t stage_time;
     uint16_t factored_stage_time;
@@ -64,6 +73,12 @@
     void SPI_put(uint8_t c);
     void SPI_put_wait(uint8_t c, DigitalIn busy_pin);
     void SPI_send(DigitalOut cs_pin, const uint8_t *buffer, uint16_t length);
+    
+    void PWM_start();
+    void PWM_stop();
+#if defined(TARGET_LPC4088)    
+    void PWM_flip();
+#endif    
 
 public:
     // power up and power down the EPD panel