SWE-350 TOTP Generator Milestone 5
The DE-10 board has six 7-segment displays, this can be used to display and generate a time based one-time pin (TOTP).
Loading...
Searching...
No Matches
LCD_Driver.c
Go to the documentation of this file.
1// ============================================================================
2// Copyright (c) 2013 by Terasic Technologies Inc.
3// ============================================================================
4//
5// Permission:
6//
7// Terasic grants permission to use and modify this code for use
8// in synthesis for all Terasic Development Boards and Altera Development
9// Kits made by Terasic. Other use of this code, including the selling
10// ,duplication, or modification of any portion is strictly prohibited.
11//
12// Disclaimer:
13//
14// This VHDL/Verilog or C/C++ source code is intended as a design reference
15// which illustrates how these types of functions can be implemented.
16// It is the user's responsibility to verify their design for
17// consistency and functionality through the use of formal
18// verification methods. Terasic provides no warranty regarding the use
19// or functionality of this code.
20//
21// ============================================================================
22//
23// Terasic Technologies Inc
24// 9F., No.176, Sec.2, Gongdao 5th Rd, East Dist, Hsinchu City, 30070. Taiwan
25//
26//
27// web: http://www.terasic.com/
28// email: support@terasic.com
29//
30// ============================================================================
31
32#include "LCD_Hw.h"
33#include "LCD_Driver.h"
34
35
36
37
38
39void LCDDrv_Display(bool bOn){
40 LCDHW_Write8(0,bOn?0xAF:0xAE);
41}
42
43// Specifies line address (refer to Figure 6) to determine the initial display line
44// When this command changes the line address, smooth scrolling or a page change takes place
45void LCDDrv_SetStartLine(uint8_t StartLine){
46 LCDHW_Write8(0,0x40 | (StartLine & 0x3F));
47}
48
49
50void LCDDrv_SetPageAddr(uint8_t PageAddr){
51 LCDHW_Write8(0,0xB0 | (PageAddr & 0x0F));
52}
53
54
55void LCDDrv_SetColAddr(uint8_t ColAddr){
56 LCDHW_Write8(0,0x00 | (ColAddr & 0x0F)); // low 4 bits
57 LCDHW_Write8(0,0x10 | ((ColAddr >> 4) & 0x0F)); // high 4-bits
58
59
60}
61
62
63
64void LCDDrv_WriteData(uint8_t Data){
65 LCDHW_Write8(1, Data);
66}
67
68void LCDDrv_WriteMultiData(uint8_t * Data, uint16_t num){
69 int i;
70 for(i=0;i<num;i++)
71 LCDHW_Write8(1, *(Data+i));
72}
73
74
75
76
77void LCDDrv_SetADC(bool bNormal){
78 LCDHW_Write8(0, bNormal?0xA0:0xA1);
79}
80
81void LCDDrv_SetReverse(bool bNormal){
82 LCDHW_Write8(0, bNormal?0xA6:0xA7);
83}
84
85void LCDDrv_EntireOn(bool bEntireOn){
86 LCDHW_Write8(0, bEntireOn?0xA5:0xA4);
87}
88
89void LCDDrv_SetBias(bool bDefault){
90 LCDHW_Write8(0, bDefault?0xA2:0xA3);
91}
92
93// Once Read-Modify-Write is issued, column address is not incremental by Read Display Data command
94// but incremental by Write Display Data command only.
95// It continues until End command is issued.
97 LCDHW_Write8(0, 0xE0);
98}
99
101 LCDHW_Write8(0, 0xEE);
102}
103
104void LCDDrv_Reset(void){
105 LCDHW_Write8(0, 0xE2);
106}
107
108
109void LCDDrv_SetOsc(bool bDefault){
110 LCDHW_Write8(0, bDefault?0xE4:0xE5);
111}
112
113void LCDDrv_SetPowerControl(uint8_t PowerMask){
114 LCDHW_Write8(0, 0x28 | (PowerMask & 0x7));
115}
116
117void LCDDrv_SetResistorRatio(uint8_t Value){
118 LCDHW_Write8(0, 0x20 | (Value & 0x7));
119}
120
121
122void LCDDrv_SetElectricVolume(uint8_t Value){
123 // write two bytes
124 LCDHW_Write8(0, 0x81);
125 LCDHW_Write8(0, Value & 0x3F);
126}
127
129 LCDHW_Write8(0, bNormal?0xC0:0xC8);
130}
131
132
void LCDDrv_SetElectricVolume(uint8_t Value)
Definition LCD_Driver.c:122
void LCDDrv_SetResistorRatio(uint8_t Value)
Definition LCD_Driver.c:117
void LCDDrv_SetPageAddr(uint8_t PageAddr)
Definition LCD_Driver.c:50
void LCDDrv_Display(bool bOn)
Definition LCD_Driver.c:39
void LCDDrv_SetStartLine(uint8_t StartLine)
Definition LCD_Driver.c:45
void LCDDrv_WriteData(uint8_t Data)
Definition LCD_Driver.c:64
void LCDDrv_SetPowerControl(uint8_t PowerMask)
Definition LCD_Driver.c:113
void LCDDrv_WriteMultiData(uint8_t *Data, uint16_t num)
Definition LCD_Driver.c:68
void LCDDrv_Reset(void)
Definition LCD_Driver.c:104
void LCDDrv_SetReverse(bool bNormal)
Definition LCD_Driver.c:81
void LCDDrv_EntireOn(bool bEntireOn)
Definition LCD_Driver.c:85
void LCDDrv_SetADC(bool bNormal)
Definition LCD_Driver.c:77
void LCDDrv_SetBias(bool bDefault)
Definition LCD_Driver.c:89
void LCDDrv_ReadModifyWrite_Start(void)
Definition LCD_Driver.c:96
void LCDDrv_SetOsc(bool bDefault)
Definition LCD_Driver.c:109
void LCDDrv_ReadModifyWrite_End(void)
Definition LCD_Driver.c:100
void LCDDrv_SetColAddr(uint8_t ColAddr)
Definition LCD_Driver.c:55
void LCDDrv_SetOuputStatusSelect(bool bNormal)
Definition LCD_Driver.c:128
void LCDHW_Write8(uint8_t bIsData, uint8_t Data)
Definition LCD_Hw.c:244