📄 main.lst
字号:
C51 COMPILER V7.50 MAIN 09/22/2006 16:41:33 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\Program Files\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #define __SRC
2 #include "ps7219.h"
3 #undef __SRC
4
5 #include <reg52.h>
6
7 void main()
8 {
9 1 while(1)
10 1 {
11 2 InitIO_PS7219();
12 2 display_led_n(0x05,1);
13 2 display_led_n(0x05,2);
14 2 bright_led_n(0x0f,1);
15 2 bright_led_n(0x0f,2);
16 2 glitter_led_n(0xff,1);
17 2 glitter_led_n(0xff,2);
18 2 }
19 1 }
20
21 /*******************************************************************************************/
22 //function InitIO_PS7219(); initialize the PS7219
23 /*******************************************************************************************/
24 void InitIO_PS7219()
25 {
26 1 LOAD=0; //clear the load signal
27 1 CLK=1; //set the clk signal high
28 1 }
29
30 /*******************************************************************************************/
31 //function Delay5us();Delay 5us
32 /*******************************************************************************************/
33 void Delay5us(unsigned char n)
34 {
35 1 unsigned int i;
36 1 while(n--)
37 1 for(i=0;i<4;i++);
38 1 }
39
40 /*******************************************************************************************/
41 //function SpiWrite();
42 /*******************************************************************************************/
43 void SpiWrite(unsigned char byte)
44 {
45 1 unsigned char i;
46 1
47 1 DATA_BUF=byte; // Put function's parameter into a bdata variable
48 1 for (i=0;i<8;i++) // Setup byte circulation bits
49 1 {
50 2 if (flag) // Put DATA_BUF.7 on data line
51 2 DO=1;
52 2 else
53 2 DO=0;
54 2 Delay5us(1); // delay 5us
55 2 CLK=0; // Set clock line low
C51 COMPILER V7.50 MAIN 09/22/2006 16:41:33 PAGE 2
56 2 Delay5us(1);
57 2 DATA_BUF=DATA_BUF<<1; // Shift DATA_BUF
58 2 CLK=1; // Set clock line high
59 2 }
60 1 }
61
62 /*******************************************************************************************/
63 //function send_ps7219();send 1 byte address and 1 byte data to PS7219
64 /*******************************************************************************************/
65 void send_ps7219(unsigned char addr,unsigned char mdata)
66 {
67 1 unsigned char j;
68 1
69 1 SpiWrite(addr);
70 1
71 1 DATA_BUF=mdata; // Put function's parameter into a bdata variable
-
72 1 for (j=0;j<7;j++) // Setup byte circulation bits
73 1 {
74 2 if (flag) // Put DATA_BUF.7 on data line
75 2 DO=1;
76 2 else
77 2 DO=0;
78 2 Delay5us(1);
79 2 CLK=0; // Set clock line low
80 2 Delay5us(1);
81 2 DATA_BUF=DATA_BUF<<1; // Shift DATA_BUF
82 2 LOAD=1; // after the 15th clock's falling edge, set the load signal high
83 2 CLK=1; // Set clock line high
84 2 }
85 1
86 1 if (flag) // Put the 16th bit on data line
87 1 DO=1;
88 1 else
89 1 DO=0;
90 1 Delay5us(1);
91 1 CLK=0; // Set clock line high
92 1 Delay5us(1);
93 1 CLK=1;
94 1 Delay5us(8); // delay 40us because the load line need to be setted high for 50us
95 1 LOAD=0; // clear the load line
96 1 }
97
98 /*******************************************************************************************/
99 //function send_ps7219_n();send 1 byte address and 1 byte data to Nth PS7219
100 /*******************************************************************************************/
101 void send_ps7219_n(unsigned char add,unsigned char mdat,unsigned char n)
102 {
103 1 unsigned char i;
104 1
105 1 if(n==1)
106 1 {
107 2 send_ps7219(add,mdat); //send the address and the data]
108 2 }
109 1 else
110 1 {
111 2 for(i=0;i<n-1;i++)
112 2 {
113 3 send_ps7219(0xf0,0xff); //send no-op code to the (n-1)th PS7219 in the head
114 3 }
115 2 }
116 1
C51 COMPILER V7.50 MAIN 09/22/2006 16:41:33 PAGE 3
117 1 }
118
119 /*******************************************************************************************/
120 //function glitter_led_n();glitter the led which is controled by the n PS7219
121 //n: 第N个PS7219
122 //ledn: 第N个PS7219控制的N个LE
123 /*******************************************************************************************/
124 void glitter_led_n(unsigned char ledn,unsigned char n)
125 {
126 1 send_ps7219_n(0x0D,ledn,n);
127 1 }
128
129 /*******************************************************************************************/
130 //function display_led_n();glitter the led which is controled by the n PS7219
131 //n: 第N个PS7219
132 //ledn: 第N个PS7219控制的显示的LED
133 /*******************************************************************************************/
134 void display_led_n(unsigned char ledn,unsigned char n)
135 {
136 1 send_ps7219_n(0x0B,ledn,n);
137 1 }
138
139 /*******************************************************************************************/
140 //function bright_led_n();control the brightness of the led
141 //n: 第N个PS7219
142 //ledn: 第N个PS72控制的LED的亮度
143 /*******************************************************************************************/
144 void bright_led_n(unsigned char ledn,unsigned char n)
145 {
146 1 send_ps7219_n(0x0A,ledn,n);
147 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 232 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 1
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -