summaryrefslogtreecommitdiff
path: root/nuttx/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-15 18:57:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-15 18:57:24 +0000
commiteac348a697436ceec946239162a85abdd1fd5b7d (patch)
treea0dddfc34d871773e242d34a8a037c2c71fe3ad6 /nuttx/examples
parenta778f0c7e076b4bab911945ee2630d767448d147 (diff)
downloadpx4-nuttx-eac348a697436ceec946239162a85abdd1fd5b7d.tar.gz
px4-nuttx-eac348a697436ceec946239162a85abdd1fd5b7d.tar.bz2
px4-nuttx-eac348a697436ceec946239162a85abdd1fd5b7d.zip
Finish framebuffer support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2672 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r--nuttx/examples/README.txt11
-rw-r--r--nuttx/examples/nx/nx_internal.h5
-rw-r--r--nuttx/examples/nx/nx_main.c14
-rw-r--r--nuttx/examples/nx/nx_server.c52
4 files changed, 77 insertions, 5 deletions
diff --git a/nuttx/examples/README.txt b/nuttx/examples/README.txt
index 1f3849975..d7da69b04 100644
--- a/nuttx/examples/README.txt
+++ b/nuttx/examples/README.txt
@@ -116,6 +116,17 @@ examples/nx
include 2, 4, 8, 16, 24, and 32. Default is 32.
CONFIG_EXAMPLES_NX_RAWWINDOWS -- Use raw windows; Default is to
use pretty, framed NXTK windows with toolbars.
+ CONFIG_EXAMPLES_NX_EXTERNINIT - The driver for the graphics device on
+ this platform requires some unusual initialization. This is the
+ for, for example, SPI LCD/OLED devices. If this configuration is
+ selected, then the platform code must provide an LCD initialization
+ function with a prototype like:
+
+ #ifdef CONFIG_NX_LCDDRIVER
+ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno);
+ #else
+ FAR struct fb_vtable_s *up_nxdrvinit(unsigned int devno);
+ #endif
This test can be performed with either the single-user version of
NX or with the multiple user version of NX selected with CONFIG_NX_MULTIUSER.
diff --git a/nuttx/examples/nx/nx_internal.h b/nuttx/examples/nx/nx_internal.h
index 51f6f927a..3af7329a4 100644
--- a/nuttx/examples/nx/nx_internal.h
+++ b/nuttx/examples/nx/nx_internal.h
@@ -190,6 +190,7 @@ enum exitcode_e
NXEXIT_EVENTNOTIFY,
NXEXIT_TASKCREATE,
NXEXIT_PTHREADCREATE,
+ NXEXIT_EXTINITIALIZE,
NXEXIT_FBINITIALIZE,
NXEXIT_FBGETVPLANE,
NXEXIT_LCDINITIALIZE,
@@ -284,6 +285,10 @@ extern nxgl_mxpixel_t g_tbcolor[CONFIG_NX_NPLANES];
* Public Function Prototypes
****************************************************************************/
+#ifdef CONFIG_EXAMPLES_NX_EXTERNINIT
+extern FAR NX_DRIVERTYPE *up_nxdrvinit(unsigned int devno);
+#endif
+
#if defined(CONFIG_NX) && defined(CONFIG_NX_MULTIUSER)
extern int nx_servertask(int argc, char *argv[]);
extern FAR void *nx_listenerthread(FAR void *arg);
diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c
index eac7c12b1..06f0c53ec 100644
--- a/nuttx/examples/nx/nx_main.c
+++ b/nuttx/examples/nx/nx_main.c
@@ -419,7 +419,19 @@ static inline int nxeg_suinitialize(void)
FAR NX_DRIVERTYPE *dev;
int ret;
-#ifdef CONFIG_NX_LCDDRIVER
+#if defined(CONFIG_EXAMPLES_NX_EXTERNINIT)
+ /* Use external graphics driver initialization */
+
+ message("nxeg_initialize: Initializing external graphics device\n");
+ dev = up_nxdrvinit(CONFIG_EXAMPLES_NX_DEVNO);
+ if (!dev)
+ {
+ message("nxeg_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO);
+ g_exitcode = NXEXIT_EXTINITIALIZE;
+ return ERROR;
+ }
+
+#elif defined(CONFIG_NX_LCDDRIVER)
/* Initialize the LCD device */
message("nxeg_initialize: Initializing LCD\n");
diff --git a/nuttx/examples/nx/nx_server.c b/nuttx/examples/nx/nx_server.c
index 1a931a87c..1f71bf900 100644
--- a/nuttx/examples/nx/nx_server.c
+++ b/nuttx/examples/nx/nx_server.c
@@ -48,6 +48,13 @@
#include <nuttx/arch.h>
#include <nuttx/nx.h>
+
+#ifdef CONFIG_NX_LCDDRIVER
+# include <nuttx/lcd.h>
+#else
+# include <nuttx/fb.h>
+#endif
+
#include "nx_internal.h"
#ifdef CONFIG_NX_MULTIUSER
@@ -78,9 +85,45 @@
int nx_servertask(int argc, char *argv[])
{
- FAR struct fb_vtable_s *fb;
+ FAR NX_DRIVERTYPE *dev;
int ret;
+#if defined(CONFIG_EXAMPLES_NX_EXTERNINIT)
+ /* Use external graphics driver initialization */
+
+ message("nxeg_initialize: Initializing external graphics device\n");
+ dev = up_nxdrvinit(CONFIG_EXAMPLES_NX_DEVNO);
+ if (!dev)
+ {
+ message("nxeg_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO);
+ g_exitcode = NXEXIT_EXTINITIALIZE;
+ return ERROR;
+ }
+
+#elif defined(CONFIG_NX_LCDDRIVER)
+ /* Initialize the LCD device */
+
+ message("nx_servertask: Initializing LCD\n");
+ ret = up_lcdinitialize();
+ if (ret < 0)
+ {
+ message("nx_servertask: up_lcdinitialize failed: %d\n", -ret);
+ return 1;
+ }
+
+ /* Get the device instance */
+
+ dev = up_lcdgetdev(CONFIG_EXAMPLES_NX_DEVNO);
+ if (!dev)
+ {
+ message("nx_servertask: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO);
+ return 2;
+ }
+
+ /* Turn the LCD on at 75% power */
+
+ (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
+#else
/* Initialize the frame buffer device */
message("nx_servertask: Initializing framebuffer\n");
@@ -91,16 +134,17 @@ int nx_servertask(int argc, char *argv[])
return 1;
}
- fb = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE);
- if (!fb)
+ dev = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE);
+ if (!dev)
{
message("nx_servertask: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE);
return 2;
}
+#endif
/* Then start the server */
- ret = nx_run(fb);
+ ret = nx_run(dev);
message("nx_servertask: nx_run returned: %d\n", errno);
return 3;
}