📄 ucosii_demo.c
字号:
/***********************************************************************
* $Workfile: ucosii_demo.c $
* $Revision: 1.3 $
* $Author: WellsK $
* $Date: Oct 28 2003 14:54:38 $
*
* Project: SDK7A404 simple uCos-II startup example
*
* Description:
* This file contains a simple uCos-II demo that will initialize
* the SDK7A404 board and then jump to c_entry(), which will
* initialize uCos-II and start the uCos-II tasks. This demo
* presently only works with the LQ035 ADTFT display.
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/startup/examples/ucosii/ucosii_demo.c-arc $
*
* Rev 1.3 Oct 28 2003 14:54:38 WellsK
* Corrected ioctl functions. SHould be abl_ioctl instead of
* lcd_ioctl.
*
* Rev 1.2 Oct 28 2003 11:32:46 WellsK
* Updated to common LCD driver format.
*
* Rev 1.1 Sep 08 2003 15:24:44 WellsK
* Added support for additional displays with automatic window
* sizing. Added changes needed for updated VIC and CP15
* (MMU) drivers. Updated display power control logic.
*
* Rev 1.0 Jul 01 2003 14:25:50 WellsK
* Initial revision.
*
*
***********************************************************************
* SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
* OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
* AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
* SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
*
* SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
* FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
* SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
* FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
*
* COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
* CAMAS, WA
**********************************************************************/
#include "lh7a404_clcdc_driver.h"
#include "lh7a404_gpio_driver.h"
#include "lh7a404_timer_driver.h"
#include "lh7a404_uart_driver.h"
#include "lh7a404_vic_driver.h"
#include "abl_arm922t_cp15_driver.h"
#include "sdk7a404_cpld_driver.h"
#include "abl_swim.h"
#include "abl_swim_font.h"
#include "abl_swim_image.h"
#include "abl_api.h"
#include "ucos_ii.h"
/* Pick only 1 panel from the following list of defines */
#define LCDPANEL sharp_lq035
//#define LCDPANEL sharp_lq039
//#define LCDPANEL sharp_lq057
//#define LCDPANEL sharp_lq064
//#define LCDPANEL sharp_lq104
//#define LCDPANEL sharp_lq121
/* Device handle for LCD driver */
static INT_32 lcddev;
/* Device handle for timer driver */
static INT_32 timer1dev;
/* The MicroCos-II interrupt and tick handler and router */
extern PFV ucos_irq_handler;
#define TASK_STK_SIZE 512 /* Size of each task's stack (WORDs) */
#define N_TASKS 4 /* Number of tasks */
/* Task stacks */
static OS_STK TaskStk[N_TASKS][TASK_STK_SIZE];
/* Display sections for the 2 windows */
INT_32 xmin[3], xmax[3], ymin[3], ymax[3], xsz, ysz;
/* Pointer to logical frame buffer address */
COLOR_T *fblog;
/* Frame buffer physical and logic addresses - be careful that the
ThreadX byte pool doesn't get too big, as it will collide with
the frame buffer, ThreadX stacks, etc. Ideally, we would like
to use the ThreadX functions to allocate a byte pool for the
frame buffer and then convert the logical address to a physical
address for the LCD hardware. Next build maybe. */
#define FBPHY 0xCC000000 /* Physical address */
/***********************************************************************
*
* Function: make_number_str
*
* Purpose: Convert a number to a positive decimal string
*
* Processing:
* Using successive division, compute the base10 value of a number
* into a string and return the string value to the caller.
*
* Parameters:
* str : Where to place the generated strinjg
* iteration: Number to generate a string from
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void make_number_str(CHAR *str,
INT_32 iteration)
{
UNS_8 tmp[32];
INT_32 dvv1, dvv2;
INT_32 cnt = 0;
/* Number 0 in string */
str[cnt] = '0';
/* Main loop */
while (iteration > 0)
{
dvv1 = iteration / 10;
dvv2 = dvv1 * 10;
dvv1 = iteration - dvv2;
tmp[cnt] = dvv1;
iteration = iteration / 10;
cnt++;
}
if (cnt > 0)
{
for (dvv1 = 0; dvv1 < cnt; dvv1++)
{
str[dvv1] = (CHAR) ('0' + tmp[cnt - (dvv1 + 1)]);
}
}
str[cnt + 1] = '\0';
}
/***********************************************************************
*
* Function: Task1
*
* Purpose: Task #1
*
* Processing:
* Initialize UART2 for 115K-8-N-1 and create a window on the
* LCD. Periodically wakeup and check for data in the UART2 ring
* buffer. If data exists, output it to the window and go back to
* sleep until the next wakeup period.
*
* Parameters:
* data: Task input data value, not used
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void Task1(void *data)
{
INT_32 uartdev;
SWIM_WINDOW_T win;
CHAR str[32];
INT_32 bytes, idx;
/* Enable UART2 at 115K-N-8-1 */
uartdev = abl_open((INT_32) UART2, 0);
abl_ioctl(uartdev, UART_SET_BAUD_RATE, BPS_115200);
abl_ioctl(uartdev, UART_SET_PARITY, UART_PARITY_NONE);
abl_ioctl(uartdev, UART_SET_DATA_BITS, 8);
abl_ioctl(uartdev, UART_SET_STOP_BITS, 1);
/* Enable the UART2 receive interrupts in the UART peripheral */
abl_ioctl(uartdev, UART_ENABLE_INTS,
(UART_INTR_RI | UART_INTR_RTI));
/* Place address of UART2 interrupt handler in IRQ router, but use
as a vectored interrupt (for best performance) */
vic_install_handler(VIC_UART2INTR, VIC_VECTORED, (PFV) uart2_isr);
/* Enable the UART2 interrupt in the interrupt controller */
vic_int_enable(VIC_UART2INTR, TRUE);
swim_window_open(&win, xsz, ysz, fblog, xmin[1], ymin[1],
xmax[1], ymax[1], 1, WHITE, BLACK, BLUE);
/* Add a title bar */
swim_set_title(&win, "Window #1", GREEN);
while(1)
{
/* Sleep for a 10th of a second */
OSTimeDly(OS_TICKS_PER_SEC / 10);
/* Try to read some data from the UART ring buffer */
idx = 0;
bytes = abl_read(uartdev, str, sizeof(str));
while (idx < bytes)
{
swim_put_char(&win, str[idx]);
idx++;
}
}
}
/***********************************************************************
*
* Function: Task2
*
* Purpose: Task #2
*
* Processing:
* Open a SWIM window in the right bottom side of the window. Add a
* title bar to the window. Enter the task loop and loop forever.
* Approximately every 100 ticks, wakeup and print the 1 second
* tick value to the window.
*
* Parameters:
* data: Task input data value, not used
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void Task2(void *data)
{
SWIM_WINDOW_T win;
CHAR str[32];
INT_32 ticks = 0;
swim_window_open(&win, xsz, ysz, fblog, xmin[2], ymin[2],
xmax[2], ymax[2], 1, WHITE, BLACK, BLUE);
/* Add a title bar */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -