📄 ucosii_demo.c
字号:
/***********************************************************************
* $Workfile: ucosii_demo.c $
* $Revision: 1.4 $
* $Author: WellsK $
* $Date: Dec 08 2003 14:20:20 $
*
* Project: SDK7A404 simple uCos-II LOLO example
*
* Description:
* This file contains a simple uCos-II demo that will load and
* execute through LOLO. The demo creates 4 windows that each
* performs different tasks.
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/demos/ucosii/ucosii_demo.c-arc $
*
* Rev 1.4 Dec 08 2003 14:20:20 WellsK
* Made some updates to the way frame buffers are mapped to
* improve future support with LOLO.
*
* 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:16:58 WellsK
* Updated to use common LCD driver format.
*
* Rev 1.1 Oct 01 2003 12:04:18 WellsK
* Added logic to get TTB address from register CP15 TTB.
*
* Rev 1.0 Sep 25 2003 14:12:20 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 5 /* Number of tasks */
/* Task stacks */
static OS_STK TaskStk[N_TASKS][TASK_STK_SIZE];
/* Display sections for the 4 windows */
INT_32 xmin[4], xmax[4], ymin[4], ymax[4], xsz, ysz;
/* Pointers to logical and physical frame buffer addresses */
COLOR_T *fblog, *fbphy;
/* Frame buffer logical addresses */
#define FBLOG 0xC1C00000
/***********************************************************************
*
* 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:
* Open a SWIM window. Add a title bar to the window. Enter the
* task loop and loop forever. Continuously draw lines that move
* in the window (and rotate colors). Sleep for 1 tick after 5
* lines are drawn.
*
* Parameters:
* data: Task input data value, not used
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void Task1(void *data)
{
SWIM_WINDOW_T win;
INT_16 left, top, right, bottom;
INT_32 tinc, binc, linc, rinc, iter;
COLOR_T lcolor;
/* Create window for this task */
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, "Task #2", GREEN);
/* Setup initial values for lines */
tinc = linc = -1;
binc = rinc = 1;
lcolor = RED;
left = top = 10;
right = 24;
bottom = 13;
iter = 0;
while(1)
{
/* Update position of next line and make sure it doesn't go
outside of the virtual window */
left += linc;
right += rinc;
top += tinc;
bottom += binc;
if ((left < 0) ||
(left >= swim_get_horizontal_size(&win)))
{
linc = -linc;
left += linc;
}
if ((right < 0) ||
(right >= swim_get_horizontal_size(&win)))
{
rinc = -rinc;
right += rinc;
}
if ((top < 0) ||
(top >= swim_get_vertical_size(&win)))
{
tinc = -tinc;
top += tinc;
}
if ((bottom < 0) ||
(bottom >= swim_get_vertical_size(&win)))
{
binc = -binc ;
bottom += binc;
}
/* Draw line in active color */
swim_set_pen_color(&win, lcolor);
swim_put_line(&win, left, top, right, bottom);
/* Update color for next line and index */
lcolor++;
/* After 5 iterations, delay for a tick */
iter++;
if (iter >= 10)
{
iter = 0;
OSTimeDly(1);
}
}
}
/***********************************************************************
*
* Function: Task2
*
* Purpose: Task #2
*
* Processing:
* Open a SWIM window. Add a title bar to the window. Enter the
* task loop and loop forever. Approximately every 1 second, wakeup
* and print the 1 second tick value to the window.
*
* Parameters:
* data: Task input data value, not used
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: This is not an accurate 1 second!
*
**********************************************************************/
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 */
swim_set_title(&win, "Task #3", MAGENTA);
while(1)
{
/* Sleep for about 1 second */
OSTimeDly(OS_TICKS_PER_SEC);
swim_put_text(&win, "Tick #");
make_number_str(str, ticks);
swim_put_text(&win, str);
swim_put_text(&win, "\n");
ticks++;
}
}
/***********************************************************************
*
* Function: Task3
*
* Purpose: Task #3
*
* Processing:
* Open a SWIM window. Add a title bar to the window. Enter the
* task loop and loop forever. Maintain the locations for and
* draw and few boxes on the display.
*
* Parameters:
* data: Task input data value, not used
*
* Outputs: None
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -