git.droids-corp.org
/
aversive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
optimize xy->corn
[aversive.git]
/
projects
/
microb2010
/
ballboard
/
main.c
diff --git
a/projects/microb2010/ballboard/main.c
b/projects/microb2010/ballboard/main.c
index
082b658
..
e737ba3
100755
(executable)
--- a/
projects/microb2010/ballboard/main.c
+++ b/
projects/microb2010/ballboard/main.c
@@
-58,6
+58,7
@@
#include "actuator.h"
#include "cs.h"
#include "i2c_protocol.h"
#include "actuator.h"
#include "cs.h"
#include "i2c_protocol.h"
+#include "state.h"
/* 0 means "programmed"
* ---- with 16 Mhz quartz
/* 0 means "programmed"
* ---- with 16 Mhz quartz
@@
-112,16
+113,21
@@
void bootloader(void)
void do_led_blink(__attribute__((unused)) void *dummy)
{
void do_led_blink(__attribute__((unused)) void *dummy)
{
-#if 1 /* simple blink */
- static uint8_t a=0;
+ static uint8_t a = 0;
- if(a)
- LED1_ON();
- else
- LED1_OFF();
-
- a = !a;
-#endif
+ if (ballboard.flags & DO_ERRBLOCKING) {
+ if (a & 1)
+ LED1_ON();
+ else
+ LED1_OFF();
+ }
+ else {
+ if (a & 4)
+ LED1_ON();
+ else
+ LED1_OFF();
+ }
+ a++;
}
static void main_timer_interrupt(void)
}
static void main_timer_interrupt(void)
@@
-149,7
+155,8
@@
int main(void)
LED1_OFF();
memset(&gen, 0, sizeof(gen));
memset(&ballboard, 0, sizeof(ballboard));
LED1_OFF();
memset(&gen, 0, sizeof(gen));
memset(&ballboard, 0, sizeof(ballboard));
- ballboard.flags = DO_ENCODERS | DO_CS | DO_POWER; // DO_BD
+ ballboard.flags = DO_ENCODERS | DO_CS | DO_POWER |
+ DO_ERRBLOCKING | DO_BD;
/* UART */
uart_init();
/* UART */
uart_init();
@@
-163,13
+170,17
@@
int main(void)
# error not supported
#endif
# error not supported
#endif
- //eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_BALLBOARD);
/* check eeprom to avoid to run the bad program */
if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) !=
EEPROM_MAGIC_BALLBOARD) {
/* check eeprom to avoid to run the bad program */
if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) !=
EEPROM_MAGIC_BALLBOARD) {
+ int c;
sei();
sei();
- printf_P(PSTR("Bad eeprom value\r\n"));
- while(1);
+ printf_P(PSTR("Bad eeprom value ('f' to force)\r\n"));
+ c = uart_recv(CMDLINE_UART);
+ if (c == 'f')
+ eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_BALLBOARD);
+ wait_ms(100);
+ bootloader();
}
/* LOGS */
}
/* LOGS */
@@
-201,8
+212,8
@@
int main(void)
&PORTD, 4);
PWM_NG_INIT16(&gen.pwm2_4B, 4, B, 10, PWM_NG_MODE_SIGNED,
&PORTD, 5);
&PORTD, 4);
PWM_NG_INIT16(&gen.pwm2_4B, 4, B, 10, PWM_NG_MODE_SIGNED,
&PORTD, 5);
- PWM_NG_INIT16(&gen.pwm3_1A, 1, A, 10, PWM_NG_MODE_SIGNED
,
- &PORTD, 6);
+ PWM_NG_INIT16(&gen.pwm3_1A, 1, A, 10, PWM_NG_MODE_SIGNED
|
+
PWM_NG_MODE_SIGN_INVERTED,
&PORTD, 6);
PWM_NG_INIT16(&gen.pwm4_1B, 1, B, 10, PWM_NG_MODE_SIGNED,
&PORTD, 7);
PWM_NG_INIT16(&gen.pwm4_1B, 1, B, 10, PWM_NG_MODE_SIGNED,
&PORTD, 7);
@@
-239,10
+250,17
@@
int main(void)
/* ax12 */
ax12_user_init();
/* ax12 */
ax12_user_init();
+ gen.logs[0] = E_USER_ST_MACH;
+ gen.log_level = 5;
+
sei();
sei();
+ actuator_init();
+
printf_P(PSTR("\r\n"));
printf_P(PSTR("Dass das Gluck deinen Haus setzt.\r\n"));
printf_P(PSTR("\r\n"));
printf_P(PSTR("Dass das Gluck deinen Haus setzt.\r\n"));
+
+ state_machine();
cmdline_interact();
return 0;
cmdline_interact();
return 0;