Skip to content

Commit

Permalink
Add LCD Controller User Manual
Browse files Browse the repository at this point in the history
Add Read Function
  • Loading branch information
Mazarei authored and Mazarei committed Dec 24, 2018
1 parent 126573a commit 9dfa0a1
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
Expand All @@ -30,7 +30,7 @@
<tool id="de.innot.avreclipse.tool.compiler.winavr.app.release.537673116" name="AVR Compiler" superClass="de.innot.avreclipse.tool.compiler.winavr.app.release">
<option id="de.innot.avreclipse.compiler.option.debug.level.205037934" name="Generate Debugging Info" superClass="de.innot.avreclipse.compiler.option.debug.level" value="de.innot.avreclipse.compiler.option.debug.level.none" valueType="enumerated"/>
<option id="de.innot.avreclipse.compiler.option.optimize.244388817" name="Optimization Level" superClass="de.innot.avreclipse.compiler.option.optimize" value="de.innot.avreclipse.compiler.optimize.size" valueType="enumerated"/>
<option id="de.innot.avreclipse.compiler.option.incpath.1290138176" superClass="de.innot.avreclipse.compiler.option.incpath" valueType="includePath">
<option id="de.innot.avreclipse.compiler.option.incpath.1290138176" name="Include Paths (-I)" superClass="de.innot.avreclipse.compiler.option.incpath" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/NokiaTFTLib}&quot;"/>
</option>
<inputType id="de.innot.avreclipse.compiler.winavr.input.73525291" name="C Source Files" superClass="de.innot.avreclipse.compiler.winavr.input"/>
Expand Down
Binary file added Doc/SPFD54124b.pdf
Binary file not shown.
19 changes: 18 additions & 1 deletion Main/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
#include <util/delay.h>
#include <nokia1661_lcd_driver.h>
#include <lcd_font5x7.h>
#include <stdio.h>

int main(void)
{
nlcdInit();



nlcdSetBackgroundColor(LCD_VGA_RED);
nlcdClear();

Expand All @@ -39,8 +42,22 @@ int main(void)
nlcdSetFont(font5x7latcyr);
nlcdClear();

uint8_t ReadID[3] = {0};
uint8_t RDDST[4];
_nlcdRead(0x04,ReadID,3); /* Read Display ID */
_nlcdRead(0x09,RDDST,4); /* Read Display Status */

char temp[20];
sprintf(temp,"RDDID:%X %X %X",ReadID[0],ReadID[1],ReadID[2]);
nlcdGotoCharXY(1,1);
nlcdStringP(LCD_VGA_RED, PSTR("Sisoog.Com"));
nlcdString(LCD_VGA_RED,temp);

sprintf(temp,"RDDST:%X %X %X %X",RDDST[0],RDDST[1],RDDST[2],RDDST[3]);
nlcdGotoCharXY(1,2);
nlcdString(LCD_VGA_RED,temp);

// nlcdGotoCharXY(1,1);
// nlcdStringP(LCD_VGA_RED, PSTR("Sisoog.Com"));
_delay_ms(250);

nlcdSetOrientation(LCD_ORIENTATION_90);
Expand Down
67 changes: 66 additions & 1 deletion NokiaTFTLib/nokia1661_lcd_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ LCD_PIN_FUNC(clk, CLK)
/*----------------------------------------------------------------------------------------------------------------
* hardware functions
*/
static uint16_t ShiftBit[] = {0x100,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};

void _nlcdSend(uint16_t data)
{
static uint16_t ShiftBit[] = {0x100,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
_cs_clr();

if(data & ShiftBit[0]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
Expand All @@ -61,6 +61,71 @@ void _nlcdSend(uint16_t data)

_cs_set();
}

uint8_t __nlcdRead(void)
{
uint8_t data = 0;
/*Read Bits*/
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;
_clk_set(); _clk_clr(); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0;

// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();
// _clk_clr();_delay_us(100); data<<=1; data|=((LCD_PIN&(1 << LCD_SDA))) ? 1:0; _clk_set();

return data;
}

void _nlcdRead(uint8_t Reg,uint8_t *Readbuffer,uint8_t NRead)
{
uint16_t data = SPFD54124B_SEND_CMD | Reg;
_cs_clr();

/*Send Command*/
if(data & ShiftBit[0]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[1]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[2]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[3]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[4]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[5]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[6]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[7]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();
if(data & ShiftBit[8]) _sda_set(); else _sda_clr();_clk_set();_clk_clr();

/*Now Input Data Line And PullUp It*/
LCD_DDR &= ~(1 << LCD_SDA);
_sda_set();

if(NRead==1)
{
*Readbuffer = __nlcdRead();
}
else
{
_clk_set();_clk_clr(); /*send Dummy Clock Cycle*/
while(NRead--)
{
*Readbuffer++ = __nlcdRead();
}
}


_cs_set();

/*Make Data Line As Output Again*/
LCD_DDR |= (1 << LCD_SDA);
}
/*----------------------------------------------------------------------------------------------------------------
* private functions
*/
Expand Down
2 changes: 2 additions & 0 deletions NokiaTFTLib/nokia1661_lcd_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

// definign LCD connection
#define LCD_PORT PORTB
#define LCD_PIN PINB
#define LCD_DDR DDRB

#define LCD_RST PINB1
Expand Down Expand Up @@ -114,6 +115,7 @@ void _nlcdSendCmd(uint8_t data);
*/
void _nlcdSendData(uint8_t data);

void _nlcdRead(uint8_t Reg,uint8_t *Readbuffer,uint8_t NRead);
/**
* inittialize lcd
*/
Expand Down

0 comments on commit 9dfa0a1

Please sign in to comment.