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 haofan Zheng

Committer:
hazheng
Date:
Tue Apr 18 17:43:12 2017 +0000
Branch:
Drift
Revision:
79:bdbac82c979b
Parent:
70:311d32a596db
Child:
90:a8a0ab59e7eb
Finished the basic function of the touch screen.

Who changed what in which revision?

UserRevisionLine numberNew 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 44:15de535c4005 6 #include <rtos.h>
hazheng 28:271fc8445e89 7 #include "PinAssignment.h"
hazheng 28:271fc8445e89 8
hazheng 65:295c222fdf88 9 #define RESOLUTION_WIDTH 80
hazheng 65:295c222fdf88 10 #define RESOLUTION_HEIGHT 60
hazheng 41:7b21c5e3599e 11 //#define MANUAL_REDUCE_RESULOTION_BY2
hazheng 70:311d32a596db 12 #define CAM_ROI_UPPER_LIMIT 6
hazheng 65:295c222fdf88 13
hazheng 65:295c222fdf88 14
hazheng 65:295c222fdf88 15 #define BOTH_NOT_FOUND 0
hazheng 65:295c222fdf88 16 #define LEFT_FOUND 1
hazheng 65:295c222fdf88 17 #define RIGHT_FOUND 2
hazheng 70:311d32a596db 18 #define BOTH_FOUND 3
hazheng 38:0fb273b28cee 19
hazheng 36:7e747e19f660 20 //=====Must pick one and only one here!=====
hazheng 37:7074a6118d03 21 //#define ARDUCAM_SHIELD_OV2640
hazheng 36:7e747e19f660 22 //#define ARDUCAM_SHIELD_OV7725
hazheng 38:0fb273b28cee 23 //#define ARDUCAM_SHIELD_OV7670
hazheng 38:0fb273b28cee 24 #define ARDUCAM_MINI_OV2640
hazheng 36:7e747e19f660 25 //==========================================
hazheng 36:7e747e19f660 26
hazheng 37:7074a6118d03 27
hazheng 37:7074a6118d03 28 #if defined(ARDUCAM_SHIELD_OV2640) || defined(ARDUCAM_SHIELD_OV7725) || defined(ARDUCAM_SHIELD_OV7670)
hazheng 36:7e747e19f660 29 #define ARDUCAM_SHIELD
hazheng 36:7e747e19f660 30 #elif defined(ARDUCAM_MINI_OV2640)
hazheng 36:7e747e19f660 31 #define ARDUCAM_MINI
hazheng 36:7e747e19f660 32 #else
hazheng 36:7e747e19f660 33 #error Must pick one and only one ArduCam type!
hazheng 36:7e747e19f660 34 #endif
hazheng 36:7e747e19f660 35
hazheng 36:7e747e19f660 36 #if defined(ARDUCAM_SHIELD_OV2640) || defined(ARDUCAM_MINI_OV2640)
hazheng 36:7e747e19f660 37 #define ARDUCAM_OV2640
hazheng 36:7e747e19f660 38 #elif defined(ARDUCAM_SHIELD_OV7725)
hazheng 36:7e747e19f660 39 #define ARDUCAM_OV7725
hazheng 37:7074a6118d03 40 #elif defined(ARDUCAM_SHIELD_OV7670)
hazheng 37:7074a6118d03 41 #define ARDUCAM_OV7670
hazheng 36:7e747e19f660 42 #else
hazheng 36:7e747e19f660 43 #error Must pick one and only one ArduCam type!
hazheng 36:7e747e19f660 44 #endif
hazheng 36:7e747e19f660 45
hazheng 36:7e747e19f660 46 #if defined(ARDUCAM_OV2640)
hazheng 36:7e747e19f660 47 #include "OV2640RegProg.h"
hazheng 46:a5eb9bd3bb55 48 //using namespace OV2640Prog;
hazheng 36:7e747e19f660 49 #elif defined(ARDUCAM_OV7725)
hazheng 36:7e747e19f660 50 #include "OV7725RegProg.h"
hazheng 46:a5eb9bd3bb55 51 //using namespace OV7725Prog;
hazheng 37:7074a6118d03 52 #elif defined(ARDUCAM_OV7670)
hazheng 37:7074a6118d03 53 #include "OV7670RegProg.h"
hazheng 46:a5eb9bd3bb55 54 //using namespace OV7670Prog;
hazheng 36:7e747e19f660 55 #endif
hazheng 36:7e747e19f660 56
hazheng 36:7e747e19f660 57 #if defined(ARDUCAM_SHIELD)
hazheng 36:7e747e19f660 58 #define ARDUCHIP_VER_NUM 0x61
hazheng 36:7e747e19f660 59 #elif defined(ARDUCAM_MINI)
hazheng 36:7e747e19f660 60 #define ARDUCHIP_VER_NUM 0x55
hazheng 36:7e747e19f660 61 #endif
hazheng 36:7e747e19f660 62
hazheng 29:f87d8790f57d 63 #define ARDUCHIP_TEST1 0x00 //TEST register
hazheng 29:f87d8790f57d 64 #define ARDUCHIP_TEST_MSG 0x72
hazheng 29:f87d8790f57d 65
hazheng 29:f87d8790f57d 66 #define ARDUCHIP_CAP_CTRL 0x01 //Capture Control Register
hazheng 29:f87d8790f57d 67
hazheng 40:be98219930e4 68 #if defined(ARDUCAM_SHIELD)
hazheng 40:be98219930e4 69 #define ARDUCHIP_MODE 0x02 //Mode register
hazheng 40:be98219930e4 70 //#define MCU2LCD_MODE 0x00
hazheng 40:be98219930e4 71 //#define CAM2LCD_MODE 0x01
hazheng 40:be98219930e4 72 #define MCU2LCD_MODE 0x01
hazheng 40:be98219930e4 73 #define CAM2LCD_MODE 0x02
hazheng 40:be98219930e4 74 //#define LCD2MCU_MODE 0x04
hazheng 40:be98219930e4 75 #endif
hazheng 29:f87d8790f57d 76
hazheng 29:f87d8790f57d 77 #define ARDUCHIP_FIFO 0x04 //FIFO and I2C control
hazheng 29:f87d8790f57d 78 #define FIFO_CLEAR_MASK 0x01
hazheng 29:f87d8790f57d 79 #define FIFO_START_MASK 0x02
hazheng 29:f87d8790f57d 80 #define FIFO_RDPTR_RST_MASK 0x10
hazheng 29:f87d8790f57d 81 #define FIFO_WRPTR_RST_MASK 0x20
hazheng 29:f87d8790f57d 82
hazheng 44:15de535c4005 83 #define ARDUCHIP_TRIG 0x41 //Trigger source
hazheng 44:15de535c4005 84 #define VSYNC_MASK 0x01
hazheng 44:15de535c4005 85 #define SHUTTER_MASK 0x02
hazheng 44:15de535c4005 86 #define CAP_DONE_MASK 0x08
hazheng 44:15de535c4005 87
hazheng 32:5badeff825dc 88 #define FIFO_SIZE1 0x42 //Camera write FIFO size[7:0] for burst to read
hazheng 32:5badeff825dc 89 #define FIFO_SIZE2 0x43 //Camera write FIFO size[15:8]
hazheng 44:15de535c4005 90 #define FIFO_SIZE3 0x44 //Camera write FIFO size[18:16]
hazheng 32:5badeff825dc 91
hazheng 32:5badeff825dc 92 #define BURST_FIFO_READ 0x3C //Burst FIFO read operation
hazheng 32:5badeff825dc 93 #define SINGLE_FIFO_READ 0x3D //Single FIFO read operation
hazheng 29:f87d8790f57d 94
hazheng 46:a5eb9bd3bb55 95 #ifdef __cplusplus
hazheng 46:a5eb9bd3bb55 96 extern "C" {
hazheng 46:a5eb9bd3bb55 97 #endif
hazheng 46:a5eb9bd3bb55 98
hazheng 28:271fc8445e89 99 bool ardu_cam_init();
hazheng 28:271fc8445e89 100
hazheng 29:f87d8790f57d 101 void ardu_cam_start_capture();
hazheng 29:f87d8790f57d 102
hazheng 32:5badeff825dc 103 uint32_t ardu_cam_get_fifo_length();
hazheng 32:5badeff825dc 104
hazheng 32:5badeff825dc 105 void ardu_cam_print_debug();
hazheng 32:5badeff825dc 106
hazheng 44:15de535c4005 107 volatile const uint8_t* ardu_cam_get_center_array();
hazheng 44:15de535c4005 108
hazheng 44:15de535c4005 109 uint8_t ardu_cam_is_capture_finished();
hazheng 43:0d1886f4848a 110
hazheng 46:a5eb9bd3bb55 111 void ardu_cam_display_img_utft();
hazheng 46:a5eb9bd3bb55 112
hazheng 57:0d8a155d511d 113 void image_processing();
hazheng 57:0d8a155d511d 114
hazheng 64:43ab429a37e0 115 uint8_t ardu_cam_get_is_encounter_terminate();
hazheng 64:43ab429a37e0 116
hazheng 79:bdbac82c979b 117 uint8_t ardu_cam_get_is_border_found();
hazheng 79:bdbac82c979b 118
hazheng 46:a5eb9bd3bb55 119 #ifdef __cplusplus
hazheng 46:a5eb9bd3bb55 120 }
hazheng 46:a5eb9bd3bb55 121 #endif
hazheng 46:a5eb9bd3bb55 122
hazheng 34:f79db3bc2f86 123 //uint8_t ardu_cam_read_reg(uint8_t addr);
hazheng 34:f79db3bc2f86 124
hazheng 34:f79db3bc2f86 125 //void ardu_cam_write_reg(uint8_t addr, uint8_t data);
hazheng 34:f79db3bc2f86 126
hazheng 34:f79db3bc2f86 127 //int ardu_cam_bus_write(int address, int value);
hazheng 34:f79db3bc2f86 128
hazheng 34:f79db3bc2f86 129 //uint8_t ardu_cam_bus_read(int address);
hazheng 34:f79db3bc2f86 130
hazheng 28:271fc8445e89 131 #endif //ARDU_CAM_H