summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/main_avr.c
diff options
context:
space:
mode:
authorFlorent Duchon2013-02-14 21:46:02 +0100
committerFlorent Duchon2013-03-24 15:51:18 +0100
commitecd22668d1be07a205fb82e580a08cc3ccc908df (patch)
treec58022f34a2a5cb3dd3fa22143f840a884a40a3a /digital/beacon/src/main_avr.c
parentc0abbe9cb71ff0aacc19a86b41662beddfb594c7 (diff)
digital/beacon: rework of main & debug_avr to use common functions
Diffstat (limited to 'digital/beacon/src/main_avr.c')
-rw-r--r--digital/beacon/src/main_avr.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/digital/beacon/src/main_avr.c b/digital/beacon/src/main_avr.c
index 5a069fc3..3d05b8bb 100644
--- a/digital/beacon/src/main_avr.c
+++ b/digital/beacon/src/main_avr.c
@@ -38,18 +38,11 @@
#include "led.h"
#include "twi.h"
-// Application related parameters
-AppState_t appState = APP_INITIAL_STATE; // application state
-
-#ifdef TYPE_COOR
- DeviceType_t deviceType = DEVICE_TYPE_COORDINATOR;
-#else
- DeviceType_t deviceType = DEVICE_TYPE_END_DEVICE;
-#endif
+static uint8_t uid;
void APL_TaskHandler(void)
{
- switch (appState)
+ switch (network_get_state())
{
case APP_INITIAL_STATE:
@@ -59,40 +52,46 @@ void APL_TaskHandler(void)
/* Init Serial Interface for debug */
initSerialInterface();
- switch(deviceType)
+ uid = get_uid();
+
+ /* Init network */
+ network_init(uid);
+
+ if(get_device_type(uid) == DEVICE_TYPE_COORDINATOR)
+ {
+ position_init_struct();
+ twi_init_specific();
+ trust_decrease_task();
+ start_codewheel_timer_task();
+// debug_start_stop_task();
+ }
+ else
{
- case DEVICE_TYPE_COORDINATOR:
- position_init_struct();
- twi_init_specific();
- trust_decrease_task();
- start_codewheel_timer_task();
- network_init();
-// debug_start_stop_task();
- uprintf("coord initialisation OK !%d\n\r",(int)0);
- break;
- case DEVICE_TYPE_END_DEVICE:
- servo_init();
- codewheel_init();
- laser_init();
- network_init();
-// motor_init();
- uprintf("LOL_%d initialisation OK !\n\r",CS_NWK_ADDR);
-// calibration_start_task();
- motor_stop();
- break;
- default:
- break;
+ servo_init();
+ codewheel_init();
+ laser_init();
+// motor_init();
+// calibration_start_task();
+ motor_stop();
}
- appState = APP_NETWORK_JOIN_REQUEST;
+ network_set_state(APP_NETWORK_JOIN_REQUEST);
break;
case APP_NETWORK_JOIN_REQUEST:
+
+ /* Activate the network status led blink */
+ led_start_blink();
+
+ /* St art network */
network_start();
- appState = APP_NETWORK_JOINING_STATE;
+
+ network_set_state(APP_NETWORK_JOINING_STATE);
+
case APP_NETWORK_JOINING_STATE:
break;
case APP_NETWORK_LEAVING_STATE:
break;
case APP_NETWORK_JOINED_STATE:
+ led_stop_blink();
break;
default:
break;