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

📄 system.c

📁 tms320c6201下的UCOS
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*
* component   :     
*
* module name :     system.c
* date        :     
*
* subcomponent:
*
******************************************************************************
*
* function    :                                                   
*               
*               
* description :                                                   
*
******************************************************************************
*
*
* dependencies:
*			   
*               uC/OS-II The Realtime KERNEL by Jean J. Labrosse
*
* author      : Kenneth Blake - Oberon Data och Elektronik AB
*               ken@oberon.se  www.oberon.se
* history     : 
*
*
******************************************************************************/


#include "includes.h"
#include <dma.h>

void minit(void);


#pragma DATA_SECTION( ClockTaskStack              ,"STACK_AREA" );
#pragma DATA_SECTION( ForSystemSupervisorStack    ,"STACK_AREA" );
#pragma DATA_SECTION( OSTaskIdleStk                 ,"STACK_AREA" );

#pragma DATA_SECTION( TaskOneStack                 ,"STACK_AREA" );
#pragma DATA_SECTION( TaskTwoStack                 ,"STACK_AREA" );
#pragma DATA_SECTION( TaskThreeStack                 ,"STACK_AREA" );
#pragma DATA_SECTION( TaskFourStack                 ,"STACK_AREA" );
#pragma DATA_SECTION( TaskFiveStack                 ,"STACK_AREA" );



far  OS_STK      OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE];  /* Idle task stack                          */

INT32U ClockTaskStack                [CLOCK_TASK_STACK_SIZE                  ] ;
INT32U ForSystemSupervisorStack      [SYSTEM_SUPERVISOR_TASK_STACK_SIZE	 	] ;
INT32U TaskOneStack                  [TASK_ONE_STACK_SIZE            	 	] ;
INT32U TaskTwoStack                  [TASK_TWO_STACK_SIZE            	 	] ;
INT32U TaskThreeStack                 [TASK_THREE_STACK_SIZE            	 	] ;
INT32U TaskFourStack                  [TASK_FOUR_STACK_SIZE            	 	] ;
INT32U TaskFiveStack                  [TASK_FIVE_STACK_SIZE            	 	] ;



KERNEL_S     KERNEL;

volatile unsigned int Volatile_Value_Of_Illegal_Interrupt ;
   
volatile unsigned int
   Always_Enabled_Interrupts  ,
   Normally_Enabled_Interrupts;


SEMAPHORE_S  *Semaphore ;
MAILBOX_S    *MailBox   ;
QUEUE_S      *Queue     ;






/******************************************************************************
*                                                                            
* function    : ClockTask
* description : 
*               2nd level interrupt handler for the clock tick ( one millisecond )
*               The Interrupt handler just sends the event and quickly leaves the
*               interrupt disabled mode. This task may then be interrupted by other                                                             
*               tasks or delayed by tasks with greater priority.                                                             
*                                                                            
* subcomponent : INTERNAL PART
* dependencies: 
*  Input      : 
*  Output     : 
* history     :                                                              
* return value : 
* Cost  :                                                                     
*                                                                            
******************************************************************************/
void        ClockTask(void *data)
{
    INT8U err;
    void *msg ;
    
    /* int 15 is the timer interrupt */
    
    OS_ENTER_CRITICAL();
    Normally_Enabled_Interrupts |= (1<<CPU_INT15) ;
    
    OS_EXIT_CRITICAL();
    
    while (1) 
    {
#define WAIT_FOREVER 0 
              msg = OSMboxPend(MailBox->ForTheClockInterrupt   , WAIT_FOREVER, &err);
              if( err == OS_NO_ERR)
              {
                  OSTimeTick() ; 
                  msg = msg ;
              }

    }

}

void        TaskOne(void *data)
{
    
    while (1) 
    {
            OSTimeDly(1000);  
    }
}
void        TaskTwo(void *data)
{
    INT8U err;
    void *msg ;
    
    
    while (1) 
    {
              msg = OSMboxPend(MailBox->ForTheHostPortInterrupt   , 1000, &err);
              if( err == OS_NO_ERR)
              {
                  msg = msg ;
              }

    }
}

void        TaskThree(void *data)
{
    INT8U err;
    
    
    while (1) 
    {
        OSTimeDly(1);                            /* Delay 1 clock tick                                 */
        OSSemPend(Semaphore->ForTaskThree, 0, &err);           /* Acquire semaphore to  */
        OSTimeDly(3);                            /* Delay                          */
        OSSemPost(Semaphore->ForTaskThree);                    /* Release semaphore                                  */
    }
}

void        TaskFour(void *data)
{
    INT8U err;
    
    
    while (1) 
    {
        OSTimeDly(10);                            /* Delay 1 clock tick                                 */
        OSSemPend(Semaphore->ForTaskThree, 0, &err);           /* Acquire semaphore to  */
        OSMboxPost( MailBox->ForCommunicationBetweenTask4_And_5, (void *)1); 
        OSSemPost(Semaphore->ForTaskThree);                    /* Release semaphore                                  */
    }
}
  

void        TaskFive(void *data)
{
    INT8U err;
    void *msg ;
    
    
    while (1) 
    {
              msg = OSMboxPend(MailBox->ForCommunicationBetweenTask4_And_5   , 1000, &err);
			  msg = msg ; /* get rid of compiler warning */
    }
}
  



  
/******************************************************************************
*                                                                            
* function    : SystemBuild__CreateTasks
* description : 
*               Builds the necessary Tasks that are to be executed in the system                                                           
*                                                                            
* dependencies: 
*  Input      : 
*  Output     : 
* history     :                                                              
* return value : 
* Cost  :                                                                     
*                                                                            
******************************************************************************/

void    SystemBuild__CreateTasks(void)  
{


  KERNEL.Stack.ForTaskOne.StackBuffer = &TaskOneStack[0]  ;
  
  OSTaskCreate( TaskOne,     
                      (void *)NO_DATA_POINTER,   
                      (void *)&KERNEL.Stack.ForTaskOne.StackBuffer[TASK_ONE_STACK_SIZE-1],        
                      TASK_ONE_PRIORITY       );
  

  KERNEL.Stack.ForTaskTwo.StackBuffer = &TaskTwoStack[0]  ;
  OSTaskCreate( TaskTwo,     
                      (void *)NO_DATA_POINTER,   
                      (void *)&KERNEL.Stack.ForTaskTwo.StackBuffer[TASK_TWO_STACK_SIZE-1],        
                      TASK_TWO_PRIORITY       );
  
  KERNEL.Stack.ForTaskThree.StackBuffer = &TaskThreeStack[0]  ;
  OSTaskCreate( TaskThree,     
                      (void *)NO_DATA_POINTER,   
                      (void *)&KERNEL.Stack.ForTaskThree.StackBuffer[TASK_THREE_STACK_SIZE-1],        
                      TASK_THREE_PRIORITY       );
  
  KERNEL.Stack.ForTaskFour.StackBuffer = &TaskFourStack[0]  ;
  OSTaskCreate( TaskFour,     
                      (void *)NO_DATA_POINTER,   
                      (void *)&KERNEL.Stack.ForTaskFour.StackBuffer[TASK_FOUR_STACK_SIZE-1],        
                      TASK_FOUR_PRIORITY       );
  
  KERNEL.Stack.ForTaskFive.StackBuffer = &TaskFiveStack[0]  ;
  OSTaskCreate( TaskFive,     
                      (void *)NO_DATA_POINTER,   
                      (void *)&KERNEL.Stack.ForTaskFive.StackBuffer[TASK_FIVE_STACK_SIZE-1],        
                      TASK_FIVE_PRIORITY       );
  



}	   

/******************************************************************************
*                                                                            
* function    : SystemSupervisor
* description : 
*               Calculates the CPU load of the system
                Preventive maintenance can include very complex diagnostic 
                procedures and background audits intended to detect problems 
                before they become critical. A diagnostic procedure is 
                typically invoked in response to an apparent problem. An audit 
                runs periodically to ensure that the system is in a consistent 
                state.
                
                    Preventive_maintenance(void)
                    SystemSecurity(void)
                    StackCheck(void)
                    ParameterCheck(void)
                    CallerIDCheck(void)


                Performance monitoring and statistics gathering are a form of 
                status feedback to some higher-level control systems (automated
                or human). This data is used to detect if a system is in some 
                type of load imbalance such as overload.

                    Performance_monitoring_and_statistics_gathering(void)
                    LocalDebug(void)
                    Supervisor(void)
                    SystemCallTimeSupervisor(void) 


*               
* dependencies: 
*  Input      : 
*  Output     : 
* history     :                                                              
* return value : 
* Cost  :                                                                     
*                                                                            
******************************************************************************/
void                    SystemSupervisor(void *data)
{
    struct
      {
             INT32U max;

⌨️ 快捷键说明

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