libpropeller
Making PropellerGCC Easier
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Macros
Pages
libpropeller
libpropeller
quadrature_encoder
quadrature_encoder.h
Go to the documentation of this file.
1
#ifndef libpropeller_quadrature_encoder_h__
2
#define libpropeller_quadrature_encoder_h__
3
4
#include <propeller.h>
5
6
extern
char
_load_start_quadrature_encoder_cog
[];
7
29
class
QuadratureEncoder
{
30
public
:
31
41
bool
Start
(
const
int
basePin,
const
int
numberOfEncoders) {
42
volatile
void
* asm_reference = NULL;
43
__asm__
volatile
(
"mov %[asm_reference], #QuadratureEncoder_Entry \n\t"
44
: [asm_reference]
"+r"
(asm_reference));
45
46
Stop
();
47
48
this->numberOfEncoders = numberOfEncoders;
49
this->basePin = basePin;
50
cog = cognew(
_load_start_quadrature_encoder_cog
, &this->basePin) + 1;
51
52
return
cog != 0;
53
}
54
55
void
Stop
(
void
) {
56
if
(cog > 0) {
57
cogstop(cog - 1);
58
}
59
}
60
61
int
GetReading
(
const
int
index) {
62
return
readings[index];
63
}
64
65
private
:
66
// Don't reorder these three volatile variables! They are used by the GAS cog.
67
volatile
int
basePin, numberOfEncoders, readings[16];
68
69
int
cog;
70
};
71
72
73
/*
74
// This function is untested!
75
int32_t QuadratureEncoder::Readdelta(int32_t Encid)
76
{
77
int32_t Deltapos = 0;
78
Deltapos = ((0 + ((Encid < Totdelta) * (-((int32_t *)Pos)[((*(int32_t *)&dat[196]) + Encid)]))) + (((int32_t *)Pos)[((*(int32_t *)&dat[196]) + Encid)] = ((int32_t *)Pos)[Encid]));
79
return Deltapos;
80
}
81
*/
82
83
#endif // libpropeller_quadrature_encoder_h__
Generated on Fri Oct 25 2013 23:41:46 for libpropeller by
1.8.4