From: Andy Spencer Date: Tue, 11 Feb 2014 01:09:24 +0000 (+0000) Subject: Add A2D signaling X-Git-Url: http://pileus.org/git/?p=~andy%2Fcsm213a-hw;a=commitdiff_plain;h=aab601d3ceac5f1a8649f1eab285744373bdd8c8 Add A2D signaling --- diff --git a/yue/main.cpp b/yue/main.cpp index 0fdb866..e580188 100644 --- a/yue/main.cpp +++ b/yue/main.cpp @@ -15,9 +15,9 @@ (x) > (max) ? (max) : (x)) #define MMA8451_I2C_ADDRESS (0x1d<<1) // acc sensor address -#define TIME_ACCURACY 0.01 +#define TIME_ACCURACY 0.001 -#define ACC_SNS_DEFAULT 0.1 // default collecting interval in seconds +#define ACC_SNS_DEFAULT 0.01 // default collecting interval in seconds #define MAG_SNS_DEFAULT 0.1 #define LGT_SNS_DEFAULT 0.1 #define TCH_SNS_DEFAULT 0.1 @@ -89,6 +89,8 @@ TSISensor tchSensor; AnalogIn lgtSensor(PTE22); AnalogIn a2dSensor(A0); +AnalogOut a2dOutput(PTE30); + DigitalOut led1(LED1); DigitalOut led2(LED2); @@ -104,11 +106,11 @@ float lgtTmr = LGT_SNS_DEFAULT; float a2dTmr = A2D_SNS_DEFAULT; float ledTmr = LED_OUT_DEFAULT; -bool accEnable = true; +bool accEnable = false; bool magEnable = false; bool lgtEnable = false; bool tchEnable = false; -bool a2dEnable = false; +bool a2dEnable = true; bool ledEnable = true; bool useStr = false; @@ -218,6 +220,9 @@ void clock1_interrupt(void){ a2dCnt++; ledCnt++; + // Write A2D output sine wave + a2dOutput.write(sin(a2dCnt * TIME_ACCURACY * (2*PI) * 0.1)); + // Send data through Serial if (accEnable && (accCnt<0 || accCnt>=accTmr/TIME_ACCURACY)){ sendAccInfo(); @@ -362,7 +367,7 @@ void sendTchInfo(void){ void sendA2dInfo(void){ float a2dData[6]; - a2dData[0] = 0; + a2dData[0] = a2dSensor.read(); a2dData[1] = 0; a2dData[2] = 0; a2dData[3] = 0;