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

📄 os_viewc.c

📁 uCOS在PIC芯片中的移植:以PIC24HJ64GP210为例进行uCOS在Microchip芯片中的移植
💻 C
字号:
/*
*********************************************************************************************************
*                                               uC/OS-View
*
*                                 (c) Copyright 2005, Micrium, Weston, FL
*                                           All Rights Reserved
*
*                                           Microchip PIC24FJ
*                                        MPLab Microchip Compiler
*
*
* Filename   : OS_VIEWc.C
* Version    : V1.00
* Programmer : Eric Shufro
*********************************************************************************************************
*/

#include <includes.h>

/*
*********************************************************************************************************
*                                              CONSTANTS
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                           EXIT uC/OS-View
*
* Description: This function is called if your target needs to 'uninstall' uC/OS-View.
*
* Note(s)    :
*********************************************************************************************************
*/

void  OSView_Exit (void)
{
}

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

void  OSView_GetCPUName (char *s)
{
    INT8U  cpu_clk_freq;


    cpu_clk_freq = (INT8U)(BSP_CPU_ClkFrq() / 1000000L);
    (void)OS_StrCopy(s, "PIC24 (-- MHz)");
    s[7]  = cpu_clk_freq / 10   +  '0';
    s[8] = cpu_clk_freq % 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 UART2 for use with OSView
*
* Note(s)    : 1) This function assumes that a free running timer can be initialized.  The timer can
*                 either be a 16 bits or 32 bits timer.  Your application needs to provide a function
*                 called OSView_TmrRd() that reads the current count of this timer.  The free running
*                 timer is initialized by the BSP function OSView_TmrInit().
*
*              2) The UART must be enabled (U2MODE Register) before it may be configured. Otherwise,
*                 improper operation will result.
*********************************************************************************************************
*/

//tbh080521b
//void  OSView_InitTarget (INT32U baud_rate)
//{
//    INT32U  Fcy;
//
//
//    OSView_TmrInit();                                                       /* Initialize the free running timer.					*/
//
//    Fcy              	=  BSP_CPU_ClkFrq();                                /* Get the Fcy frequency which drives the UART			*/
//    U2BRG	            = (INT16U)((Fcy / (16 * baud_rate)) - 1);           /* Compute divisor for desired baud rate                */
//
//	U2MODE              =  UART_EN;                                         /* Enable the UART with the parameters 8N1              */
//    
//    U2STA               =  UTXEN | UTXISEL;                                 /* Enable the transmitter, configure the Tx and Rx      */
//                                                                            /* interrupt modes, but do not enable interrupts        */
//                                                                            /* Tx Interrupt Mode is set for Tx Shift Reg Empty      */
//                                                                            /* Rx Interrupt Mode is set to Interrupt for each Rx    */
//    
//    IFS1               &= ~(U2TXIF | U2RXIF);                               /* Clear pending interrupts                             */
//
//    //tbh080521b
////    IPC6               &= ~U2TXIP_MASK;                                     /* Clear the UART2 Tx priority bits                     */
////    IPC6               &= ~U2RXIP_MASK;                                     /* Clear the UART2 Rx priority bits                     */
////    IPC6               |= (OSVIEW_INT_PRIO << 0) | (OSVIEW_INT_PRIO << 4);  /* Configure the UART2 Rx and Tx interrupt priorities   */
//    IPC7               &= ~U2TXIP_MASK;                                     /* Clear the UART2 Tx priority bits                     */
//    IPC7               &= ~U2RXIP_MASK;                                     /* Clear the UART2 Rx priority bits                     */
//    IPC7               |= (OSVIEW_INT_PRIO << 8) | (OSVIEW_INT_PRIO << 12);  /* Configure the UART2 Rx and Tx interrupt priorities   */
//    //tbh080521e
//}
//tbh080521e
/*$PAGE*/
/*
*********************************************************************************************************
*                                       Disable Rx Interrupts
*********************************************************************************************************
*/

void  OSView_RxIntDis (void)
{
    IEC1    &= ~U2RXIE;                                                     /* Disable Rs Interrupts                                */
}

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

void  OSView_RxIntEn (void)
{
    IEC1    |=  U2RXIE;                                                     /* Enable Receive Interrupts                            */
}

/*
*********************************************************************************************************
*                                 Rx Communication handler for uC/OS-View
*
* Description: This function is called by OSView_RxISR (see OS_VIEWa.ASM) to process a received
*              character interrupt.
*********************************************************************************************************
*/

void  OSView_RxISRHandler (void)
{
    OSView_RxHandler(U2RXREG);                                              /* Call the generic Rx handler with the received data   */
}

/*
*********************************************************************************************************
*                                 Tx Communication handler for uC/OS-View
*                                            (PORT SPECIFIC)
*
* Description: Handle transmission of a character
*
* Note(s)    : 1) This function is called by OSView_TxISR (see OS_VIEWa.ASM)
*********************************************************************************************************
*/

void  OSView_TxISRHandler (void)
{
    OSView_TxHandler();                                                     /* Call the Tx handler                                  */
}

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

void  OSView_Tx1 (INT8U c)
{
    U2TXREG = c;
}

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

void  OSView_TxIntDis (void)
{
    IEC1   &= ~U2TXIE;                                                      /* Disable Tx interrupts                                */
}

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

void  OSView_TxIntEn (void)
{
    IEC1   |=  U2TXIE;                                                      /* Enable Tx interrupts                                 */
}




⌨️ 快捷键说明

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