⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 在Freescale16位单片机MC9s12dp256上移植了J1939源码和操作系统(ucOSII)。
💻 C
字号:
#include "Includes.h"
#include <hidef.h>      /* common defines and macros */
#include "APPTask.h"
#include "AllJ1939.h"

#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"

//DEFINE AppTaskStart STACK HERE
static OS_STK  OS_STK_START[512]= {0xA5};
//DEFINE AppTaskStart priority HERE
#define INITIALTASK_PRIO   0x3d


/********************************************************************************************************
*                                            FUNCTION PROTOTYPES
********************************************************************************************************/


// DECLARE AppStartTask HERE
static void  AppStartTask(void *pdata);

void AppStartTask_Create(void);
void initTickTimer(void);


/********************************************************************************************************
*                                            initialization functions
********************************************************************************************************/
void initTickTimer(void)
{
#if	OS_TICK_OC	==	7
	 TSCR2	=	0x03;  
    TSCR1	=	0x80;                         /* Enable timer*/
    TIOS |= 0x80;                          /* Make channel an output compare  */
    TC7   = TCNT + OS_TICK_OC_CNTS;
	  TIE  |=	0x80;  								                             
#endif
#if OS_TICK_OC== 8
	RTICTL = 	0x64; /* set RTI prescaler */ 
	CRGINT = 	0x80; /* enable RTI interrupts */ 
#endif
}


/********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary 68HC12 and C initialization.
* Arguments   : none
********************************************************************************************************/
void main(void) {
  /* put your own code here */
  /*var for some initialization*/
  
  /*---- Any initialization code before starting multitasking -----------------------*/
   /* set HW environment */
  PrepareEnvironment();
 // vApp_GraphicsInit(0x8e);

  /*control power relay to close */
  //ClosePowerRelayKey(); 
  /*----Initialization code of J1939 -------------------------------------------*/
  /* [USER DEPENDENT] */
   
  OSInit(); // Initialize "uC/OS-II, The Real-Time Kernel" 
  AppStartTask_Create();//Create other tasks
  OSStart();  /* Start multitasking (i.e. give control to uC/OS-II)  */
  
} 


/*$PAGE*/

/********************************************************************************************************
*                                          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   : pdata   is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
* Notes       : 1) The first line of code is used to prevent a compiler warning because 'pdata' is not
*                  used.  The compiler should not generate any code for this statement.
*               2) Interrupts are enabled once the task start because the I-bit of the CCR register was
*                  set to 0 by 'OSTaskCreate()'.
********************************************************************************************************/
void AppStartTask_Create(void) 
{
  #if OS_TASK_CREATE_EXT_EN
	  OSTaskCreateExt(AppStartTask,
		(void*)0,
		&OS_STK_START[511],
		INITIALTASK_PRIO,
		INITIALTASK_PRIO,
		&OS_STK_START[0],
		128,
		(void*) 0,
		OS_TASK_OPT_STK_CHK|OS_TASK_OPT_STK_CLR);
  #else
	  OSTaskCreate(AppStartTask,
		(void*)0,
		&OS_STK_START[OS_STK_DEFAULT_SIZE-1],
		INITIALTASK_PRIO
		);
  #endif	
}

static void  AppStartTask (void *pdata){
  pdata = pdata;
  initTickTimer();                       /* Initialize the ticker                                 */
  Task_J1939_Create();  
  //Task_DataTOMessage_Create();
  Task_MessageToData_Create();
  //Task_MyCAN_Create();

  while (TRUE){                          /* Task body, always written as an infinite loop.          */
        /*---- Task code goes HERE! -------------------------------------------------------------------*/
       /* OSTimeDly(100);   */           /* Delay task execution for one clock tick                 */
    pdata=pdata;   
    OSTaskSuspend(60);
  }
}
/*$PAGE*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -