summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Duchon2012-04-03 18:37:44 +0200
committerFlorent Duchon2012-04-03 19:34:39 +0200
commit753e2ab11ad8b253be26c34e175bec8b159b18d2 (patch)
tree89d42218dcd7aa35c5b5ed042d060c296a8a6c15
parentacf4617c9f264dc5813abb4b305d8c1d76ad19b0 (diff)
digital/beacon: add APBTeam twi module
-rw-r--r--digital/beacon/src/Bitcloud_stack/Components/HAL/Makerules5
-rw-r--r--digital/beacon/src/Bitcloud_stack/Components/HAL/avr/Makefile6
-rw-r--r--digital/beacon/src/Bitcloud_stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.abin92190 -> 84176 bytes
-rw-r--r--digital/beacon/src/Makefile6
-rw-r--r--digital/beacon/src/main_avr.c181
-rw-r--r--digital/beacon/src/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc15
6 files changed, 70 insertions, 143 deletions
diff --git a/digital/beacon/src/Bitcloud_stack/Components/HAL/Makerules b/digital/beacon/src/Bitcloud_stack/Components/HAL/Makerules
index deea8742..8f133d44 100644
--- a/digital/beacon/src/Bitcloud_stack/Components/HAL/Makerules
+++ b/digital/beacon/src/Bitcloud_stack/Components/HAL/Makerules
@@ -761,11 +761,6 @@ else
$(error unsupported COMPILER_AND_MICRO_TYPE)
endif
-ifneq ($(EXP_VERSION), $(COMPILER_VERSION))
- $(error ERROR in file Makerules: You are using incorrect version of compiler: \
- installed $(COMPILER_VERSION), expected $(EXP_VERSION))
-endif
-
ifeq ($(COMPILER_TYPE), IAR)
COMPILER_TYPE_LOWER_CASE = _Iar
else
diff --git a/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/Makefile b/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/Makefile
index 6b894b7f..450e054d 100644
--- a/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/Makefile
+++ b/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/Makefile
@@ -28,7 +28,7 @@ endif
#### DEFINES FLAGS #######
CFLAGS += -DHAL_USE_ADC
CFLAGS += -DHAL_USE_EE_READY
-CFLAGS += -DHAL_USE_TWI
+# CFLAGS += -DHAL_USE_TWI
CFLAGS += -DHAL_USE_TIMER4_COMPA
CFLAGS += -DHAL_USE_EXT_HANDLER
ifneq ($(HAL), AT90USB1287)
@@ -146,7 +146,7 @@ common_hwd += halAppClock
common_hwd += halClkCtrl
common_hwd += halUsart
common_hwd += halIrq
-common_hwd += i2c
+# common_hwd += i2c
common_hwd += halEeprom
common_hwd += wdt
common_hwd += halSleep
@@ -190,7 +190,7 @@ hwi += usart
hwi += w1
hwi += irq
hwi += resetReason
-hwi += i2cPacket
+# hwi += i2cPacket
hwi += eeprom
hwi += timer
hwi += adc
diff --git a/digital/beacon/src/Bitcloud_stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a b/digital/beacon/src/Bitcloud_stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a
index a787ec56..1985112a 100644
--- a/digital/beacon/src/Bitcloud_stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a
+++ b/digital/beacon/src/Bitcloud_stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a
Binary files differ
diff --git a/digital/beacon/src/Makefile b/digital/beacon/src/Makefile
index 34cf8bc5..85c4cd26 100644
--- a/digital/beacon/src/Makefile
+++ b/digital/beacon/src/Makefile
@@ -11,6 +11,7 @@ include $(BASE)/make/Makefile.gen
BITCLOUD_PATH = $(PWD)/Bitcloud_stack
+APB_AVR_PATH = $(PWD)/../../avr
CONFIG_NAME = All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
#CONFIG_NAME = Coordinator_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
#CONFIG_NAME = Router_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -26,15 +27,16 @@ 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) APB_AVR_PATH=$(APB_AVR_PATH) LOL_NUMBER=$$count;\
done;\
flash:
avrdude -c stk500v2 -P /dev/ttyUSB1 -p atmega1281 -B3 -U flash:w:obj/beacon_$(TARGET).hex
+ ../../dev2/tools/dev2ctl.py -s 1
clean:
for count in $(NUMBER); do\
- $(MAKE) -C makefiles/$(PROJECT_NAME) -f Makefile_$(CONFIG_NAME) clean APP_NAME=Beacon_$$count BITCLOUD_PATH=$(BITCLOUD_PATH);\
+ $(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 e826e39f..3410efa4 100644
--- a/digital/beacon/src/main_avr.c
+++ b/digital/beacon/src/main_avr.c
@@ -1,48 +1,48 @@
-/**************************************************************************//**
-\file Peer2Peer.c
+/* main_avr.c */
+/* Beacon State Machine & Main. {{{
+ *
+ * Copyright (C) 2012 Florent Duchon
+ *
+ * APBTeam:
+ * Web: http://apbteam.org/
+ * Email: team AT apbteam DOT org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
-\brief Peer-2-peer sample application.
-
-\author
-Atmel Corporation: http://www.atmel.com \n
-Support email: avr@atmel.com
-
-Copyright (c) 2008 , Atmel Corporation. All rights reserved.
-Licensed under Atmel's Limited License Agreement (BitCloudTM).
-
-\internal
-History:
-14.10.09 A. Taradov - Added FIFO for received packets
-******************************************************************************/
-
-/******************************************************************************
- Includes section
-******************************************************************************/
#include <types.h>
-#include <configServer.h>
-#include <appTimer.h>
-#include <zdo.h>
+#include <util/delay.h>
#include "configuration.h"
#include "network.h"
-// #include <serialInterface.h>
-#include <irq.h>
#include "sensors.h"
#include "servo.h"
-#include <stdio.h>
#include "debug.h"
#include "position.h"
-#include <math.h>
-#include <util/delay.h>
-/******************************************************************************
- Define(s) section
-******************************************************************************/
-
-/******************************************************************************
- Variables section
-******************************************************************************/
+#include "led.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
+
+
// int jack = 0;
// status_s status;
// extern int lost_packet;
@@ -53,71 +53,43 @@ AppState_t appState = APP_INITIAL_STATE; // application state
// extern APS_DataReq_t test;
// extern buff_t buf_to_send;
-/***********************************************************************************
- Implementation section
-***********************************************************************************/
-/**************************************************************************//**
-\brief Application task handler.
-
-\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
+ case APP_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);
- }
+ /* Init Led */
+ init_led();
+
+ /* Init Serial Interface for debug */
+ initSerialInterface();
-// initSerialInterface(); // Open USART
-
switch(deviceType)
{
case DEVICE_TYPE_COORDINATOR:
-// error = init_twi();
-// initNetwork();
+ network_init();
+ twi_init(AC_BEACON_TWI_ADDRESS);
+ uprintf("DEVICE_TYPE_COORDINATOR init OK\n\r");
break;
case DEVICE_TYPE_END_DEVICE:
-// init_ILS();
-// control_motor_ms(100);
-// init_timer_servo();
-// initNetwork();
+ sensors_laser_init();
+ sensors_codewheel_init();
+ network_init();
+ uprintf("DEVICE_TYPE_END_DEVICE init OK\n\r");
break;
default:
break;
}
appState = APP_NETWORK_JOINING_STATE;
- SYS_PostTask(APL_TASK_ID); // Execute next step
+ SYS_PostTask(APL_TASK_ID);
break;
-
case APP_NETWORK_JOINING_STATE:
-// startNetwork();
+ network_start();
break;
-
case APP_NETWORK_LEAVING_STATE:
break;
case APP_NETWORK_JOINED_STATE:
-// if(jack == 1)
-// {
-// send_angle(angle);
-// }
break;
default:
break;
@@ -125,64 +97,13 @@ void APL_TaskHandler(void)
}
-
-/**************************************************************************//**
-\brief Wakeup event handler (dummy).
-
-\param none.
-\return none.
-******************************************************************************/
-void ZDO_WakeUpInd(void)
-{
-}
-
-
-#ifdef _BINDING_
-/***********************************************************************************
-Stub for ZDO Binding Indication
-
-Parameters:
-bindInd - indication
-
-Return:
-none
-
-***********************************************************************************/
-void ZDO_BindIndication(ZDO_BindInd_t *bindInd)
-{
-(void)bindInd;
-}
-
-/***********************************************************************************
-Stub for ZDO Unbinding Indication
-
-Parameters:
-unbindInd - indication
-
-Return:
-none
-
-***********************************************************************************/
-void ZDO_UnbindIndication(ZDO_UnbindInd_t *unbindInd)
-{
-(void)unbindInd;
-}
-#endif //_BINDING_
-
-/**********************************************************************//**
-\brief Main - C program main start function
-
-\param none
-\return none
-**************************************************************************/
int main(void)
{
-// init_timer3();
SYS_SysInit();
-// init_struct();
for(;;)
{
SYS_RunTask();
}
}
-// eof peer2Peer.c
+
+
diff --git a/digital/beacon/src/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/beacon/src/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
index 937534b4..21e5001c 100644
--- a/digital/beacon/src/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+++ b/digital/beacon/src/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -51,7 +51,10 @@ INCLUDES = \
-I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWI/include \
-I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/include \
-I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
- -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include \
+ -I$(APB_AVR_PATH) \
+ -I$(APB_AVR_PATH)/common \
+ -I$(APB_AVR_PATH)/modules/twi
LIBS = \
$(BITCLOUD_PATH)/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a \
@@ -66,7 +69,9 @@ SRCS = \
$(BITCLOUD_PATH)/Components/BSP/MESHBEAN/src/bspTaskManager.c \
$(BITCLOUD_PATH)/Components/ConfigServer/src/csPersistentMem.c \
$(BITCLOUD_PATH)/Components/ConfigServer/src/csMem.c \
- $(BITCLOUD_PATH)/Components/ConfigServer/src/configServer.c
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/configServer.c \
+ $(APB_AVR_PATH)/modules/twi/twi_hard.avr.c \
+ $(APB_AVR_PATH)/modules/twi/twi.c
PREINCLUDE = MakerulesBc_All_Atmega1281_Rf230_Gcc.h
@@ -88,6 +93,9 @@ CFLAGS += $(INCLUDES)
CFLAGS += -include $(PREINCLUDE)
CFLAGS += -g
+# APB sources need to be compiled without this option in order to manage correctly APB inline functions
+APB_CFLAGS := $(filter-out -std=gnu99,$(CFLAGS))
+
ASFLAGS = $(INCLUDES)
ASFLAGS += $(filter -mmcu%,$(CFLAGS))
@@ -102,6 +110,7 @@ all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_P
$(OBJ_PATH)/%.o: $(SRCS)
$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc/Obj/twi_hard.avr.o: CFLAGS=$(APB_CFLAGS)
$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
@@ -120,7 +129,7 @@ root_files:
cp -f $(EXE_PATH)/*.* ./../obj
clean:
- rm -rf $(CONFIG_NAME) ./../../$(APP_NAME).elf ./../../$(APP_NAME).hex ./../../$(APP_NAME).srec ./../../$(APP_NAME).bin
+ rm -rf $(CONFIG_NAME) ./../obj/$(APP_NAME).elf ./../obj/$(APP_NAME).hex ./../obj/$(APP_NAME).srec ./../obj/$(APP_NAME).bin
directories:
@mkdir -p $(LIST_PATH)