ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
pcd8544_stc8h3k.c File Reference
#include "fw_hal.h"
#include "pcd8544.h"

Go to the source code of this file.

Functions

void SPI_Init (void)
 
void GPIO_Init (void)
 
int main (void)
 

Function Documentation

◆ GPIO_Init()

void GPIO_Init ( void  )

Definition at line 52 of file pcd8544_stc8h3k.c.

53{
54 // Configure GPIO pins before SPI and device
55 // DIN(P34)
57 // SCLK(P32)
60}
#define GPIO_P3_SetMode(__PINS__, __MODE__)
Definition: fw_gpio.h:89
@ GPIO_Pin_5
Definition: fw_gpio.h:50
@ GPIO_Pin_2
Definition: fw_gpio.h:47
@ GPIO_Pin_4
Definition: fw_gpio.h:49
@ GPIO_Pin_6
Definition: fw_gpio.h:51
@ GPIO_Pin_7
Definition: fw_gpio.h:52
#define GPIO_P1_SetMode(__PINS__, __MODE__)
Definition: fw_gpio.h:79
@ GPIO_Mode_Output_PP
Definition: fw_gpio.h:24
@ GPIO_Mode_InOut_QBD
Definition: fw_gpio.h:23

◆ main()

int main ( void  )

Definition at line 62 of file pcd8544_stc8h3k.c.

63{
64 uint8_t y1, y2;
65
67 GPIO_Init();
68 SPI_Init();
70
71 while(1)
72 {
74 SYS_Delay(500);
76 SYS_Delay(200);
78 SYS_Delay(200);
80 SYS_Delay(200);
82 SYS_Delay(500);
83 PCD8544_Fill(0);
84
85 PCD8544_DrawLine(0, 0, 83, 0, 1);
86 PCD8544_DrawLine(0, 0, 0, 47, 1);
87 PCD8544_DrawLine(83, 0, 83, 47, 1);
88 PCD8544_DrawLine(0, 47, 83, 47, 1);
90 SYS_Delay(500);
91
92 PCD8544_GotoXY(3, 3);
93 PCD8544_Puts("LCD:PCD8544", &Font_5x7, 1);
94 PCD8544_GotoXY(3, 11);
95 PCD8544_Puts("STC8 FwLib", &Font_5x7, 1);
96 PCD8544_GotoXY(3, 19);
97 PCD8544_Puts("A demo of PCD8544", &Font_3x5, 1);
98 PCD8544_GotoXY(3, 25);
99 PCD8544_Puts("Font 3x5: 01234567890", &Font_3x5, 1);
101 SYS_Delay(500);
103 SYS_Delay(1000);
105 SYS_Delay(1000);
107 SYS_Delay(1000);
109 SYS_Delay(1000);
110
111 for (y1 = 0x05; y1 < 0x08; y1++)
112 {
113 for (y2 = 0x00; y2 < 0x60; y2+=2)
114 {
115 PCD8544_GotoXY(3, 32);
116 PCD8544_Putc(HEX_TABLE[y1 >> 4], &Font_5x7, 1);
117 PCD8544_Putc(HEX_TABLE[y1 & 0x0F], &Font_5x7, 1);
118 PCD8544_Putc(' ', &Font_5x7, 1);
119 PCD8544_Putc(HEX_TABLE[y2 >> 4], &Font_5x7, 1);
120 PCD8544_Putc(HEX_TABLE[y2 & 0x0F], &Font_5x7, 1);
122 PCD8544_SetContrast(y1, y2);
123 SYS_Delay(100);
124 }
125 SYS_Delay(1000);
126 }
127 PCD8544_SetContrast(0x06, 0x20);
128 PCD8544_Fill(0);
129
130 y1 = 47, y2 = 0;
131 while (y1 < 0xF0)
132 {
133 PCD8544_DrawLine(0, y1, 83, y2, 1);
135 y1 -= 2;
136 y2 += 2;
137 SYS_Delay(100);
138 }
139 SYS_Delay(1000);
140 PCD8544_Fill(0);
141
142 y1 = 83, y2 = 0;
143 while (y1 < 0xF0)
144 {
145 PCD8544_DrawLine(y1, 0, y2, 47, 1);
147 y1 -= 2;
148 y2 += 2;
149 SYS_Delay(100);
150 }
151 SYS_Delay(1000);
152
153 PCD8544_Fill(0);
155 SYS_Delay(1000);
157 SYS_Delay(1000);
158 }
159}
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
@ HAL_State_OFF
Definition: fw_types.h:70
@ HAL_State_ON
Definition: fw_types.h:71
unsigned char uint8_t
Definition: fw_types.h:18
__CODE char HEX_TABLE[16]
Definition: fw_util.c:18
char PCD8544_Putc(char ch, FontDef_t *font, uint8_t color)
Put one character to internal RAM.
Definition: pcd8544.c:281
void PCD8544_GotoXY(uint8_t x, uint8_t y)
Sets cursor pointer to desired location for strings.
Definition: pcd8544.c:274
void PCD8544_UpdateScreen(void)
Update LCD display with changes.
Definition: pcd8544.c:147
void PCD8544_DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t color)
Draws line on LCD.
Definition: pcd8544.c:177
char PCD8544_Puts(char *str, FontDef_t *Font, uint8_t color)
Puts string to internal RAM.
Definition: pcd8544.c:328
void PCD8544_Init(void)
Initializes PCD8544 Display.
Definition: pcd8544.c:129
void PCD8544_SetDisplayAllOn(void)
Set PCD8544 To Turn On All Segments.
Definition: pcd8544.c:109
void PCD8544_SetDisplayInverted(void)
Set PCD8544 Display Mode to Inverted.
Definition: pcd8544.c:114
void PCD8544_SetBackLightState(HAL_State_t state)
Turn PCD8544 LCD backlight on or off.
Definition: pcd8544.c:136
void PCD8544_Fill(uint8_t color)
Fills entire LCD with specified color.
Definition: pcd8544.c:141
void PCD8544_SetContrast(uint8_t bias, uint8_t val)
Set the contrast level by adjusting Vlcd.
Definition: pcd8544.c:87
void PCD8544_SetPowerDownMode(HAL_State_t state)
Powerdown mode control.
Definition: pcd8544.c:64
__CODE FontDef_t Font_5x7
Definition: pcd8544.c:548
void PCD8544_SetDisplayBlank(void)
Set PCD8544 Display Mode to Blank.
Definition: pcd8544.c:119
void PCD8544_SetDisplayNormal(void)
Set PCD8544 Display Mode to Normal.
Definition: pcd8544.c:124
__CODE FontDef_t Font_3x5
Definition: pcd8544.c:547
void SPI_Init(void)
void GPIO_Init(void)

◆ SPI_Init()

void SPI_Init ( void  )

Definition at line 33 of file pcd8544_stc8h3k.c.

34{
36 // Clock is low when idle
38 // Data transfer is driven by lower SS pin
40 // MSB first
42 // Define the output pins
44 // Ignore SS pin, use MSTR to swith between master/slave mode
46 // Master mode
48 // Start SPI
50}
#define SPI_SetClockPrescaler(__PRE_SCALER__)
Definition: fw_spi.h:88
#define SPI_SetPort(__ALTER_PORT__)
Definition: fw_spi.h:92
#define SPI_SetDataOrder(__ORDER__)
Definition: fw_spi.h:70
@ SPI_ClockPreScaler_16
Definition: fw_spi.h:47
#define SPI_SetEnabled(__STATE__)
Definition: fw_spi.h:69
#define SPI_SetClockPolarity(__STATE__)
Definition: fw_spi.h:78
#define SPI_SetClockPhase(__PHASE__)
Definition: fw_spi.h:84
@ SPI_ClockPhase_LeadingEdge
Definition: fw_spi.h:53
#define SPI_IgnoreSlaveSelect(__STATE__)
Definition: fw_spi.h:68
#define SPI_SetMasterMode(__STATE__)
Definition: fw_spi.h:71
@ SPI_AlterPort_P35_P34_P33_P32
Definition: fw_spi.h:39
@ SPI_DataOrder_MSB
Definition: fw_spi.h:59