-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample.cpp
67 lines (58 loc) · 1.35 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// $Id$
/**
* @file example.cpp
* Example implementation of the Simple C++ class wrapper for beaglebone PWM eHRPWM interface
*
* @author claus
* Created on: Jun 13, 2012
* Author: claus http://quadrotordiaries.blogspot.com
*
*/
// $Log$
/// Example implementation of the Simple C++ class wrapper for beaglebone PWM eHRPWM interface
#include "cPWM.h"
#include <iostream>
#include <unistd.h>
using namespace std;
int main()
{
cout << "Hello Beagle!" << endl;
cPWM::cPWM* a[3];
for (int i=0; i<3; i++)
{
a[i] = new cPWM::cPWM(i);
}
/*
a[0]->Period(20000000);
a[0]->DutyA( 1000000);
a[0]->Polarity(1);
a[0]->Run();
usleep(100000); //pausa de 0.1s=100,000us
a[0]->DutyA( 1500000);
a[0]->Stop();
*/
for (int i=0; i<3; i++)
{
// delete(a[i]);
a[i]->Period_ns(20000000);
//usleep(100000); //pausa de 0.1s=100,000us
a[i]->DutyA_ns(1000000);
//usleep(100000); //pausa de 0.1s=100,000us
a[i]->DutyB_percent(50);
//usleep(100000); //pausa de 0.1s=100,000us
a[i]->PolarityA(cPWM::cPWM::ActiveHigh);
//usleep(100000); //pausa de 0.1s=100,000us
a[i]->RunA();
//usleep(100000); //pausa de 0.1s=100,000us
a[i]->RunB();
//usleep(100000); //pausa de 0.1s=100,000us
}
usleep(10000000);
for (int i=0; i<3; i++)
{
a[i]->StopA();
a[i]->StopB();
//usleep(100000); //pausa de 0.1s=100,000us
}
return 0;
}