📄 2_01_12g.lst
字号:
220 =3
221 =3
33 =2
34 =2 // Include oscillator / chip details here
35 =2 // (essential if generic delays / timeouts are used)
36 =2 // -
37 =2 // Oscillator / resonator frequency (in Hz) e.g. (11059200UL)
38 =2 #define OSC_FREQ (12000000UL)
39 =2
40 =2 // Number of oscillations per instruction (4, 6 or 12)
41 =2 // 12 - Original 8051 / 8052 and numerous modern versions
42 =2 // 6 - Various Infineon and Philips devices, etc.
43 =2 // 4 - Dallas, etc.
44 =2 //
45 =2 // Take care with Dallas devices
46 =2 // - Timers default to *12* osc ticks unless CKCON is modified
47 =2 // - If using generic code on a Dallas device, use 12 here
48 =2 #define OSC_PER_INST (12)
49 =2
50 =2 //------------------------------------------------------------------
51 =2 // SHOULD NOT NEED TO EDIT THE SECTIONS BELOW
52 =2 //------------------------------------------------------------------
53 =2 typedef unsigned char tByte;
54 =2 typedef unsigned int tWord;
55 =2 typedef unsigned long tLong;
56 =2
57 =2 // Misc #defines
58 =2 #ifndef TRUE
59 =2 #define FALSE 0
60 =2 #define TRUE (!FALSE)
61 =2 #endif
62 =2
63 =2 #define RETURN_NORMAL (bit) 0
64 =2 #define RETURN_ERROR (bit) 1
65 =2
66 =2
67 =2 //------------------------------------------------------------------
68 =2 // Interrupts
69 =2 // - see Chapter 13.
70 =2 //------------------------------------------------------------------
71 =2
72 =2 // Generic 8051/52 timer interrupts (used in most schedulers)
73 =2 #define INTERRUPT_Timer_0_Overflow 1
74 =2 #define INTERRUPT_Timer_1_Overflow 3
75 =2 #define INTERRUPT_Timer_2_Overflow 5
76 =2
77 =2 // Additional interrupts (used in shared-clock schedulers)
78 =2 #define INTERRUPT_EXTERNAL_0 0
79 =2 #define INTERRUPT_EXTERNAL_1 2
80 =2 #define INTERRUPT_UART_Rx_Tx 4
81 =2 #define INTERRUPT_CAN_c515c 17
82 =2
83 =2 //------------------------------------------------------------------
84 =2 // Error codes
85 =2 // - see Chapter 14.
86 =2 //------------------------------------------------------------------
87 =2
88 =2 #define ERROR_SCH_TOO_MANY_TASKS (1)
89 =2 #define ERROR_SCH_CANNOT_DELETE_TASK (2)
90 =2
91 =2 #define ERROR_SCH_WAITING_FOR_SLAVE_TO_ACK (3)
92 =2 #define ERROR_SCH_WAITING_FOR_START_COMMAND_FROM_MASTER (3)
C51 COMPILER V8.05a 2_01_12G 06/07/2007 19:40:26 PAGE 7
93 =2
94 =2 #define ERROR_SCH_ONE_OR_MORE_SLAVES_DID_NOT_START (4)
95 =2 #define ERROR_SCH_LOST_SLAVE (5)
96 =2
97 =2 #define ERROR_SCH_CAN_BUS_ERROR (6)
98 =2
99 =2 #define ERROR_I2C_WRITE_BYTE (10)
100 =2 #define ERROR_I2C_READ_BYTE (11)
101 =2 #define ERROR_I2C_WRITE_BYTE_AT24C64 (12)
102 =2 #define ERROR_I2C_READ_BYTE_AT24C64 (13)
103 =2 #define ERROR_I2C_DS1621 (14)
104 =2
105 =2 #define ERROR_USART_TI (21)
106 =2 #define ERROR_USART_WRITE_CHAR (22)
107 =2
108 =2 #define ERROR_SPI_EXCHANGE_BYTES_TIMEOUT (31)
109 =2 #define ERROR_SPI_X25_TIMEOUT (32)
110 =2 #define ERROR_SPI_MAX1110_TIMEOUT (33)
111 =2
112 =2 #define ERROR_ADC_MAX150_TIMEOUT (44)
113 =2
114 =2 #endif
115 =2
116 =2 /*------------------------------------------------------------------*-
117 =2 ---- END OF FILE -------------------------------------------------
118 =2 -*------------------------------------------------------------------*/
25 =1 #include "SCH51.H"
1 =2 /*------------------------------------------------------------------*-
2 =2
3 =2 SCH51.H (v1.00)
4 =2
5 =2 ------------------------------------------------------------------
6 =2
7 =2 - see SCH51.C for details
8 =2
9 =2
10 =2 COPYRIGHT
11 =2 ---------
12 =2
13 =2 This code is from the book:
14 =2
15 =2 PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
16 =2 [Pearson Education, 2001; ISBN: 0-201-33138-1].
17 =2
18 =2 This code is copyright (c) 2001 by Michael J. Pont.
19 =2
20 =2 See book for copyright details and other information.
21 =2
22 =2 -*------------------------------------------------------------------*/
23 =2
24 =2 #ifndef _SCH51_H
25 =2 #define _SCH51_H
26 =2
27 =2 #include "Main.h"
1 =3 /*------------------------------------------------------------------*-
2 =3
3 =3 Main.H (v1.00)
4 =3
5 =3 ------------------------------------------------------------------
6 =3
7 =3 'Project Header' (see Chap 9) for project LED_TIME (see Chap 21)
8 =3
C51 COMPILER V8.05a 2_01_12G 06/07/2007 19:40:26 PAGE 8
9 =3
10 =3 COPYRIGHT
11 =3 ---------
12 =3
13 =3 This code is from the book:
14 =3
15 =3 PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
16 =3 [Pearson Education, 2001; ISBN: 0-201-33138-1].
17 =3
18 =3 This code is copyright (c) 2001 by Michael J. Pont.
19 =3
20 =3 See book for copyright details and other information.
21 =3
22 =3 -*------------------------------------------------------------------*/
23 =3
24 =3 #ifndef _MAIN_H
=3 #define _MAIN_H
=3
=3 //------------------------------------------------------------------
=3 // WILL NEED TO EDIT THIS SECTION FOR EVERY PROJECT
=3 //------------------------------------------------------------------
=3
=3 // Must include the appropriate microcontroller header file here
=3 #include <AT89x52.h>
=3
=3 // Include oscillator / chip details here
=3 // (essential if generic delays / timeouts are used)
=3 // -
=3 // Oscillator / resonator frequency (in Hz) e.g. (11059200UL)
=3 #define OSC_FREQ (12000000UL)
=3
=3 // Number of oscillations per instruction (4, 6 or 12)
=3 // 12 - Original 8051 / 8052 and numerous modern versions
=3 // 6 - Various Infineon and Philips devices, etc.
=3 // 4 - Dallas, etc.
=3 //
=3 // Take care with Dallas devices
=3 // - Timers default to *12* osc ticks unless CKCON is modified
=3 // - If using generic code on a Dallas device, use 12 here
=3 #define OSC_PER_INST (12)
=3
=3 //------------------------------------------------------------------
=3 // SHOULD NOT NEED TO EDIT THE SECTIONS BELOW
=3 //------------------------------------------------------------------
=3 typedef unsigned char tByte;
=3 typedef unsigned int tWord;
=3 typedef unsigned long tLong;
=3
=3 // Misc #defines
=3 #ifndef TRUE
=3 #define FALSE 0
=3 #define TRUE (!FALSE)
=3 #endif
=3
=3 #define RETURN_NORMAL (bit) 0
=3 #define RETURN_ERROR (bit) 1
=3
=3
=3 //------------------------------------------------------------------
=3 // Interrupts
=3 // - see Chapter 13.
=3 //------------------------------------------------------------------
C51 COMPILER V8.05a 2_01_12G 06/07/2007 19:40:26 PAGE 9
=3
=3 // Generic 8051/52 timer interrupts (used in most schedulers)
=3 #define INTERRUPT_Timer_0_Overflow 1
=3 #define INTERRUPT_Timer_1_Overflow 3
=3 #define INTERRUPT_Timer_2_Overflow 5
=3
=3 // Additional interrupts (used in shared-clock schedulers)
=3 #define INTERRUPT_EXTERNAL_0 0
=3 #define INTERRUPT_EXTERNAL_1 2
=3 #define INTERRUPT_UART_Rx_Tx 4
=3 #define INTERRUPT_CAN_c515c 17
=3
=3 //------------------------------------------------------------------
=3 // Error codes
=3 // - see Chapter 14.
=3 //------------------------------------------------------------------
=3
=3 #define ERROR_SCH_TOO_MANY_TASKS (1)
=3 #define ERROR_SCH_CANNOT_DELETE_TASK (2)
=3
=3 #define ERROR_SCH_WAITING_FOR_SLAVE_TO_ACK (3)
=3 #define ERROR_SCH_WAITING_FOR_START_COMMAND_FROM_MASTER (3)
=3
=3 #define ERROR_SCH_ONE_OR_MORE_SLAVES_DID_NOT_START (4)
=3 #define ERROR_SCH_LOST_SLAVE (5)
=3
=3 #define ERROR_SCH_CAN_BUS_ERROR (6)
=3
=3 #define ERROR_I2C_WRITE_BYTE (10)
=3 #define ERROR_I2C_READ_BYTE (11)
=3 #define ERROR_I2C_WRITE_BYTE_AT24C64 (12)
=3 #define ERROR_I2C_READ_BYTE_AT24C64 (13)
=3 #define ERROR_I2C_DS1621 (14)
=3
=3 #define ERROR_USART_TI (21)
=3 #define ERROR_USART_WRITE_CHAR (22)
=3
=3 #define ERROR_SPI_EXCHANGE_BYTES_TIMEOUT (31)
=3 #define ERROR_SPI_X25_TIMEOUT (32)
=3 #define ERROR_SPI_MAX1110_TIMEOUT (33)
=3
=3 #define ERROR_ADC_MAX150_TIMEOUT (44)
=3
=3 #endif
115 =3
116 =3 /*------------------------------------------------------------------*-
117 =3 ---- END OF FILE -------------------------------------------------
118 =3 -*------------------------------------------------------------------*/
28 =2
29 =2 // ------ Public data type declarations ----------------------------
30 =2
31 =2 // Store in DATA area, if possible, for rapid access
32 =2 // Total memory per task is 7 bytes
33 =2 typedef data struct
34 =2 {
35 =2 // Pointer to the task (must be a 'void (void)' function)
36 =2 void (code * pTask)(void);
37 =2
38 =2 // Delay (ticks) until the function will (next) be run
39 =2 // - see SCH_Add_Task() for further details
40 =2 tWord Delay;
41 =2
C51 COMPILER V8.05a 2_01_12G 06/07/2007 19:40:26 PAGE 10
42 =2 // Interval (ticks) between subsequent runs.
43 =2 // - see SCH_Add_Task() for further details
44 =2 tWord Period;
45 =2
46 =2 // Incremented (by scheduler) when task is due to execute
47 =2 tByte RunMe;
48 =2 } sTask;
49 =2
50 =2 // ------ Public function prototypes -------------------------------
51 =2
52 =2 // Core scheduler functions
53 =2 void SCH_Dispatch_Tasks(void);
54 =2 tByte SCH_Add_Task(void (code*) (void), const tWord, const tWord);
55 =2 bit SCH_Delete_Task(const tByte);
56 =2 void SCH_Report_Status(void);
57 =2
58 =2 // ------ Public constants -----------------------------------------
59 =2
60 =2 // The maximum number of tasks required at any one time
61 =2 // during the execution of the program
62 =2 //
63 =2 // MUST BE ADJUSTED FOR EACH NEW PROJECT
64 =2 #define SCH_MAX_TASKS (3)
65 =2
66 =2 #endif
67 =2
68 =2 /*------------------------------------------------------------------*-
69 =2 ---- END OF FILE -------------------------------------------------
70 =2 -*------------------------------------------------------------------*/
71 =2
26 =1
27 =1
28 =1 // ------ Public function prototypes -------------------------------
29 =1
30 =1 void SCH_Init_T2(void);
31 =1 void SCH_Start(void);
32 =1
33 =1 /*------------------------------------------------------------------*-
34 =1 ---- END OF FILE -------------------------------------------------
35 =1 -*------------------------------------------------------------------*/
36 =1
28
29 // ------ Public variable declarations -----------------------------
30
31 // The array of tasks (see Sch51.C)
32 extern sTask SCH_tasks_G[SCH_MAX_TASKS];
33
34 // Used to display the error code
35 // See Main.H for details of error codes
36 // See Port.H for details of the error port
37 extern tByte Error_code_G;
38
39 /*------------------------------------------------------------------*-
40
41 SCH_Init_T2()
42
43 Scheduler initialisation function. Prepares scheduler
44 data structures and sets up timer interrupts at required rate.
45
46 You must call this function before using the scheduler.
47
48 -*------------------------------------------------------------------*/
C51 COMPILER V8.05a 2_01_12G 06/07/2007 19:40:26 PAGE 11
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -