From a49184a93f371aaa0283948070d2c264945c81c1 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Sun, 18 Mar 2012 19:45:09 +0100 Subject: digital/beacon: avr flashing rule --- digital/beacon/src/Makefile | 7 +- digital/beacon/src/main_avr.c | 163 +++++++++++++++++++++--------------------- 2 files changed, 88 insertions(+), 82 deletions(-) diff --git a/digital/beacon/src/Makefile b/digital/beacon/src/Makefile index b336554b..34cf8bc5 100644 --- a/digital/beacon/src/Makefile +++ b/digital/beacon/src/Makefile @@ -26,12 +26,17 @@ simu:host avr: for count in $(NUMBER); do\ $(MAKE) -C makefiles/ -f Makefile_$(CONFIG_NAME) clean BITCLOUD_PATH=$(BITCLOUD_PATH);\ - $(MAKE) -C makefiles/ -f Makefile_$(CONFIG_NAME) all APP_NAME=Beacon_$$count BITCLOUD_PATH=$(BITCLOUD_PATH) LOL_NUMBER=$$count;\ + $(MAKE) -C makefiles/ -f Makefile_$(CONFIG_NAME) all APP_NAME=beacon_$$count BITCLOUD_PATH=$(BITCLOUD_PATH) LOL_NUMBER=$$count;\ done;\ +flash: + avrdude -c stk500v2 -P /dev/ttyUSB1 -p atmega1281 -B3 -U flash:w:obj/beacon_$(TARGET).hex + clean: for count in $(NUMBER); do\ $(MAKE) -C makefiles/$(PROJECT_NAME) -f Makefile_$(CONFIG_NAME) clean APP_NAME=Beacon_$$count BITCLOUD_PATH=$(BITCLOUD_PATH);\ done;\ + + diff --git a/digital/beacon/src/main_avr.c b/digital/beacon/src/main_avr.c index 6c0cd3be..e826e39f 100644 --- a/digital/beacon/src/main_avr.c +++ b/digital/beacon/src/main_avr.c @@ -18,20 +18,21 @@ History: /****************************************************************************** Includes section ******************************************************************************/ -// #include -// #include -// #include -// #include -// #include -// #include +#include +#include +#include +#include +#include "configuration.h" +#include "network.h" // #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include +#include +#include "sensors.h" +#include "servo.h" +#include +#include "debug.h" +#include "position.h" +#include +#include /****************************************************************************** Define(s) section ******************************************************************************/ @@ -41,7 +42,7 @@ History: ******************************************************************************/ // Application related parameters -// AppState_t appState = APP_INITIAL_STATE; // application state +AppState_t appState = APP_INITIAL_STATE; // application state // int jack = 0; // status_s status; // extern int lost_packet; @@ -61,68 +62,68 @@ History: \param none. \return none. ******************************************************************************/ -// #ifdef TYPE_COOR -// DeviceType_t deviceType = DEVICE_TYPE_COORDINATOR; -// #else -// DeviceType_t deviceType = DEVICE_TYPE_END_DEVICE; -// #endif -// int top = 0; -// void APL_TaskHandler(void) -// { -// switch (appState) -// { -// case APP_INITIAL_STATE: // Node has initial state -// -// /*D5/D6/D7 are configured in output */ -// DDRD = 0xE0; -// /* Power on the led */ -// int temp=0; -// for(temp=0;temp<3;temp++) -// { -// PORTD=0xE0; -// _delay_ms(100); -// PORTD=0; -// _delay_ms(100); -// } -// +#ifdef TYPE_COOR + DeviceType_t deviceType = DEVICE_TYPE_COORDINATOR; +#else + DeviceType_t deviceType = DEVICE_TYPE_END_DEVICE; +#endif +int top = 0; +void APL_TaskHandler(void) +{ + switch (appState) + { + case APP_INITIAL_STATE: // Node has initial state + + /*D5/D6/D7 are configured in output */ + DDRD = 0xE0; + /* Power on the led */ + int temp=0; + for(temp=0;temp<3;temp++) + { + PORTD=0xE0; + _delay_ms(100); + PORTD=0; + _delay_ms(100); + } + // initSerialInterface(); // Open USART -// -// switch(deviceType) -// { -// case DEVICE_TYPE_COORDINATOR: -// // error = init_twi(); + + switch(deviceType) + { + case DEVICE_TYPE_COORDINATOR: +// error = init_twi(); // initNetwork(); -// break; -// case DEVICE_TYPE_END_DEVICE: + break; + case DEVICE_TYPE_END_DEVICE: // init_ILS(); // control_motor_ms(100); // init_timer_servo(); // initNetwork(); -// break; -// default: -// break; -// } -// appState = APP_NETWORK_JOINING_STATE; -// SYS_PostTask(APL_TASK_ID); // Execute next step -// break; -// -// case APP_NETWORK_JOINING_STATE: + break; + default: + break; + } + appState = APP_NETWORK_JOINING_STATE; + SYS_PostTask(APL_TASK_ID); // Execute next step + break; + + case APP_NETWORK_JOINING_STATE: // startNetwork(); -// break; -// -// case APP_NETWORK_LEAVING_STATE: -// break; -// case APP_NETWORK_JOINED_STATE: + break; + + case APP_NETWORK_LEAVING_STATE: + break; + case APP_NETWORK_JOINED_STATE: // if(jack == 1) // { // send_angle(angle); // } -// break; -// default: -// break; -// } -// } -// + break; + default: + break; + } +} + /**************************************************************************//** @@ -131,9 +132,9 @@ History: \param none. \return none. ******************************************************************************/ -// void ZDO_WakeUpInd(void) -// { -// } +void ZDO_WakeUpInd(void) +{ +} #ifdef _BINDING_ @@ -147,10 +148,10 @@ Return: none ***********************************************************************************/ -// void ZDO_BindIndication(ZDO_BindInd_t *bindInd) -// { -// (void)bindInd; -// } +void ZDO_BindIndication(ZDO_BindInd_t *bindInd) +{ +(void)bindInd; +} /*********************************************************************************** Stub for ZDO Unbinding Indication @@ -162,10 +163,10 @@ Return: none ***********************************************************************************/ -// void ZDO_UnbindIndication(ZDO_UnbindInd_t *unbindInd) -// { -// (void)unbindInd; -// } +void ZDO_UnbindIndication(ZDO_UnbindInd_t *unbindInd) +{ +(void)unbindInd; +} #endif //_BINDING_ /**********************************************************************//** @@ -177,11 +178,11 @@ none int main(void) { // init_timer3(); -// SYS_SysInit(); + SYS_SysInit(); // init_struct(); -// for(;;) -// { -// SYS_RunTask(); -// } + for(;;) + { + SYS_RunTask(); + } } // eof peer2Peer.c -- cgit v1.2.3