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 15 00:02:03 2017 +0000
Revision:
38:0fb273b28cee
Parent:
37:7074a6118d03
Child:
40:be98219930e4
Adjusted the camera selection.

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