spi_1110.lst
来自「时间触发嵌入式系统设计模式:使用8051系列微控制器开发可靠应用」· LST 代码 · 共 113 行
LST
113 行
C51 COMPILER V6.10 SPI_1110 04/19/2001 12:00:57 PAGE 1
C51 COMPILER V6.10, COMPILATION OF MODULE SPI_1110
OBJECT MODULE PLACED IN .\SPI_1110.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE .\SPI_1110.C OPTIMIZE(6,SPEED) BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*------------------------------------------------------------------*-
2
3 SPI_1110.C (v1.00)
4
5 ------------------------------------------------------------------
6
7 Simple SPI library for Atmel AT89S53
8 - allows data to be read from Max1110 / 1111 ADC
9
10
11 COPYRIGHT
12 ---------
13
14 This code is from the book:
15
16 PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
17 [Pearson Education, 2001; ISBN: 0-201-33138-1].
18
19 This code is copyright (c) 2001 by Michael J. Pont.
20
21 See book for copyright details and other information.
22
23 -*------------------------------------------------------------------*/
24
25 #include "Main.H"
26 #include "Port.H"
27
28 #include "SPI_Core.h"
29 #include "SPI_1110.h"
30 #include "TimeoutH.h"
31
32 // ------ Public variable declarations -----------------------------
33
34 // The error code variable
35 //
36 // See Port.H for port on which error codes are displayed
37 // and for details of error codes
38 extern tByte Error_code_G;
39
40 /*------------------------------------------------------------------*-
41
42 SPI_MAX1110_Read_Byte()
43
44 Read a byte of data from the ADC.
45
46 -*------------------------------------------------------------------*/
47 tByte SPI_MAX1110_Read_Byte(void)
48 {
49 1 tByte Data, Data0, Data1;
50 1
51 1 // 0. Pin /CS is pulled low to select the device
52 1 SPI_CS = 0;
53 1
54 1 // 1. Send a MAX1110 control byte
55 1
C51 COMPILER V6.10 SPI_1110 04/19/2001 12:00:57 PAGE 2
56 1 // Bit 7 = 1 (start of control byte)
57 1 // Bit 6 = SEL2
58 1 // Bit 5 = SEL1
59 1 // Bit 4 = SEL0 (these three select the input channel, p9 MAX1110 docs)
60 1 // Bit 3 = 1 for unipolar, 0 for bipolar
61 1 // Bit 2 = 1 for single ended, 0 for differential
62 1 // Bit 1 = 1 for fully operational, 0 for power-down mode
63 1 // Bit 0 = 1 for external clock, 0 for internal clock
64 1 //
65 1 // Control byte 0x8F sets single-ended unipolar mode, input channel 0 (pin 1)
66 1 SPI_Exchange_Bytes(0x8F);
67 1
68 1 // 2. The data requested is shifted out on SO by sending two dummy bytes
69 1 Data0 = SPI_Exchange_Bytes(0x00);
70 1 Data1 = SPI_Exchange_Bytes(0x00);
71 1
72 1 // The data are contained in bits 5-0 of Data0
73 1 // and 7-6 of Data1 - shift these bytes to give a combined byte,
74 1 Data0 <<= 2;
75 1 Data1 >>= 6;
76 1 Data = (Data0 | Data1);
77 1
78 1 // 3. We pull the /CS pin high to complete the operation
79 1 SPI_CS = 1;
80 1
81 1 // 4. We return the required data
82 1 return Data; // Return SPI data byte
83 1 }
84
85 /*------------------------------------------------------------------*-
86 ---- END OF FILE -------------------------------------------------
87 -*------------------------------------------------------------------*/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 40 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 1
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?