SRD Standelone programmation box: display.c File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Functions | Variables
display.c File Reference

Source file for display driver. More...

`#include "display.h"`
Include dependency graph for display.c:

Go to the source code of this file.

## Functions

void | DisplayInit (void)
| Function used to initialized the display. More...
void | DisplaySetDataDisplayed (char digit[DISPLAY_TOTAL_DIGIT])
| Function used set the data displayed. More...
void | DisplayGetDataDisplayed (char digit[DISPLAY_TOTAL_DIGIT])
| Function used get the data displayed. More...
unsigned char | DisplayDigitTo7Seg (tDisplay7SegId digitId, t7SegDisplay seg)
| Function used to root 7 segments command on the rigth PIN. More...
unsigned short | DisplayDigitTo16Seg (tDisplay16SegId digitId, t16SegDisplay seg)
| Function used to root 16 segments command on the rigth PIN. More...
void | DisplaySetPower (tDisplayPowerState power)
| Function used to enable/disable the display power. More...

## Variables

char | currentDigit [DISPLAY_TOTAL_DIGIT] = {[0 ... DISPLAY_TOTAL_DIGIT-1] = 0}
tDisplayPowerState | displayPower = DISPLAY_POWER_OFF

## Detailed Description

Source file for display driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  26/09/2014

Version
  1.0

All Right Reserved.

Definition in file display.c.

## Function Documentation

unsigned char DisplayDigitTo16Seg | ( | tDisplay16SegId | digitId,
|  | t16SegDisplay | seg
| ) |  |

Function used to root 16 segments command on the rigth PIN.

Parameters

  [in] | digitId | (tDisplay16SegId) : digit ID.
  [in] | seg | (t16SegDisplay) : state of the 16 segments of this digit.

Definition at line 170 of file display.c.

References DISPLAY_16SEG_1_ID, and t16SegDisplay::seg.

Referenced by DisplaySetDataDisplayed().

170 {
171
172 unsigned short segMap = 0;
173
174 switch(digitId) {
175
176 case DISPLAY_16SEG_1_ID :
177 segMap |= seg.seg.A << 0;
178 segMap |= seg.seg.B << 11;
179 segMap |= seg.seg.C << 9;
180 segMap |= seg.seg.D << 14;
181 segMap |= seg.seg.E << 13;
182 segMap |= seg.seg.F << 12;
183 segMap |= seg.seg.G << 7;
184 segMap |= seg.seg.H << 3;
185 segMap |= seg.seg.K << 2;
186 segMap |= seg.seg.M << 1;
187 segMap |= seg.seg.N << 10;
188 segMap |= seg.seg.U << 4;
189 segMap |= seg.seg.P << 8;
190 segMap |= seg.seg.T << 6;
191 segMap |= seg.seg.S << 5;
192 segMap |= seg.seg.R << 15;
193 break;
194
195 default :
196 segMap = 0;
197 break;
198 }
199
200 return ~segMap;
201
202 }
DISPLAY_16SEG_1_ID
Definition: display.h:95
t16SegDisplay::seg
struct t16SegDisplay::@22::@24 seg

Here is the caller graph for this function:

unsigned char DisplayDigitTo7Seg | ( | tDisplay7SegId | digitId,
|  | t7SegDisplay | seg
| ) |  |

Function used to root 7 segments command on the rigth PIN.

Parameters

  [in] | digitId | (tDisplay7SegId) : digit ID.
  [in] | seg | (t7SegDisplay) : state of the 7 segments of this digit.

Definition at line 126 of file display.c.

References DISPLAY_7SEG_1_ID, DISPLAY_7SEG_2_ID, DISPLAY_7SEG_3_ID, and t7SegDisplay::seg.

Referenced by DisplaySetDataDisplayed().

126 {
127
128 unsigned char segMap = 0;
129
130 switch(digitId) {
131
132 case DISPLAY_7SEG_1_ID:
133 segMap |= seg.seg.A << 1;
134 segMap |= seg.seg.B << 3;
135 segMap |= seg.seg.C << 5;
136 segMap |= seg.seg.D << 7;
137 segMap |= seg.seg.E << 6;
138 segMap |= seg.seg.F << 2;
139 segMap |= seg.seg.G << 0;
140 segMap |= seg.seg.dot<<4;
141 break;
142
143 case DISPLAY_7SEG_2_ID:
144 segMap |= seg.seg.A << 2;
145 segMap |= seg.seg.B << 0;
146 segMap |= seg.seg.C << 6;
147 segMap |= seg.seg.D << 4;
148 segMap |= seg.seg.E << 5;
149 segMap |= seg.seg.F << 1;
150 segMap |= seg.seg.G << 3;
151 break;
152
153 case DISPLAY_7SEG_3_ID:
154 segMap |= seg.seg.A << 2;
155 segMap |= seg.seg.B << 3;
156 segMap |= seg.seg.C << 6;
157 segMap |= seg.seg.D << 4;
158 segMap |= seg.seg.E << 5;
159 segMap |= seg.seg.F << 1;
160 segMap |= seg.seg.G << 0;
161 break;
162
163 default:
164 segMap = 0x00;
165 break;
166 }
167 return ~segMap;
168 }
DISPLAY_7SEG_3_ID
Definition: display.h:85
DISPLAY_7SEG_1_ID
Definition: display.h:83
t7SegDisplay::seg
struct t7SegDisplay::@25::@27 seg
DISPLAY_7SEG_2_ID
Definition: display.h:84

Here is the caller graph for this function:

void DisplayGetDataDisplayed | ( | char | digit[DISPLAY_TOTAL_DIGIT] | ) |

Function used get the data displayed.

Parameters

  [out] | digit[DISPLAY_TOTAL_DIGIT] | (char[]) : data displayed.

Definition at line 117 of file display.c.

References currentDigit, and DISPLAY_TOTAL_DIGIT.

Referenced by ButtonManager(), PowerManagerDisplayLoaded(), and PowerManagerDisplayLoading().

117 {
118
119 unsigned char i;
120
121 for(i=0 ; i<DISPLAY_TOTAL_DIGIT ; i++) {
122 digit[i] = currentDigit[i];
123 }
124 }
currentDigit
char currentDigit[DISPLAY_TOTAL_DIGIT]
Definition: display.c:44
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the caller graph for this function:

void DisplayInit | ( | void |  | ) |

Function used to initialized the display.

Definition at line 71 of file display.c.

References DISPLAY_BAUDRATE, DISPLAY_CMD_MASK, DISPLAY_CMD_SHIFT, DISPLAY_POWER_MASK, DISPLAY_POWER_OFF, DISPLAY_POWER_SHIFT, DISPLAY_TOTAL_DIGIT, displayPower, DisplaySetDataDisplayed(), Spi0Enable, and Spi0Init().

Referenced by Setup().

71 {
72
73 SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK;
74 PTD->PDDR |= GPIO_PDDR_PDD(DISPLAY_POWER_MASK); //As output
75 PORTD->PCR[DISPLAY_POWER_SHIFT] = PORT_PCR_MUX(0x01);
76 PTD->PCOR |= DISPLAY_POWER_MASK; //Command is idle high
77 displayPower = DISPLAY_POWER_OFF; //Power is off at startup
78
79 SIM->SCGC5 |= SIM_SCGC5_PORTE_MASK;
80 PTE->PDDR |= GPIO_PDDR_PDD(DISPLAY_CMD_MASK); //As output
81 PORTE->PCR[DISPLAY_CMD_SHIFT] = PORT_PCR_MUX(0x01);
82
83 Spi0Init(DISPLAY_BAUDRATE);
84 Spi0Enable();
85
86 char data[DISPLAY_TOTAL_DIGIT] = {0};
87 DisplaySetDataDisplayed(data);
88 }
DISPLAY_POWER_MASK
#define DISPLAY_POWER_MASK
Define the IO shift and mask used by the display driver.
Definition: display.h:63
DISPLAY_CMD_MASK
#define DISPLAY_CMD_MASK
Define the IO shift and mask used by the display driver.
Definition: display.h:65
DISPLAY_CMD_SHIFT
#define DISPLAY_CMD_SHIFT
Define the IO shift and mask used by the display driver.
Definition: display.h:64
DISPLAY_BAUDRATE
#define DISPLAY_BAUDRATE
Define the baudrate used by the display interface.
Definition: display.h:36
DISPLAY_POWER_OFF
Definition: display.h:117
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
Spi0Init
void Spi0Init(unsigned long sclkFreq)
Function used to initialize the SPI0 module.
Definition: spi0.c:80
Spi0Enable
#define Spi0Enable()
Set/Clear/Read the SPI enable status.
Definition: spi0.h:132
DISPLAY_POWER_SHIFT
#define DISPLAY_POWER_SHIFT
Define the IO shift and mask used by the display driver.
Definition: display.h:62
displayPower
tDisplayPowerState displayPower
Definition: display.c:45
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void DisplaySetDataDisplayed | ( | char | digit[DISPLAY_TOTAL_DIGIT] | ) |

Function used set the data displayed.

Parameters

  [in] | digit[DISPLAY_TOTAL_DIGIT] | (char[]) : data to display.

Definition at line 90 of file display.c.

References currentDigit, Decode16segDigitASCII(), Decode7segDigitASCII(), DISPLAY_16SEG_1_ID, DISPLAY_7SEG_1_ID, DISPLAY_7SEG_2_ID, DISPLAY_7SEG_3_ID, DISPLAY_CMD_OFF, DISPLAY_CMD_ON, DISPLAY_NBR_16SEG, DISPLAY_NBR_7SEG, DISPLAY_TOTAL_DIGIT, DisplayDigitTo16Seg(), DisplayDigitTo7Seg(), DisplaySetCmd, and Spi0Send().

Referenced by ButtonManager(), ButtonManagerDisplayDateError(), ButtonManagerDisplayLogError(), ButtonManagerDisplayNone(), ButtonManagerDisplayProgrammedError(), ButtonManagerDisplayRead(), ButtonManagerDisplayRfidError(), ButtonManagerDisplayWrite(), ButtonManagerDisplayWriteError(), DisplayInit(), PowerManagerDisplayLoaded(), PowerManagerDisplayLoading(), and PowerManagerDisplayLoadingError().

90 {
91
92 unsigned char i;
93
94 for(i=0 ; i<DISPLAY_TOTAL_DIGIT ; i++) {
95 currentDigit[i] = digit[i];
96 }
97
98 char outputData[DISPLAY_NBR_16SEG*2 + DISPLAY_NBR_7SEG];
99 unsigned char ptr = 0;
100
101 outputData[0] = DisplayDigitTo7Seg(DISPLAY_7SEG_3_ID, Decode7segDigitASCII(currentDigit[3]));
102 outputData[1] = DisplayDigitTo7Seg(DISPLAY_7SEG_2_ID, Decode7segDigitASCII(currentDigit[2]));
103 outputData[2] = DisplayDigitTo7Seg(DISPLAY_7SEG_1_ID, Decode7segDigitASCII(currentDigit[1]));
104
105 unsigned short tmp = DisplayDigitTo16Seg(DISPLAY_16SEG_1_ID, Decode16segDigitASCII(currentDigit[0]));
106 outputData[3] = (unsigned char)((tmp>>8)&0xFF);
107 outputData[4] = (unsigned char)(tmp&0xFF);
108
109
110 DisplaySetCmd(DISPLAY_CMD_ON);
111 //unsigned long tmp = 1000000;
112 //while(tmp-- != 0);
113 Spi0Send(outputData, DISPLAY_NBR_16SEG*2 + DISPLAY_NBR_7SEG );
114 DisplaySetCmd(DISPLAY_CMD_OFF);
115 }
DisplaySetCmd
#define DisplaySetCmd(cmd)
Macro used to set the command line.
Definition: display.h:152
DISPLAY_7SEG_3_ID
Definition: display.h:85
DISPLAY_7SEG_1_ID
Definition: display.h:83
Spi0Send
signed short Spi0Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 0.
Definition: spi0.c:152
DISPLAY_NBR_7SEG
#define DISPLAY_NBR_7SEG
Define the number of segment by type.
Definition: display.h:44
DISPLAY_16SEG_1_ID
Definition: display.h:95
Decode7segDigitASCII
t7SegDisplay Decode7segDigitASCII(char digit)
Function used to decode a char and display it on a 7 segments digit.
Definition: decoder7Seg.c:78
currentDigit
char currentDigit[DISPLAY_TOTAL_DIGIT]
Definition: display.c:44
DISPLAY_7SEG_2_ID
Definition: display.h:84
DISPLAY_CMD_ON
Definition: display.h:105
DisplayDigitTo7Seg
unsigned char DisplayDigitTo7Seg(tDisplay7SegId digitId, t7SegDisplay seg)
Function used to root 7 segments command on the rigth PIN.
Definition: display.c:126
DisplayDigitTo16Seg
unsigned short DisplayDigitTo16Seg(tDisplay16SegId digitId, t16SegDisplay seg)
Function used to root 16 segments command on the rigth PIN.
Definition: display.c:170
DISPLAY_CMD_OFF
Definition: display.h:106
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54
DISPLAY_NBR_16SEG
#define DISPLAY_NBR_16SEG
Define the number of segment by type.
Definition: display.h:45
Decode16segDigitASCII
t16SegDisplay Decode16segDigitASCII(char digit)
Function used to decode a char and display it on a 16 segments digit.
Definition: decoder16Seg.c:78

Here is the call graph for this function:

Here is the caller graph for this function:

void DisplaySetPower | ( | tDisplayPowerState | power | ) |

Function used to enable/disable the display power.

Parameters

  [in] | power | (tDisplayPowerState) : power state to apply.

Definition at line 204 of file display.c.

References DISPLAY_CMD_MASK, DISPLAY_POWER_MASK, DISPLAY_POWER_OFF, DISPLAY_POWER_SHIFT, displayPower, and SPI0PinMappingPeripheral().

Referenced by ButtonManager(), ButtonManagerDisplayDateError(), ButtonManagerDisplayLogError(), ButtonManagerDisplayNone(), ButtonManagerDisplayProgrammedError(), ButtonManagerDisplayRead(), ButtonManagerDisplayRfidError(), ButtonManagerDisplayWrite(), ButtonManagerDisplayWriteError(), PowerManagerDisplayLoading(), PowerManagerDisplayLoadingError(), PowerManagerEnterLPM(), and Setup().

204 {
205
206 (PTD->PDOR = (PTD->PDOR & ~DISPLAY_POWER_MASK) | (power<<DISPLAY_POWER_SHIFT) );
207
208 if(power != displayPower) {
209 displayPower = power;
210
211 if(power == DISPLAY_POWER_OFF) {
212 PTE->PDDR &= ~GPIO_PDDR_PDD(DISPLAY_CMD_MASK);
213 PORTE->PCR[17] &= ~PORT_PCR_MUX_MASK;
214 PORTE->PCR[17] |= PORT_PCR_MUX(1);
215 PTE->PDDR &= ~GPIO_PDDR_PDD(1<<17);
216 PORTE->PCR[18] &= ~PORT_PCR_MUX_MASK;
217 PORTE->PCR[18] |= PORT_PCR_MUX(1);
218 PTE->PDDR &= ~GPIO_PDDR_PDD(1<<18);
219 } else {
220 PTE->PDDR |= GPIO_PDDR_PDD(DISPLAY_CMD_MASK);
221 SPI0PinMappingPeripheral(); //ReMap SPI IO
222 }
223 }
224 }
DISPLAY_POWER_MASK
#define DISPLAY_POWER_MASK
Define the IO shift and mask used by the display driver.
Definition: display.h:63
DISPLAY_CMD_MASK
#define DISPLAY_CMD_MASK
Define the IO shift and mask used by the display driver.
Definition: display.h:65
DISPLAY_POWER_OFF
Definition: display.h:117
DISPLAY_POWER_SHIFT
#define DISPLAY_POWER_SHIFT
Define the IO shift and mask used by the display driver.
Definition: display.h:62
displayPower
tDisplayPowerState displayPower
Definition: display.c:45
SPI0PinMappingPeripheral
void SPI0PinMappingPeripheral(void)
Functions to MAP the defined IO of the SPI module x in the rigth pin.
Definition: DSP_mkl16z256vlh4.c:278

Here is the call graph for this function:

Here is the caller graph for this function:

## Variable Documentation

char currentDigit[DISPLAY_TOTAL_DIGIT] = {[0 ... DISPLAY_TOTAL_DIGIT-1] = 0}

Definition at line 44 of file display.c.

Referenced by DisplayGetDataDisplayed(), and DisplaySetDataDisplayed().

tDisplayPowerState displayPower = DISPLAY_POWER_OFF

Definition at line 45 of file display.c.

Referenced by DisplayInit(), and DisplaySetPower().