📄 app.s
字号:
.module app.c
.area vector(rom, abs)
.org 64
jmp _OSTickISR
.area text(rom, con, rel)
.dbfile E:\ypt050912\XIAZAI\xinzai\UCOSAVR128\app.c
.dbfunc e main _main fV
.even
_main::
sbiw R28,3
.dbline -1
.dbline 79
; /*
; *************************************************************************************************************
; * uC/OS-II
; * The Real-Time Kernel
; *
; * ATmega128 Sample code
; *
; * File : APP.C
; * By : Jean J. Labrosse
; *************************************************************************************************************
; */
;
; #include <includes.h>
;
; /*
; **************************************************************************************************************
; * CONSTANTS
; *
; * Note(s) : 1) See OS_CFG.H for the default stack size: 'OS_TASK_STK_SIZE'
; **************************************************************************************************************
; */
;
; #define CPU_CLK_FREQ 3684000L
;
;
; #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
;
; #define OS_TASK_3_STK_SIZE OS_TASK_STK_SIZE
; #define OS_TASK_3_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];
; OS_STK AppTask3Stk[OS_TASK_3_STK_SIZE];
; /*
; **************************************************************************************************************
; * FUNCTION PROTOTYPES
; **************************************************************************************************************
; */
;
; //void main(void);
; #pragma interrupt_handler OSTickISR:17
;
; static void AppTaskStart(void *p_arg);
; static void AppTaskCreate(void);
; static void AppTask1(void *p_arg);
; static void AppTask2(void *p_arg);
; static void AppTask3(void *p_arg);
;
; static void AppIOInit(void);
;
; static void LED_Toggle(INT8U led);
;
; OS_EVENT *testsem;
; OS_EVENT *testsem1;
; /*
; **************************************************************************************************************
; * 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 83
; /*---- 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,256
ldi R25,1
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 84
; OSTaskHardStkSize = OS_TASK_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,64
ldi R25,0
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 86
;
; OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
xcall _OSInit
.dbline 90
;
; /*---- Any initialization code before starting multitasking ---------------------------------------*/
;
; OSTaskStkSize = OS_TASK_START_STK_SIZE; /* Setup the total stack size */
ldi R24,256
ldi R25,1
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 91
; OSTaskHardStkSize = OS_TASK_START_HARD_STK_SIZE; /* Setup the hardware stack size */
ldi R24,64
ldi R25,0
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 92
; OSTaskCreate(AppTaskStart, (void *)0, (OS_STK *)&AppTaskStartStk[OSTaskStkSize - 1], 4);
ldi R24,4
std y+2,R24
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
xcall _OSTaskCreate
.dbline 95
;
;
; OSTaskStkSize = OS_TASK_3_STK_SIZE; /* Setup the default stack size */
ldi R24,256
ldi R25,1
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 96
; OSTaskHardStkSize = OS_TASK_3_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,64
ldi R25,0
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 97
; OSTaskCreate(AppTask3, (void *)0, (OS_STK *)&AppTask3Stk[OSTaskStkSize - 1], 7);
ldi R24,7
std y+2,R24
ldi R24,<_AppTask3Stk
ldi R25,>_AppTask3Stk
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_AppTask3
ldi R17,>PL_AppTask3
xcall _OSTaskCreate
.dbline 103
; //OSTaskCreate(AppTask3,(void *)0,(OS_STK *)&AppTask3Stk[OS_TASK_3_STK_SIZE-1],7);
; /*---- Create any other task you want before we start multitasking --------------------------------*/
;
; /* Initialize the I/Os */
;
; OSTickISR_Init(); /* Initialize the ticker */
xcall _OSTickISR_Init
.dbline 104
; AppIOInit();
xcall _AppIOInit
.dbline 105
; AppTaskCreate();
xcall _AppTaskCreate
.dbline 107
;
; testsem = OSSemCreate(1);
ldi R16,1
ldi R17,0
xcall _OSSemCreate
sts _testsem+1,R17
sts _testsem,R16
.dbline 108
; testsem1= OSSemCreate(0);
clr R16
clr R17
xcall _OSSemCreate
sts _testsem1+1,R17
sts _testsem1,R16
.dbline 110
;
; OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
xcall _OSStart
.dbline -2
L1:
adiw R28,3
.dbline 0 ; func end
ret
.dbend
.dbfunc s AppTaskStart _AppTaskStart fV
; p_arg -> R20,R21
.even
_AppTaskStart:
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 128
; }
;
; /*
; *********************************************************************************************************
; * 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 129
; p_arg = p_arg; /* Prevent compiler warnings */
xjmp L4
L3:
.dbline 133
.dbline 134
ldi R16,1
xcall _LED_Toggle
.dbline 135
ldi R16,1
ldi R17,0
xcall _OSTimeDly
.dbline 137
L4:
.dbline 133
xjmp L3
X0:
.dbline -2
L2:
xcall 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 155
;
; //OSTaskSuspend(5);
; //OSTaskDel(4);
; while (TRUE) { /* Task body, always written as an infinite loop. */
; LED_Toggle(1);
; OSTimeDly(OS_TICKS_PER_SEC / 50); //10
;
; }
; }
;
;
; /*
; *********************************************************************************************************
; * 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 157
; /*---- Task initialization code goes HERE! --------------------------------------------------------*/
; OSTaskStkSize = OS_TASK_1_STK_SIZE; /* Setup the default stack size */
ldi R24,256
ldi R25,1
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 158
; OSTaskHardStkSize = OS_TASK_1_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,64
ldi R25,0
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 159
; OSTaskCreate(AppTask1, (void *)0, (OS_STK *)&AppTask1Stk[OSTaskStkSize - 1], 5);
ldi R24,5
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
xcall _OSTaskCreate
.dbline 161
;
; OSTaskStkSize = OS_TASK_2_STK_SIZE; /* Setup the default stack size */
ldi R24,256
ldi R25,1
sts _OSTaskStkSize+1,R25
sts _OSTaskStkSize,R24
.dbline 162
; OSTaskHardStkSize = OS_TASK_2_HARD_STK_SIZE; /* Setup the default hardware stack size */
ldi R24,64
ldi R25,0
sts _OSTaskHardStkSize+1,R25
sts _OSTaskHardStkSize,R24
.dbline 163
; OSTaskCreate(AppTask2, (void *)0, (OS_STK *)&AppTask2Stk[OSTaskStkSize - 1], 6);
ldi R24,6
std y+2,R24
ldi R24,<_AppTask2Stk
ldi R25,>_AppTask2Stk
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_AppTask2
ldi R17,>PL_AppTask2
xcall _OSTaskCreate
.dbline -2
L6:
adiw R28,3
.dbline 0 ; func end
ret
.dbend
.dbfunc s AppTask1 _AppTask1 fV
; err -> y+2
; p_arg -> R20,R21
.even
_AppTask1:
xcall push_gset1
movw R20,R16
sbiw R28,3
.dbline -1
.dbline 173
; }
;
; /*
; *********************************************************************************************************
; * TASK #1
; *********************************************************************************************************
; */
;
; static void AppTask1(void *p_arg)
; {
.dbline 175
; INT8U err;
; p_arg = p_arg;
xjmp L9
L8:
.dbline 179
.dbline 180
ldi R16,2
xcall _LED_Toggle
.dbline 182
movw R24,R28
adiw R24,2
std y+1,R25
std y+0,R24
clr R18
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -