Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: MARY_CAMERA.h
- Revision:
- 0:f4584dba3bac
- Child:
- 1:1e51936de820
- Child:
- 2:ee71ffdf317e
diff -r 000000000000 -r f4584dba3bac MARY_CAMERA.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MARY_CAMERA.h Fri Feb 14 14:19:49 2014 +0000
@@ -0,0 +1,95 @@
+#ifndef MBED_MARY_CAMERA
+#define MBED_MARY_CAMERA
+
+#define PARAM_NUM 99
+#define CAM_I2C_ADDR 0x42
+
+#define COMMAND_WRITE 0x00
+#define COMMAND_READ 0x80
+#define COMMAND_ADDR_INCREMENT 0x20
+
+#define MEMORY_ADDR_LOW__REGISTER 0x0
+#define MEMORY_ADDR_MID__REGISTER 0x1
+#define MEMORY_ADDR_HIGH_REGISTER 0x2
+#define CAMERA_DATA_REGISTER 0x8
+#define CONTROL_DATA_REGISTER 0x3
+#define STATUS_REGISTER 0x4
+
+#define CONTROL__PAUSE_BUFFER_UPDATE 0x01
+#define CONTROL__RESUME_BUFFER_UPDATE 0x00
+
+#define PIXEL_PER_LINE 176
+#define BYTE_PER_PIXEL 2
+#define BYTE_PER_LINE (PIXEL_PER_LINE * BYTE_PER_PIXEL)
+
+#define SPI_FREQUENCY 1000000
+
+// sample MARY_CAMERA camera( p5, p6, p7, p22, p9, p26, p28, p27 )
+
+
+class MARY_CAMERA
+{
+public:
+
+ /** Create a MARY_CAMERA instance connected to specified SPI and DigitalOut pins with specified address
+ *
+ * @param I2C_sda I2C-bus SDA pin
+ * @param I2C_scl I2C-bus SCL pin
+ * @param steps_per_rotation motor specific setting. This determines how many steps are needed to execute one full turn of motor shaft (360°).
+ * @param I2C_address I2C-bus address (default: 0x42)
+ */
+
+ MARY_CAMERA(
+ PinName spi_mosi,
+ PinName spi_miso,
+ PinName spi_sck,
+ PinName spi_cs,
+ PinName cam_vsync,
+ PinName cam_reset,
+ PinName i2c_sda,
+ PinName i2c_scl
+ );
+ void init( void );
+ void open_transfer( void );
+ void close_transfer( void );
+ void transfer_a_line( short *p, int line_number, int x_offset, int n_of_pixels );
+
+private:
+ int send_spi( char data );
+ void write_register( char reg, char value );
+ int read_register( char reg );
+ void set_address( int address );
+
+
+ SPI spi;
+ DigitalOut cs;
+ DigitalOut vsync;
+ DigitalOut reset;
+ I2C i2c;
+};
+
+
+
+
+#if 0
+SPI camspi( p5, p6, p7 );
+DigitalOut cs2( p22 );
+DigitalOut vsync( p9 );
+DigitalOut camera_reset( p26 );
+#endif
+
+#define COMMAND_WRITE 0x00
+#define COMMAND_READ 0x80
+#define COMMAND_ADDR_INCREMENT 0x20
+
+#define MEMORY_ADDR_LOW__REGISTER 0x0
+#define MEMORY_ADDR_MID__REGISTER 0x1
+#define MEMORY_ADDR_HIGH_REGISTER 0x2
+#define CAMERA_DATA_REGISTER 0x8
+#define CONTROL_DATA_REGISTER 0x3
+#define STATUS_REGISTER 0x4
+
+#define CONTROL__PAUSE_BUFFER_UPDATE 0x01
+#define CONTROL__RESUME_BUFFER_UPDATE 0x00
+
+#endif // MBED_MARY_CAMERA
\ No newline at end of file