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:
Wed Mar 29 21:19:27 2017 +0000
Revision:
44:15de535c4005
Parent:
43:0d1886f4848a
Child:
46:a5eb9bd3bb55
Made the car move!...

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