1 | /**************************************************************************************************
|
2 | * @fn HalLcd_Clean
|
3 | *
|
4 | * @brief Sets All pixels Off
|
5 | *
|
6 | * @param None
|
7 | *
|
8 | * @return None
|
9 | **************************************************************************************************/
|
10 | void HalLcd_Clean(void)
|
11 | {
|
12 | uint8 LcdData[] = {0x00};
|
13 |
|
14 | for(uint8 p=0; p<26; p++){ /* 25 Pages */
|
15 | for(uint8 c=0; c<160; c++){ /* 160 Columns */
|
16 | HalLCD_SetPageAddress(0x00 + p);
|
17 | HalLCD_SetColumnAdress(0x00 + c);
|
18 | HalLcd_SendData(LcdData, 1);
|
19 | }
|
20 | }
|
21 | }
|
22 |
|
23 |
|
24 |
|
25 | /**************************************************************************************************
|
26 | * @fn HalLcd_SendData
|
27 | *
|
28 | * @brief Sends Data to LCD via 3 wire SPI
|
29 | *
|
30 | * @param uint8* SData - Pointer to the Data to be written to the LCD
|
31 | * uint i - Number of the Datas to be written to the LCD
|
32 | *
|
33 | * @return None
|
34 | **************************************************************************************************/
|
35 |
|
36 | void HalLcd_SendData(uint8* SData, uint8 i)
|
37 |
|
38 | {
|
39 | LCD_Data(SData,i);
|
40 | //P3OUT |= CD; /* CD High */
|
41 | //SPI_A0_Send_Data(SData , i);
|
42 | }
|
43 |
|
44 | void LCD_Data(uint8* DATA, uint8 i)
|
45 | {
|
46 | while(i)
|
47 | {
|
48 | TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); //TWSTA = TWI START Condition Bit
|
49 | while (!(TWCR & (1<<TWINT)));
|
50 |
|
51 | if ((TWSR & 0xF8) != TW_START) // Passcaller 00 == 1
|
52 | Led0_on(); //Fehlerbehandlung
|
53 |
|
54 | TWDR = 0x7A;//SLA_W;
|
55 | TWCR = (1<<TWINT) | (1<<TWEN);
|
56 |
|
57 | while (!(TWCR & (1<<TWINT)));
|
58 |
|
59 | if ((TWSR & 0xF8) != TW_MT_SLA_ACK)
|
60 | Led0_on();
|
61 |
|
62 | TWDR = *DATA;
|
63 | TWCR = (1<<TWINT) | (1<<TWEN);
|
64 |
|
65 | while (!(TWCR & (1<<TWINT)));
|
66 |
|
67 | if ((TWSR & 0xF8) != TW_MT_DATA_ACK)
|
68 | Led0_on();
|
69 |
|
70 |
|
71 | TWCR = (1<<TWINT)|(1<<TWEN)|
|
72 | (1<<TWSTO);
|
73 |
|
74 | DATA++; /* Increment the pointer on the array */
|
75 | i--; /* Decrement the Byte counter */
|
76 | }
|
77 |
|
78 | return;
|
79 | }
|