📄 app.s
字号:
.module app.c
.area text(rom, con, rel)
.dbfile F:\AVRPRA~1\ucosii-port2-mega8\app.c
.dbfunc e main _main fV
.even
_main::
sbiw R28,3
.dbline -1
.dbline 75
; /*
; *************************************************************************************************************
; * uC/OS-II
; * The Real-Time Kernel
; *
; * ATmega128 Sample code
; *
; * File : APP.C
; * By : Jean J. Labrosse
; *************************************************************************************************************
; */
;
; #include "includes.h"
; #include "iom8v.h"
; #include "1602LCD.h"
; /*
; **************************************************************************************************************
; * CONSTANTS
; *
; * Note(s) : 1) See OS_CFG.H for the default stack size: 'OS_TASK_STK_SIZE'
; **************************************************************************************************************
; */
;
; #define CPU_CLK_FREQ 8000000L
;
;
; #define OS_TASK_START_STK_SIZE OS_TASK_STK_SIZE
; #define OS_TASK_START_HARD_STK_SIZE OS_TASK_HARD_STK_SIZE
;
; #define OS_TASK_1_STK_SIZE OS_TASK_STK_SIZE
; #define OS_TASK_1_HARD_STK_SIZE OS_TASK_HARD_STK_SIZE
;
; #define OS_TASK_2_STK_SIZE OS_TASK_STK_SIZE
; #define OS_TASK_2_HARD_STK_SIZE OS_TASK_HARD_STK_SIZE
;
;
; /*
; **************************************************************************************************************
; * VARIABLES
; **************************************************************************************************************
; */
;
; OS_STK AppTaskStartStk[OS_TASK_START_STK_SIZE];
; OS_STK AppTask1Stk[OS_TASK_1_STK_SIZE];
; OS_STK AppTask2Stk[OS_TASK_2_STK_SIZE];
;
; /*
; **************************************************************************************************************
; * FUNCTION PROTOTYPES
; **************************************************************************************************************
; */
;
; void main(void);
;
; static void AppTaskStart(void *p_arg);
; static void AppTaskCreate(void);
; static void AppTask1(void *p_arg);
; static void AppTask2(void *p_arg);
;
; static void AppIOInit(void);
;
; static void LED_Toggle(INT8U led);
; unsigned char *i;
; /*
; **************************************************************************************************************
; * MAIN
; *
; * Note(s): 1) You SHOULD use OS_TASK_STK_SIZE (see OS_CFG.H) when setting OSTaskStkSize prior to calling
; * OSInit() because OS_TASK_IDLE_STK_SIZE and OS_TASK_STAT_STK_SIZE are set to this value in
; * OS_CFG.H.
; **************************************************************************************************************
; */
;
; void main (void)
; {
.dbline 79
; /*---- Any initialization code prior to calling OSInit() goes HERE --------------------------------*/
;
; /* IMPORTANT: MUST be setup before calling 'OSInit()' */
; OSTaskStkSize = OS_TASK_STK_SIZE; /* Setup the default stack size */
ldi R24,128
ldi R25,0
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 80
; OSTaskHardStkSize = OS_TASK_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,32
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 82
;
; OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
rcall _OSInit
.dbline 86
;
; /*---- Any initialization code before starting multitasking ---------------------------------------*/
;
; OSTaskStkSize = OS_TASK_START_STK_SIZE; /* Setup the total stack size */
ldi R24,128
ldi R25,0
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 87
; OSTaskHardStkSize = OS_TASK_START_HARD_STK_SIZE; /* Setup the hardware stack size */
ldi R24,32
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 88
; OSTaskCreate(AppTaskStart, (void *)0, (OS_STK *)&AppTaskStartStk[OSTaskStkSize - 1], 0);
clr R2
std y+2,R2
ldi R24,<_AppTaskStartStk
ldi R25,>_AppTaskStartStk
lds R30,_OSTaskStkSize
lds R31,_OSTaskStkSize+1
sbiw R30,1
add R30,R24
adc R31,R25
std y+1,R31
std y+0,R30
clr R18
clr R19
ldi R16,<PL_AppTaskStart
ldi R17,>PL_AppTaskStart
rcall _OSTaskCreate
.dbline 92
;
; /*---- Create any other task you want before we start multitasking --------------------------------*/
;
; OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
rcall _OSStart
.dbline -2
L3:
adiw R28,3
.dbline 0 ; func end
ret
.dbend
.dbfunc s AppTaskStart _AppTaskStart fV
; p_arg -> R20,R21
.even
_AppTaskStart:
rcall push_gset1
movw R20,R16
sbiw R28,4
.dbline -1
.dbline 110
; }
;
; /*
; *********************************************************************************************************
; * STARTUP TASK
; *
; * Description : This is an example of a startup task. As mentioned in the book's text, you MUST
; * initialize the ticker only once multitasking has started.
; *
; * Arguments : p_arg is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
; *
; * Notes : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
; * used. The compiler should not generate any code for this statement.
; *********************************************************************************************************
; */
;
; static void AppTaskStart (void *p_arg)
; {
.dbline 111
; p_arg = p_arg; /* Prevent compiler warnings */
.dbline 113
;
; OSTickISR_Init(); /* Initialize the ticker */
rcall _OSTickISR_Init
.dbline 115
;
; AppIOInit(); /* Initialize the I/Os */
rcall _AppIOInit
.dbline 116
; LCD_init();
rcall _LCD_init
.dbline 117
; AppTaskCreate();
rcall _AppTaskCreate
rjmp L6
L5:
.dbline 119
.dbline 123
clr R18
clr R19
ldi R16,1
ldi R17,0
rcall _LCD_write_char
.dbline 125
ldi R24,<L8
ldi R25,>L8
std y+1,R25
std y+0,R24
clr R18
clr R16
rcall _LCD_write_string
.dbline 126
clr R2
clr R3
std y+3,R3
std y+2,R2
ldi R24,3
std y+0,R24
clr R18
clr R16
rcall _OSTimeDlyHMSM
.dbline 127
L6:
.dbline 119
rjmp L5
X0:
.dbline -2
L4:
adiw R28,4
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r p_arg 20 pV
.dbend
.dbfunc s AppTaskCreate _AppTaskCreate fV
.even
_AppTaskCreate:
sbiw R28,3
.dbline -1
.dbline 145
;
; while (TRUE) { /* Task body, always written as an infinite loop. */
; //LED_Toggle(1);
; //OSTimeDly(OS_TICKS_PER_SEC / 10);
;
; LCD_write_char(0x01,0); /*显示清屏 */
;
; LCD_write_string(0,0,"Welcome");
; OSTimeDlyHMSM(0,0,3,0);
; }
; }
;
;
; /*
; *********************************************************************************************************
; * CREATE APPLICATION TASKS
; *
; * Description : This function creates the application tasks.
; *
; * Arguments : p_arg is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
; *
; * Notes : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
; * used. The compiler should not generate any code for this statement.
; *********************************************************************************************************
; */
;
; static void AppTaskCreate (void)
; {
.dbline 147
; /*---- Task initialization code goes HERE! --------------------------------------------------------*/
; OSTaskStkSize = OS_TASK_1_STK_SIZE; /* Setup the default stack size */
ldi R24,128
ldi R25,0
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 148
; OSTaskHardStkSize = OS_TASK_1_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,32
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 149
; OSTaskCreate(AppTask1, (void *)0, (OS_STK *)&AppTask1Stk[OSTaskStkSize - 1], 1);
ldi R24,1
std y+2,R24
ldi R24,<_AppTask1Stk
ldi R25,>_AppTask1Stk
lds R30,_OSTaskStkSize
lds R31,_OSTaskStkSize+1
sbiw R30,1
add R30,R24
adc R31,R25
std y+1,R31
std y+0,R30
clr R18
clr R19
ldi R16,<PL_AppTask1
ldi R17,>PL_AppTask1
rcall _OSTaskCreate
.dbline 151
;
; OSTaskStkSize = OS_TASK_2_STK_SIZE; /* Setup the default stack size */
ldi R24,128
ldi R25,0
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 152
; OSTaskHardStkSize = OS_TASK_2_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,32
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -