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
main.cpp
- Committer:
- Mbize
- Date:
- 2014-05-23
- Revision:
- 0:57a88d862c8b
File content as of revision 0:57a88d862c8b:
#include "mbed.h"
#define buffsize 1500
Serial pc(USBTX, USBRX); // tx, rx
InterruptIn event(p16);
AnalogOut speed(p18);
Timer timer;
PwmOut pwm1(p23);
int start=0;
int stop=0;
int tim=0;
int i=0;
int s=0;
int send=0;
/*
int bufferstart[buffsize];
int bufferstop[buffsize];
*/
void trigger1(void)
{
if (s==0)
{
timer.reset();
s=1;
}
if (send==0)
{
start=timer.read_us();
send=1;
}
}
void trigger2(void)
{
if (send==1)
{
stop=timer.read_us();
pc.printf("%i %i ", start, stop);
send=0;
}
}
int main()
{
pc.baud(921600);
pwm1.period_us(20); //p=1/f
pwm1.pulsewidth_us(10); //
event.rise(&trigger1);
event.fall(&trigger2);
timer.start();
//pc.printf("Init_time %i\n", init_t);
while(1)
{
/* if (i>=(2*buffsize-2))
{
__disable_irq();
int k=0;
while (k<buffsize-1)
{
pc.printf("%i %i ", bufferstart[k], bufferstop[k]);
k++;
}
while(k<=(2*buffsize)-2)
{
pc.printf("%i %i ", bufferstart2[k-buffsize-1], bufferstop2[k-buffsize-1]);
k++;
}
while (k>=(2*buffsize)-2)
{
}
}
*/
}
}
/*
void trigger1(void)
{
if (s==0)
{
timer.reset();
s=1;
}
if (i<buffsize-1)
{
bufferstart[i] = timer.read_us();
}
if (i>=buffsize-1)
{
bufferstart2[i-buffsize-1] = timer.read_us();
}
}
void trigger2(void)
{
if (i<buffsize-1)
{
bufferstop[i] = timer.read_us();
}
if (i>=buffsize-1)
{
bufferstop2[i-buffsize-1] = timer.read_us();
}
i++;
}
*/