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

📄 os_viewc.c

📁 基于 ST 公司的 ARM-7 使用之 uC/OS-II 作业系统,此例程是移植于 STR-750 上的应用,有支援 OS_View 观察器功能,于 IAR EWARM V4.41A 工程编译,而 u
💻 C
字号:
/*
*********************************************************************************************************
*                                               uC/OS-View
*
*                               (c) Copyright 2004, Micrium, Inc., Weston, FL
*                                           All Rights Reserved
*
*                                            STMicroelectronics
*                                                  STR750
*                                               IAR C Compiler
*
*
* Filename   : os_viewc.c
* Version    :
* Programmer : Brian Nagel
* Note(s)    :
*********************************************************************************************************
*/

#include  <includes.h>

/*
*********************************************************************************************************
*                                           EXIT uC/OS-View
*
* Description: This function is not used in this port.
*********************************************************************************************************
*/

void  OSView_Exit (void)
{

}

/*
*********************************************************************************************************
*                                           Obtain CPU name
*
* Description: This routine allows the OSView application to display the name of the processor.
*********************************************************************************************************
*/

void  OSView_GetCPUName (INT8U *s)
{
    INT8U  cpu_clk_freq;


    cpu_clk_freq = (INT8U)(BSP_CPU_ClkFreq() / 1000000L);       /* Convert cpu_clk_frequency from hz to mhz                 */
    (void)OS_StrCopy(s, "ST STR750 (xx MHz)");
    s[11] = cpu_clk_freq / 10 + '0';
    s[12] = cpu_clk_freq % 10 + '0';}

/*
*********************************************************************************************************
*                                  Obtain Interrupt Stack Base
*
* Description: This function simply returns a zero
* Returns    : 0
*********************************************************************************************************
*/

INT32U  OSView_GetIntStkBase (void)
{
    return ((INT32U)0);                                         /* There is no separate interrupt stack                     */
}

/*
*********************************************************************************************************
*                                  Obtain Interrupt Stack Size
*
* Description: This function simply returns a zero
* Returns    : 0
*********************************************************************************************************
*/

INT32U  OSView_GetIntStkSize (void)
{
    return ((INT32U)0);                                         /* There is no separate interrupt stack                     */
}

/*
*********************************************************************************************************
*                                    INITIALIZE uC/OS-View COM PORT
*
* Description: Initialize the hardware required for the OS to run. It is assumed that the timer has
*              already been initialized by a BSP function.
*********************************************************************************************************
*/

void  OSView_InitTarget (INT32U baud_rate)
{
    UART_InitTypeDef        uart_init_struct;
    EIC_IRQInitTypeDef      eic_irq_init_struct;


    OSView_TmrInit();

#if OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    MRCC_PeripheralClockConfig(MRCC_Peripheral_UART0, ENABLE);      /* Enable  UART clock                                   */
    MRCC_PeripheralSWResetConfig(MRCC_Peripheral_UART0, DISABLE);   /* Release UART reset                                   */

                                                                /* Define UART initialization structure for UART0:          */
    uart_init_struct.UART_WordLength          = UART_WordLength_8D;
    uart_init_struct.UART_StopBits            = UART_StopBits_1;
    uart_init_struct.UART_Parity              = UART_Parity_No;
    uart_init_struct.UART_BaudRate            = baud_rate;
    uart_init_struct.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
    uart_init_struct.UART_Mode                = UART_Mode_Tx_Rx;
    uart_init_struct.UART_FIFO                = UART_FIFO_Disable;
    uart_init_struct.UART_TxFIFOLevel         = UART_FIFOLevel_1_8;
    uart_init_struct.UART_RxFIFOLevel         = UART_FIFOLevel_1_8;
    UART_Init(UART0, &uart_init_struct);                        /* Initialize UART0                                         */

    UART_ITConfig(UART0, UART_IT_Transmit, ENABLE);             /* Enable UART0 transmit interrupt                          */
    UART_Cmd(UART0, ENABLE);                                    /* Enable UART0                                             */

                                                                /* Define IRQ initialization structure for UART0:           */
    eic_irq_init_struct.EIC_IRQChannel          = UART0_IRQChannel;     /* ... Specify UART0 channel;                       */
    eic_irq_init_struct.EIC_IRQChannelPriority  = 3;                    /* ... Use priority of 3;                           */
    eic_irq_init_struct.EIC_IRQChannelCmd       = ENABLE;               /* ... Enable IRQ.                                  */
    EIC_IRQInit(&eic_irq_init_struct);                          /* Initialize TIM0 Update IRQ                               */

    BSP_VectSet(UART0_IRQChannel, OSView_RxTxISRHandler);       /* Set UART0 interrupt vector                               */
#endif
}

/*
*********************************************************************************************************
*                                       Disable Rx Interrupts
*
* Description: Disable receive interrupts from the UART
*********************************************************************************************************
*/

void  OSView_RxIntDis (void)
{
#if  OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    UART_ITConfig(UART0, UART_IT_Receive, DISABLE);
#endif
}

/*
*********************************************************************************************************
*                                       Enable Rx Interrupts
*
* Description: Enable receive interrupts from the UART
*********************************************************************************************************
*/

void  OSView_RxIntEn (void)
{
#if  OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    UART_ITConfig(UART0, UART_IT_Receive, ENABLE);
#endif
}

/*
*********************************************************************************************************
*                                 Rx Communication handler for uC/OS-View
*
* Description: This routine is not used because the UART produces a single interrupt for receives and
*              transmits
*********************************************************************************************************
*/

void  OSView_RxISRHandler (void)
{

}

/*
*********************************************************************************************************
*                                Rx/Tx Communication handler for uC/OS-View
*
* Description: This function is called whenever there is an interrupt from the UART
*********************************************************************************************************
*/

void  OSView_RxTxISRHandler (void)
{
    INT8U   uart_chr;


#if  OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    if (UART_GetITStatus(UART0, UART_IT_Receive) == SET) {
        uart_chr = UART_ReceiveData(UART0);                     /* Receive byte of data                                     */
        UART_ClearITPendingBit(UART0, UART_IT_Receive);         /* Clear pending bit                                        */
        OSView_RxHandler(uart_chr);                             /* Handle byte of data                                      */
    }

    if (UART_GetITStatus(UART0, UART_IT_Transmit) == SET) {
        UART_ClearITPendingBit(UART0, UART_IT_Transmit);        /* Clear pending bit                                        */
        OSView_TxHandler();                                     /* Handle data transmission                                 */
    }

    EIC->IPR = (CPU_INT32U)(1 << UART0_IRQChannel);             /* Clear interrupt pending bit in EIC_IPR register          */
#endif
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                      Transmit a Character
*
* Description: Send 1 character to COM Port
*********************************************************************************************************
*/

void  OSView_Tx1 (INT8U c)
{
#if  OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    UART_SendData(UART0, c);                                    /* Place the character in the TX buffer                     */
#endif
}

/*
*********************************************************************************************************
*                                       Disable Tx Interrupts
*
* Description: This routine disables transmit interrupts from the UART
*********************************************************************************************************
*/

void  OSView_TxIntDis (void)
{
#if  OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    UART_ITConfig(UART0, UART_IT_Transmit, DISABLE);
#endif
}

/*
*********************************************************************************************************
*                                       Enable Tx Interrupts
*
* Description: This routine enables transmit interrupts from the UART
*********************************************************************************************************
*/

void  OSView_TxIntEn (void)
{
#if  OS_VIEW_COMM_SEL == OS_VIEW_UART_0
    UART_ITConfig(UART0, UART_IT_Transmit, ENABLE);
#endif
}


/*
*********************************************************************************************************
*                                 Tx Communication handler for uC/OS-View
*
* Description: This routine is not used because the UART produces a single interrupt for receives and
*              transmits
*********************************************************************************************************
*/

void  OSView_TxISRHandler (void)
{

}













⌨️ 快捷键说明

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