SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Hardwares/ArduCAM.h@90:a8a0ab59e7eb, 2017-04-19 (annotated)
- Committer:
- hazheng
- Date:
- Wed Apr 19 04:26:17 2017 +0000
- Revision:
- 90:a8a0ab59e7eb
- Parent:
- 79:bdbac82c979b
- Child:
- 93:8e1bd3602d53
Removed not used Real-Time OS library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hazheng | 28:271fc8445e89 | 1 | #pragma once |
hazheng | 28:271fc8445e89 | 2 | #ifndef ARDU_CAM_H |
hazheng | 28:271fc8445e89 | 3 | #define ARDU_CAM_H |
hazheng | 28:271fc8445e89 | 4 | |
hazheng | 29:f87d8790f57d | 5 | #include <mbed.h> |
hazheng | 28:271fc8445e89 | 6 | #include "PinAssignment.h" |
hazheng | 28:271fc8445e89 | 7 | |
hazheng | 65:295c222fdf88 | 8 | #define RESOLUTION_WIDTH 80 |
hazheng | 65:295c222fdf88 | 9 | #define RESOLUTION_HEIGHT 60 |
hazheng | 41:7b21c5e3599e | 10 | //#define MANUAL_REDUCE_RESULOTION_BY2 |
hazheng | 70:311d32a596db | 11 | #define CAM_ROI_UPPER_LIMIT 6 |
hazheng | 65:295c222fdf88 | 12 | |
hazheng | 65:295c222fdf88 | 13 | |
hazheng | 65:295c222fdf88 | 14 | #define BOTH_NOT_FOUND 0 |
hazheng | 65:295c222fdf88 | 15 | #define LEFT_FOUND 1 |
hazheng | 65:295c222fdf88 | 16 | #define RIGHT_FOUND 2 |
hazheng | 70:311d32a596db | 17 | #define BOTH_FOUND 3 |
hazheng | 38:0fb273b28cee | 18 | |
hazheng | 36:7e747e19f660 | 19 | //=====Must pick one and only one here!===== |
hazheng | 37:7074a6118d03 | 20 | //#define ARDUCAM_SHIELD_OV2640 |
hazheng | 36:7e747e19f660 | 21 | //#define ARDUCAM_SHIELD_OV7725 |
hazheng | 38:0fb273b28cee | 22 | //#define ARDUCAM_SHIELD_OV7670 |
hazheng | 38:0fb273b28cee | 23 | #define ARDUCAM_MINI_OV2640 |
hazheng | 36:7e747e19f660 | 24 | //========================================== |
hazheng | 36:7e747e19f660 | 25 | |
hazheng | 37:7074a6118d03 | 26 | |
hazheng | 37:7074a6118d03 | 27 | #if defined(ARDUCAM_SHIELD_OV2640) || defined(ARDUCAM_SHIELD_OV7725) || defined(ARDUCAM_SHIELD_OV7670) |
hazheng | 36:7e747e19f660 | 28 | #define ARDUCAM_SHIELD |
hazheng | 36:7e747e19f660 | 29 | #elif defined(ARDUCAM_MINI_OV2640) |
hazheng | 36:7e747e19f660 | 30 | #define ARDUCAM_MINI |
hazheng | 36:7e747e19f660 | 31 | #else |
hazheng | 36:7e747e19f660 | 32 | #error Must pick one and only one ArduCam type! |
hazheng | 36:7e747e19f660 | 33 | #endif |
hazheng | 36:7e747e19f660 | 34 | |
hazheng | 36:7e747e19f660 | 35 | #if defined(ARDUCAM_SHIELD_OV2640) || defined(ARDUCAM_MINI_OV2640) |
hazheng | 36:7e747e19f660 | 36 | #define ARDUCAM_OV2640 |
hazheng | 36:7e747e19f660 | 37 | #elif defined(ARDUCAM_SHIELD_OV7725) |
hazheng | 36:7e747e19f660 | 38 | #define ARDUCAM_OV7725 |
hazheng | 37:7074a6118d03 | 39 | #elif defined(ARDUCAM_SHIELD_OV7670) |
hazheng | 37:7074a6118d03 | 40 | #define ARDUCAM_OV7670 |
hazheng | 36:7e747e19f660 | 41 | #else |
hazheng | 36:7e747e19f660 | 42 | #error Must pick one and only one ArduCam type! |
hazheng | 36:7e747e19f660 | 43 | #endif |
hazheng | 36:7e747e19f660 | 44 | |
hazheng | 36:7e747e19f660 | 45 | #if defined(ARDUCAM_OV2640) |
hazheng | 36:7e747e19f660 | 46 | #include "OV2640RegProg.h" |
hazheng | 46:a5eb9bd3bb55 | 47 | //using namespace OV2640Prog; |
hazheng | 36:7e747e19f660 | 48 | #elif defined(ARDUCAM_OV7725) |
hazheng | 36:7e747e19f660 | 49 | #include "OV7725RegProg.h" |
hazheng | 46:a5eb9bd3bb55 | 50 | //using namespace OV7725Prog; |
hazheng | 37:7074a6118d03 | 51 | #elif defined(ARDUCAM_OV7670) |
hazheng | 37:7074a6118d03 | 52 | #include "OV7670RegProg.h" |
hazheng | 46:a5eb9bd3bb55 | 53 | //using namespace OV7670Prog; |
hazheng | 36:7e747e19f660 | 54 | #endif |
hazheng | 36:7e747e19f660 | 55 | |
hazheng | 36:7e747e19f660 | 56 | #if defined(ARDUCAM_SHIELD) |
hazheng | 36:7e747e19f660 | 57 | #define ARDUCHIP_VER_NUM 0x61 |
hazheng | 36:7e747e19f660 | 58 | #elif defined(ARDUCAM_MINI) |
hazheng | 36:7e747e19f660 | 59 | #define ARDUCHIP_VER_NUM 0x55 |
hazheng | 36:7e747e19f660 | 60 | #endif |
hazheng | 36:7e747e19f660 | 61 | |
hazheng | 29:f87d8790f57d | 62 | #define ARDUCHIP_TEST1 0x00 //TEST register |
hazheng | 29:f87d8790f57d | 63 | #define ARDUCHIP_TEST_MSG 0x72 |
hazheng | 29:f87d8790f57d | 64 | |
hazheng | 29:f87d8790f57d | 65 | #define ARDUCHIP_CAP_CTRL 0x01 //Capture Control Register |
hazheng | 29:f87d8790f57d | 66 | |
hazheng | 40:be98219930e4 | 67 | #if defined(ARDUCAM_SHIELD) |
hazheng | 40:be98219930e4 | 68 | #define ARDUCHIP_MODE 0x02 //Mode register |
hazheng | 40:be98219930e4 | 69 | //#define MCU2LCD_MODE 0x00 |
hazheng | 40:be98219930e4 | 70 | //#define CAM2LCD_MODE 0x01 |
hazheng | 40:be98219930e4 | 71 | #define MCU2LCD_MODE 0x01 |
hazheng | 40:be98219930e4 | 72 | #define CAM2LCD_MODE 0x02 |
hazheng | 40:be98219930e4 | 73 | //#define LCD2MCU_MODE 0x04 |
hazheng | 40:be98219930e4 | 74 | #endif |
hazheng | 29:f87d8790f57d | 75 | |
hazheng | 29:f87d8790f57d | 76 | #define ARDUCHIP_FIFO 0x04 //FIFO and I2C control |
hazheng | 29:f87d8790f57d | 77 | #define FIFO_CLEAR_MASK 0x01 |
hazheng | 29:f87d8790f57d | 78 | #define FIFO_START_MASK 0x02 |
hazheng | 29:f87d8790f57d | 79 | #define FIFO_RDPTR_RST_MASK 0x10 |
hazheng | 29:f87d8790f57d | 80 | #define FIFO_WRPTR_RST_MASK 0x20 |
hazheng | 29:f87d8790f57d | 81 | |
hazheng | 44:15de535c4005 | 82 | #define ARDUCHIP_TRIG 0x41 //Trigger source |
hazheng | 44:15de535c4005 | 83 | #define VSYNC_MASK 0x01 |
hazheng | 44:15de535c4005 | 84 | #define SHUTTER_MASK 0x02 |
hazheng | 44:15de535c4005 | 85 | #define CAP_DONE_MASK 0x08 |
hazheng | 44:15de535c4005 | 86 | |
hazheng | 32:5badeff825dc | 87 | #define FIFO_SIZE1 0x42 //Camera write FIFO size[7:0] for burst to read |
hazheng | 32:5badeff825dc | 88 | #define FIFO_SIZE2 0x43 //Camera write FIFO size[15:8] |
hazheng | 44:15de535c4005 | 89 | #define FIFO_SIZE3 0x44 //Camera write FIFO size[18:16] |
hazheng | 32:5badeff825dc | 90 | |
hazheng | 32:5badeff825dc | 91 | #define BURST_FIFO_READ 0x3C //Burst FIFO read operation |
hazheng | 32:5badeff825dc | 92 | #define SINGLE_FIFO_READ 0x3D //Single FIFO read operation |
hazheng | 29:f87d8790f57d | 93 | |
hazheng | 46:a5eb9bd3bb55 | 94 | #ifdef __cplusplus |
hazheng | 46:a5eb9bd3bb55 | 95 | extern "C" { |
hazheng | 46:a5eb9bd3bb55 | 96 | #endif |
hazheng | 46:a5eb9bd3bb55 | 97 | |
hazheng | 28:271fc8445e89 | 98 | bool ardu_cam_init(); |
hazheng | 28:271fc8445e89 | 99 | |
hazheng | 29:f87d8790f57d | 100 | void ardu_cam_start_capture(); |
hazheng | 29:f87d8790f57d | 101 | |
hazheng | 32:5badeff825dc | 102 | uint32_t ardu_cam_get_fifo_length(); |
hazheng | 32:5badeff825dc | 103 | |
hazheng | 32:5badeff825dc | 104 | void ardu_cam_print_debug(); |
hazheng | 32:5badeff825dc | 105 | |
hazheng | 44:15de535c4005 | 106 | volatile const uint8_t* ardu_cam_get_center_array(); |
hazheng | 44:15de535c4005 | 107 | |
hazheng | 44:15de535c4005 | 108 | uint8_t ardu_cam_is_capture_finished(); |
hazheng | 43:0d1886f4848a | 109 | |
hazheng | 46:a5eb9bd3bb55 | 110 | void ardu_cam_display_img_utft(); |
hazheng | 46:a5eb9bd3bb55 | 111 | |
hazheng | 57:0d8a155d511d | 112 | void image_processing(); |
hazheng | 57:0d8a155d511d | 113 | |
hazheng | 64:43ab429a37e0 | 114 | uint8_t ardu_cam_get_is_encounter_terminate(); |
hazheng | 64:43ab429a37e0 | 115 | |
hazheng | 79:bdbac82c979b | 116 | uint8_t ardu_cam_get_is_border_found(); |
hazheng | 79:bdbac82c979b | 117 | |
hazheng | 46:a5eb9bd3bb55 | 118 | #ifdef __cplusplus |
hazheng | 46:a5eb9bd3bb55 | 119 | } |
hazheng | 46:a5eb9bd3bb55 | 120 | #endif |
hazheng | 46:a5eb9bd3bb55 | 121 | |
hazheng | 34:f79db3bc2f86 | 122 | //uint8_t ardu_cam_read_reg(uint8_t addr); |
hazheng | 34:f79db3bc2f86 | 123 | |
hazheng | 34:f79db3bc2f86 | 124 | //void ardu_cam_write_reg(uint8_t addr, uint8_t data); |
hazheng | 34:f79db3bc2f86 | 125 | |
hazheng | 34:f79db3bc2f86 | 126 | //int ardu_cam_bus_write(int address, int value); |
hazheng | 34:f79db3bc2f86 | 127 | |
hazheng | 34:f79db3bc2f86 | 128 | //uint8_t ardu_cam_bus_read(int address); |
hazheng | 34:f79db3bc2f86 | 129 | |
hazheng | 28:271fc8445e89 | 130 | #endif //ARDU_CAM_H |