Library to control the EM027BS013 ePaper display from Pervasive Display.
Dependents: app_epaper_EM027BS013_LPC1549 lpc4088_ebb_epaper EaEpaper_EM027BS013 app_epaper_EM027BS013 ... more
Revision 0:9297e33f50cf, committed 2014-07-22
- Comitter:
- embeddedartists
- Date:
- Tue Jul 22 11:59:06 2014 +0000
- Commit message:
- First version of library for the EM027BS013 ePaper display.
Changed in this revision
diff -r 000000000000 -r 9297e33f50cf EM027BS013.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EM027BS013.cpp Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright 2014 Embedded Artists AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ + +#include "mbed.h" +#include "EM027BS013.h" + +#include "Pervasive_Displays_small_EPD.h" + +/****************************************************************************** + * Global variables + *****************************************************************************/ + +//PinName SEC01; // GND +//PinName SEC02; // 3v3 +PinName SEC03; +PinName SEC04; +PinName SEC05; +PinName SEC06; +PinName SEC07; +PinName SEC08; +PinName SEC09; +PinName SEC10; +PinName SEC11; +PinName SEC12; +PinName SEC13; +PinName SEC14; + +/****************************************************************************** + * Defines and typedefs + *****************************************************************************/ + +EM027BS013::EM027BS013(PinName sec03_SpiSCK, + PinName sec04_SpiMOSI, + PinName sec05_SpiMISO, + PinName sec06_EpdCS, + PinName sec07_EpdBusy, + PinName sec08_EpdBorder, + PinName sec09_I2cSCL, + PinName sec10_I2cSDA, + PinName sec11_FlashCS, + PinName sec12_EpdReset, + PinName sec13_EpdPanelOn, + PinName sec14_EpdDischarge) +{ + initialized = false; + + SEC03 = sec03_SpiSCK; + SEC04 = sec04_SpiMOSI; + SEC05 = sec05_SpiMISO; + SEC06 = sec06_EpdCS; + SEC07 = sec07_EpdBusy; + SEC08 = sec08_EpdBorder; + SEC09 = sec09_I2cSCL; + SEC10 = sec10_I2cSDA; + SEC11 = sec11_FlashCS; + SEC12 = sec12_EpdReset; + SEC13 = sec13_EpdPanelOn; + SEC14 = sec14_EpdDischarge; +} + +void EM027BS013::init(void) +{ + if (!initialized) { + EPD_display_init(); + initialized = true; + } +} + +void EM027BS013::drawImage(uint8_t * image) +{ + init(); + EPD_display_from_pointer(EPD_270, NULL, image); +} +
diff -r 000000000000 -r 9297e33f50cf EM027BS013.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EM027BS013.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright 2014 Embedded Artists AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef EM027BS013_H +#define EM027BS013_H + +/** An interface to Embedded Artists' ePaper display, EM027BS013 + * + */ +class EM027BS013 { +public: + + /** Create an interface to an Embedded Artistss ePaper display, EM027BS013. + * + * The parameters are all for the Serial Expansion Connector (SEC) + */ + EM027BS013(PinName sec03_SpiSCK, + PinName sec04_SpiMOSI, + PinName sec05_SpiMISO, + PinName sec06_EpdCS, + PinName sec07_EpdBusy, + PinName sec08_EpdBorder, + PinName sec09_I2cSCL, + PinName sec10_I2cSDA, + PinName sec11_FlashCS, + PinName sec12_EpdReset, + PinName sec13_EpdPanelOn, + PinName sec14_EpdDischarge); + + /** Draws the specified image on the display. + * + * @param image The image data, must be 264x176 bytes + */ + void drawImage(uint8_t* image); + +private: + /** Initializes the display + */ + void init(void); + + bool initialized; +}; + +#endif +
diff -r 000000000000 -r 9297e33f50cf EPD_COG.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_COG.cpp Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,45 @@ +/** + * \file + * + * \brief The link source of different COG and EPD + * + * Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. + * + * Authors: Pervasive Displays Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +//#include "Pervasive_Displays_small_EPD.h" + +//#if (defined COG_V110_G1) +//#include "COG/V110_G1/EPD_COG_process_V110_G1.c" +//#include "COG/V110_G1/EPD_COG_partial_update_V110_G1.c" +//#elif (defined COG_V230_G2) +//#include "COG/V230_G2/EPD_COG_process_V230_G2.c" +//#else +//#error "ERROR: The EPD's COG type is not defined." +//#endif + +
diff -r 000000000000 -r 9297e33f50cf EPD_COG_process.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_COG_process.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,241 @@ +/** +* \file +* +* \brief The definition of COG driving data and process +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef DISPLAY_COG_PROCESS__H_INCLUDED +#define DISPLAY_COG_PROCESS__H_INCLUDED + +#include "Pervasive_Displays_small_EPD.h" +/** + * \brief The definition for driving stage to compare with for getting Odd and Even data */ +#define BLACK0 (uint8_t)(0x03) /**< getting bit1 or bit0 as black color(11) */ +#define BLACK1 (uint8_t)(0x0C) /**< getting bit3 or bit2 as black color(11) */ +#define BLACK2 (uint8_t)(0x30) /**< getting bit5 or bit4 as black color(11) */ +#define BLACK3 (uint8_t)(0xC0) /**< getting bit7 or bit6 as black color(11) */ +#define WHITE0 (uint8_t)(0x02) /**< getting bit1 or bit0 as white color(10) */ +#define WHITE1 (uint8_t)(0x08) /**< getting bit3 or bit2 as white color(10) */ +#define WHITE2 (uint8_t)(0x20) /**< getting bit5 or bit4 as white color(10) */ +#define WHITE3 (uint8_t)(0x80) /**< getting bit7 or bit6 as white color(10) */ +#define NOTHING0 (uint8_t)(0x01) /**< getting bit1 or bit0 as nothing input(01) */ +#define NOTHING1 (uint8_t)(0x04) /**< getting bit3 or bit2 as nothing input(01) */ +#define NOTHING2 (uint8_t)(0x10) /**< getting bit5 or bit4 as nothing input(01) */ +#define NOTHING3 (uint8_t)(0x40) /**< getting bit7 or bit6 as nothing input(01) */ +#define NOTHING (uint8_t)(0x55) /**< sending Nothing frame, 01=Nothing, 0101=0x5 */ + + +#define ALL_BLACK (uint8_t)(0xFF) +#define ALL_WHITE (uint8_t)(0xAA) +#define BORDER_BYTE_B (uint8_t)(0xFF) +#define BORDER_BYTE_W (uint8_t)(0xAA) +#define ERROR_BUSY (uint8_t)(0xF0) +#define ERROR_COG_ID (uint8_t)(0xF1) +#define ERROR_BREAKAGE (uint8_t)(0xF2) +#define ERROR_DC (uint8_t)(0xF3) +#define ERROR_CHARGEPUMP (uint8_t)(0xF4) +#define RES_OK (uint8_t)(0x00) + +/** + * \brief The COG Driver uses a buffer to update the EPD line by line. + \note Use the 2.7" maximum data(66)+scan(44)+dummy(1) bytes as line buffer size=111.*/ +#define LINE_BUFFER_DATA_SIZE 33 +#define COG_line_Max_Size 33 +/** + * \brief Support 1.44", 2" and 2.7" three type EPD currently */ +#define COUNT_OF_EPD_TYPE 3 + +/** + * \brief Four driving stages */ +enum Stage { + Stage1, /**< Inverse previous image */ + Stage2, /**< White */ + Stage3, /**< Inverse new image */ + Stage4 /**< New image */ +}; + +#if (defined COG_V110_G1) +/** + * \brief Line data structure of 1.44 inch EPD + * \note + * 1.44 inch needs to put border_control byte at the front of data line. + * Refer to COG document Section 5.2 - 1.44" Input Data Order. + */ +struct COG_144_line_data_t { + uint8_t border_byte; /**< Internal border_control, for 1.44" EPD only */ + uint8_t even[16]; /**< 1.44" even byte array */ + uint8_t scan[24]; /**< 1.44" scan byte array */ + uint8_t odd [16]; /**< 1.44" odd byte array */ +} ; + +/** + * \brief Line data structure of 2 inch EPD + * \note + * Add one byte x00 to complete a line + * Refer to COG document Section 5.2 - 2" Input Data Order. + */ +struct COG_200_line_data_t { + uint8_t even[25]; /**< 2" even byte array */ + uint8_t scan[24]; /**< 2" scan byte array */ + uint8_t odd [25]; /**< 2" odd byte array */ + uint8_t dummy_data; /**< dummy byte 0x00 */ +} ; + +/** + * \brief Line data structure of 2.7 inch EPD + * \note + * Add one byte x00 to complete a line + * Refer to COG document Section 5.2 - 2.7" Input Data Order. + */ +struct COG_270_line_data_t { + uint8_t even[33]; /**< 2.7" even byte array */ + uint8_t scan[44]; /**< 2.7" scan byte array */ + uint8_t odd [33]; /**< 2.7" odd byte array */ + uint8_t dummy_data; /**< dummy byte 0x00 */ +} ; + + +#elif (defined COG_V230_G2) +/** + * \brief Line data structure of 1.44 inch V230 EPD with G2 COG + * \note + * 1.44 inch needs to put border_control byte at the front of data line. + * Refer to COG document Section 5.2 - 1.44" Input Data Order. + */ +struct COG_144_line_data_t { + uint8_t even[16]; /**< 1.44" even byte array */ + uint8_t scan[24]; /**< 1.44" scan byte array */ + uint8_t odd [16]; /**< 1.44" odd byte array */ + uint8_t border_byte; /**< Internal border_control*/ +} ; + +/** + * \brief Line data structure of 2 inch V230 EPD with G2 COG + * \note + * Add one byte x00 to complete a line + * Refer to COG document Section 5.2 - 2" Input Data Order. + */ +struct COG_200_line_data_t { + uint8_t border_byte; /**< Internal border_control*/ + uint8_t even[25]; /**< 2" even byte array */ + uint8_t scan[24]; /**< 2" scan byte array */ + uint8_t odd [25]; /**< 2" odd byte array */ +} ; + +/** + * \brief Line data structure of 2.7 inch V230 EPD with G2 COG + * \note + * Add one byte x00 to complete a line + * Refer to COG document Section 5.2 - 2.7" Input Data Order. + */ +struct COG_270_line_data_t { + uint8_t border_byte; /**< Internal border_control*/ + uint8_t even[33]; /**< 2.7" even byte array */ + uint8_t scan[44]; /**< 2.7" scan byte array */ + uint8_t odd [33]; /**< 2.7" odd byte array */ +} ; + +/** + * \brief Define waveform stages for V230 EPD with G2 COG + */ +struct EPD_WaveformTable_Struct +{ + uint8_t stage1_frame1; + uint8_t stage1_block1; + uint8_t stage1_step1; + + uint16_t stage2_t1; + uint16_t stage2_t2; + uint8_t stage2_cycle; + + uint8_t stage3_frame3; + uint8_t stage3_block3; + uint8_t stage3_step3; +}; + +/** + * \brief Define the Block type waveform structure + */ +struct EPD_V230_G2_Struct +{ + int16_t frame_y0; + int16_t frame_y1; + int16_t block_y0; + int16_t block_y1; + int16_t block_size; + int16_t step_size; + int16_t frame_cycle; + int16_t step_y0; + int16_t step_y1; + int16_t number_of_steps; +}; +#else +#error "ERROR: The EPD's COG type is not defined." +#endif + +/** + * \brief Packet structure of a line data */ +typedef union { + union { + struct COG_144_line_data_t line_data_for_144; /**< line data structure of 1.44" EPD */ + struct COG_200_line_data_t line_data_for_200; /**< line data structure of 2" EPD */ + struct COG_270_line_data_t line_data_for_270; /**< line data structure of 2.7" EPD */ + } line_data_by_size; /**< the line data of specific EPD size */ + uint8_t uint8[LINE_BUFFER_DATA_SIZE]; /**< the maximum line buffer data size as length */ +} COG_line_data_packet_type; + +/** + * \brief Define the COG driver's parameters */ +struct COG_parameters_t { + uint8_t channel_select[8]; /**< the SPI register data of Channel Select */ + uint8_t voltage_level; /**< the SPI register data of Voltage Level */ + uint16_t horizontal_size; /**< the bytes of width of EPD */ + uint16_t vertical_size; /**< the bytes of height of EPD */ + uint8_t data_line_size; /**< Data + Scan + Dummy bytes */ + uint16_t frame_time_offset; /**< the rest of frame time in a stage */ + uint16_t stage_time; /**< defined stage time */ +} ; + +extern const struct COG_parameters_t COG_parameters[COUNT_OF_EPD_TYPE]; +extern const uint8_t SCAN_TABLE[4]; +void EPD_init(void); +void EPD_power_on (void); +uint8_t EPD_initialize_driver (uint8_t EPD_type_index); +void EPD_display_from_array_prt (uint8_t EPD_type_index, uint8_t *previous_image_ptr, +uint8_t *new_image_ptr); +void EPD_display_from_flash_prt (uint8_t EPD_type_index, long previous_image_flash_address, + long new_image_flash_address,EPD_read_flash_handler On_EPD_read_flash); +uint8_t EPD_power_off (uint8_t EPD_type_index); +void COG_driver_EPDtype_select(uint8_t EPD_type_index); + +#endif //DISPLAY_COG_PROCESS__H_INCLUDED + + +
diff -r 000000000000 -r 9297e33f50cf EPD_COG_process_v230_G2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_COG_process_v230_G2.cpp Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,849 @@ +/** +* \file +* +* \brief The waveform driving processes and updating stages of G2 COG with V230 EPD +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* \asf_license_start +* +* \page License +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* 3. The name of Atmel may not be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* 4. This software may only be redistributed and used in connection with an +* Atmel microcontroller product. +* +* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE +* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* \asf_license_stop +**/ + +#include "EPD_COG_process.h" +#ifdef COG_V230_G2 + +#define ADDRESS_NULL 0xffffffff +//EPD Panel parameters +const struct COG_parameters_t COG_parameters[COUNT_OF_EPD_TYPE] = { + { + // FOR 1.44" + {0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0x00}, + 0x03, + (128/8), + 96, + ((((128+96)*2)/8)+1), + 0, + 480 + }, + { + // For 2.0" + {0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00}, + 0x03, + (200/8), + 96, + ((((200+96)*2)/8)+1), + 0, + 480 + }, + { + // For 2.7" + {0x00,0x00,0x00,0x7F,0xFF,0xFE,0x00,0x00}, + 0x00, + (264/8), + 176, + ((((264+176)*2)/8)+1), + 0, + 630 + } +}; + +/* \brief EPD Waveform parameters + * \note the parameters of waveform table below is different from the G2 COG document due to + * use block size is easier to achieve than accurate block time for different MCU. + * The approach is also working. + * */ + const struct EPD_WaveformTable_Struct E_Waveform[COUNT_OF_EPD_TYPE][3] = { + {// FOR 1.44" + {//50 �� T �� 40 + 4, //stage1_frame1 + 16, //stage1_block1 + 2, //stage1_step1 + 155, //stage2_t1 + 155, //stage2_t2 + 4, //stage2_cycle + 4, //stage3_frame3 + 16, //stage3_block3 + 2 //stage3_step3 + } + ,{//40 �� T �� 10 + 4, //stage1_frame1 + 16, //stage1_block1 + 2, //stage1_step1 + 155, //stage2_t1 + 155, //stage2_t2 + 4, //stage2_cycle + 4, //stage3_frame3 + 16, //stage3_block3 + 2 //stage3_step3 + }, + {//10 �� T �� 0 + 2, //stage1_frame1 + 42, //stage1_block1 + 6, //stage1_step1 + 392, //stage2_t1 + 392, //stage2_t2 + 4, //stage2_cycle + 2, //stage3_frame3 + 42, //stage3_block3 + 6 //stage3_step3 + } + + }, + {// For 2.0" + {//50 �� T �� 40 + 4, //stage1_frame1 + 36, //stage1_block1 + 2, //stage1_step1 + 196, //stage2_t1 + 196, //stage2_t2 + 4, //stage2_cycle + 4, //stage3_frame3 + 36, //stage3_block3 + 2 //stage3_step3 + }, + {//40 �� T �� 10 + 2, //stage1_frame1 + 36, //stage1_block1 + 2, //stage1_step1 + 196, //stage2_t1 + 196, //stage2_t2 + 4, //stage2_cycle + 2, //stage3_frame3 + 36, //stage3_block3 + 2 //stage3_step3 + }, + {//10 �� T �� 0 + 2, //stage1_frame1 + 36, //stage1_block1 + 2, //stage1_step1 + 392, //stage2_t1 + 392, //stage2_t2 + 4, //stage2_cycle + 2, //stage3_frame3 + 36, //stage3_block3 + 2 //stage3_step3 + } + }, + {// For 2.7" + {//50 �� T �� 40 + 4, //stage1_frame1 + 28, //stage1_block1 + 4, //stage1_step1 + 196, //stage2_t1 + 196, //stage2_t2 + 4, //stage2_cycle + 4, //stage3_frame3 + 28, //stage3_block3 + 4 //stage3_step3 + }, + {//40 �� T �� 10 + 2, //stage1_frame1 + 28, //stage1_block1 + 2, //stage1_step1 + 196, //stage2_t1 + 196, //stage2_t2 + 4, //stage2_cycle + 2, //stage3_frame3 + 28, //stage3_block3 + 2 //stage3_step3 + }, + {//10 �� T �� 0 + 2, //stage1_frame1 + 28, //stage1_block1 + 4, //stage1_step1 + 392, //stage2_t1 + 392, //stage2_t2 + 4, //stage2_cycle + 2, //stage3_frame3 + 28, //stage3_block3 + 4 //stage3_step3 + } + }, + + }; + +const uint8_t SCAN_TABLE[4] = {0xC0,0x30,0x0C,0x03}; + +static struct EPD_WaveformTable_Struct *action__Waveform_param; +static COG_line_data_packet_type COG_Line; +static EPD_read_flash_handler _On_EPD_read_flash; +static uint8_t *data_line_even; +static uint8_t *data_line_odd; +static uint8_t *data_line_scan; +static uint8_t *data_line_border_byte; + +/** +* \brief According to EPD size and temperature to get stage_time +* \note Refer to COG document Section 5.3 for more details +* +* \param EPD_type_index The defined EPD size +*/ +static void set_temperature_factor(uint8_t EPD_type_index) { + int8_t temperature; + temperature = get_temperature(); + if (50 >= temperature && temperature > 40){ + action__Waveform_param=(struct EPD_WaveformTable_Struct *)&E_Waveform[EPD_type_index][0]; + }else if (40 >= temperature && temperature > 10){ + action__Waveform_param=(struct EPD_WaveformTable_Struct *)&E_Waveform[EPD_type_index][1]; + }else if (10 >= temperature && temperature > 0){ + action__Waveform_param=(struct EPD_WaveformTable_Struct *)&E_Waveform[EPD_type_index][2]; + }else action__Waveform_param=(struct EPD_WaveformTable_Struct *)&E_Waveform[EPD_type_index][1]; //Default +} + +/** +* \brief Initialize the EPD hardware setting +*/ +void EPD_init(void) { + EPD_display_hardware_init(); + EPD_cs_low(); + EPD_rst_low(); + EPD_discharge_low(); + EPD_border_low(); +} + +/** +* \brief Select the EPD size to get line data array for driving COG +* +* \param EPD_type_index The defined EPD size +*/ +void COG_driver_EPDtype_select(uint8_t EPD_type_index) { + switch(EPD_type_index) { + case EPD_144: + data_line_even = &COG_Line.line_data_by_size.line_data_for_144.even[0]; + data_line_odd = &COG_Line.line_data_by_size.line_data_for_144.odd[0]; + data_line_scan = &COG_Line.line_data_by_size.line_data_for_144.scan[0]; + data_line_border_byte = &COG_Line.line_data_by_size.line_data_for_144.border_byte; + break; + case EPD_200: + data_line_even = &COG_Line.line_data_by_size.line_data_for_200.even[0]; + data_line_odd = &COG_Line.line_data_by_size.line_data_for_200.odd[0]; + data_line_scan = &COG_Line.line_data_by_size.line_data_for_200.scan[0]; + data_line_border_byte = &COG_Line.line_data_by_size.line_data_for_200.border_byte; + break; + case EPD_270: + data_line_even = &COG_Line.line_data_by_size.line_data_for_270.even[0]; + data_line_odd = &COG_Line.line_data_by_size.line_data_for_270.odd[0]; + data_line_scan = &COG_Line.line_data_by_size.line_data_for_270.scan[0]; + data_line_border_byte = &COG_Line.line_data_by_size.line_data_for_270.border_byte; + break; + } +} + +/** +* \brief Power on COG Driver +* \note For detailed flow and description, please refer to the COG G2 document Section 3. +*/ +void EPD_power_on (void) { + /* Initial state */ + EPD_Vcc_turn_on(); //Vcc and Vdd >= 2.7V + EPD_cs_high(); + EPD_border_high(); + EPD_rst_high(); + delay_ms(5); + EPD_rst_low(); + delay_ms(5); + EPD_rst_high(); + delay_ms(5); +} + + +/** +* \brief Initialize COG Driver +* \note For detailed flow and description, please refer to the COG G2 document Section 4. +* +* \param EPD_type_index The defined EPD size +*/ +uint8_t EPD_initialize_driver (uint8_t EPD_type_index) { + + uint16_t i; + // Empty the Line buffer + for (i = 0; i <= LINE_BUFFER_DATA_SIZE; i ++) { + COG_Line.uint8[i] = 0x00; + } + // Determine the EPD size for driving COG + COG_driver_EPDtype_select(EPD_type_index); + + // Sense temperature to determine Temperature Factor + set_temperature_factor(EPD_type_index); + i = 0; + + while (EPD_IsBusy()) { + if((i++) >= 0x0FFF) return ERROR_BUSY; + } + + //Check COG ID + if((SPI_R(0x72,0x00) & 0x0f) !=0x02) return ERROR_COG_ID; + + //Disable OE + epd_spi_send_byte(0x02,0x40); + + //Check Breakage + if((SPI_R(0x0F,0x00) & 0x80) != 0x80) return ERROR_BREAKAGE; + + //Power Saving Mode + epd_spi_send_byte(0x0B, 0x02); + + //Channel Select + epd_spi_send (0x01, (uint8_t *)&COG_parameters[EPD_type_index].channel_select, 8); + + //High Power Mode Osc Setting + epd_spi_send_byte(0x07,0xD1); + + //Power Setting + epd_spi_send_byte(0x08,0x02); + + //Set Vcom level + epd_spi_send_byte(0x09,0xC2); + + //Power Setting + epd_spi_send_byte(0x04,0x03); + + //Driver latch on + epd_spi_send_byte(0x03,0x01); + + //Driver latch off + epd_spi_send_byte(0x03,0x00); + + delay_ms(5); + + //Chargepump Start + i=0; + do { + //Start chargepump positive V + //VGH & VDH on + epd_spi_send_byte(0x05,0x01); + + delay_ms(240); + + //Start chargepump neg voltage + //VGL & VDL on + epd_spi_send_byte(0x05,0x03); + + delay_ms(40); + + //Set chargepump + //Vcom_Driver to ON + //Vcom_Driver on + epd_spi_send_byte(0x05,0x0F); + + delay_ms(40); + + //Check DC/DC + if((SPI_R(0x0F,0x00) & 0x40) != 0x00) break; + + }while((i++) != 4); + + if(i>=4) + { + //Output enable to disable + epd_spi_send_byte(0x02,0x40); + return ERROR_CHARGEPUMP; + } + else return RES_OK; +} + +/** +* \brief Initialize the parameters of Block type stage +* +* \param EPD_type_index The defined EPD size +* \param EPD_V230_G2_Struct The Block type waveform structure +* \param block_size The width of Block size +* \param step_size The width of Step size +* \param frame_cycle The width of Step size +*/ +void stage_init(uint8_t EPD_type_index,struct EPD_V230_G2_Struct *S_epd_v230, + uint8_t block_size,uint8_t step_size, + uint8_t frame_cycle) +{ + S_epd_v230->frame_y0 = 0; + S_epd_v230->frame_y1 = 176; + S_epd_v230->block_y0 = 0; + S_epd_v230->block_y1 = 0; + S_epd_v230->step_y0 = 0; + S_epd_v230->step_y1 = 0; + S_epd_v230->block_size = action__Waveform_param->stage1_block1; + S_epd_v230->step_size =action__Waveform_param->stage1_step1; + S_epd_v230->frame_cycle = action__Waveform_param->stage1_frame1; + S_epd_v230->number_of_steps = (COG_parameters[EPD_type_index].vertical_size / S_epd_v230->step_size) + (action__Waveform_param->stage1_block1 / action__Waveform_param->stage1_step1) -1; + +} + +/** +* \brief For Frame type waveform to update all black/white pattern +* +* \param EPD_type_index The defined EPD size +* \param bwdata Black or White color to whole screen +* \param work_time The working time +*/ +static inline void same_data_frame (uint8_t EPD_type_index, uint8_t bwdata, uint32_t work_time) { + uint16_t i; + for (i = 0; i < COG_parameters[EPD_type_index].horizontal_size; i++) { + data_line_even[i]=bwdata; + data_line_odd[i]=bwdata; + } + start_EPD_timer(); + do + { + for (i = 0; i < COG_parameters[EPD_type_index].vertical_size; i++) { + + /* Scan byte shift per data line */ + data_line_scan[(i>>2)]=SCAN_TABLE[(i%4)]; + + /* Sending data */ + epd_spi_send (0x0A, (uint8_t *)&COG_Line.uint8, COG_parameters[EPD_type_index].data_line_size); + + /* Turn on Output Enable */ + epd_spi_send_byte (0x02, 0x07); + + data_line_scan[(i>>2)]=0; + + } + } while (get_current_time_tick()<(work_time)); + /* Stop system timer */ + stop_EPD_timer(); +} + +/** +* \brief Write nothing Line to COG +* \note A line whose all Scan Bytes are 0x00 +* +* \param EPD_type_index The defined EPD size +*/ +void nothing_line(uint8_t EPD_type_index) { + uint16_t i; + for (i = 0; i < COG_parameters[EPD_type_index].horizontal_size; i++) { + data_line_even[i] = NOTHING; + data_line_odd[i] = NOTHING; + } +} + + +/** +* \brief Get line data of Stage 1 and 3 +* +* \note +* - One dot/pixel is comprised of 2 bits which are White(10), Black(11) or Nothing(01). +* The image data bytes must be divided into Odd and Even bytes. +* - The COG driver uses a buffer to write one line of data (FIFO) - interlaced +* It's different order from COG_G1 +* Odd byte {D(199,y),D(197,y), D(195,y), D(193,y)}, ... ,{D(7,y),D(5,y),D(3,y), D(1,y)} +* Scan byte {S(96), S(95)...} +* Odd byte {D(2,y),D(4,y), D(6,y), D(8,y)}, ... ,{D(194,y),D(196,y),D(198,y), D(200,y)} +* - For more details on the driving stages, please refer to the COG G2 document Section 5. +* +* \param EPD_type_index The defined EPD size +* \param image_ptr The pointer of memory that stores image that will send to COG +* \param stage_no The assigned stage number that will proceed +*/ + +void read_line_data_handle(uint8_t EPD_type_index,uint8_t *image_prt,uint8_t stage_no) +{ + int16_t x,k; + uint8_t temp_byte; // Temporary storage for image data check + k=COG_parameters[EPD_type_index].horizontal_size-1; + for (x =0 ; x < COG_parameters[EPD_type_index].horizontal_size ; x++) { + temp_byte = *image_prt++; + switch(stage_no) { + case Stage1: // Inverse image + /* Example at stage 1 to get Even and Odd data. It's different order from G1. + * +---------+----+----+----+----+----+----+----+----+ + * | |bit7|bit6|bit5|bit4|bit3|bit2|bit1|bit0| + * |temp_byte+----+----+----+----+----+----+----+----+ + * | | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | + * +---------+----+----+----+----+----+----+----+----+ */ + data_line_odd[x] = ((temp_byte & 0x40) ? BLACK3 : WHITE3); // WHITE3 = 0x80 = 1000 0000 + data_line_odd[x] |= ((temp_byte & 0x10) ? BLACK2 : WHITE2); // BLACK2 = 0x30 = 0011 0000 + data_line_odd[x] |= ((temp_byte & 0x04) ? BLACK1 : WHITE1); // BLACK1 = 0x0C = 0000 1100 + data_line_odd[x] |= ((temp_byte & 0x01) ? BLACK0 : WHITE0); // WHITE0 = 0x02 = 0000 0010 + /* data_line_odd[x] = 1000 0000 | 0011 0000 | 0000 1100 | 0000 0010 = 1011 1110 ==> 1011 1110 + * See Even data row at the table below*/ + + data_line_even[k] = ((temp_byte & 0x80) ? BLACK0 : WHITE0); // BLACK0 = 0x03 = 0000 0011 + data_line_even[k] |= ((temp_byte & 0x20) ? BLACK1 : WHITE1); // BLACK1 = 0x0C = 0000 1100 + data_line_even[k] |= ((temp_byte & 0x08) ? BLACK2 : WHITE2); // WHITE2 = 0x20 = 0010 0000 + data_line_even[k--] |= ((temp_byte & 0x02) ? BLACK3 : WHITE3); // WHITE3 = 0x80 = 1000 0000 + /* data_line_even[k] = 0000 0011 | 0000 1100 | 0010 0000 | 1000 0000 = 1010 1111 ==> 1111 1010 + * See Odd data row at the table below + * +---------+----+----+----+----+----+----+----+----+ + * | |bit7|bit6|bit5|bit4|bit3|bit2|bit1|bit0| + * |temp_byte+----+----+----+----+----+----+----+----+ + * | | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | + * +---------+----+----+----+----+----+----+----+----+ + * | Color | W | B | W | W | B | W | B | B | W=White, B=Black, N=Nothing + * +---------+----+----+----+----+----+----+----+----+ + * | Stage 1 | B | W | B | B | W | B | W | W | Inverse + * +---------+----+----+----+----+----+----+----+----+ + * | Input | 11 | 10 | 11 | 11 | 10 | 11 | 10 | 10 | W=10, B=11, N=01 + * +---------+----+----+----+----+----+----+----+----+ + * |Even data| 11 | | 11 | | 10 | | 10 | | = 1111 1010 + * +---------+----+----+----+----+----+----+----+----+ + * |Odd data | | 10 | | 11 | | 11 | | 10 | = 1011 1110 + * +---------+----+----+----+----+----+----+----+----+ */ + break; + case Stage3: // New image + data_line_odd[x] = ((temp_byte & 0x40) ? WHITE3 : BLACK3 ); + data_line_odd[x] |= ((temp_byte & 0x10) ? WHITE2 : BLACK2 ); + data_line_odd[x] |= ((temp_byte & 0x04) ? WHITE1 : BLACK1 ); + data_line_odd[x] |= ((temp_byte & 0x01) ? WHITE0 : BLACK0 ); + + data_line_even[k] = ((temp_byte & 0x80) ? WHITE0 : BLACK0 ); + data_line_even[k] |= ((temp_byte & 0x20) ? WHITE1 : BLACK1 ); + data_line_even[k] |= ((temp_byte & 0x08) ? WHITE2 : BLACK2 ); + data_line_even[k--] |= ((temp_byte & 0x02) ? WHITE3 : BLACK3 ); + break; + } + } +} + + +/** +* \brief The base function to handle the driving stages for Frame and Block type +* +* \note +* - There are 3 stages to complete an image update on COG_V230_G2 type EPD. +* - For more details on the driving stages, please refer to the COG G2 document Section 5.4 +* +* \param EPD_type_index The defined EPD size +* \param image_ptr The pointer of image array that stores image that will send to COG +* \param image_data_address The address of memory that stores image +* \param stage_no The assigned stage number that will proceed +* \param lineoffset Line data offset +*/ +void stage_handle_Base(uint8_t EPD_type_index,uint8_t *image_prt,long image_data_address, + uint8_t stage_no,uint8_t lineoffset) +{ + struct EPD_V230_G2_Struct S_epd_v230; + int16_t cycle,m,i; //m=number of steps + //uint8_t isLastframe = 0; //If it is the last frame to send Nothing at the fist scan line + uint8_t isLastBlock=0; //If the beginning line of block is in active range of EPD + int16_t scanline_no=0; + uint8_t *action_block_prt; + long action_block_address; + uint8_t byte_array[LINE_BUFFER_DATA_SIZE]; + /** Stage 2: BLACK/WHITE image, Frame type */ + if(stage_no==Stage2) + { + for(i=0;i<action__Waveform_param->stage2_cycle;i++) + { + same_data_frame (EPD_type_index,ALL_BLACK,action__Waveform_param->stage2_t1); + same_data_frame (EPD_type_index,ALL_WHITE,action__Waveform_param->stage2_t2); + } + return; + } + /** Stage 1 & 3, Block type */ + // The frame/block/step of Stage1 and Stage3 are default the same. + stage_init(EPD_type_index, + &S_epd_v230, + action__Waveform_param->stage1_block1, + action__Waveform_param->stage1_step1, + action__Waveform_param->stage1_frame1); + + /* Repeat number of frames */ + for (cycle = 0; cycle < (S_epd_v230.frame_cycle ); cycle++) + { + + // if (cycle == (S_epd_v230.frame_cycle - 1)) isLastframe = 1; + + isLastBlock = 0; + S_epd_v230.step_y0 = 0; + S_epd_v230.step_y1 = S_epd_v230.step_size ; + S_epd_v230.block_y0 = 0; + S_epd_v230.block_y1 = 0; + /* Move number of steps */ + for (m = 0; m < S_epd_v230.number_of_steps; m++) + { + S_epd_v230.block_y1 += S_epd_v230.step_size; + S_epd_v230.block_y0 = S_epd_v230.block_y1 - S_epd_v230.block_size; + /* reset block_y0=frame_y0 if block is not in active range of EPD */ + if (S_epd_v230.block_y0 < S_epd_v230.frame_y0) S_epd_v230.block_y0 = S_epd_v230.frame_y0; + + /* if the beginning line of block is in active range of EPD */ + if (S_epd_v230.block_y1 == S_epd_v230.block_size) isLastBlock = 1; + + if(image_prt!=NULL) + { + action_block_prt=(image_prt+(int)(S_epd_v230.block_y0*lineoffset)); + } + else if(_On_EPD_read_flash!=NULL) //Read line data in range of block, read first + { + action_block_address=image_data_address+(long)(S_epd_v230.block_y0*lineoffset); + _On_EPD_read_flash(action_block_address,(uint8_t *)&byte_array, + COG_parameters[EPD_type_index].horizontal_size); + action_block_prt=(uint8_t *)&byte_array; + } + /* Update line data */ + for (i = S_epd_v230.block_y0; i < S_epd_v230.block_y1; i++) + { + + if (i >= COG_parameters[EPD_type_index].vertical_size) break; + //if (isLastframe && + if ( + isLastBlock &&(i < (S_epd_v230.step_size + S_epd_v230.block_y0))) + { + nothing_line(EPD_type_index); + } + else + { + read_line_data_handle(EPD_type_index,action_block_prt,stage_no); + } + + if(_On_EPD_read_flash!=NULL) //Read line data in range of block + { + action_block_address +=lineoffset; + _On_EPD_read_flash(action_block_address,(uint8_t *)&byte_array, + COG_parameters[EPD_type_index].horizontal_size); + action_block_prt=(uint8_t *)&byte_array; + } + else action_block_prt+=lineoffset; + + scanline_no= (COG_parameters[EPD_type_index].vertical_size-1)-i; + + /* Scan byte shift per data line */ + data_line_scan[(scanline_no>>2)] = SCAN_TABLE[(scanline_no%4)]; + + /* the border uses the internal signal control byte. */ + *data_line_border_byte=0x00; + + /* Sending data */ + epd_spi_send (0x0A, (uint8_t *)&COG_Line.uint8, + COG_parameters[EPD_type_index].data_line_size); + + + /* Turn on Output Enable */ + epd_spi_send_byte (0x02, 0x07); + + data_line_scan[(scanline_no>>2)]=0; + + } + } + + } +} + +/** +* \brief The driving stages from image array (image_data.h) to COG +* +* \param EPD_type_index The defined EPD size +* \param image_ptr The pointer of image array that stores image that will send to COG +* \param stage_no The assigned stage number that will proceed +* \param lineoffset Line data offset +*/ +void stage_handle(uint8_t EPD_type_index,uint8_t *image_prt,uint8_t stage_no,uint8_t lineoffset) +{ + stage_handle_Base(EPD_type_index,image_prt,ADDRESS_NULL,stage_no,lineoffset); +} + +/** +* \brief The driving stages from memory to COG +* +* \note +* - This function is additional added here for developer if the image data +* is stored in Flash memory. +* +* \param EPD_type_index The defined EPD size +* \param image_data_address The address of flash memory that stores image +* \param stage_no The assigned stage number that will proceed +* \param lineoffset Line data offset +*/ +static void stage_handle_ex(uint8_t EPD_type_index,long image_data_address,uint8_t stage_no,uint8_t lineoffset) { + stage_handle_Base(EPD_type_index,NULL,image_data_address,stage_no,lineoffset); +} + +/** +* \brief Write image data from memory array (image_data.h) to the EPD +* +* \param EPD_type_index The defined EPD size +* \param previous_image_ptr The pointer of memory that stores previous image +* \param new_image_ptr The pointer of memory that stores new image +*/ +void EPD_display_from_array_prt (uint8_t EPD_type_index, uint8_t *previous_image_ptr, + uint8_t *new_image_ptr) { + _On_EPD_read_flash=0; + stage_handle(EPD_type_index,new_image_ptr,Stage1,COG_parameters[EPD_type_index].horizontal_size); + stage_handle(EPD_type_index,new_image_ptr,Stage2,COG_parameters[EPD_type_index].horizontal_size); + stage_handle(EPD_type_index,new_image_ptr,Stage3,COG_parameters[EPD_type_index].horizontal_size); +} + +/** +* \brief Write image data from Flash memory to the EPD +* \note This function is additional added here for developer if the image data +* is stored in Flash. +* +* \param EPD_type_index The defined EPD size +* \param previous_image_flash_address The start address of memory that stores previous image +* \param new_image_flash_address The start address of memory that stores new image +* \param On_EPD_read_flash Developer needs to create an external function to read flash +*/ +void EPD_display_from_flash_prt (uint8_t EPD_type_index, long previous_image_flash_address, + long new_image_flash_address,EPD_read_flash_handler On_EPD_read_flash) { + + uint8_t line_len; + line_len=LINE_SIZE; + if(line_len==0) line_len=COG_parameters[EPD_type_index].horizontal_size; + + _On_EPD_read_flash=On_EPD_read_flash; + stage_handle_ex(EPD_type_index,new_image_flash_address,Stage1,line_len); + stage_handle_ex(EPD_type_index,new_image_flash_address,Stage2,line_len); + stage_handle_ex(EPD_type_index,new_image_flash_address,Stage3,line_len); +} + + +/** +* \brief Write Dummy Line to COG +* \note A line whose all Scan Bytes are 0x00 +* +* \param EPD_type_index The defined EPD size +*/ +static inline void dummy_line(uint8_t EPD_type_index) { + uint8_t i; + for (i = 0; i < (COG_parameters[EPD_type_index].vertical_size/8); i++) { + switch(EPD_type_index) { + case EPD_144: + COG_Line.line_data_by_size.line_data_for_144.scan[i]=0x00; + break; + case EPD_200: + COG_Line.line_data_by_size.line_data_for_200.scan[i]=0x00; + break; + case EPD_270: + COG_Line.line_data_by_size.line_data_for_270.scan[i]=0x00; + break; + } + } + /* Set charge pump voltage level reduce voltage shift */ + epd_spi_send_byte (0x04, COG_parameters[EPD_type_index].voltage_level); + + /* Sending data */ + epd_spi_send (0x0A, (uint8_t *)&COG_Line.uint8, COG_parameters[EPD_type_index].data_line_size); + + /* Turn on Output Enable */ + epd_spi_send_byte (0x02, 0x07); +} + + +/** +* \brief Write Border(Input) Dummy Line +* \note Set Border byte 0xFF to write Black and set 0xAA to write White +* +* \param EPD_type_index The defined EPD size +*/ +static void border_dummy_line(uint8_t EPD_type_index) +{ + uint16_t i; + for (i = 0; i < COG_parameters[EPD_type_index].data_line_size; i++) + { + COG_Line.uint8[i] = 0x00; + } + + *data_line_border_byte=BORDER_BYTE_B; + //Write a Border(B) Dummy Line + epd_spi_send (0x0a, (uint8_t *)&COG_Line.uint8, COG_parameters[EPD_type_index].data_line_size); + //Turn on OE + epd_spi_send_byte (0x02, 0x07); + + sys_delay_ms(40); + + *data_line_border_byte=BORDER_BYTE_W; + //Write a Borde(B) Dummy Line + epd_spi_send (0x0a, (uint8_t *)&COG_Line.uint8, COG_parameters[EPD_type_index].data_line_size); + //Turn on OE + epd_spi_send_byte (0x02, 0x07); + + sys_delay_ms(200); + + +} + + +/** +* \brief Power Off COG Driver +* \note For detailed flow and description, please refer to the COG G2 document Section 6. +* +* \param EPD_type_index The defined EPD size +*/ +uint8_t EPD_power_off(uint8_t EPD_type_index) { + uint8_t y; + + if(EPD_type_index==EPD_144 || EPD_type_index==EPD_200) { + border_dummy_line(EPD_type_index); + dummy_line(EPD_type_index); + } + + delay_ms (25); + if(EPD_type_index==EPD_270) { + EPD_border_low(); + delay_ms (200); + EPD_border_high(); + } + + //Check DC/DC + if((SPI_R(0x0F,0x00) & 0x40) == 0x00) return ERROR_DC; + + //Turn on Latch Reset + epd_spi_send_byte (0x03, 0x01); + //Turn off OE + epd_spi_send_byte (0x02, 0x05); + //Power off charge pump Vcom + epd_spi_send_byte (0x05, 0x0E); + //Power off charge pump neg voltage + epd_spi_send_byte (0x05, 0x02); + //Turn off all charge pump + epd_spi_send_byte (0x05, 0x00); + //Turn off OSC + epd_spi_send_byte (0x07, 0x0D); + + epd_spi_send_byte (0x04, 0x83); + delay_ms(120); + epd_spi_send_byte (0x04, 0x00); + + epd_spi_detach (); + EPD_cs_low(); + EPD_rst_low(); + EPD_Vcc_turn_off (); + EPD_border_low(); + delay_ms (10); + + for(y=0;y<10;y++) + { + EPD_discharge_high (); + delay_ms (10); + EPD_discharge_low (); + delay_ms (10); + } + return RES_OK; +} + +#endif + + +
diff -r 000000000000 -r 9297e33f50cf EPD_controller.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_controller.cpp Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,134 @@ +/** +* \file +* +* \brief The interface for external application wants to update EPD +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "EPD_controller.h" + +/** + * \brief Initialize the EPD hardware setting + */ +void EPD_display_init(void) { + EPD_init(); +} + + + + +/** + * \brief Show image from the pointer of memory array + * + * \param EPD_type_index The defined EPD size + * \param previous_image_ptr The pointer of memory that stores previous image + * \param new_image_ptr The pointer of memory that stores new image + */ +void EPD_display_from_pointer(uint8_t EPD_type_index,uint8_t *previous_image_ptr, + uint8_t *new_image_ptr) { + /* Initialize EPD hardware */ + EPD_init(); + + /* Power on COG Driver */ + EPD_power_on(); + + /* Initialize COG Driver */ + EPD_initialize_driver(EPD_type_index); + + /* Display image data on EPD from image array */ + EPD_display_from_array_prt(EPD_type_index,previous_image_ptr,new_image_ptr); + + /* Power off COG Driver */ + EPD_power_off (EPD_type_index); +} + +/** + * \brief Show image from Flash memory + * + * \param EPD_type_index The defined EPD size + * \param previous_image_address The address of memory that stores previous image + * \param new_image_address The address of memory that stores new image + * \param On_EPD_read_flash Developer needs to create an external function to read flash + */ +void EPD_display_from_flash(uint8_t EPD_type_index,long previous_image_address, +long new_image_address,EPD_read_flash_handler On_EPD_read_flash) { + /* Initialize EPD hardware */ + EPD_init(); + + /* Power on COG Driver */ + EPD_power_on(); + + /* Initialize COG Driver */ + EPD_initialize_driver(EPD_type_index); + + /* Display image data on EPD from Flash memory */ + EPD_display_from_flash_prt(EPD_type_index,previous_image_address, + new_image_address,On_EPD_read_flash); + + /* Power off COG Driver */ + EPD_power_off (EPD_type_index); +} +/** + * \brief Initialize the EPD hardware setting and COG driver + * + * \param EPD_type_index The defined EPD size + */ +void EPD_power_init(uint8_t EPD_type_index) { + EPD_init(); + EPD_power_on (); + EPD_initialize_driver (EPD_type_index); +} + +/** + * \brief Show image from Flash memory when SPI is common used with COG and Flash + * + * \note + * - This function must work with EPD_power_init when SPI is common used with + * COG and Flash, or the charge pump doesn't work correctly. + * - EPD_power_init -> write data to flash (switch SPI) -> EPD_display_from_flash_Ex + * + * \param EPD_type_index The defined EPD size + * \param previous_image_address The address of memory that stores previous image + * \param new_image_address The address of memory that stores new image + * \param On_EPD_read_flash Developer needs to create an external function to read flash + */ +void EPD_display_from_flash_Ex(uint8_t EPD_type_index,long previous_image_address, + long new_image_address,EPD_read_flash_handler On_EPD_read_flash) { + + /* Display image data on EPD from Flash memory */ + EPD_display_from_flash_prt(EPD_type_index,previous_image_address, + new_image_address,On_EPD_read_flash); + + /* Power off COG Driver */ + EPD_power_off (EPD_type_index); +} + + + +
diff -r 000000000000 -r 9297e33f50cf EPD_controller.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_controller.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,47 @@ +/** +* \file +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef DISPLAY_CONTROLLER_H_INCLUDED +#define DISPLAY_CONTROLLER_H_INCLUDED +#include "Pervasive_Displays_small_EPD.h" + +void EPD_display_init(void); +void EPD_power_init(uint8_t EPD_type_index); +void EPD_display_from_pointer(uint8_t EPD_type_index,uint8_t *previous_image_ptr, + uint8_t *new_image_ptr); +void EPD_display_from_flash(uint8_t EPD_type_index,long previous_image_address, + long new_image_address,EPD_read_flash_handler On_EPD_read_flash); +void EPD_display_from_flash_Ex(uint8_t EPD_type_index,long previous_image_address, + long new_image_address,EPD_read_flash_handler On_EPD_read_flash); + +#endif //DISPLAY_CONTROLLER_H_INCLUDED + +
diff -r 000000000000 -r 9297e33f50cf EPD_hardware_driver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_hardware_driver.cpp Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,485 @@ +/** + * \file + * + * \brief The initialization and configuration of COG hardware driver + * + * Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. + * + * Authors: Pervasive Displays Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +//#include <math.h> +#include "EPD_hardware_driver.h" + +static uint16_t EPD_Counter; +static uint8_t spi_flag = FALSE; + +#include "mbed.h" +#include "LM75B.h" +static Ticker systemTicker; +static SPI* expSPI = NULL; +static LM75B* expLM75B = NULL; +void SysTick_Handler(void); + +extern PinName SEC03; +extern PinName SEC04; +extern PinName SEC05; +extern PinName SEC09; +extern PinName SEC10; + + +/** + * \brief Set up EPD Timer for 1 mSec interrupts + * + * \note + * desired value: 1mSec + * actual value: 1.000mSec + */ +static void initialize_EPD_timer(void) { + //------------------Timer A1---------------------------------------- + //set up Timer_A CCR1 as master timer using ACLK +// TA0CCTL2 &= ~(CCIFG | CCIE); // reset CCIFG Interrupt Flag +// TA0CTL = TASSEL_2 + MC_0 + TACLR + ID_3; +// TA0CCTL2 = OUTMOD_4; + EPD_Counter = 0; +} + +/** + * \brief Start Timer + */ +void start_EPD_timer(void) { + initialize_EPD_timer(); +// TA0R = 0; +// TA0CCR0 = 990 * 2; // 1ms +// TA0CCTL2 |= CCIE; +// TA0CTL |= MC_1; + EPD_Counter = 0; + systemTicker.attach_us(&SysTick_Handler, 1000); +} + +/** + * \brief Stop Timer + */ +void stop_EPD_timer(void) { +// TA0CCTL2 &= ~CCIE; +// TA0CTL &= ~MC_1; + systemTicker.detach(); +} + +/** + * \brief Get current Timer after starting a new one + */ +uint32_t get_current_time_tick(void) { + return EPD_Counter; +} +/** + * \brief Set current Timer after starting a new one + */ +void set_current_time_tick(uint32_t count) { + EPD_Counter=count; +} +/** + * \brief Interrupt Service Routine for system tick counter + */ +void SysTick_Handler(void) { + EPD_Counter++; +} + +///** +// * \brief Interrupt Service Routine for Timer A0 +// */ +//#pragma vector=TIMER0_A1_VECTOR +//__interrupt void Timer_A0(void) { +// switch (__even_in_range(TA0IV, 10)) { +// case 2: +// //LPM3_EXIT; +// break; + +// case 4: +// EPD_Counter++; +// LPM3_EXIT; +// break; +// } + +//} + +/** + * \brief Delay mini-seconds + * \param ms The number of mini-seconds + */ +void delay_ms(unsigned int ms) { +// while (ms--) { +// __delay_cycles(SMCLK_FREQ / 1000); +// } + wait_ms(ms); +} + +/** + * \brief Delay mini-seconds + * \param ms The number of mini-seconds + */ +void sys_delay_ms(unsigned int ms) { +// delay_ms(ms); + wait_ms(ms); +} + +static void Wait_10us(void) { +// __delay_cycles(SMCLK_FREQ / 100000); + wait_us(10); +} + +//****************************************************************** +//* PWM Configuration/Control //PWM output : PD3 +//****************************************************************** + +/** + * \brief The PWM signal starts toggling + */ +void PWM_start_toggle(void) { + +} + +/** + * \brief The PWM signal stops toggling. + */ +void PWM_stop_toggle(void) { + +} + +/** + * \brief PWM toggling. + * + * \param ms The interval of PWM toggling (mini seconds) + */ +void PWM_run(uint16_t ms) { +// start_EPD_timer(); +// do { +// EPD_pwm_high(); +// __delay_cycles(30); +// EPD_pwm_low(); +// __delay_cycles(30); +// } while (get_current_time_tick() < ms); //wait Delay Time +// stop_EPD_timer(); + mbed_die(); +} + +//****************************************************************** +//* SPI Configuration +//****************************************************************** + +/** + * \brief Configure SPI + */ +void epd_spi_init(void) { + if (spi_flag) + return; + spi_flag = TRUE; +// //config i/o +// config_gpio_dir_o(SPICLK_PORT, SPICLK_PIN); +// config_gpio_dir_o(SPIMOSI_PORT, SPIMOSI_PIN); +// config_gpio_dir_i(SPIMISO_PORT, SPIMISO_PIN); + +// BITSET(SPISEL, SPICLK_PIN + SPIMOSI_PIN + SPIMISO_PIN); +// BITSET(SPISEL2, SPICLK_PIN + SPIMOSI_PIN + SPIMISO_PIN); +// //comfig SPI +// SPICTL0 = UCCKPH | UCMST | UCSYNC | UCMSB; +// SPICTL1 = UCSSEL_2 + UCSWRST; +// SPIBR0 = 2; //16MHz/2=8MHz +// SPIBR1 = 0; + +// BITSET(REN (SPIMISO_PORT), SPIMISO_PIN); +// BITCLR(SPICTL1, UCSWRST); + + expSPI = new SPI(SEC04, SEC05, SEC03); // mosi, miso, sclk + expSPI->frequency(COG_SPI_baudrate); +} + +/** + * \brief Initialize SPI + */ +void epd_spi_attach(void) { + EPD_flash_cs_high(); + EPD_cs_high(); + epd_spi_init(); +} + +/** + * \brief Disable SPI and change to GPIO + */ +void epd_spi_detach(void) { +// BITCLR(SPISEL, SPICLK_PIN + SPIMOSI_PIN + SPIMISO_PIN); +// BITCLR(SPISEL2, SPICLK_PIN + SPIMOSI_PIN + SPIMISO_PIN); +// //config_gpio_dir_o(SPICLK_PORT,SPICLK_PIN); +// //config_gpio_dir_o(SPIMOSI_PORT,SPIMOSI_PIN); +// //config_gpio_dir_o(SPIMISO_PORT,SPIMISO_PIN); +// SPIMISO_low(); +// SPIMOSI_low(); +// SPICLK_low(); + if (expSPI != NULL) { + delete expSPI; + expSPI = NULL; + } + spi_flag = FALSE; +} + +/** + * \brief SPI synchronous write + */ +void epd_spi_write(unsigned char Data) { +// SPITXBUF = Data; +// while (!(SPIIFG & SPITXIFG)) +// ; + expSPI->write(Data); +} + +/** + * \brief SPI synchronous read + */ +uint8_t epd_spi_read(unsigned char RDATA) { +// SPITXBUF = RDATA; +// while ((SPISTAT & UCBUSY)) +// ; +// RDATA = SPIRXBUF; +// return RDATA; + return expSPI->write(RDATA) & 0xff; +} + +/** + * \brief Send data to SPI with time out feature + * + * \param data The data to be sent out + */ +uint8_t epd_spi_write_ex(unsigned char Data) { +// uint8_t cnt = 200; +// uint8_t flag = 1; +// SPITXBUF = Data; +// while (!(SPIIFG & SPITXIFG)) { +// if ((cnt--) == 0) { +// flag = 0; +// break; +// } +// } +// return flag; + + // Not used + mbed_die(); + return 0; +} + +#if (defined COG_V230_G2) +/** +* \brief SPI command +* +* \param register_index The Register Index as SPI Data to COG +* \param register_data The Register Data for sending command data to COG +* \return the SPI read value +*/ +uint8_t SPI_R(uint8_t Register, uint8_t Data) { + uint8_t result; + EPD_cs_low (); + epd_spi_write (0x70); // header of Register Index + epd_spi_write (Register); + + EPD_cs_high (); + Wait_10us (); + EPD_cs_low (); + + epd_spi_write (0x73); // header of Register Data of read command + result=epd_spi_read (Data); + + EPD_cs_high (); + + return result; +} +#endif + +/** +* \brief SPI command if register data is larger than two bytes +* +* \param register_index The Register Index as SPI command to COG +* \param register_data The Register Data for sending command data to COG +* \param length The number of bytes of Register Data which depends on which +* Register Index is selected. +*/ +void epd_spi_send (unsigned char register_index, unsigned char *register_data, + unsigned length) { + EPD_cs_low (); + epd_spi_write (0x70); // header of Register Index + epd_spi_write (register_index); + + EPD_cs_high (); + Wait_10us (); + EPD_cs_low (); + + epd_spi_write (0x72); // header of Register Data of write command + while(length--) { + epd_spi_write (*register_data++); + } + EPD_cs_high (); +} + +/** +* \brief SPI command +* +* \param register_index The Register Index as SPI command to COG +* \param register_data The Register Data for sending command data to COG +*/ +void epd_spi_send_byte (uint8_t register_index, uint8_t register_data) { + EPD_cs_low (); + epd_spi_write (0x70); // header of Register Index + epd_spi_write (register_index); + + EPD_cs_high (); + Wait_10us (); + EPD_cs_low (); + epd_spi_write (0x72); // header of Register Data + epd_spi_write (register_data); + EPD_cs_high (); +} + +//****************************************************************** +//* Temperature sensor Configuration +//****************************************************************** +#ifdef __Internal_Temperature_Sensor +// ADC10 interrupt service routine +#pragma vector=ADC10_VECTOR +__interrupt void ADC10_ISR(void) { + __bic_SR_register_on_exit(CPUOFF); + // Clear CPUOFF bit from 0(SR) +} +/** + * \brief Get temperature value from ADC + * + * \return the Celsius temperature + */ +int16_t get_temperature(void) { + const uint8_t DegCOffset=0; + long temp; + float IntDegC; + + ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/4 + ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON+ADC10IE; + ADC10CTL0 |= ENC + ADC10SC;// Sampling and conversion start + __bis_SR_register(CPUOFF + GIE);// LPM0, ADC10_ISR will force exit + // oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278 + temp = ADC10MEM; + + ADC10CTL0 |= ENC + ADC10SC;// Sampling and conversion start + __bis_SR_register(CPUOFF + GIE);// LPM0, ADC10_ISR will force exit + temp = ADC10MEM; + ADC10CTL0 |= ENC + ADC10SC;// Sampling and conversion start + __bis_SR_register(CPUOFF + GIE);// LPM0, ADC10_ISR will force exit + temp += ADC10MEM; + temp=temp/2; + + IntDegC =(long)((long)(temp*423)/1024)-(278+DegCOffset);//(long)((long)(temp - 673) * 423) / 1024; + + __no_operation();// SET BREAKPOINT HERE + + return (int8_t) IntDegC; +} +#elif defined __External_Temperature_Sensor + +/** + * \brief Get temperature value from ADC + * + * \return the Celsius temperature + */ +int16_t get_temperature(void) { +// float IntDegC; +// const uint8_t DegCOffset = 2; +// long temp; +// ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start +// __bis_SR_register(CPUOFF + GIE); +// // LPM0, ADC10_ISR will force exit +// temp = ADC10MEM; + +// ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start +// __bis_SR_register(CPUOFF + GIE); +// // LPM0, ADC10_ISR will force exit +// temp = ADC10MEM; +// ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start +// __bis_SR_register(CPUOFF + GIE); +// // LPM0, ADC10_ISR will force exit +// temp = ADC10MEM; +// ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start +// __bis_SR_register(CPUOFF + GIE); +// // LPM0, ADC10_ISR will force exit +// temp = ADC10MEM; + +// //org +// /* +// temp = (ADC10MEM*5)/2; +// voltage = (float)((float)temp*2.5)/1024.0; //(2.5/1024)*ADC=Mcu voltage,Temperature voltage=Mcu voltage*2 +// IntDegC=100.0- (((voltage*1000)/10.77)-111.3); //100-((Temperature voltage-1.199)*1000)/10.77=IntDegC +// __no_operation(); // SET BREAKPOINT HERE +// */ +// //adj +// // IntDegC=(203-DegCOffset)-((long)((7*temp)/128)+(temp/2)); +// IntDegC = (201 - DegCOffset) - ((long) ((5 * temp) / 128) + (temp / 2)); +// return (int16_t) IntDegC; + + float f = *expLM75B; + return (int)f; +} + +#endif + +/** + * \brief Initialize the temperature sensor + */ +void initialize_temperature(void) { +#ifdef __External_Temperature_Sensor + + //Create an LM75B object at 0x92/0x93 (ADDRESS_1) + expLM75B = new LM75B(SEC10, SEC09, LM75B::ADDRESS_1); // Requires JP8 and JP9 in 1-2 position to avoid interference from LM75 on ARM University BB + + //Try to open the LM75B + if (!expLM75B->open()) { +// mbed_die(); + } +// ADC10CTL0 = SREF_1 + ADC10SHT_3 + ADC10ON + ADC10IE + REFON + REF2_5V; // ADC10ON, interrupt enabled +// ADC10CTL1 = INCH_4 + ADC10DIV_3; // input A1.4 + +#endif +} + +/** + * \brief Initialize the EPD hardware setting + */ +void EPD_display_hardware_init(void) { + EPD_initialize_gpio(); + EPD_Vcc_turn_off(); + epd_spi_init(); + initialize_temperature(); + EPD_cs_low(); + EPD_pwm_low(); + EPD_rst_low(); + EPD_discharge_low(); + EPD_border_low(); + //initialize_EPD_timer(); +} +
diff -r 000000000000 -r 9297e33f50cf EPD_hardware_driver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_hardware_driver.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,84 @@ +/** +* \file +* +* \brief The SPI, PWM, Temperature definitions of COG hardware driver +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef DISPLAY_HARDWARE_DRIVCE_H_INCLUDED_ +#define DISPLAY_HARDWARE_DRIVCE_H_INCLUDED_ + +#include "Pervasive_Displays_small_EPD.h" + +#define SMCLK_FREQ (16000000) +#define __External_Temperature_Sensor + +/**SPI Defines ****************************************************************/ +#define SPISEL P1SEL +#define SPISEL2 P1SEL2 +#define SPIIE IE2 +#define SPICTL0 UCB0CTL0 +#define SPICTL1 UCB0CTL1 +#define SPIBR0 UCB0BR0 +#define SPIBR1 UCB0BR1 +#define SPIMCTL UCA0MCTL +#define SPIIFG IFG2 +#define SPIRXBUF UCB0RXBUF +#define SPIRXIFG UCB0RXIFG +#define SPITXBUF UCB0TXBUF +#define SPITXIFG UCB0TXIFG +#define SPISTAT UCB0STAT +#define SPI_baudrate (SMCLK_FREQ/COG_SPI_baudrate) /**< the baud rate of SPI */ + +void epd_spi_init (void); +void epd_spi_attach (void); +void epd_spi_detach (void); +void epd_spi_send (unsigned char Register, unsigned char *Data, unsigned Length); +void epd_spi_send_byte (uint8_t Register, uint8_t Data); +uint8_t epd_spi_read(unsigned char RDATA); +void epd_spi_write (unsigned char Data); +uint8_t epd_spi_write_ex (unsigned char Data); +void sys_delay_ms(unsigned int ms); +void start_EPD_timer(void); +void stop_EPD_timer(void); +uint32_t get_current_time_tick(void); +void set_current_time_tick(uint32_t count); +void PWM_start_toggle(void); +void PWM_stop_toggle(void); +void PWM_run(uint16_t time); +void initialize_temperature(void); +int16_t get_temperature(void); +void EPD_display_hardware_init (void); + +#if (defined COG_V230_G2) +uint8_t SPI_R(uint8_t Register, uint8_t Data); +#endif +#endif //DISPLAY_HARDWARE_DRIVCE_H_INCLUDED_ + +
diff -r 000000000000 -r 9297e33f50cf EPD_hardware_gpio.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_hardware_gpio.cpp Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,238 @@ +/** +* \file +* +* \brief The functions of EPD GPIO +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "EPD_hardware_gpio.h" + +#include "mbed.h" + +extern PinName SEC06; +extern PinName SEC07; +extern PinName SEC08; +extern PinName SEC11; +extern PinName SEC12; +extern PinName SEC13; +extern PinName SEC14; + +static DigitalOut* pinEpdCS = NULL; +static DigitalIn* pinEpdBusy = NULL; +static DigitalOut* pinEpdBorder = NULL; +static DigitalOut* pinFlashCS = NULL; +static DigitalOut* pinEpdReset = NULL; +static DigitalOut* pinEpdPanelOn = NULL; +static DigitalOut* pinEpdDischarge = NULL; + +/** +* \brief Set EPD_CS pin to high +*/ +void EPD_cs_high (void) { + //set_gpio_high(EPD_CS_PORT,EPD_CS_PIN); + *pinEpdCS = 1; +} + +/** +* \brief Set EPD_CS pin to low +*/ +void EPD_cs_low (void) { +// set_gpio_low(EPD_CS_PORT,EPD_CS_PIN); + *pinEpdCS = 0; +} + +/** +* \brief Set Flash_CS pin to high +*/ +void EPD_flash_cs_high(void) { +// set_gpio_high(Flash_CS_PORT,Flash_CS_PIN); + *pinFlashCS = 1; +} + +/** +* \brief Set Flash_CS pin to low +*/ +void EPD_flash_cs_low (void) { +// set_gpio_low(Flash_CS_PORT,Flash_CS_PIN); + *pinFlashCS = 0; +} + +/** +* \brief Set /RESET pin to high +*/ +void EPD_rst_high (void) { +// set_gpio_high(EPD_RST_PORT,EPD_RST_PIN); + *pinEpdReset = 1; +} + +/** +* \brief Set /RESET pin to low +*/ +void EPD_rst_low (void) { +// set_gpio_low(EPD_RST_PORT,EPD_RST_PIN); + *pinEpdReset = 0; +} + +/** +* \brief Set DISCHARGE pin to high +*/ +void EPD_discharge_high (void) { +// set_gpio_high(EPD_DISCHARGE_PORT,EPD_DISCHARGE_PIN); + *pinEpdDischarge = 1; +} + +/** +* \brief Set DISCHARGE pin to low +*/ +void EPD_discharge_low (void) { +// set_gpio_low(EPD_DISCHARGE_PORT,EPD_DISCHARGE_PIN); + *pinEpdDischarge = 0; +} + +/** +* \brief Set Vcc (PANEL_ON) to high +*/ +void EPD_Vcc_turn_on (void) { +// set_gpio_high(EPD_PANELON_PORT,EPD_PANELON_PIN); + *pinEpdPanelOn = 1; +} + +/** +* \brief Set Vcc (PANEL_ON) to low +*/ +void EPD_Vcc_turn_off (void) { +// set_gpio_low(EPD_PANELON_PORT,EPD_PANELON_PIN); + *pinEpdPanelOn = 0; +} + +/** +* \brief Set BORDER_CONTROL pin to high +*/ +void EPD_border_high(void) { +// set_gpio_high(EPD_PANELON_PORT,EPD_BORDER_PIN); + *pinEpdBorder = 1; +} + +/** +* \brief Set BORDER_CONTROL pin to low +*/ +void EPD_border_low (void) { +// set_gpio_low(EPD_PANELON_PORT,EPD_BORDER_PIN); + *pinEpdBorder = 0; +} + +/** +* \brief Set PWM pin to high +*/ +void EPD_pwm_high(void) { +// set_gpio_high(PWM_PORT,PWM_PIN); + + // Not in use +} + +/** +* \brief Set PWM pin to low +*/ +void EPD_pwm_low (void) { +// config_gpio_dir_o(SPIMISO_PORT,SPIMISO_PIN); +// set_gpio_low(PWM_PORT,PWM_PIN); + + // Not in use +} + +/** +* \brief Set MISO pin of SPI to low +*/ +void SPIMISO_low(void) { +// config_gpio_dir_o(SPIMISO_PORT,SPIMISO_PIN); +// set_gpio_low(SPIMISO_PORT,SPIMISO_PIN); + + // Not in use +} + +/** +* \brief Set MOSI pin of SPI to low +*/ +void SPIMOSI_low(void) { +// set_gpio_low(SPIMOSI_PORT,SPIMOSI_PIN); + + // Not in use +} + +/** +* \brief Set Clock of SPI to low +*/ +void SPICLK_low(void) { +// set_gpio_low(SPICLK_PORT,SPICLK_PIN); + + // Not in use +} + +/** +* \brief Get BUSY pin status +*/ +bool EPD_IsBusy(void) { +// return (bool)input_get(EPD_BUSY_PORT,EPD_BUSY_PIN); + return pinEpdBusy->read(); +} + +/** +* \brief Configure GPIO +*/ +void EPD_initialize_gpio(void) { + + pinEpdCS = new DigitalOut(SEC06); // SEC-06 Requires J14 9-10 to NOT be connected + pinEpdBusy = new DigitalIn(SEC07); // SEC-07 + pinEpdBorder = new DigitalOut(SEC08); // SEC-08 + pinFlashCS = new DigitalOut(SEC11); // SEC-11 + pinEpdReset = new DigitalOut(SEC12); // SEC-12 + pinEpdPanelOn = new DigitalOut(SEC13); // SEC-13 + pinEpdDischarge = new DigitalOut(SEC14); // SEC-14 + +// config_gpio_dir_i( EPD_BUSY_PORT,EPD_BUSY_PIN); +// //Set Xin to GPIO +// BITCLR (CS_PORT_SEL, EPD_CS_PIN); +// BITCLR (CS_PORT_SEL2,EPD_CS_PIN); +// //Set Xout to GPIO +// BITCLR (Flash_CS_PORT_SEL, Flash_CS_PIN); +// BITCLR (Flash_CS_PORT_SEL2,Flash_CS_PIN); +// +// config_gpio_dir_o( EPD_CS_PORT,EPD_CS_PIN); +// config_gpio_dir_o( EPD_RST_PORT,EPD_RST_PIN); +// config_gpio_dir_o( EPD_PANELON_PORT,EPD_PANELON_PIN); +// config_gpio_dir_o( EPD_DISCHARGE_PORT,EPD_DISCHARGE_PIN); +// config_gpio_dir_o( EPD_BORDER_PORT,EPD_BORDER_PIN); +// config_gpio_dir_o( Flash_CS_PORT,Flash_CS_PIN); +// config_gpio_dir_o( PWM_PORT,PWM_PIN); +// config_gpio_dir_i( Temper_PORT,Temper_PIN); + EPD_flash_cs_high(); + EPD_border_low(); +} +
diff -r 000000000000 -r 9297e33f50cf EPD_hardware_gpio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EPD_hardware_gpio.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,123 @@ +/** +* \file +* +* \brief The definition of EPD GPIO pins +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "Pervasive_Displays_small_EPD.h" + +#ifndef DISPLAY_HARDWARE_GPIO_H_INCLUDED +#define DISPLAY_HARDWARE_GPIO_H_INCLUDED + +#define _BV(bit) (1 << (bit)) /**< left shift 1 bit */ +#define _HIGH 1 /**< signal high */ +#define _LOW !_HIGH /**< signal low */ + +////FOR MSP430 +//#define DIR_(x) x ## DIR +//#define DIR(x) (DIR_(x)) +//#define OUT_(x) x ## OUT +//#define OUTPORT(x) (OUT_(x)) +//#define SEL_(x) x ## SEL +//#define SEL(x) (SEL_(x)) +//#define SEL2_(x) x ## SEL2 +//#define SEL2(x) (SEL2_(x)) +//#define IN_(x) x ## IN +//#define INPORT(x) (IN_(x)) +//#define REN_(x) x ## REN +//#define REN(x) (REN_(x)) +//#define BITSET(x,y) ((x) |= (y)) +//#define BITCLR(x,y) ((x) &= ~(y)) +//#define BITINV(x,y) ((x) ^= (y)) + +//#define config_gpio_dir_o(Port,Pin) BITSET(DIR (Port), Pin) /**< set output direction for an IOPORT pin */ +//#define config_gpio_dir_i(Port,Pin) BITCLR(DIR (Port), Pin) /**< set input direction for an IOPORT pin */ +//#define set_gpio_high(Port,Pin) BITSET (OUTPORT (Port), Pin) /**< set HIGH for an IOPORT pin */ +//#define set_gpio_low(Port,Pin) BITCLR (OUTPORT (Port), Pin) /**< set LOW for an IOPORT pin */ +//#define set_gpio_invert(Port,Pin) BITINV(OUTPORT (Port),Pin) /**< toggle the value of an IOPORT pin */ +//#define input_get(Port,Pin) (INPORT (Port) & Pin ) /**< get current value of an IOPORT pin */ + +/****************************************************************************** +* GPIO Defines +*****************************************************************************/ +//#define Temper_PIN BIT4 +//#define Temper_PORT P1 /**< LaunchPad P1.4 */ +//#define SPICLK_PIN BIT5 +//#define SPICLK_PORT P1 /**< LaunchPad P1.5 */ +//#define EPD_BUSY_PIN BIT0 +//#define EPD_BUSY_PORT P2 /**< LaunchPad P2.0 */ +//#define PWM_PIN BIT1 +//#define PWM_PORT P2 /**< LaunchPad P2.1 */ +//#define EPD_RST_PIN BIT2 +//#define EPD_RST_PORT P2 /**< LaunchPad P2.2 */ +//#define EPD_PANELON_PIN BIT3 +//#define EPD_PANELON_PORT P2 /**< LaunchPad P2.3 */ +//#define EPD_DISCHARGE_PIN BIT4 +//#define EPD_DISCHARGE_PORT P2 /**< LaunchPad P2.4 */ +//#define EPD_BORDER_PIN BIT5 +//#define EPD_BORDER_PORT P2 /**< LaunchPad P2.5 */ +//#define SPIMISO_PIN BIT6 +//#define SPIMISO_PORT P1 /**< LaunchPad P1.6 */ +//#define SPIMOSI_PIN BIT7 +//#define SPIMOSI_PORT P1 /**< LaunchPad P1.7 */ +//#define Flash_CS_PIN BIT7 +//#define Flash_CS_PORT P2 /**< LaunchPad P2.7 */ +//#define Flash_CS_PORT_SEL (SEL (Flash_CS_PORT)) +//#define Flash_CS_PORT_SEL2 (SEL2(Flash_CS_PORT)) +//#define EPD_CS_PIN BIT6 +//#define EPD_CS_PORT P2 /**< LaunchPad P2.6 */ +//#define CS_PORT_SEL (SEL (EPD_CS_PORT)) +//#define CS_PORT_SEL2 (SEL2(EPD_CS_PORT)) + +bool EPD_IsBusy(void); +void EPD_cs_high (void); +void EPD_cs_low (void); +void EPD_flash_cs_high(void); +void EPD_flash_cs_low (void); +void EPD_rst_high (void); +void EPD_rst_low (void); +void EPD_discharge_high (void); +void EPD_discharge_low (void); +void EPD_Vcc_turn_off (void); +void EPD_Vcc_turn_on (void); +void EPD_border_high(void); +void EPD_border_low (void); +void EPD_pwm_low (void); +void EPD_pwm_high(void); +void SPIMISO_low(void); +void SPIMOSI_low(void); +void SPICLK_low(void); +void EPD_initialize_gpio(void); + +#endif //DISPLAY_HARDWARE_GPIO_H_INCLUDED + + + +
diff -r 000000000000 -r 9297e33f50cf LM75B.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.lib Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/neilt6/code/LM75B/#7ac462ba84ac
diff -r 000000000000 -r 9297e33f50cf Pervasive_Displays_small_EPD.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pervasive_Displays_small_EPD.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,91 @@ +/** +* \file +* +* \brief The definition of Pervasive Displays Inc.'s EPDs +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef EPAPER_H_INCLUDED +#define EPAPER_H_INCLUDED + +#include "platform.h" +//#include <stdint.h> +//#include <string.h> +//#include <stdlib.h> +//#include <msp430g2553.h> + +/** + * \brief Developer needs to create an external function if wants to read flash */ +typedef void (*EPD_read_flash_handler)(long flash_address,uint8_t *target_buffer, + uint8_t byte_length); + +#if !defined(FALSE) +#define FALSE 0 /**< define FALSE=0 */ +#endif + +#if !defined(TRUE) +#define TRUE (1) /**< define TRUE=1 */ +#endif + +#if !defined(NULL) +#define NULL (void *)0 /**< define NULL */ +#endif + +#if !defined(_NOP) +#define _NOP() asm("nop") +#endif + +#if !defined(bool) +#define bool uint8_t +#endif + + +extern void delay_ms(unsigned int ms); + +#define LINE_SIZE 64 /**< maximum data line size */ + +/** + * \brief Support 1.44", 2" and 2.7" three type EPD */ +enum EPD_SIZE { + EPD_144, + EPD_200, + EPD_270 +}; +#include "conf_EPD.h" +#include "EPD_hardware_gpio.h" +#include "EPD_hardware_driver.h" +#include "EPD_COG_process.h" +#include "EPD_controller.h" + +#endif //EPAPER_H_INCLUDED + + + + +
diff -r 000000000000 -r 9297e33f50cf conf_EPD.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf_EPD.h Tue Jul 22 11:59:06 2014 +0000 @@ -0,0 +1,84 @@ +/** +* \file +* +* \brief The EPD configurations +* +* Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. +* +* Authors: Pervasive Displays Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef CONF_EPD_H_INCLUDED +#define CONF_EPD_H_INCLUDED + +/** Define EPD_KIT_TOOL_FUNCTIONS if the code will work with EPD Kit Tool. + * \note Comment out the #define below if you won't work with EPD Kit tool and + * just want to show two images change alternately by predefined image array. + */ +//#define EPD_KIT_TOOL_FUNCTIONS + +/** \brief Supported COG version + * + * \note + * - place the value here to assign which COG driving waveform will be used. + * - Options are COG_V110_G1 and COG_V230_G2 */ +//#define COG_V110_G1 +#define COG_V230_G2 + +/** The SPI frequency of this kit (8MHz) */ +#define COG_SPI_baudrate 8000000 + +/** Define the number of ram buffer for system packet used interchangeably*/ +#define BUFFER_SIZE 1 + +/** System Packet length=6~64, maximum=64. +* The payload length of MSP430 LaunchPad is 32 bytes only. +* ======================== +* | Byte | Name | +* |------|---------------| +* | 0 | Packet Header | +* | 1 | Packet Length | +* | 2-3 | Kit ID | +* | 4 | Command Type | +* | 5-62 | Data | +* | 63 | CRC | +*/ +#define PAYLOAD_SIZE 32 + +/** Firmware version to display on EPD Kit Tool */ +#define EPD_KIT_TOOL_VERSION "1.11 " + +/** \brief Kit ID for recognizing by EPD Kit Tool + * + * \note + * - High byte is IC vendor, low byte is the name of supported development kit + * - Texas Instruments=01, MSP430 LaunchPad=01 */ +#define EPD_KIT_TOOL_ID (uint16_t)0x0101 + +#endif /* CONF_EPD_H_INCLUDED */ + + +