git.droids-corp.org
/
protos
/
rc_servos.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5d39ce2
)
fix ppm decoding
author
Olivier Matz
<zer0@droids-corp.org>
Thu, 10 Oct 2013 17:46:36 +0000
(19:46 +0200)
committer
Olivier Matz
<zer0@droids-corp.org>
Thu, 10 Oct 2013 17:46:36 +0000
(19:46 +0200)
main.c
patch
|
blob
|
history
diff --git
a/main.c
b/main.c
index
f06bc44
..
74f6629
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-167,7
+167,6
@@
static void poll_spi(void)
static void poll_input_capture(void)
{
uint16_t icp, diff;
static void poll_input_capture(void)
{
uint16_t icp, diff;
- uint8_t rising;
/* no new sample, return */
if ((TIFR1 & _BV(ICF1)) == 0)
/* no new sample, return */
if ((TIFR1 & _BV(ICF1)) == 0)
@@
-177,11
+176,6
@@
static void poll_input_capture(void)
icp = ICR1;
sei();
icp = ICR1;
sei();
- rising = !!(TCCR1B & _BV(ICES1));
-
- /* change the edge type */
- TCCR1B ^= _BV(ICES1);
-
/* clear the flag by writing a one */
TIFR1 = TIFR1 | _BV(ICF1);
/* clear the flag by writing a one */
TIFR1 = TIFR1 | _BV(ICF1);
@@
-190,15
+184,17
@@
static void poll_input_capture(void)
/* a rising edge with at least 2ms of state 0 means that we
* get the first servo */
/* a rising edge with at least 2ms of state 0 means that we
* get the first servo */
- if (
rising == 1 && diff > 2
000) {
+ if (
diff > 3
000) {
icp_idx = 0;
return;
}
/* get the value for the servo */
icp_idx = 0;
return;
}
/* get the value for the servo */
- if (
rising == 0 &&
icp_idx < NB_SERVO) {
+ if (icp_idx < NB_SERVO) {
if (diff < 1000)
icp_servos[icp_idx] = 0;
if (diff < 1000)
icp_servos[icp_idx] = 0;
+ else if (diff > 2023)
+ icp_servos[icp_idx] = 1023;
else
icp_servos[icp_idx] = diff - 1000;
icp_idx++;
else
icp_servos[icp_idx] = diff - 1000;
icp_idx++;