git.droids-corp.org
/
protos
/
rc_servos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support new board (fpv motherboard v1)
[protos/rc_servos.git]
/
main.c
diff --git
a/main.c
b/main.c
index
dd98345
..
ad0af05
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-1,4
+1,5
@@
#include <aversive.h>
#include <aversive.h>
+#include <aversive/wait.h>
struct servo {
uint8_t bit;
struct servo {
uint8_t bit;
@@
-6,9
+7,13
@@
struct servo {
};
static struct servo servo_table[] = {
};
static struct servo servo_table[] = {
+ {
+ .bit = 2,
+ .command = 300,
+ },
{
.bit = 3,
{
.bit = 3,
- .command = 0,
+ .command =
70
0,
},
{
.bit = 4,
},
{
.bit = 4,
@@
-37,6
+42,9
@@
static volatile uint8_t rxidx;
#define BYPASS_ENABLE 14
#define BYPASS_DISABLE 15
#define BYPASS_ENABLE 14
#define BYPASS_DISABLE 15
+#define LED_ON() do { PORTB |= 0x02; } while(0)
+#define LED_OFF() do { PORTB &= ~0x02; } while(0)
+
/*
* SPI protocol:
*
/*
* SPI protocol:
*
@@
-152,11
+160,19
@@
int main(void)
uint8_t t, diff;
/* LED */
uint8_t t, diff;
/* LED */
- DDRB = 0x20;
+ DDRB = 0x02;
+
+#if 0 /* LED debug */
+ while (1) {
+ LED_ON();
+ wait_ms(100);
+ LED_OFF();
+ wait_ms(100);
+ }
+#endif
- /* servo outputs */
- DDRD = 0xf8;
- DDRB |= 0x01;
+ /* servo outputs PD2-PD7 */
+ DDRD = 0xfc;
/* start timer1 at clk/1 (8Mhz) */
TCNT1 = 0;
/* start timer1 at clk/1 (8Mhz) */
TCNT1 = 0;
@@
-171,7
+187,7
@@
int main(void)
sei();
sei();
- bypass =
1
;
+ bypass =
0
;
while (1) {
t = TCNT0;
for (i = 0; i < NB_SERVO; i++) {
while (1) {
t = TCNT0;
for (i = 0; i < NB_SERVO; i++) {
@@
-186,9
+202,11
@@
int main(void)
}
/* bypass mode */
while (bypass == 1) {
}
/* bypass mode */
while (bypass == 1) {
- PORTD = ((PINC & 0x0f) << 3) | ((PINB & 0x01) << 7);
+ LED_ON();
+ PORTD = (PINC & 0x3f) << 2;
poll_spi();
}
poll_spi();
}
+ LED_OFF();
}
return 0;
}
return 0;