Initial Release of Library for PAT9125 OTS on L476RG Platform

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pixus_mbed
Date:
Tue Oct 31 09:45:52 2017 +0000
Parent:
16:7bea34dc0356
Child:
18:27c8c623f5d4
Commit message:
LCM & Serial port work at the same time.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Oct 20 11:17:05 2017 +0000
+++ b/main.cpp	Tue Oct 31 09:45:52 2017 +0000
@@ -19,18 +19,14 @@
 #include "pat9125_i2c.h"
 #include "pat9125_mbed.h"
 
-//#define LCM_MODE
+#define LCM_MODE
 
 pat9125_mbed_state_s g_pat9125_mbed_state ;
 pat9125_mbed *gp_pat9125_mbed ;
 pixart_lcm *gp_pixart_lcm = NULL;
-Serial  *serial = NULL ;
 
-#ifdef LCM_MODE
 SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
-#else
 Serial  pc(USBTX, USBRX);
-#endif
 
 #define I2C_SDA_PIN I2C_SDA
 #define I2C_SCL_PIN I2C_SCL
@@ -58,11 +54,12 @@
 //-----------------------------------------------------------------------
 int main(void)
 {
-    int i = 0;
     char addr = 0;
     char data ;
+//    pc.set_flow_control(SerialBase::Disabled) ;
+    pc.baud(115200);
+    pc.printf("---------- Pixart PAT9125 Demo\n");  
 
-#ifdef LCM_MODE
     // +++++++ LCM Initialization +++++++ //
     // Chip must be deselected
     PIN_LCM_CSB = 1 ;
@@ -73,17 +70,12 @@
     spi.frequency(1000000);
     gp_pixart_lcm = new pixart_lcm(&spi, &PIN_LCM_CSB, &PIN_LCM_RSTB, &PIN_LCM_RS) ;
     // ------- LCM Initialization ------- //
-#else
-    serial = &pc ;
-    //pc.set_flow_control(SerialBase::Disabled) ;
-    pc.baud(115200);
-    pc.printf("---------- Pixart PAT9125 Demo\n");      
-#endif    
+    
     // +++++++ PAT9125 Initialization +++++++ //
     gp_pat9125_i2c = new pat9125_i2c(I2C_SDA_PIN, I2C_SCL_PIN);
     gp_pat9125_i2c->frequency(400000); 
     g_pat9125_mbed_state.p_i2c = gp_pat9125_i2c;
-    g_pat9125_mbed_state.p_pc = serial;
+    g_pat9125_mbed_state.p_pc = &pc;
     g_pat9125_mbed_state.pBTN_L = &PIN_BTN_L ;
     g_pat9125_mbed_state.pBTN_R = &PIN_BTN_R ;
     g_pat9125_mbed_state.pINT = &PIN_SEN_MOTION;
@@ -93,10 +85,9 @@
     g_pat9125_mbed_state.slave_id = (I2C_ADDRESS << 1);
     g_pat9125_mbed_state.sen_status = 0;
     
-    gp_pat9125_mbed = new pat9125_mbed(&g_pat9125_mbed_state) ;  
-#ifdef LCM_MODE     
+    gp_pat9125_mbed = new pat9125_mbed(&g_pat9125_mbed_state) ;        
     gp_pixart_lcm->LCM_DisplayString_Boot(g_pat9125_mbed_state.sen_status);
-#else    
+    
     if(g_pat9125_mbed_state.sen_status == true) 
     {
         pc.printf("Initial Sensor ... Done\n");
@@ -105,10 +96,8 @@
     {
         pc.printf("Initial Sensor ... Fail\n");
     }
-#endif    
     while(true)
     {
       gp_pat9125_mbed->task();
     }
-    
 }