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

📄 os_viewc.c

📁 uCOS-II 2.8和uC-TCP/IP在ATMEL AT91SAM9261上移植
💻 C
字号:
/*
*********************************************************************************************************
*                                               uC/OS-View
*
*                                 (c) Copyright 2005, Micrium, Weston, FL
*                                           All Rights Reserved
*
*                                          Atmel AT91SAM7X256
*                                             IAR C Compiler
*
*
* Filename   : OS_VIEWc.C
* Version    : V1.20
* Programmer : Eric Shufro
*********************************************************************************************************
*/

#include <includes.h>


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

/*
*********************************************************************************************************
*                                              PROTOTYPES
*********************************************************************************************************
*/

extern  void  Sys_Int_Handler(void);

/*
*********************************************************************************************************
*                                           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 (INT8U *s)
{
    INT8U  cpu_clk_frq;


    cpu_clk_frq = (INT8U)(BSP_PCK_Frq() / 1000000L);            /* Convert cpu_clk_frequency from Hz to Mhz   */
    (void)OS_StrCopy(s, "AT91SAM9261 (xxx MHz)");
    s[13] = cpu_clk_frq /  100      + '0';
    s[14] = cpu_clk_frq /  10 % 10  + '0';
    s[15] = cpu_clk_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 hardware required for the OS to run. This will work on any target hardware,
*              but may have to be tailored a little (regarding the clock frequency). Of course the same
*              holds true if for some reason you choose to use another timer.
*
* Note(s)    : 1) This function assumes that a free running timer has been 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 counts of this timer.  The free running
*                 timer is initialized by the BSP function OSView_TmrInit().
*********************************************************************************************************
*/

void  OSView_InitTarget (INT32U baud_rate)
{
    INT32U     peripheral_clk_frq;


    OSView_TmrInit();                                           /* Initialize the free running timer          */
    peripheral_clk_frq         = BSP_MCK_Frq();                 /* peripheral_clk_freq = MCLK (set in US_MR)  */

#if OS_VIEW_COMM_SEL == DBGU
    AT91C_BASE_PIOA->PIO_PDR   = 0x00000600;                    /* Set GPIOA pins 9 and 10 as DBGU UART pins  */
    AT91C_BASE_PIOA->PIO_ASR   = 0x00000600;                    /* Select GPIOA attached peripheral (DBGU)    */

    AT91C_BASE_DBGU->DBGU_IDR  = AT91C_US_RXRDY         |       /* Disable Rx interrupts                      */
                                 AT91C_US_TXRDY;                /* Disable Tx interrupt                       */

    AT91C_BASE_DBGU->DBGU_CR   = AT91C_US_RXEN          |       /* Enable the receiver                        */
                                 AT91C_US_TXEN;                 /* Enable the transmitter                     */

    AT91C_BASE_DBGU->DBGU_MR   = AT91C_US_USMODE_NORMAL |        /* Normal mode selected                      */
                                 AT91C_US_PAR_NONE;              /* No parity bit selected                    */

                                                                 /* Set the DBGU baud rate                    */
    AT91C_BASE_DBGU->DBGU_BRGR = (INT16U)(peripheral_clk_frq / (baud_rate * 16));

                                                                 /* Interrupt AIC init has been performed in  */
                                                                 /* bsp.c since the sys vector is shared with */
                                                                 /* ths OS ticker which was previously setup  */
    
    AT91C_BASE_PMC->PMC_PCER   = (1 << AT91C_ID_SYS);            /* Enable the DBGU peripheral clock          */
#endif
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                       Disable Rx Interrupts
*********************************************************************************************************
*/

void  OSView_RxIntDis (void)
{
#if OS_VIEW_COMM_SEL == DBGU
    AT91C_BASE_DBGU->DBGU_IDR  = AT91C_US_RXRDY;
#endif
}

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

void  OSView_RxIntEn (void)
{
#if OS_VIEW_COMM_SEL == DBGU
    AT91C_BASE_DBGU->DBGU_IER  = AT91C_US_RXRDY;
#endif
}

/*
*********************************************************************************************************
*                                 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.
*
* Note(s)    : This adaptation of uC/OS-View assumes that a 'combined' interrupt is generated by the UART
*              and thus this function is not needed.
*********************************************************************************************************
*/

void  OSView_RxISRHandler (void)
{
}

/*
*********************************************************************************************************
*                   Rx/Tx Communication handler for uC/OS-View ('combined' interrupt handler)
*********************************************************************************************************
*/

void  OSView_RxTxISRHandler (void)
{
    INT8U  rx_data;


#if OS_VIEW_COMM_SEL == DBGU
                                                                /* If we received a byte                      */
    if ((AT91C_BASE_DBGU->DBGU_CSR & AT91C_US_RXRDY) == AT91C_US_RXRDY) {
        rx_data = (INT8U)(AT91C_BASE_DBGU->DBGU_RHR & 0x00FF);  /* Remove the data from the holding register  */
        OSView_RxHandler(rx_data);                              /* Call the generic Rx handler                */
    }
                                                                /* If we completed transmitting a byte        */
    if ((AT91C_BASE_DBGU->DBGU_CSR & AT91C_US_TXRDY) == AT91C_US_TXRDY) {
        OSView_TxHandler();                                     /* Call the generic Tx handler                */
    }

    if ((AT91C_BASE_DBGU->DBGU_CSR  & AT91C_US_OVRE) == AT91C_US_OVRE) {
        AT91C_BASE_DBGU->DBGU_CSR   = AT91C_US_RSTSTA;          /* If an overrun occurs, reset the OR flag    */
    }
#endif
}

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

void  OSView_Tx1 (INT8U c)
{
#if OS_VIEW_COMM_SEL == DBGU
    AT91C_BASE_DBGU->DBGU_THR     = c;
#endif
}

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

void  OSView_TxIntDis (void)
{
#if OS_VIEW_COMM_SEL == DBGU
    AT91C_BASE_DBGU->DBGU_IDR     = AT91C_US_TXRDY;
#endif
}

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

void  OSView_TxIntEn (void)
{
#if OS_VIEW_COMM_SEL == DBGU
    AT91C_BASE_DBGU->DBGU_IER     = AT91C_US_TXRDY;
#endif
}

/*
*********************************************************************************************************
*                                 Tx Communication handler for uC/OS-View
*                                            (PORT SPECIFIC)
*
* Description: Handle transmission of a character
*
* Note(s)    : 1) This function is called by OSView_RxISR (see OS_VIEWa.ASM)
*              2) This adaptation of uC/OS-View assumes that a 'combined' interrupt is generated by the
*                 UART and thus this function is not needed.
*********************************************************************************************************
*/

void  OSView_TxISRHandler (void)
{
}


⌨️ 快捷键说明

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