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

📄 os_viewc.c

📁 UCOS-II对freescale的MC9S12NE64的移植范例
💻 C
字号:
/*
*********************************************************************************************************
*                                               uC/OS-View
*
*                           (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
;                                             Freescale HCS12
*********************************************************************************************************
*/

#include <includes.h>

/*$PAGE*/
/*
*********************************************************************************************************
*                                           EXIT uC/OS-View
*
* Description: 
*
* Note(s)    : 
*********************************************************************************************************
*/

void  OSView_Exit (void)
{
}					      

/*
*********************************************************************************************************
*                                           Obtain CPU name 
*********************************************************************************************************
*/

void  OSView_GetCPUName (INT8U *s)
{
    INT32U  cpu_frq;
    
    
    cpu_frq  = BSP_CPU_ClkFreq();
    cpu_frq /= 1000000L;                                                /* Convert from HZ to MHZ                                   */
    
    Str_Copy(s, "MC9S12 (xx MHZ)");
    if ((cpu_frq / 10) > 0) {        
        s[8]   = (cpu_frq /  10) + '0';
    } else {
        s[8]   = 32;                                                   /* Display a 'space' character instead of 'x'               */
    }			
    																					   
    s[9]       = (cpu_frq % 10)  + '0';
}

/*
*********************************************************************************************************
*                                  Obtain Interrupt Stack information
*********************************************************************************************************
*/

INT32U  OSView_GetIntStkBase (void)					  
{
    return (0);										                    /* We are not using an ISR stack                            */
}


INT32U  OSView_GetIntStkSize (void)
{
    return (0);										                    /* We are not using an ISR stack                            */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                    INITIALISE uC/OS-View COM PORT
*
* Description: Initialize the OS-Viewer communication port
*
* Note(s)    : 
*********************************************************************************************************
*/

void  OSView_InitTarget (INT32U baud)
{
    INT32U  baudDiv;
    
    
    baudDiv  = BSP_CPU_ClkFreq();                                       /* Get the CPU frq. Note: Divide by 2 to get the BUS Frq    */
    baudDiv /= (2 * baud * 16);                                         /* Calculate the baud rate divider, Include Div by 2        */
       
#if OS_VIEW_COMM_SEL == 0
    SCI0CR2 = 0x00;                                                     /* disable the receiver, transmitter and interrupts         */
    SCI0BDH = baudDiv >> 8;	                                            /* Calculated Baudrate                                      */
    SCI0BDL = baudDiv & 0xFF;
    SCI0CR1 = 0x00;                                                     /* 8 data bits, no parity, 1 stop bit                       */
    SCI0CR2 = 0x0C;                                                     /* Eenable the receiver and transmiter                      */  
                
#endif

#if OS_VIEW_COMM_SEL == 1
    SCI1CR2 = 0x00;                                                     /* disable the receiver, transmitter and interrupts         */
    SCI1BDH = baudDiv >> 8;	                                            /* Calculated Baudrate                                      */
    SCI1BDL = baudDiv & 0xFF;
    SCI1CR1 = 0x00;                                                     /* 8 data bits, no parity, 1 stop bit                       */
    SCI1CR2 = 0x0C;                                                     /* Enable the receiver and transmiter                       */
#endif
}
    					                                   
/*$PAGE*/
/*
*********************************************************************************************************
*                                       Disable Rx Interrupts
*********************************************************************************************************
*/

void  OSView_RxIntDis (void) 
{
#if OS_VIEW_COMM_SEL == 0
    SCI0CR2 &= ~SCI0SR1_RDRF_MASK;                                      /* Disable SCI Rx Interrupts                                */
#endif

#if OS_VIEW_COMM_SEL == 1
    SCI1CR2 &= ~SCI1SR1_RDRF_MASK;                                      /* Disable SCI Rx Interrupts                                */
#endif
}

/*
*********************************************************************************************************
*                                       Enable Rx Interrupts
*********************************************************************************************************
*/

void  OSView_RxIntEn (void) 
{
#if OS_VIEW_COMM_SEL == 0
    SCI0CR2 |=  SCI0SR1_RDRF_MASK;                                      /* Enable SCI Rx Interrupts                                 */
#endif

#if OS_VIEW_COMM_SEL == 1
    SCI1CR2 |=  SCI1SR1_RDRF_MASK;                                      /* Enable SCI Rx Interrupts                                 */
#endif
}

/*
*********************************************************************************************************
*                                Rx/Tx Communication handler for uC/OS-View
*
* Description:  This function is called to handle a Receive or Transmit Complete Interrupt after the
*               OSView_RxTxISR completes.  
*********************************************************************************************************
*/

void  OSView_RxTxISRHandler (void) 
{
    INT8U  status;
    INT8U  data;
    
        
#if OS_VIEW_COMM_SEL == 0
    status  =  SCI0SR1;                                                 /* Read the status register (part of interrupt clearing)    */
    if ((status & SCI0SR1_RDRF_MASK) == SCI0SR1_RDRF_MASK) {            /* If Receive Interrupt                                     */
        OSView_RxHandler(SCI0DRL);                                      /* Call the generic Rx handler                              */
    } 
    if ((status & SCI0SR1_TC_MASK) == SCI0SR1_TC_MASK) {                /* If Transmit Complete Interrupt                           */
   	    OSView_TxHandler();
    }
#endif

#if OS_VIEW_COMM_SEL == 1
    status  =  SCI1SR1;                                                 /* Read the status register (part of interrupt clearing)    */
    if ((status & SCI1SR1_RDRF_MASK) == SCI1SR1_RDRF_MASK) {            /* If Receive Interrupt                                     */
        OSView_RxHandler(SCI1DRL);                                      /* Call the generic Rx handler                              */
    } else {
        if ((status & SCI1SR1_TC_MASK) == SCI1SR1_TC_MASK) {            /* If Transmit Complete Interrupt                           */
       	    OSView_TxHandler();
        }
    }
#endif   
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                      Communication for uC/OS-View
*
* Description: Send 1 character to COM Port
*
* Note(s)    : 
*********************************************************************************************************
*/

void  OSView_Tx1 (INT8U c) 
{
#if OS_VIEW_COMM_SEL == 0	
    SCI0DRL = c; 
#endif

#if OS_VIEW_COMM_SEL == 1
	SCI1DRL = c;
#endif
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                       Disable Tx Interrupts
*********************************************************************************************************
*/

void  OSView_TxIntDis (void) 
{
#if OS_VIEW_COMM_SEL == 0
    SCI0CR2 &= ~SCI0SR1_TC_MASK;                                        /* disable tx interrupts				                    */
#endif

#if OS_VIEW_COMM_SEL == 1
    SCI1CR2 &= ~SCI1SR1_TC_MASK;                                        /* disable tx interrupts				                    */
#endif      
}

/*
*********************************************************************************************************
*                                       Enable Tx Interrupts
*********************************************************************************************************
*/

void  OSView_TxIntEn (void) 
{
#if OS_VIEW_COMM_SEL == 0
    SCI0CR2 |=  SCI0SR1_TC_MASK;                                        /* enable tx interrupts				                        */
#endif

#if OS_VIEW_COMM_SEL == 1
    SCI1CR2 |=  SCI1SR1_TC_MASK;                                        /* enable tx interrupts				                        */
#endif   
}

/*
*********************************************************************************************************
*                                     READ TIMER FOR uC/OS-View
*
* Description : This function is called to read the current counts of a 16 bit free running timer.
*
* Arguments   : none
*
* Returns     ; The 16 bit count (in a 32 bit variable) of the timer assuming the timer is an UP counter.
*********************************************************************************************************
*/

INT32U  OSView_TmrRd (void)
{
    return  ((INT32U)TCNT);
}


⌨️ 快捷键说明

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