Tijl Goens
/
EpaperdisplayII
tempcommit 13/05
Embed:
(wiki syntax)
Show/hide line numbers
epdif.cpp
00001 /** 00002 * @filename : epdif.cpp 00003 * @brief : Implements EPD interface functions 00004 * Users have to implement all the functions in epdif.cpp 00005 * @author : Yehui from Waveshare 00006 * 00007 * Copyright (C) Waveshare August 10 2017 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a copy 00010 * of this software and associated documnetation files (the "Software"), to deal 00011 * in the Software without restriction, including without limitation the rights 00012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 * copies of the Software, and to permit persons to whom the Software is 00014 * furished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in 00017 * all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 * THE SOFTWARE. 00026 */ 00027 00028 #include "epdif.h" 00029 #include "SPI.h" 00030 00031 //DigitalOut cs_pin (D9); 00032 00033 00034 EpdIf::EpdIf():_spi(D11,D12,D13),/*_cs(D9)*/dc_pin(D5),busy_pin(D3),reset_pin(A2),_cs(D9){ 00035 int whoami = 20; 00036 _spi.format(8,3); 00037 _spi.frequency(2000000); 00038 _cs = 0; 00039 _spi.write(0x8F); 00040 whoami = _spi.write(0x00); 00041 printf( "pre print \r\n"); 00042 printf("WHOAMI register = 0x%X\r\n", whoami); 00043 printf( "post print \r\n"); 00044 _cs = 1; 00045 }; 00046 00047 //EpdIf::EpdIf() {}; 00048 00049 EpdIf::~EpdIf(void) { 00050 }; 00051 00052 void EpdIf::DigitalWrite(DigitalOut &pin, int value) { 00053 //digitalWrite(pin, value); 00054 pin = value; 00055 //pin_val value; 00056 } 00057 00058 int EpdIf::DigitalRead(PinName &pin) { 00059 //return DigitalOut(pin).read(); 00060 //DigitalOut pin_val(pin); 00061 return pin; 00062 } 00063 00064 void EpdIf::DelayMs(unsigned int delaytime) { 00065 //delay(delaytime); 00066 00067 wait ((((float)delaytime)/100)); 00068 } 00069 00070 void EpdIf::SpiTransfer(unsigned char data) { 00071 //DigitalOut(CS_PIN, LOW); 00072 //DigitalOut cs_pin(D9); 00073 _cs = 0; 00074 //SPI.transfer(data); 00075 //_spi.transfer (*tx_buffer , 256,*rx_buffer,256,NULL,SPI_EVENT_COMPLETE); 00076 //for (int i=0; i< 256; i++) 00077 //{ 00078 00079 int result = _spi.write(data); 00080 //printf("SPI_transfer_reply %i\r\n",result); 00081 00082 //} 00083 00084 //DigitalOut(CS_PIN, HIGH); 00085 _cs = 1; 00086 } 00087 00088 int EpdIf::IfInit(void) { 00089 //pinMode(CS_PIN, OUTPUT); 00090 //pinMode(RST_PIN, OUTPUT); 00091 //pinMode(DC_PIN, OUTPUT); 00092 //pinMode(BUSY_PIN, INPUT); 00093 //_spi.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); 00094 //_spi.begin(); 00095 return 0; 00096 } 00097
Generated on Thu Jul 14 2022 00:56:38 by 1.7.2