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.
Dependents: CameraOV528-Example
CameraOV528.h
00001 /* Copyright (c) 2016 ARM Limited 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 #ifndef MBED_CAMERAOV528_H 00016 #define MBED_CAMERAOV528_H 00017 00018 #include "mbed.h" 00019 #include "rtos.h" 00020 00021 class Camera { 00022 public: 00023 Camera(void) {}; 00024 virtual ~Camera(void) {}; 00025 virtual int powerup(void) = 0; 00026 virtual int powerdown(void) = 0; 00027 virtual int take_picture(void) = 0; 00028 virtual uint32_t get_picture_size(void) = 0; 00029 virtual uint32_t read_picture_data(uint8_t *data, uint32_t size) = 0; 00030 }; 00031 00032 class CameraOV528 : public Camera { 00033 00034 public: 00035 enum Resolution { 00036 // RES_80x60 = 0x01, // Does not work 00037 RES_160x120 = 0x03, 00038 RES_320x240 = 0x05, 00039 RES_640x480 = 0x07, 00040 }; 00041 00042 enum Format { 00043 // FMT_2_BIT_GRAY_SCALE = 1, //Does not work 00044 // FMT_4_BIT_GRAY_SCALE = 2, 00045 // FMT_8_BIT_GRAY_SCALE = 3, 00046 // FMT_2_BIT_COLOR = 5, 00047 // FMT_16_BIT = 6, 00048 FMT_JPEG = 7, 00049 }; 00050 00051 CameraOV528(PinName rx, PinName tx); 00052 virtual ~CameraOV528(void); 00053 virtual int powerup(void); 00054 virtual int powerup(uint32_t baud); 00055 virtual int powerdown(void); 00056 virtual int take_picture(void); 00057 virtual uint32_t get_picture_size(void); 00058 virtual uint32_t read_picture_data(uint8_t *data, uint32_t size); 00059 00060 void set_resolution(Resolution resolution); 00061 void set_format(Format format); 00062 void set_baud(uint32_t baud); 00063 00064 void attach_debug_function(void (*func)(const char* fmt, ...)); 00065 int camera_error(const char* message); 00066 00067 private: 00068 00069 bool _init_sequence(); 00070 void _set_baud(uint32_t baud); 00071 void _set_package_size(uint32_t size); 00072 void _set_fmt_and_res(Format fmt, Resolution res); 00073 int _read_picture_block(); 00074 00075 void _rx_irq(void); 00076 00077 bool _send(const uint8_t *data, uint32_t size, uint32_t timeout_ms=500); 00078 uint32_t _read(uint8_t * data, uint32_t size, uint32_t timeout_ms=500); 00079 void _flush_rx(void); 00080 00081 bool _send_cmd(uint8_t cmd, uint8_t p1=0, uint8_t p2=0, uint8_t p3=0, uint8_t p4=0); 00082 void _send_ack(uint8_t p1, uint8_t p2, uint8_t p3, uint8_t p4); 00083 00084 RawSerial _serial; 00085 00086 bool _init_done; 00087 Resolution _resolution; 00088 Format _format; 00089 uint32_t _baud; 00090 00091 Resolution _dev_resolution; 00092 Format _dev_format; 00093 uint32_t _dev_baud; 00094 00095 uint32_t picture_length; 00096 uint32_t picture_data_id; 00097 uint32_t picture_data_id_count; 00098 uint8_t picture_buffer[128]; 00099 uint32_t picture_buffer_size_limit; 00100 uint32_t picture_buffer_pos; 00101 uint32_t picture_buffer_size; 00102 00103 uint8_t _read_buf[sizeof(picture_buffer) + 1]; 00104 uint32_t _read_buf_head; 00105 uint32_t _read_buf_tail; 00106 uint32_t _read_wake_pos; 00107 Semaphore _read_sem; 00108 00109 void (*log_func)(const char* fmt, ...); 00110 }; 00111 00112 #endif
Generated on Wed Jul 13 2022 05:09:17 by
1.7.2
Camera OV528