📄 sdk7a404_os_viewc.c
字号:
UNS_8 data;
/* Read UART data */
while ((*uartintstatus & (UART_INTR_RTI | UART_INTR_RI)) != 0)
{
data = (UNS_8) (*uartdata & UART_DATA_MASK);
OSView_RxHandler(data);
}
/* UART transmit interrupt */
if ((*uartintstatus & UART_INTR_TI) != 0)
{
OSView_TxHandler();
}
}
/***********************************************************************
*
* Function: OSView_RxTxISR
*
* Purpose: Combined UART receive/transmit interrupt
*
* Processing:
* None
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: This function is not needed.
*
**********************************************************************/
void OSView_RxTxISR(void)
{
;
}
/***********************************************************************
*
* Function: OSView_TickHook
*
* Purpose: Time management hook
*
* Processing:
* Do nothing
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void OSView_TickHook(void)
{
;
}
/***********************************************************************
*
* Function: OSView_TimeGetCycles
*
* Purpose: Returns the absolute time
*
* Processing:
* Return the absolute time (OSView_CyclesCtr) to the caller.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Returns absolute time
*
* Notes: None
*
**********************************************************************/
INT32U OSView_TimeGetCycles(void)
{
/* Stop timer for the measurement */
timer_ioctl(ucos_timer_dev, TIMER_ENABLE, 0);
/* Update count value */
OSView_CyclesCtr = cnts_major + (INT32U) (0xFFFF -
timer_ioctl(ucos_timer_dev, TIMER_GET_STATUS, TIMER_VALUE_ST));
/* Restart timer */
timer_ioctl(ucos_timer_dev, TIMER_ENABLE, 1);
return OSView_CyclesCtr;
}
/***********************************************************************
*
* Function: OSView_Tx1
*
* Purpose: Send a single character to the UART
*
* Processing:
* Send a single character to the UART.
*
* Parameters:
* data: Data to send to the UART
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void OSView_Tx1(INT8U data)
{
*uartdata = (UNS_32) data;
}
/***********************************************************************
*
* Function: OSView_GetCPUName
*
* Purpose: Return the CPU name to uCos/View
*
* Processing:
* Fill in the string (s) with the CPU name.
*
* Parameters:
* s : Pointer to the string to place the CPU name in
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
* strcpy can be used to copy the string, but may not be available
* if the standard libraries aren't used.
*
**********************************************************************/
void OSView_GetCPUName(char *s)
{
CHAR *cpuname;
INT_32 idx = 0;
cpuname =OSCPU_NAME;
/* Copy the string into the passed parameter */
while (cpuname[idx] != '\0')
{
s[idx] = cpuname[idx];
idx++;
}
s[idx] = '\0';
}
/***********************************************************************
*
* Function: OSView_GetIntStkBase
*
* Purpose: Return the interrupt stack base
*
* Processing:
* None
*
* Parameters: None
*
* Outputs: None
*
* Returns: ALways returns 0
*
* Notes: This function may be implemented at a later date.
*
**********************************************************************/
INT32U OSView_GetIntStkBase(void)
{
return ((INT32U) 0);
}
/***********************************************************************
*
* Function: OSView_GetIntStkSize
*
* Purpose: Return the interrupt stack size
*
* Processing:
* None
*
* Parameters: None
*
* Outputs: None
*
* Returns: ALways returns 0
*
* Notes: This function may be implemented at a later date.
*
**********************************************************************/
INT32U OSView_GetIntStkSize(void)
{
return ((INT32U) 0);
}
/***********************************************************************
*
* Function: OSView_GetIntStkSize
*
* Purpose: Initialize the UART and timer for uCos/View
*
* Processing:
* Install the UART interrupt handler (as OSView_RxTxISR) and setup
* the UART to the correct baud rate and configuration. Setup the
* timer for a 508KHz clock and freerun mode. Enable the UART
* interrupt in the interrupt controller.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void OSView_InitTarget(void)
{
/* Clear count value */
OSView_CyclesCtr = cnts_major = 0;
/* Install UART handler */
vic_install_handler(UCOSUART_INT, VIC_IRQ,
(PFV) OSVIew_RxTxISRHandler);
/* Open UART interface and configure for 115K-8-N-1 */
ucos_uart_dev = uart_open(UCOSUART, 0);
uart_ioctl(ucos_uart_dev, UART_SET_PARITY, UART_PARITY_NONE);
uart_ioctl(ucos_uart_dev, UART_SET_DATA_BITS, 8);
uart_ioctl(ucos_uart_dev, UART_SET_STOP_BITS, 1);
#if OS_VIEW_BAUDRATE == 9600
uart_ioctl(ucos_uart_dev, UART_SET_BAUD_RATE, BPS_9600);
#endif
#if OS_VIEW_BAUDRATE == 19200
uart_ioctl(ucos_uart_dev, UART_SET_BAUD_RATE, BPS_19200);
#endif
#if OS_VIEW_BAUDRATE == 38400
uart_ioctl(ucos_uart_dev, UART_SET_BAUD_RATE, BPS_38400);
#endif
#if OS_VIEW_BAUDRATE == 57600
uart_ioctl(ucos_uart_dev, UART_SET_BAUD_RATE, BPS_57600);
#endif
#if OS_VIEW_BAUDRATE == 115200
uart_ioctl(ucos_uart_dev, UART_SET_BAUD_RATE, BPS_115200);
#endif
/* Disable UART FIFO for faster response time */
uart_ioctl(ucos_uart_dev, UART_ENABLE_FIFO, 0);
switch (UCOSUART_INT)
{
case VIC_UART1INTR:
uartintstatus = (UNS_32 *) &UART1->intr;
uartdata = (UNS_32 *) &UART1->data;
break;
case VIC_UART2INTR:
uartintstatus = (UNS_32 *) &UART2->intr;
uartdata = (UNS_32 *) &UART2->data;
break;
case VIC_UART3INTR:
uartintstatus = (UNS_32 *) &UART3->intr;
uartdata = (UNS_32 *) &UART3->data;
break;
}
/* Open timer interface and configure for 508KHz count with
freerunning underflow */
ucos_timer_dev = timer_open(UCOSTIMER, 0);
timer_ioctl(ucos_timer_dev, TIMER_SET_COUNT, 0xFFFF);
timer_ioctl(ucos_timer_dev, TIMER_MODE, TIMER_FREERUN);
timer_ioctl(ucos_timer_dev, TIMER_CLOCK, TIMER_CLOCK_508K);
timer_ioctl(ucos_timer_dev, TIMER_ENABLE, 1);
/* Install timer interrupt for uView clock major tick */
vic_install_handler(UCOSTIMER_INT, VIC_IRQ,
(PFV) ucos_mjr_ttick);
/* Enable UART and timer interrupts in the interrupt controller */
OSView_RxIntEn();
vic_int_enable(UCOSUART_INT, TRUE);
vic_int_enable(UCOSTIMER_INT, TRUE);
}
/***********************************************************************
*
* Function: OSView_Exit
*
* Purpose: uCos/View exit code
*
* Processing:
* Disable the timer and UART interrupts used for uCos/View and
* close the devices.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void OSView_Exit(void)
{
/* Disable UART and timer interrupts in the interrupt controller */
vic_int_enable(UCOSUART_INT, FALSE);
vic_int_enable(UCOSTIMER_INT, FALSE);
/* Close timer and uart devices */
timer_close(ucos_timer_dev);
uart_close(ucos_uart_dev);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -