Merge branch 'eCos'
This commit is contained in:
commit
85fe4a9672
7 changed files with 325 additions and 2 deletions
95
boards/addons/gdisp/board_framebuffer_eCos.h
Normal file
95
boards/addons/gdisp/board_framebuffer_eCos.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Note: this implementation makes a number of design choices...
|
||||
* 1/ We are using the macro definitions for eCos framebuffer driver. If you want to use the
|
||||
* function's instead you could use the g->board variable to store your cyg_fb pointer.
|
||||
* 2/ We assume the initialisation succeeds. It is probably a fatal error if it doesn't.
|
||||
* 3/ We hard-code in this file the pixel format, whether flushing is required and the FRAMEBUF device.
|
||||
* Please adjust them for your hardware.
|
||||
*/
|
||||
|
||||
// Set this to your frame buffer pixel format.
|
||||
#ifndef GDISP_LLD_PIXELFORMAT
|
||||
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
|
||||
#endif
|
||||
|
||||
// Uncomment this if your frame buffer device requires flushing ("Synch" in eCos speak)
|
||||
//#define GDISP_HARDWARE_FLUSH TRUE
|
||||
|
||||
#ifdef GDISP_DRIVER_VMT
|
||||
|
||||
#include <cyg/io/framebuf.h>
|
||||
|
||||
// SET THIS HERE!!!
|
||||
// This must also match the pixel format above
|
||||
//#define FRAMEBUF 640x480x16
|
||||
#define FRAMEBUF fb0
|
||||
|
||||
static void board_init(GDisplay *g, fbInfo *fbi) {
|
||||
// Initialize the frame buffer device - we assume everything is going to succeed.
|
||||
CYG_FB_ON(FRAMEBUF);
|
||||
#if (CYG_FB_FLAGS0(FRAMEBUF) & CYG_FB_FLAGS0_MUST_BE_ON)
|
||||
CYG_FB_FILL_BLOCK(FRAMEBUF, 0, 0, CYG_FB_WIDTH(FRAMEBUF), CYG_FB_HEIGHT(FRAMEBUF), CYG_FB_MAKE_COLOUR(FRAMEBUF, 0, 0, 0));
|
||||
#endif
|
||||
|
||||
// Set the details of the frame buffer
|
||||
#ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_VIEWPORT
|
||||
g->g.Width = CYG_FB_VIEWPORT_WIDTH(FRAMEBUF);
|
||||
g->g.Height = CYG_FB_VIEWPORT_HEIGHT(FRAMEBUF);
|
||||
#else
|
||||
g->g.Width = CYG_FB_WIDTH(FRAMEBUF);
|
||||
g->g.Height = CYG_FB_HEIGHT(FRAMEBUF);
|
||||
#endif
|
||||
g->g.Backlight = 100;
|
||||
g->g.Contrast = 50;
|
||||
fbi->linelen = CYG_FB_STRIDE(FRAMEBUF); // bytes per row
|
||||
fbi->pixels = CYG_FB_BASE(FRAMEBUF); // pointer to the memory frame buffer
|
||||
}
|
||||
|
||||
#if GDISP_HARDWARE_FLUSH
|
||||
static void board_flush(GDisplay *g) {
|
||||
(void) g;
|
||||
|
||||
// You might want to replace CYG_FB_UPDATE_NOW with CYG_FB_UPDATE_VERTICAL_RETRACE
|
||||
// if you are not using uGFX's auto flush or timer flush mechanisms and frame synchronisation
|
||||
// is important for your display.
|
||||
CYG_FB_SYNCH(FRAMEBUF, CYG_FB_UPDATE_NOW);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GDISP_NEED_CONTROL
|
||||
static void board_backlight(GDisplay *g, uint8_t percent) {
|
||||
(void) g;
|
||||
#if (CYG_FB_FLAGS0(FRAMEBUF) & CYG_FB_FLAGS0_BACKLIGHT)
|
||||
cyg_fb_ioctl_backlight backlight;
|
||||
size_t len = sizeof(cyg_fb_ioctl_backlight);
|
||||
|
||||
if (CYG_FB_IOCTL(FRAMEBUF, CYG_FB_IOCTL_BACKLIGHT_GET, &backlight, &len) || !backlight.fbbl_max)
|
||||
return;
|
||||
if (backlight.fbbl_max == 1)
|
||||
backlight.fbbl_current = percent ? 1 : 0;
|
||||
else
|
||||
backlight.fbbl_current = (((uint32_t)percent)*backlight.fbbl_max)/100;
|
||||
CYG_FB_IOCTL(FRAMEBUF, CYG_FB_IOCTL_BACKLIGHT_SET, &backlight, &len);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void board_contrast(GDisplay *g, uint8_t percent) {
|
||||
(void) g;
|
||||
(void) percent;
|
||||
}
|
||||
|
||||
static void board_power(GDisplay *g, powermode_t pwr) {
|
||||
// Not implemented yet.
|
||||
(void) g;
|
||||
(void) pwr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GDISP_DRIVER_VMT */
|
|
@ -32,6 +32,7 @@
|
|||
//#define GFX_USE_OS_WIN32 FALSE
|
||||
//#define GFX_USE_OS_LINUX FALSE
|
||||
//#define GFX_USE_OS_OSX FALSE
|
||||
//#define GFX_USE_OS_ECOS FALSE
|
||||
//#define GFX_USE_OS_RAW32 FALSE
|
||||
// #define GOS_RAW_HEAP_SIZE 0
|
||||
// #define INTERRUPTS_OFF() optional_code
|
||||
|
|
112
src/gos/ecos.c
Normal file
112
src/gos/ecos.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_OS_ECOS
|
||||
|
||||
void _gosInit(void)
|
||||
{
|
||||
/* Don't initialise if the user already has */
|
||||
//cyg_scheduler_start();
|
||||
}
|
||||
|
||||
void _gosDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void gfxSleepMilliseconds(delaytime_t ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: cyg_thread_yield(); return;
|
||||
case TIME_INFINITE: cyg_thread_suspend(cyg_thread_self()); return;
|
||||
default: cyg_thread_delay(gfxMillisecondsToTicks(ms)); return;
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSleepMicroseconds(delaytime_t ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return;
|
||||
case TIME_INFINITE: cyg_thread_suspend(cyg_thread_self()); return;
|
||||
default: cyg_thread_delay(gfxMillisecondsToTicks(ms/1000)); return;
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
|
||||
{
|
||||
if (val > limit)
|
||||
val = limit;
|
||||
|
||||
psem->limit = limit;
|
||||
cyg_semaphore_init(&psem->sem, val);
|
||||
}
|
||||
|
||||
void gfxSemDestroy(gfxSem *psem)
|
||||
{
|
||||
cyg_semaphore_destroy(&psem->sem);
|
||||
}
|
||||
|
||||
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return cyg_semaphore_trywait(&psem->sem);
|
||||
case TIME_INFINITE: return cyg_semaphore_wait(&psem->sem);
|
||||
default: return cyg_semaphore_timed_wait(&psem->sem, gfxMillisecondsToTicks(ms)+cyg_current_time());
|
||||
}
|
||||
}
|
||||
|
||||
bool_t gfxSemWaitI(gfxSem *psem)
|
||||
{
|
||||
return cyg_semaphore_trywait(&psem->sem);
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem *psem)
|
||||
{
|
||||
if (psem->limit == MAX_SEMAPHORE_COUNT)
|
||||
cyg_semaphore_post(&psem->sem);
|
||||
else {
|
||||
cyg_scheduler_lock();
|
||||
if (gfxSemCounterI(psem) < psem->limit)
|
||||
cyg_semaphore_post(&psem->sem);
|
||||
cyg_scheduler_unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSemSignalI(gfxSem *psem)
|
||||
{
|
||||
if (psem->limit == MAX_SEMAPHORE_COUNT || gfxSemCounterI(psem) < psem->limit)
|
||||
cyg_semaphore_post(&psem->sem);
|
||||
}
|
||||
|
||||
semcount_t gfxSemCounterI(gfxSem *psem) {
|
||||
semcount_t cnt;
|
||||
|
||||
cyg_semaphore_peek(&psem->sem, &cnt);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
{
|
||||
gfxThreadHandle th;
|
||||
|
||||
if (!stackarea) {
|
||||
if (!stacksz) stacksz = CYGNUM_HAL_STACK_SIZE_TYPICAL;
|
||||
if (!(stackarea = gfxAlloc(stacksz+sizeof(cyg_thread))))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!stacksz)
|
||||
return 0;
|
||||
|
||||
cyg_thread_create(prio, fn, param, "uGFX", (((cyg_thread *)stackarea)+1), stacksz, &th, (cyg_thread *)stackarea);
|
||||
cyg_thread_resume(th);
|
||||
return th;
|
||||
}
|
||||
|
||||
#endif /* GFX_USE_OS_ECOS */
|
106
src/gos/ecos.h
Normal file
106
src/gos/ecos.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
#ifndef _GOS_ECOS_H
|
||||
#define _GOS_ECOS_H
|
||||
|
||||
#if GFX_USE_OS_ECOS
|
||||
|
||||
#include <cyg/hal/hal_arch.h>
|
||||
#include <cyg/kernel/kapi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Type definitions */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef cyg_bool_t bool_t;
|
||||
typedef cyg_int8 int8_t;
|
||||
typedef cyg_uint8 uint8_t;
|
||||
typedef cyg_int16 int16_t;
|
||||
typedef cyg_uint16 uint16_t;
|
||||
typedef cyg_int32 int32_t;
|
||||
typedef cyg_uint32 uint32_t;
|
||||
typedef cyg_uint32 size_t;
|
||||
|
||||
#define TRUE -1
|
||||
#define FALSE 0
|
||||
#define TIME_IMMEDIATE 0
|
||||
#define TIME_INFINITE 0xFFFFFFFF
|
||||
|
||||
typedef cyg_ucount32 delaytime_t;
|
||||
typedef cyg_tick_count_t systemticks_t;
|
||||
typedef cyg_count32 semcount_t;
|
||||
typedef void threadreturn_t;
|
||||
typedef cyg_addrword_t threadpriority_t;
|
||||
typedef cyg_handle_t gfxThreadHandle;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT 0x7FFFFFFF
|
||||
#define LOW_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
|
||||
#define NORMAL_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
|
||||
#define HIGH_PRIORITY 0
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[sz]; } name[1]
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(cyg_addrword_t param)
|
||||
|
||||
typedef struct {
|
||||
cyg_sem_t sem;
|
||||
semcount_t limit;
|
||||
} gfxSem;
|
||||
|
||||
typedef cyg_mutex_t gfxMutex;
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Function declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define gfxSystemTicks() cyg_current_time()
|
||||
#define gfxExit() exit(0)
|
||||
#define gfxHalt(msg) exit(-1)
|
||||
#define gfxYield() cyg_thread_yield()
|
||||
|
||||
#define gfxMillisecondsToTicks(ms) (((ms)*(CYGNUM_HAL_RTC_DENOMINATOR*1000))/(CYGNUM_HAL_RTC_NUMERATOR/1000))
|
||||
void gfxSleepMilliseconds(delaytime_t ms);
|
||||
void gfxSleepMicroseconds(delaytime_t ms);
|
||||
|
||||
#define gfxAlloc(sz) malloc(sz)
|
||||
#define gfxFree(ptr) free(sz)
|
||||
#define gfxRealloc(ptr, oldsz, newsz) realloc(ptr, newsz)
|
||||
|
||||
#define gfxSystemLock() cyg_scheduler_lock()
|
||||
#define gfxSystemUnlock() cyg_scheduler_unlock()
|
||||
|
||||
#define gfxMutexInit(pmutex) cyg_mutex_init(pmutex)
|
||||
#define gfxMutexExit(pmutex) cyg_mutex_unlock(pmutex)
|
||||
#define gfxMutexDestroy(pmutex) cyg_mutex_destroy(pmutex)
|
||||
#define gfxMutexEnter(pmutex) cyg_mutex_lock(pmutex)
|
||||
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
|
||||
bool_t gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
semcount_t gfxSemCounterI(gfxSem *psem);
|
||||
#define gfxSemCounter(psem) gfxSemCounterI(psem)
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
#define gfxThreadWait(thread) NOTIMPLEMENTED_YET
|
||||
#define gfxThreadMe() cyg_thread_self()
|
||||
#define gfxThreadClose(thread) (void)thread
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GFX_USE_OS_ECOS */
|
||||
#endif /* _GOS_ECOS_H */
|
|
@ -451,6 +451,8 @@
|
|||
#include "src/gos/osx.h"
|
||||
#elif GFX_USE_OS_RAW32
|
||||
#include "src/gos/raw32.h"
|
||||
#elif GFX_USE_OS_ECOS
|
||||
#include "src/gos/ecos.h"
|
||||
#else
|
||||
#error "Your operating system is not supported yet"
|
||||
#endif
|
||||
|
|
|
@ -62,6 +62,13 @@
|
|||
#ifndef GFX_USE_OS_RAW32
|
||||
#define GFX_USE_OS_RAW32 FALSE
|
||||
#endif
|
||||
/**
|
||||
* @brief Use a eCos
|
||||
* @details Defaults to FALSE
|
||||
*/
|
||||
#ifndef GFX_USE_OS_ECOS
|
||||
#define GFX_USE_OS_ECOS FALSE
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef _GOS_RULES_H
|
||||
#define _GOS_RULES_H
|
||||
|
||||
#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS
|
||||
#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS
|
||||
#if GFX_DISPLAY_RULE_WARNINGS
|
||||
#warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you."
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@
|
|||
#define GFX_USE_OS_CHIBIOS TRUE
|
||||
#endif
|
||||
|
||||
#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS != 1 * TRUE
|
||||
#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS != 1 * TRUE
|
||||
#error "GOS: More than one operation system has been defined as TRUE."
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue