Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MODSERIAL telemetry-master
Diff: main.cpp
- Revision:
- 3:39e6440ccd45
- Parent:
- 1:ff0fc50372c8
- Child:
- 4:8ee76f6d32b5
--- a/main.cpp Tue May 05 00:43:51 2015 +0000
+++ b/main.cpp Tue May 05 21:44:06 2015 +0000
@@ -1,8 +1,12 @@
#include "mbed.h"
#include "telemetry.h"
#include "telemetry-mbed.h"
+#include "MODSERIAL.h"
-MODSERIAL telemetry_serial(PTA2, PTA1);
+#include "stdlib.h"
+#include <vector>
+
+MODSERIAL telemetry_serial(USBTX, USBRX);
telemetry::MbedHal telemetry_hal(telemetry_serial);
telemetry::Telemetry telemetry_obj(telemetry_hal);
@@ -10,24 +14,72 @@
telemetry::NumericArray<uint16_t, 128> tele_linescan(telemetry_obj, "linescan", "Linescan", "ADC", 0);
telemetry::Numeric<float> tele_motor_pwm(telemetry_obj, "motor", "Motor PWM", "%DC", 0);
+//Outputs
DigitalOut myled(LED1);
+DigitalOut clk(PTD5);
+DigitalOut si(PTD4);
+PwmOut motor1(PTA12);
+PwmOut motor2(PTA4);
+DigitalOut break1(PTC7);
+DigitalOut break2(PTC0);
+PwmOut servo(PTA5);
+
+//Serial pc(USBTX, USBRX); // tx, rx
+
+//Inputs
+AnalogIn camData(PTC2);
+
+//Encoder setup and variables
+InterruptIn interrupt(PTA13);
+
+Timer t;
+
+float ADCdata [128];
+
+void initADC(void){
+
+ ADC0->CFG1 = ADC0->CFG1 & (
+ ~(
+ 0x80 // LDLPC = 0 ; no low-power mode
+ | 0x60 // ADIV = 1
+ | 0x10 // Sample time short
+ | 0x03 // input clock = BUS CLK
+ )
+ ) ; // clkdiv <= 1
+ ADC0->CFG2 = ADC0->CFG2
+ | 0x03 ; // Logsample Time 11 = 2 extra ADCK
+ ADC0->SC3 = ADC0->SC3
+ & (~(0x03)) ; // hardware avarage off
+}
int main() {
-
+
+ telemetry_serial.baud(115200);
telemetry_obj.transmit_header();
- uint16_t data [128] = [0];
+ //uint16_t data [128] = {0};
+
+ //Alter reg values to speed up KL25Z
+ initADC();
+
+ t.start();
//uint16_t* data = cam1.read();
while(1) {
- myled = 1;
+/* myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
-
+*/
/*for (uint16_t i=0; i<128; i++) {
tele_linescan[i] = data[i];
}
*/
+
+ tele_time_ms = t.read_ms();
+ for (uint16_t i=0; i<128; i++) {
+ tele_linescan[i] = ADCdata[i];
+ }
+
telemetry_obj.do_io();
}