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

Revision:
56:7d3395ae022d
Parent:
54:f1f5648dfacf
Child:
57:0d8a155d511d
--- a/Hardwares/ArduCAM.cpp	Thu Apr 06 21:43:15 2017 +0000
+++ b/Hardwares/ArduCAM.cpp	Thu Apr 06 22:19:59 2017 +0000
@@ -1,8 +1,9 @@
 #include "ArduCAM.h"
 
-
+#define SW_DEBUG
 #include "GlobalVariable.h"
-#include "SWUSBServer.h"
+#include "SWCommon.h"
+
 
 #include "CamRegBuf.h"
 
@@ -34,23 +35,35 @@
 inline void ardu_cam_spi_write_8(int address, int value)
 {
     // take the SS pin low to select the chip:
+#ifdef SW_DEBUG
+    g_sw_spi_lock.lock();
+#endif
     cam_cs = 0;
     //  send in the address and value via SPI:
     g_spi_port.write(address | 0x80);
     g_spi_port.write(value);
     // take the SS pin high to de-select the chip:
     cam_cs = 1;
+#ifdef SW_DEBUG
+    g_sw_spi_lock.unlock();
+#endif
 }
  
 inline uint8_t ardu_cam_spi_read_8(int address)
 { 
     // take the SS pin low to select the chip:
+#ifdef SW_DEBUG
+    g_sw_spi_lock.lock();
+#endif
     cam_cs = 0;
     //  send in the address and value via SPI:
     g_spi_port.write(address & 0x7F);
     uint8_t value = static_cast<uint8_t>(g_spi_port.write(0x00));
     // take the SS pin high to de-select the chip:
     cam_cs = 1;
+#ifdef SW_DEBUG
+    g_sw_spi_lock.unlock();
+#endif
     return value;
 }
 /*
@@ -79,7 +92,7 @@
 
 bool ardu_cam_init()
 {
-    char buf[20];
+    //char buf[20];
     
     CamRegBuf * camReg = new CamRegBuf(g_core, CAM_SCCB_WRITE, CAM_SCCB_READ);
 
@@ -357,6 +370,7 @@
 
             centerLine[CAM_ROI_UPPER_LIMIT - i - 1] = temp_mid_pos;
         }
+        
     }
 }