|
|
|
#ifndef LIB_EPAPER_2IN9_H_
|
|
|
|
#define LIB_EPAPER_2IN9_H_
|
|
|
|
|
|
|
|
#include "LPC8xx.h"
|
|
|
|
#include "swm.h"
|
|
|
|
#include "spi.h"
|
|
|
|
#include "syscon.h"
|
|
|
|
|
|
|
|
// Pin definition - à modifier
|
|
|
|
#define SPIBAUD 115200
|
|
|
|
#define SCK_PIN P0_1
|
|
|
|
#define MOSI_PIN P0_8
|
|
|
|
#define CS_PIN P0_16
|
|
|
|
#define RST_PIN P0_11
|
|
|
|
#define DC_PIN P0_21
|
|
|
|
#define BUSY_PIN P0_17
|
|
|
|
|
|
|
|
// Display resolution
|
|
|
|
#define EPD_WIDTH 128
|
|
|
|
#define EPD_HEIGHT 296
|
|
|
|
|
|
|
|
// EPD2IN9 commands
|
|
|
|
#define DRIVER_OUTPUT_CONTROL 0x01
|
|
|
|
#define BOOSTER_SOFT_START_CONTROL 0x0C
|
|
|
|
#define GATE_SCAN_START_POSITION 0x0F
|
|
|
|
#define DEEP_SLEEP_MODE 0x10
|
|
|
|
#define DATA_ENTRY_MODE_SETTING 0x11
|
|
|
|
#define SW_RESET 0x12
|
|
|
|
#define TEMPERATURE_SENSOR_CONTROL 0x1A
|
|
|
|
#define MASTER_ACTIVATION 0x20
|
|
|
|
#define DISPLAY_UPDATE_CONTROL_1 0x21
|
|
|
|
#define DISPLAY_UPDATE_CONTROL_2 0x22
|
|
|
|
#define WRITE_RAM 0x24
|
|
|
|
#define WRITE_VCOM_REGISTER 0x2C
|
|
|
|
#define WRITE_LUT_REGISTER 0x32
|
|
|
|
#define SET_DUMMY_LINE_PERIOD 0x3A
|
|
|
|
#define SET_GATE_TIME 0x3B
|
|
|
|
#define BORDER_WAVEFORM_CONTROL 0x3C
|
|
|
|
#define SET_RAM_X_ADDRESS_START_END_POSITION 0x44
|
|
|
|
#define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
|
|
|
|
#define SET_RAM_X_ADDRESS_COUNTER 0x4E
|
|
|
|
#define SET_RAM_Y_ADDRESS_COUNTER 0x4F
|
|
|
|
#define TERMINATE_FRAME_READ_WRITE 0xFF
|
|
|
|
|
|
|
|
// Macro functions
|
|
|
|
#define WaitEpaperReady() while(LPC_GPIO_PORT->B0[BUSY_PIN]) // à modifier
|
|
|
|
#define WaitSPIReady() while(!(LPC_SPI0->STAT & SPI_TXRDY));
|
|
|
|
|
|
|
|
// Basic functions
|
|
|
|
void _epaper_spiinit();
|
|
|
|
void _epaper_spitransfer(uint8_t data);
|
|
|
|
uint8_t _epaper_digitalread(uint8_t pin);
|
|
|
|
void _epaper_digitalwrite(uint8_t pin, uint8_t value);
|
|
|
|
void _epaper_setlut(const uint8_t* lut);
|
|
|
|
void _epaper_setmemoryarea(uint16_t x_start, uint16_t y_start, uint16_t x_stop, uint16_t y_stop);
|
|
|
|
void _epaper_setmemorypointer(uint16_t x, uint16_t y);
|
|
|
|
|
|
|
|
// User functions
|
|
|
|
uint8_t epaper_init();
|
|
|
|
void epaper_sendcommand(uint8_t command);
|
|
|
|
void epaper_senddata(uint8_t data);
|
|
|
|
void epaper_reset();
|
|
|
|
void epaper_setframe(uint8_t* image_buffer, uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
|
|
|
void epaper_clearframe(uint8_t color);
|
|
|
|
void epaper_display();
|
|
|
|
void epaper_sleep();
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* LIB_EPAPER_2IN9_H_ */
|