?? test.c
字號:
/******************************************************************************
* File: TEST.C
*
* Description: This is a test application for uC/OS.
*
* Comments:
*
* Revision Control:
* $Revision: $
* $Date: $
* $Log: $
*****************************************************************************/
#include <ioas.h>
#include <stdio.h>
#include "includes.h"
/* Initialize IO ports */
#define DDRA_INIT 0x01 /* PTA0 is output */
#define DDRB_INIT 0x08 /* PTB3 is output */
#define DDRC_INIT 0x1F /* PTC - All outputs */
#define DDRD_INIT 0x00 /* PTD - All inputs */
#define DDRE_INIT 0xFF /* PTE - All outputs */
#define DDRF_INIT 0x0F /* PTF - All outputs */
/* Initialize SCI */
#define SCC1_INIT 0x00
#define SCC2_INIT 0x00
#define SCC3_INIT 0x00
/* Initialize IRQ */
#define ISCR_INIT 0x06 /* Acknowledge and turn on interrupt mask */
/* Initialize CGM */
#define PCTL_INIT 0x0F /* PLL off */
#define PPG_INIT 0x00 /* VCO multiplier = 1 */
/* Bit to turn on external switched power */
#define PTB_SWITCHED_POWER 0x08
/** Application Stack "variables" including the system IdleTask **/
#define TASK_STK_SIZE 32
INT8U Task1Stk[TASK_STK_SIZE];
INT8U Task2Stk[TASK_STK_SIZE];
INT8U Task3Stk[TASK_STK_SIZE];
/********************************************************************/
/** The actual multitasked code starts here **/
void Task1(void* pdata)
{
for(;;)
{
/* Turn off the COP watchdog (set to pet when done debugging) */
COPCTL = 0;
/* Delay 0.5 second */
OSTimeDly(24);
}
}
void Task2(void* pdata)
{
for(;;)
{
/* Delay 1 second */
OSTimeDly(49);
}
}
void Task3(void* pdata)
{
for(;;)
{
/* Delay 2 seconds */
OSTimeDly(99);
}
}
/** The multitasked code ends here **/
/********************************************************************/
int main()
{
/* Initialize the hardware */
HardwareInit();
/* Initialize the OS, create the tasks and start */
OSInit();
OSTaskCreate(Task1, (void*)0, (void*)&Task1Stk[TASK_STK_SIZE], 50);
OSTaskCreate(Task2, (void*)0, (void*)&Task2Stk[TASK_STK_SIZE], 51);
OSTaskCreate(Task3, (void*)0, (void*)&Task3Stk[TASK_STK_SIZE], 52);
OSStart();
return 0; //This will never happen...
}
void HardwareInit(void)
{
/* Initialize CGM */
PCTL = PCTL_INIT; /* PLL off */
PPG = PPG_INIT; /* VCO multiplier = 1 */
/* Initialize IO ports */
PTA = 0;
DDRA = DDRA_INIT;
PTB = PTB_SWITCHED_POWER;
DDRB = DDRB_INIT;
PTC = 0;
DDRC = DDRC_INIT;
PTD = 0;
DDRD = DDRD_INIT;
PTE = 0;
DDRE = DDRE_INIT;
PTF = 0;
DDRF = DDRF_INIT;
/* Initialize SCI */
SCC1 = SCC1_INIT;
SCC2 = SCC2_INIT;
SCC3 = SCC3_INIT;
/* Initialize IRQ input */
ISCR = ISCR_INIT;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -