MARMEX-VB : "Mary Camera module" library
Dependents: MARMEX_VB_test MARMEX_VB_Hello
MARMEX-VB (MARY-VB) camera module library for mbed. (This module may be available in Japan only.)
Kown problem / 既知の問題
The read data may have contouring. In this case, it may require reset or changing order of data reading. The order change API is available as "read_order_change()" function.
カメラから読み出したデータに擬似輪郭が発生することがあります.この問題にはシステム全体のリセットを行うか,または読み出し順の変更を行うことで対処して下さい.読み出し順の変更はAPIの"read_order_change()"関数を使うことができます.
Diff: MARMEX_VB.cpp
- Revision:
- 1:b2324313d4da
- Parent:
- 0:c4d14dd5d479
- Child:
- 2:88213c3ca312
--- a/MARMEX_VB.cpp Fri Jun 06 03:36:58 2014 +0000 +++ b/MARMEX_VB.cpp Mon Jun 09 19:41:32 2014 +0000 @@ -1,7 +1,7 @@ /** MARMEX_VB Camera control library * * @class MARMEX_VB - * @version 0.1 + * @version 0.2 * @date 10-Jun-2014 * * Released under the Apache License, Version 2.0 : http://mbed.org/handbook/Apache-Licence @@ -102,6 +102,7 @@ // SPI settings + _cs = 1; // set ChipSelect signal HIGH _spi.format( 8 ); // camera SPI : 8bits/transfer _spi.frequency( SPI_FREQUENCY ); // SPI frequency setting @@ -193,8 +194,6 @@ _vertical_size = VGA_LINE_PER_FRAME / 4; break; } - -printf( "resolution : h,v = %d,%d\r\n", _horizontal_size, _vertical_size ); #endif return _error_state; // return non-zero if I2C access failed @@ -275,12 +274,88 @@ } else { +#define OPTIMIZE_BY_GPIO_REGISTER_ACCESS +#if defined( TARGET_MBED_LPC1768 ) && defined (OPTIMIZE_BY_GPIO_REGISTER_ACCESS ) + // optimized by IO register access and loop unroll + LPC_GPIO2->FIOMASK = ~0x10; + + char reg = COMMAND_READ | CAMERA_DATA_REGISTER | COMMAND_ADDR_INCREMENT; + + for( int x = 0; x < n_of_pixels; x += 8 ) { + // perform 2 bytes read. a pixel data is in RGB565 format (16bits) + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p = _spi.write( reg ); + LPC_GPIO2->FIOSET = 0x10; + + LPC_GPIO2->FIOCLR = 0x10; + *p++ |= _spi.write( reg ) << 8; + LPC_GPIO2->FIOSET = 0x10; + } + +#else for( int x = 0; x < n_of_pixels; x++ ) { // perform 2 bytes read. a pixel data is in RGB565 format (16bits) tmp = read_register( CAMERA_DATA_REGISTER ); // read lower byte *p++ = (read_register( CAMERA_DATA_REGISTER ) << 8) | tmp; // read upper byte } - +#endif } #endif @@ -347,8 +422,8 @@ int tmp; // SPI access - _cs = 0; + LPC_GPIO2->FIOCLR = 0x10; tmp = _spi.write( data ); _cs = 1;