📄 sp35_devlib.lst
字号:
C51 COMPILER V8.05a SP35_DEVLIB 06/01/2007 15:22:01 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE SP35_DEVLIB
OBJECT MODULE PLACED IN SP35_DevLib.OBJ
COMPILER INVOKED BY: C:\Program Files\Keil\C51\BIN\C51.EXE SP35_DevLib.c ROM(COMPACT) DEBUG OBJECTEXTEND
line level source
1 /* ****************************************************************************************************/
2 /* Development Library Functions for SP35 Application Development */
3 /* ----------------------------------------------------------------------------------------------- */
4 /* */
-
5 /* Purpose: Software UART, Automatic Register Configurations,... */
6 /* */
7 /* */
8 /* Filename: SP35_DevLib.c */
9 /* */
10 /* Target: SP35 */
11 /* */
12 /* Dev. Envir: Keil Software C51 V7.10 */
13 /* 礦ision2 V2.40 */
14 /* Author: SH */
15 /* */
16 /* History: 15.March 2006: First Release */
17 /* 10.October 2006: Update for Target Datasheet V1.2 */
18 /* */
19 /* Status: Release V1.1 */
20 /* ************************************************************************************************** */
21 /* (C)opyright Infineon Technologies AG. All rights reserved. */
22 /* ****************************************************************************************************/
23
24 /**********************************************************************************
25 Includes
26 ***********************************************************************************/
27 #include "Reg_SP35.h"
28 #include "SP35_DevLib.h"
29
30 /**********************************************************************************
31 Initializes Ports
32 ***********************************************************************************/
33 void RS232_Init(unsigned char Tx, Rx)
34 {
35 1 P1Dir &= ~(Tx); // Set PP2 to Output
36 1 P1Out |= Tx; // TX to IDLE
37 1 P1Dir |= Rx; // Set PP1 to Input
38 1 GPR0 = 0; // Clear GPR0... <- This holds information about Input/OutPut
39 1 GPR0 = ((Tx<<4) | (Rx)); // GPR0 TxPP RxPP
40 1 // xxxx | xxxx
41 1 }
42
43 /**********************************************************************************
44 Un- Initializes Ports
45 ***********************************************************************************/
46 void RS232_UnInit(unsigned char Tx, Rx)
47 {
48 1 P1Dir |= (Tx | Rx); // Set needed Pins to Input again
49 1 }
50
51 /**********************************************************************************
52 Converts from HEX -> ASCII and transmits to UART
53 ***********************************************************************************/
54 void RS232_Send_Hex (unsigned char Byte)
C51 COMPILER V8.05a SP35_DEVLIB 06/01/2007 15:22:01 PAGE 2
55 {
56 1 unsigned char Nibble;
57 1
58 1 Nibble = (Byte >> 4) + 0x30;
59 1 if ( Nibble > 0x39)
60 1 Nibble += 7;
61 1 putchar (Nibble);
62 1 Nibble = (Byte & 0x0F) + 0x30;
63 1 if ( Nibble > 0x39)
64 1 Nibble += 7;
65 1 putchar (Nibble);
66 1 }
67
68 /**********************************************************************************
69 Transmits number of "bits" of a value "dat" - MSB first
70 ***********************************************************************************/
71 void RS232_Send_Bin(char dat, char bits)
72 {
73 1 int i;
74 1 for(i=bits;i>0;i--)
75 1 {
76 2 if ( dat & ( 1<<(i-1) ) )
77 2 putchar('1');
78 2 else
79 2 putchar('0');
80 2 }
81 1 }
82
83 /**********************************************************************************
84 Sends one character to UART
85 ***********************************************************************************/
86 char putchar (char Result)
87 {
88 1 unsigned char i;
89 1 unsigned char TMOD_old, TL0_old, TH0_old;
90 1
91 1 // SAVE olf Timer Registers
92 1 TMOD_old = TMOD;
93 1 TL0_old = TL0;
94 1 TH0_old = TH0;
95 1
96 1 TMOD = 0x12; // Set up Timer Mode 2 and systemclock/8 as timebase
97 1
98 1 // CONFIGURE Timer Values for actual system clock SFR
99 1 if (DSR & 0x80) // IF CRYSTAL IS USED DETERMINE CRYSTAL FREQ AND SET TIMER
100 1 {
101 2 #ifdef _19687500_Crystal_315MHz
102 2 TL0 = 0x40;
103 2 TH0 = 0x40;
104 2 #endif
105 2
106 2 #ifdef _18080000_Crystal_433_92MHz
TL0 = 0x3B;
TH0 = 0x3B;
#endif
110 2 }
111 1
112 1 else // IF RC-HF IS USED USE DEFAULT VALUES
113 1 {
114 2 TL0 = 0x4E;
115 2 TH0 = 0x4E;
116 2 }
C51 COMPILER V8.05a SP35_DEVLIB 06/01/2007 15:22:01 PAGE 3
117 1
118 1 // START Bit
119 1 P1Out &= ~(GPR0>>4); // Set Tx Bit = 0
120 1 T0Run = 1; // Start Timer0
121 1 IDLE = 1; // Wait for a timer event before starting transmission
122 1 T0Full = 0; // Write to Timer full event flag to reset it
123 1
124 1 // DATA Bit [7:0]
125 1 for (i=0; i < 8; i++)
126 1 {
127 2 if (Result & 0x01)
128 2 P1Out |= (GPR0>>4); // Set Tx Bit = 1
129 2 else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -