Tedd OKANO / MARY_CAMERA
Committer:
okano
Date:
Sat Mar 22 01:50:50 2014 +0000
Revision:
29:4432c5282c7b
Parent:
28:b5d5a2f7f0d0
Child:
30:5d8e86cd337d
test code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:f4584dba3bac 1 #include "mbed.h"
okano 0:f4584dba3bac 2 #include "MARY_CAMERA.h"
okano 0:f4584dba3bac 3
okano 28:b5d5a2f7f0d0 4
okano 2:ee71ffdf317e 5 #define CAM_I2C_ADDR 0x42
okano 2:ee71ffdf317e 6
okano 2:ee71ffdf317e 7 #define COMMAND_WRITE 0x00
okano 2:ee71ffdf317e 8 #define COMMAND_READ 0x80
okano 2:ee71ffdf317e 9 #define COMMAND_ADDR_INCREMENT 0x20
okano 0:f4584dba3bac 10
okano 2:ee71ffdf317e 11 #define MEMORY_ADDR_LOW__REGISTER 0x0
okano 2:ee71ffdf317e 12 #define MEMORY_ADDR_MID__REGISTER 0x1
okano 2:ee71ffdf317e 13 #define MEMORY_ADDR_HIGH_REGISTER 0x2
okano 2:ee71ffdf317e 14 #define CAMERA_DATA_REGISTER 0x8
okano 2:ee71ffdf317e 15 #define CONTROL_DATA_REGISTER 0x3
okano 2:ee71ffdf317e 16 #define STATUS_REGISTER 0x4
okano 2:ee71ffdf317e 17
okano 2:ee71ffdf317e 18 #define CONTROL__PAUSE_BUFFER_UPDATE 0x01
okano 2:ee71ffdf317e 19 #define CONTROL__RESUME_BUFFER_UPDATE 0x00
okano 0:f4584dba3bac 20
okano 0:f4584dba3bac 21
okano 0:f4584dba3bac 22 MARY_CAMERA::MARY_CAMERA(
okano 4:cb0ef3fd89c9 23 PinName SPI_mosi,
okano 4:cb0ef3fd89c9 24 PinName SPI_miso,
okano 4:cb0ef3fd89c9 25 PinName SPI_sck,
okano 4:cb0ef3fd89c9 26 PinName SPI_cs,
okano 0:f4584dba3bac 27 PinName cam_reset,
okano 4:cb0ef3fd89c9 28 PinName I2C_sda,
okano 4:cb0ef3fd89c9 29 PinName I2C_scl
okano 2:ee71ffdf317e 30 ) :
okano 4:cb0ef3fd89c9 31 _spi( SPI_mosi, SPI_miso, SPI_sck ),
okano 4:cb0ef3fd89c9 32 _cs( SPI_cs ),
okano 4:cb0ef3fd89c9 33 _reset( cam_reset ),
okano 4:cb0ef3fd89c9 34 _i2c( I2C_sda, I2C_scl )
okano 0:f4584dba3bac 35 {
okano 11:61a025e8ab68 36 #ifdef IGNORE_INITIALIZATION_ERROR
okano 0:f4584dba3bac 37 init();
okano 11:61a025e8ab68 38 #else
okano 22:1a923c255be6 39 if ( 0 != init() )
okano 11:61a025e8ab68 40 error( "camera initialization failed." );
okano 11:61a025e8ab68 41 #endif
okano 0:f4584dba3bac 42 }
okano 0:f4584dba3bac 43
okano 28:b5d5a2f7f0d0 44 int MARY_CAMERA::init( CameraResolution res )
okano 11:61a025e8ab68 45 {
okano 29:4432c5282c7b 46 #define PARAM_NUM 99
okano 29:4432c5282c7b 47 #define RES_CHANGE_PARAM_NUM 12
okano 29:4432c5282c7b 48 #define RESET_PULSE_WIDTH 100 // mili-seconds
okano 29:4432c5282c7b 49 #define RESET_RECOVERY_TIME 100 // mili-seconds
okano 29:4432c5282c7b 50 #define COMMAND_INTERVAL 20 // mili-seconds
okano 29:4432c5282c7b 51
okano 28:b5d5a2f7f0d0 52
okano 28:b5d5a2f7f0d0 53 char camera_register_setting[ PARAM_NUM ][ 2 ] = {
okano 23:214896356355 54 { 0x01, 0x40 }, { 0x02, 0x60 }, { 0x03, 0x02 }, { 0x0C, 0x0C },
okano 23:214896356355 55 { 0x0E, 0x61 }, { 0x0F, 0x4B }, { 0x11, 0x81 }, { 0x12, 0x04 },
okano 23:214896356355 56 { 0x15, 0x00 }, { 0x16, 0x02 }, { 0x17, 0x39 }, { 0x18, 0x03 },
okano 23:214896356355 57 { 0x19, 0x03 }, { 0x1A, 0x7B }, { 0x1E, 0x37 }, { 0x21, 0x02 },
okano 23:214896356355 58 { 0x22, 0x91 }, { 0x29, 0x07 }, { 0x32, 0x80 }, { 0x33, 0x0B },
okano 23:214896356355 59 { 0x34, 0x11 }, { 0x35, 0x0B }, { 0x37, 0x1D }, { 0x38, 0x71 },
okano 23:214896356355 60 { 0x39, 0x2A }, { 0x3B, 0x12 }, { 0x3C, 0x78 }, { 0x3D, 0xC3 },
okano 23:214896356355 61 { 0x3E, 0x11 }, { 0x3F, 0x00 }, { 0x40, 0xD0 }, { 0x41, 0x08 },
okano 23:214896356355 62 { 0x41, 0x38 }, { 0x43, 0x0A }, { 0x44, 0xF0 }, { 0x45, 0x34 },
okano 23:214896356355 63 { 0x46, 0x58 }, { 0x47, 0x28 }, { 0x48, 0x3A }, { 0x4B, 0x09 },
okano 23:214896356355 64 { 0x4C, 0x00 }, { 0x4D, 0x40 }, { 0x4E, 0x20 }, { 0x4F, 0x80 },
okano 23:214896356355 65 { 0x50, 0x80 }, { 0x51, 0x00 }, { 0x52, 0x22 }, { 0x53, 0x5E },
okano 23:214896356355 66 { 0x54, 0x80 }, { 0x56, 0x40 }, { 0x58, 0x9E }, { 0x59, 0x88 },
okano 23:214896356355 67 { 0x5A, 0x88 }, { 0x5B, 0x44 }, { 0x5C, 0x67 }, { 0x5D, 0x49 },
okano 23:214896356355 68 { 0x5E, 0x0E }, { 0x69, 0x00 }, { 0x6A, 0x40 }, { 0x6B, 0x0A },
okano 23:214896356355 69 { 0x6C, 0x0A }, { 0x6D, 0x55 }, { 0x6E, 0x11 }, { 0x6F, 0x9F },
okano 23:214896356355 70 { 0x70, 0x3A }, { 0x71, 0x35 }, { 0x72, 0x11 }, { 0x73, 0xF1 },
okano 23:214896356355 71 { 0x74, 0x10 }, { 0x75, 0x05 }, { 0x76, 0xE1 }, { 0x77, 0x01 },
okano 23:214896356355 72 { 0x78, 0x04 }, { 0x79, 0x01 }, { 0x8D, 0x4F }, { 0x8E, 0x00 },
okano 23:214896356355 73 { 0x8F, 0x00 }, { 0x90, 0x00 }, { 0x91, 0x00 }, { 0x96, 0x00 },
okano 23:214896356355 74 { 0x96, 0x00 }, { 0x97, 0x30 }, { 0x98, 0x20 }, { 0x99, 0x30 },
okano 23:214896356355 75 { 0x9A, 0x00 }, { 0x9A, 0x84 }, { 0x9B, 0x29 }, { 0x9C, 0x03 },
okano 23:214896356355 76 { 0x9D, 0x4C }, { 0x9E, 0x3F }, { 0xA2, 0x52 }, { 0xA4, 0x88 },
okano 23:214896356355 77 { 0xB0, 0x84 }, { 0xB1, 0x0C }, { 0xB2, 0x0E }, { 0xB3, 0x82 },
okano 23:214896356355 78 { 0xB8, 0x0A }, { 0xC8, 0xF0 }, { 0xC9, 0x60 },
okano 13:210f4bbd0cd6 79 };
okano 28:b5d5a2f7f0d0 80 const char res_change_param[ 5 ][ RES_CHANGE_PARAM_NUM ] = {
okano 28:b5d5a2f7f0d0 81 { 0x17, 0x18, 0x32, 0x19, 0x1a, 0x03, 0x0c, 0x3e, 0x71, 0x72, 0x73, 0xa2 }, // register addr
okano 28:b5d5a2f7f0d0 82 { 0x39, 0x03, 0x80, 0x03, 0x7b, 0x02, 0x0c, 0x11, 0x35, 0x11, 0xf1, 0x52 }, // QSIF
okano 28:b5d5a2f7f0d0 83 { 0x13, 0x01, 0xb6, 0x02, 0x7a, 0x0a, 0x00, 0x00, 0x35, 0x11, 0xf0, 0x02 }, // VGA
okano 28:b5d5a2f7f0d0 84 { 0x16, 0x04, 0x80, 0x02, 0x7a, 0x0a, 0x04, 0x19, 0x35, 0x11, 0xf1, 0x02 }, // QVGA
okano 28:b5d5a2f7f0d0 85 { 0x16, 0x04, 0xa4, 0x02, 0x7a, 0x0a, 0x04, 0x1a, 0x35, 0x22, 0xf2, 0x02 }, // QQVGA
okano 28:b5d5a2f7f0d0 86 };
okano 27:f31bff7335ae 87 const char camera_reset_command[] = { 0x12, 0x80 };
okano 19:1d07d6d762a9 88
okano 11:61a025e8ab68 89 // SPI settings
okano 11:61a025e8ab68 90
okano 11:61a025e8ab68 91 _cs = 1; // set ChipSelect signal HIGH
okano 11:61a025e8ab68 92 _spi.format( 8 ); // camera SPI : 8bits/transfer
okano 11:61a025e8ab68 93 _spi.frequency( SPI_FREQUENCY ); // SPI frequency setting
okano 11:61a025e8ab68 94
okano 11:61a025e8ab68 95 // reset
okano 0:f4584dba3bac 96
okano 4:cb0ef3fd89c9 97 _reset = 0;
okano 11:61a025e8ab68 98 wait_ms( RESET_PULSE_WIDTH ); // assert RESET signal
okano 4:cb0ef3fd89c9 99 _reset = 1;
okano 27:f31bff7335ae 100
okano 27:f31bff7335ae 101 if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, camera_reset_command, 2 )) )
okano 27:f31bff7335ae 102 return _error_state; // return non-zero if I2C access failed
okano 27:f31bff7335ae 103
okano 11:61a025e8ab68 104 wait_ms( RESET_RECOVERY_TIME ); // deassert RESET signal
okano 0:f4584dba3bac 105
okano 22:1a923c255be6 106 _horizontal_size = QCIF_PIXEL_PER_LINE;
okano 22:1a923c255be6 107 _vertical_size = QCIF_LINE_PER_FRAME;
okano 19:1d07d6d762a9 108
okano 29:4432c5282c7b 109 #ifdef UNIFIED_RESOLUTION_CHANGE
okano 28:b5d5a2f7f0d0 110 if ( QCIF != res ) {
okano 28:b5d5a2f7f0d0 111 for ( int i = 0; i < RES_CHANGE_PARAM_NUM; i++ ) {
okano 28:b5d5a2f7f0d0 112 for ( int j = 0; j < PARAM_NUM; j++ ) {
okano 28:b5d5a2f7f0d0 113 if ( camera_register_setting[ j ][ 0 ] == res_change_param[ 0 ][ i ] ) {
okano 28:b5d5a2f7f0d0 114 camera_register_setting[ j ][ 1 ] = res_change_param[ res ][ i ];
okano 28:b5d5a2f7f0d0 115 }
okano 28:b5d5a2f7f0d0 116 }
okano 28:b5d5a2f7f0d0 117 }
okano 28:b5d5a2f7f0d0 118 }
okano 29:4432c5282c7b 119 #endif
okano 29:4432c5282c7b 120
okano 29:4432c5282c7b 121 switch ( res ) {
okano 29:4432c5282c7b 122 case QCIF:
okano 29:4432c5282c7b 123 _horizontal_size = QCIF_PIXEL_PER_LINE;
okano 29:4432c5282c7b 124 _vertical_size = QCIF_LINE_PER_FRAME;
okano 29:4432c5282c7b 125 break;
okano 29:4432c5282c7b 126 case VGA:
okano 29:4432c5282c7b 127 _horizontal_size = VGA_PIXEL_PER_LINE;
okano 29:4432c5282c7b 128 _vertical_size = VGA_LINE_PER_FRAME;
okano 29:4432c5282c7b 129 break;
okano 29:4432c5282c7b 130 case QVGA:
okano 29:4432c5282c7b 131 _horizontal_size = VGA_PIXEL_PER_LINE / 2;
okano 29:4432c5282c7b 132 _vertical_size = VGA_LINE_PER_FRAME / 2;
okano 29:4432c5282c7b 133 break;
okano 29:4432c5282c7b 134 case QQVGA:
okano 29:4432c5282c7b 135 _horizontal_size = VGA_PIXEL_PER_LINE / 4;
okano 29:4432c5282c7b 136 _vertical_size = VGA_LINE_PER_FRAME / 4;
okano 29:4432c5282c7b 137 break;
okano 29:4432c5282c7b 138 }
okano 28:b5d5a2f7f0d0 139
okano 22:1a923c255be6 140 for ( int i = 0; i < PARAM_NUM; i++ ) {
okano 22:1a923c255be6 141 if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, camera_register_setting[ i ], 2 )) )
okano 22:1a923c255be6 142 break;
okano 22:1a923c255be6 143
okano 29:4432c5282c7b 144 wait_ms( COMMAND_INTERVAL ); // camera register writing requires this interval
okano 22:1a923c255be6 145 }
okano 22:1a923c255be6 146
okano 29:4432c5282c7b 147 #ifndef UNIFIED_RESOLUTION_CHANGE
okano 29:4432c5282c7b 148 char d[ 2 ];
okano 29:4432c5282c7b 149 for ( int i = 0; i < RES_CHANGE_PARAM_NUM; i++ ) {
okano 29:4432c5282c7b 150 d[ 0 ] = res_change_param[ 0 ][ i ];
okano 29:4432c5282c7b 151 d[ 1 ] = res_change_param[ res ][ i ];
okano 29:4432c5282c7b 152
okano 29:4432c5282c7b 153 if ( 0 != (_error_state = _i2c.write( CAM_I2C_ADDR, d, 2 )) )
okano 29:4432c5282c7b 154 break;
okano 29:4432c5282c7b 155 }
okano 29:4432c5282c7b 156 #endif
okano 29:4432c5282c7b 157
okano 29:4432c5282c7b 158
okano 22:1a923c255be6 159 return _error_state; // return non-zero if I2C access failed
okano 22:1a923c255be6 160 }
okano 22:1a923c255be6 161
okano 20:fa4a54e25fc4 162 void MARY_CAMERA::colorbar( SwitchState sw )
okano 20:fa4a54e25fc4 163 {
okano 20:fa4a54e25fc4 164 char s[ 2 ];
okano 22:1a923c255be6 165
okano 20:fa4a54e25fc4 166 s[ 0 ] = 0x12;
okano 20:fa4a54e25fc4 167 s[ 1 ] = sw ? 0x06 : 0x04;
okano 22:1a923c255be6 168
okano 20:fa4a54e25fc4 169 _error_state = _i2c.write( CAM_I2C_ADDR, s, 2 );
okano 20:fa4a54e25fc4 170 }
okano 20:fa4a54e25fc4 171
okano 19:1d07d6d762a9 172 int MARY_CAMERA::horizontal_size( void )
okano 19:1d07d6d762a9 173 {
okano 19:1d07d6d762a9 174 return _horizontal_size; // return last state of I2C access
okano 19:1d07d6d762a9 175 }
okano 2:ee71ffdf317e 176
okano 19:1d07d6d762a9 177 int MARY_CAMERA::vertical_size( void )
okano 19:1d07d6d762a9 178 {
okano 19:1d07d6d762a9 179 return _vertical_size; // return last state of I2C access
okano 0:f4584dba3bac 180 }
okano 0:f4584dba3bac 181
okano 13:210f4bbd0cd6 182 int MARY_CAMERA::ready( void )
okano 13:210f4bbd0cd6 183 {
okano 11:61a025e8ab68 184 return _error_state; // return last state of I2C access
okano 8:23d14d5254d2 185 }
okano 8:23d14d5254d2 186
okano 24:cc4271d1545f 187 extern int read_order_change;
okano 24:cc4271d1545f 188
okano 13:210f4bbd0cd6 189 void MARY_CAMERA::transfer_a_line( short *p, int line_number, int x_offset, int n_of_pixels )
okano 13:210f4bbd0cd6 190 {
okano 24:cc4271d1545f 191 #if 0
okano 24:cc4271d1545f 192
okano 9:c1e24f1bec19 193 char tmp;
okano 24:cc4271d1545f 194
okano 23:214896356355 195 if ( line_number < 0 )
okano 23:214896356355 196 return;
okano 10:82394d226c74 197
okano 11:61a025e8ab68 198 // set camera module's buffer address
okano 19:1d07d6d762a9 199 set_address( line_number * horizontal_size() * BYTE_PER_PIXEL + x_offset * BYTE_PER_PIXEL );
okano 0:f4584dba3bac 200
okano 11:61a025e8ab68 201 // put a read command, first return byte should be ignored
okano 0:f4584dba3bac 202 read_register( CAMERA_DATA_REGISTER );
okano 11:61a025e8ab68 203
okano 10:82394d226c74 204 for( int x = 0; x < n_of_pixels; x++ ) {
okano 11:61a025e8ab68 205 // perform 2 bytes read. a pixel data is in RGB565 format (16bits)
okano 11:61a025e8ab68 206 tmp = read_register( CAMERA_DATA_REGISTER ); // read lower byte
okano 11:61a025e8ab68 207 *p++ = (read_register( CAMERA_DATA_REGISTER ) << 8) | tmp; // read upper byte
okano 9:c1e24f1bec19 208 }
okano 24:cc4271d1545f 209
okano 24:cc4271d1545f 210 #else
okano 24:cc4271d1545f 211
okano 24:cc4271d1545f 212
okano 24:cc4271d1545f 213 short tmp;
okano 24:cc4271d1545f 214
okano 24:cc4271d1545f 215 if ( line_number < 0 )
okano 24:cc4271d1545f 216 return;
okano 24:cc4271d1545f 217
okano 24:cc4271d1545f 218 // set camera module's buffer address
okano 24:cc4271d1545f 219 set_address( line_number * horizontal_size() * BYTE_PER_PIXEL + x_offset * BYTE_PER_PIXEL );
okano 24:cc4271d1545f 220
okano 24:cc4271d1545f 221 // put a read command, first return byte should be ignored
okano 24:cc4271d1545f 222 read_register( CAMERA_DATA_REGISTER );
okano 24:cc4271d1545f 223
okano 24:cc4271d1545f 224
okano 24:cc4271d1545f 225 if ( read_order_change ) {
okano 24:cc4271d1545f 226
okano 24:cc4271d1545f 227 read_register( CAMERA_DATA_REGISTER );
okano 24:cc4271d1545f 228
okano 24:cc4271d1545f 229 for( int x = 0; x < n_of_pixels; x++ ) {
okano 24:cc4271d1545f 230 // perform 2 bytes read. a pixel data is in RGB565 format (16bits)
okano 24:cc4271d1545f 231 tmp = read_register( CAMERA_DATA_REGISTER ) << 8; // read lower byte
okano 24:cc4271d1545f 232 *p++ = (read_register( CAMERA_DATA_REGISTER ) << 0) | tmp; // read upper byte
okano 24:cc4271d1545f 233 }
okano 24:cc4271d1545f 234
okano 24:cc4271d1545f 235 } else {
okano 24:cc4271d1545f 236
okano 24:cc4271d1545f 237 for( int x = 0; x < n_of_pixels; x++ ) {
okano 24:cc4271d1545f 238 // perform 2 bytes read. a pixel data is in RGB565 format (16bits)
okano 24:cc4271d1545f 239 tmp = read_register( CAMERA_DATA_REGISTER ); // read lower byte
okano 24:cc4271d1545f 240 *p++ = (read_register( CAMERA_DATA_REGISTER ) << 8) | tmp; // read upper byte
okano 24:cc4271d1545f 241 }
okano 24:cc4271d1545f 242
okano 24:cc4271d1545f 243 }
okano 24:cc4271d1545f 244
okano 24:cc4271d1545f 245 #endif
okano 0:f4584dba3bac 246 }
okano 0:f4584dba3bac 247
okano 13:210f4bbd0cd6 248 void MARY_CAMERA::open_transfer( void )
okano 13:210f4bbd0cd6 249 {
okano 11:61a025e8ab68 250 // send command to pause the camera buffer update
okano 0:f4584dba3bac 251 write_register( CONTROL_DATA_REGISTER, CONTROL__PAUSE_BUFFER_UPDATE );
okano 0:f4584dba3bac 252
okano 11:61a025e8ab68 253 // read status register (first return byte should be ignored)
okano 0:f4584dba3bac 254 read_register( STATUS_REGISTER );
okano 7:942d8d0a1760 255
okano 11:61a025e8ab68 256 // wait until the status register become 0x51(ready to transfer data)
okano 11:61a025e8ab68 257 while ( 0x51 != read_register( STATUS_REGISTER ) )
okano 11:61a025e8ab68 258 ;
okano 0:f4584dba3bac 259 }
okano 0:f4584dba3bac 260
okano 13:210f4bbd0cd6 261 void MARY_CAMERA::close_transfer( void )
okano 13:210f4bbd0cd6 262 {
okano 11:61a025e8ab68 263 // send command to resume the camera buffer update
okano 0:f4584dba3bac 264 write_register( CONTROL_DATA_REGISTER, CONTROL__RESUME_BUFFER_UPDATE );
okano 0:f4584dba3bac 265
okano 11:61a025e8ab68 266 // read status register (first return byte should be ignored)
okano 0:f4584dba3bac 267 read_register( STATUS_REGISTER );
okano 7:942d8d0a1760 268
okano 11:61a025e8ab68 269 // wait until the status register become 0x50(camera updating the buffer)
okano 11:61a025e8ab68 270 while ( 0x50 != read_register( STATUS_REGISTER ) )
okano 11:61a025e8ab68 271 ;
okano 0:f4584dba3bac 272 }
okano 0:f4584dba3bac 273
okano 13:210f4bbd0cd6 274 void MARY_CAMERA::set_address( int address )
okano 13:210f4bbd0cd6 275 {
okano 11:61a025e8ab68 276 // set memory address (3 bytes)
okano 12:614be3290c47 277
okano 0:f4584dba3bac 278 write_register( MEMORY_ADDR_LOW__REGISTER, (address >> 0) & 0xFF );
okano 0:f4584dba3bac 279 write_register( MEMORY_ADDR_MID__REGISTER, (address >> 8) & 0xFF );
okano 0:f4584dba3bac 280 write_register( MEMORY_ADDR_HIGH_REGISTER, (address >> 16) & 0xFF );
okano 0:f4584dba3bac 281 }
okano 0:f4584dba3bac 282
okano 13:210f4bbd0cd6 283 void MARY_CAMERA::write_register( char reg, char value )
okano 13:210f4bbd0cd6 284 {
okano 11:61a025e8ab68 285 // camera register write
okano 12:614be3290c47 286
okano 11:61a025e8ab68 287 send_spi( COMMAND_WRITE | reg ); // send command and register number
okano 11:61a025e8ab68 288 send_spi( value ); // send register value
okano 11:61a025e8ab68 289 }
okano 11:61a025e8ab68 290
okano 13:210f4bbd0cd6 291 int MARY_CAMERA::read_register( char reg )
okano 13:210f4bbd0cd6 292 {
okano 11:61a025e8ab68 293 // camera register read
okano 11:61a025e8ab68 294 // returning current data in SPI buffer (data returned by previous command)
okano 11:61a025e8ab68 295
okano 11:61a025e8ab68 296 return ( send_spi( COMMAND_READ | reg | ((reg == CAMERA_DATA_REGISTER) ? COMMAND_ADDR_INCREMENT : 0x00) ) );
okano 11:61a025e8ab68 297 }
okano 10:82394d226c74 298
okano 13:210f4bbd0cd6 299 int MARY_CAMERA::send_spi( char data )
okano 13:210f4bbd0cd6 300 {
okano 0:f4584dba3bac 301 int tmp;
okano 12:614be3290c47 302
okano 11:61a025e8ab68 303 // SPI access
okano 0:f4584dba3bac 304
okano 4:cb0ef3fd89c9 305 _cs = 0;
okano 4:cb0ef3fd89c9 306 tmp = _spi.write( data );
okano 4:cb0ef3fd89c9 307 _cs = 1;
okano 12:614be3290c47 308
okano 0:f4584dba3bac 309 return ( tmp );
okano 0:f4584dba3bac 310 }