1 Star 0 Fork 1

zhanggong/IoT_2G4_Send

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
spi.LST 6.17 KB
一键复制 编辑 原始数据 按行查看 历史
zgYaoDao 提交于 2015-12-21 12:29 . init
C51 COMPILER V7.10 SPI 12/18/2015 16:49:54 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE SPI
OBJECT MODULE PLACED IN .\spi.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\spi.c BROWSE DEBUG OBJECTEXTEND OBJECT(.\spi.obj)
line level source
1 #include <GPM8F2202.h>
2 #include "spi.h"
3 #include "ver.h"
4
5 /*void Set_RF_Channel(unsigned char channel)
6 {
7 GetReg7FromChip();
8 gReg7_low &= 0x80;
9 gReg7_low |= channel;
10 Reg_write16(0x07, gReg7_high, gReg7_low);
11 }*/
12
13 void Reg_write16(uint8 addr, uint8 v1, uint8 v2){
14 1
15 1
16 1 SPICS = 0;
17 1
18 1 spi_write(addr);
19 1 spi_write(v1);
20 1 spi_write(v2);
21 1
22 1 pdelay(3);
23 1 SPICS = 1;
24 1
25 1 if(addr < 0x20){
26 2 // Wait_mSec(35); // RF register DBUS propergation time
27 2 Wait_mSec(10);
28 2 }
29 1 return;
30 1 }
31
32 uint16 Reg_read16(uint8 addr)
33 {
34 1 uint16 value =0;
35 1 SPICS = 0;
36 1
37 1 spi_write(addr | REG_RD);
38 1
39 1 value = spi_read();
40 1 value <<= 8;
41 1 pdelay(3);
42 1 value |= spi_read();
43 1
44 1 pdelay(3);
45 1 SPICS = 1;
46 1
47 1 return value;
48 1 }
49
50 void spi_write(uint8 spi_bValue){
51 1
52 1 uint8 i;
53 1
54 1 SPICS = 0;
55 1 pdelay(10);
C51 COMPILER V7.10 SPI 12/18/2015 16:49:54 PAGE 2
56 1
57 1 for(i=0; i<8; i++){
58 2
59 2 SPICLK = 1;
60 2 pdelay(10);
61 2 if((spi_bValue&0x80)==0x80){
62 3 SPIMOSI = 1;
63 3 }else{
64 3 SPIMOSI = 0;
65 3 }
66 2 pdelay(10);
67 2 SPICLK = 0;
68 2 pdelay(10);
69 2 spi_bValue = (spi_bValue<<1);
70 2 }
71 1 }
72
73 uint8 spi_read()
74 {
75 1 uint8 i, spi_bValue;
76 1
77 1 SPICS = 0;
78 1 SPICS = 0;
79 1
80 1 for(i=0; i<8; i++)
81 1 {
82 2 SPICLK = 1;
83 2 pdelay(10);
84 2
85 2 spi_bValue <<= 1;
86 2 SPICLK = 0;
87 2 pdelay(10);
88 2
89 2 if(SPIMISO == 1){
90 3
91 3 spi_bValue ++;
92 3 }
93 2
94 2 }
95 1
96 1 SPICLK = 0;
97 1
98 1 return spi_bValue;
99 1 }
100
101
102 //获取寄存器 7 的值
103 uint16 GetReg7FromChip(void)
104 {
105 1 uint16 temp;
106 1
107 1 temp = Reg_read16(0x07);
108 1 gReg7_high = (uint8)((temp&0xff00)>>8);
109 1 gReg7_low = (uint8)(temp&0x00ff);
110 1
111 1 return temp;
112 1 }
113
114 void spi_Send(uint8 *ptr, uint8 bytes) //only tx loop
115 {
116 1 uint8 i;
117 1
C51 COMPILER V7.10 SPI 12/18/2015 16:49:54 PAGE 3
118 1 Reg_write16(0x34,0x80,0x00); //清空邋FIFO
119 1 pdelay(3);
120 1 spi_write(0x32); //Fill data to FIFO;
121 1 spi_write(CMD_BUFF_LEN);
122 1 for(i=0; i<(bytes); i++) //发送数据
123 1 {
124 2 spi_write(*ptr++);
125 2 }
126 1
127 1 SPICS = 1;
128 1 pdelay(3);
129 1
130 1 //Reg_write16(0x07,0x01,0x30); //使能TX
131 1 Reg_write16(0x07, (gReg7_high|0x01), gReg7_low&0x7f); //使能TX
132 1
133 1 //while(P3&0x80 == 0);
134 1 pdelay(3);
135 1 //Reg_write16(0x07,0x00,0x30); //disable TX
136 1 Reg_write16(0x07, (gReg7_high&0xfe), gReg7_low&0x7f); //TX Disable
137 1 }
138
139
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 325 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 14
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/zhanggong/IoT_2G4_Send.git
git@gitee.com:zhanggong/IoT_2G4_Send.git
zhanggong
IoT_2G4_Send
IoT_2G4_Send
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385