![](/media/cache/group/site_id.gif.50x50_q85.jpg)
A "Hello" program for MARMEX_VB library. This application may work 40pin type mbed platforms ;) This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1)
Dependencies: MARMEX_VB NokiaLCD mbed
Sample code for MARMEX-VB (MARY-VB) camera module.
This is a very simple program just copies the data from camera to OELD.
Revision 2:7294334432d4, committed 2014-06-20
- Comitter:
- nxpfan
- Date:
- Fri Jun 20 09:19:00 2014 +0000
- Parent:
- 1:715bb00d7008
- Commit message:
- sample code with latest libraries (SPI-FIFO optimize option version)
Changed in this revision
--- a/MARMEX_OB_oled.h Mon Jun 16 14:04:33 2014 +0000 +++ b/MARMEX_OB_oled.h Fri Jun 20 09:19:00 2014 +0000 @@ -2,8 +2,8 @@ * * @class MARMEX_OB_oled * @author tedd - * @version 0.53 (optimized for "line data transfer") - * @date 16-Jun-2014 + * @version 0.55 (optimized for "line data transfer") + * @date 20-Jun-2014 * * Released under the MIT License: http://mbed.org/license/mit * @@ -22,6 +22,19 @@ #include "mbed.h" #include "NokiaLCD.h" +//#define LINE_WRITE_OPT NO_OPTIMIZATION +//#define LINE_WRITE_OPT LOOP_UNROLL +#define LINE_WRITE_OPT USING_SSP_FIFO + +/* Setting for "LINE_WRITE_OPT == USING_SSP_FIFO" + * Choose one line from next 3 lines when the FIFO option is taken + */ +#define SSP_AUTO_SELECTION // for demo setup on "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1) +//#define SSP_USE_SSP0 +//#define SSP_USE_SSP1 + + + /** @def MARMEX_OB_SPI_8BIT_MODE * * MARMEX_OB_oled_oled OLED screen SPI access length setting @@ -320,10 +333,24 @@ } void blit565( int x, int y, int width, int height, short* colour ) { + + // OPTION REFERENCE NUMBER (DO NOT EDIT) + #define NO_OPTIMIZATION 0 + #define LOOP_UNROLL 1 + #define USING_SSP_FIFO 2 + _window( x, y, width, height ); -#define OPTIMIZE_KEEP_ASSERTING_CS_DURING_LINE_DATA_TRANSFER -#ifdef OPTIMIZE_KEEP_ASSERTING_CS_DURING_LINE_DATA_TRANSFER +#if ( LINE_WRITE_OPT == NO_OPTIMIZATION ) + + for (int i = 0; i < width * height; i++ ) { + _putp565( colour[i] ); + } + +#endif + + +#if ( LINE_WRITE_OPT == LOOP_UNROLL ) _cs = 0; @@ -352,18 +379,63 @@ _spi.write( 0x100 | (*colour >> 8) ); _spi.write( 0x100 | *colour++ ); } - + + _cs = 1; +#endif + + +#if ( LINE_WRITE_OPT == USING_SSP_FIFO ) + + #define FIFO_DEPTH 4 + + #if defined( SSP_AUTO_SELECTION ) + #if defined( TARGET_MBED_LPC1768 ) + #define SPI_PORT_SELECTOR LPC_SSP1 + #elif defined( TARGET_LPC11U35_501 ) || defined( TARGET_LPC11U24_401 ) + #define SPI_PORT_SELECTOR LPC_SSP0 + #endif + #elif defined( SSP_USE_SSP0 ) + #define SPI_PORT_SELECTOR LPC_SSP0 + #elif defined( SSP_USE_SSP1 ) + #define SPI_PORT_SELECTOR LPC_SSP1 + #else + #error when using FIFO option for the optimization, choose one of definition from SSP_AUTO_SELECTION, SSP_USE_SSP0 or SSP_USE_SSP1 + #endif // #if defined( SSP_AUTO_SELECTION ) + + int length = width * height; + char dummy; + int n; + _cs = 0; -#else - for (int i = 0; i < width * height; i++ ) { - _putp565( colour[i] ); + for(n = (FIFO_DEPTH >> 1); n > 0; n--) { + SPI_PORT_SELECTOR->DR = (*colour >> 8) | 0x100; + SPI_PORT_SELECTOR->DR = ((*colour++) & 0xFF) | 0x100; } + + do { +#pragma diag_suppress 550 // surpressing a warning messase of "Variable "dummy" was set but never used" + + while (!(SPI_PORT_SELECTOR->SR & 0x4)); + dummy = SPI_PORT_SELECTOR->DR; + + if (n < length - (FIFO_DEPTH >> 1)) + SPI_PORT_SELECTOR->DR = (*colour >> 8) | 0x100; + + while (!(SPI_PORT_SELECTOR->SR & 0x4)); + dummy = SPI_PORT_SELECTOR->DR; + + if (n++ < length - (FIFO_DEPTH >> 1)) + SPI_PORT_SELECTOR->DR = ((*colour++) & 0xFF) | 0x100; + + + } while(n < length); #endif + _cs = 1; _window( 0, 0, WIDTH, HEIGHT ); - _cs = 1; } + void bitblit( int x, int y, int width, int height, const char* bitstream ) { _cs = 0; _window( x, y, width, height ); @@ -527,4 +599,3 @@ -
--- a/MARMEX_VB.lib Mon Jun 16 14:04:33 2014 +0000 +++ b/MARMEX_VB.lib Fri Jun 20 09:19:00 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/CQ-Publishing/code/MARMEX_VB/#7f26004cfbce +http://mbed.org/teams/CQ-Publishing/code/MARMEX_VB/#84e6c89a9a6d
--- a/main.cpp Mon Jun 16 14:04:33 2014 +0000 +++ b/main.cpp Fri Jun 20 09:19:00 2014 +0000 @@ -12,9 +12,24 @@ #include "MARMEX_OB_oled.h" #include "MARMEX_VB.h" -MARMEX_OB_oled oled1( p5, p7, p20, p16, p15 ); // mosi, sclk, cs, rst, power_control -- maple-mini-type-b-board-slot1 -MARMEX_VB camera( p5, p6, p7, p22, p26, p28, p27 ); // mosi, miso, sclk, cs, reset, sda, scl -- maple-mini-type-b-board-slot2 -BusOut led( LED3, LED4 ); +// Baseboard type selection +#define BASEBOARD_MAPLE_MINI_TYPE_B +//#define BASEBOARD_MAPLE_ORIGINAL + +#ifdef BASEBOARD_MAPLE_MINI_TYPE_B +MARMEX_OB_oled oled1( p5, p7, p20, p16, p15 ); +// mosi, sclk, cs, rst, power_control -- maple-mini-type-b-board-slot1 +MARMEX_VB camera( p5, p6, p7, p22, p26, p28, p27 ); +// mosi, miso, sclk, cs, reset, sda, scl -- maple-mini-type-b-board-slot2 +#endif + +#ifdef BASEBOARD_MAPLE_ORIGINAL +MARMEX_OB_oled oled1( p5, p7, p8, p30, p11 ); +// mosi, sclk, cs, rst, power_control -- maple-board-slot1 +MARMEX_VB camera( p5, p6, p7, p26, p17, p28, p27 ); +// mosi, miso, sclk, cs, reset, sda, scl -- maple-board-slot2 +#endif +//BusOut led( LED3, LED4 ); // image size (default image size) #define CAMERA_WIDTH MARMEX_VB::QCIF_PIXEL_PER_LINE // 176 pixels(default size) @@ -32,12 +47,10 @@ { short buf[ OLED_WIDTH ]; - led = 0x3; oled1.cls(); // clear OLED screen while ( 1 ) { - led = 0x1; camera.open_transfer(); // pause updating the camera buffer // data transfer from camera to OLED (line by line copy) @@ -51,7 +64,6 @@ oled1.blit565( 0, line, OLED_WIDTH, 1, buf ); } - led = 0x2; camera.close_transfer(); // resume updating the camera buffer } }