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
main.cpp
- Committer:
- cheryl_he
- Date:
- 2015-05-05
- Revision:
- 3:39e6440ccd45
- Parent:
- 1:ff0fc50372c8
- Child:
- 4:8ee76f6d32b5
File content as of revision 3:39e6440ccd45:
#include "mbed.h"
#include "telemetry.h"
#include "telemetry-mbed.h"
#include "MODSERIAL.h"
#include "stdlib.h"
#include <vector>
MODSERIAL telemetry_serial(USBTX, USBRX);
telemetry::MbedHal telemetry_hal(telemetry_serial);
telemetry::Telemetry telemetry_obj(telemetry_hal);
telemetry::Numeric<uint32_t> tele_time_ms(telemetry_obj, "time", "Time", "ms", 0);
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};
//Alter reg values to speed up KL25Z
initADC();
t.start();
//uint16_t* data = cam1.read();
while(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();
}
}