Merge pull request #266 from ismb-pert/fix-mbxxx
mb851 platform is now the more generic mbxxx. STM32W_CPUREV environment variable is used to select the variant of STM32W to use.
This commit is contained in:
commit
5d19de3dbf
2
.gitignore
vendored
2
.gitignore
vendored
@ -17,7 +17,7 @@
|
||||
*.esb
|
||||
*.avr-raven
|
||||
*.exp5438
|
||||
*.mb851
|
||||
*.mbxxx
|
||||
*.win32
|
||||
*.apple2enh
|
||||
*.atari
|
||||
|
@ -68,16 +68,17 @@ STRIP = strip
|
||||
ifndef DEBUG
|
||||
OPTI = -Ohz --no_unroll
|
||||
endif
|
||||
CFLAGSNO = --endian=little --cpu=Cortex-M3 -e --diag_suppress Pa050 -D BOARD_HEADER=\"board.h\" \
|
||||
CFLAGSNO = --debug --endian=little --cpu=Cortex-M3 -e --diag_suppress Pa050 -D BOARD_HEADER=\"board.h\" \
|
||||
-D BOARD_MB851 -D "PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/iar.h\"" -D CORTEXM3 \
|
||||
-D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
|
||||
-D __SOURCEFILE__=\"$*.c\" -lC $(OBJECTDIR) \
|
||||
-I $(CONTIKI)/../iar-files \
|
||||
-I $(IAR_PATH)/arm/inc --dlib_config=DLib_Config_Normal.h
|
||||
|
||||
CFLAGS += $(CFLAGSNO) $(OPTI)
|
||||
CFLAGS += $(CFLAGSNO) $(OPTI) -D__ICCARM__
|
||||
AROPTS = --create
|
||||
ASFLAGS = -s+ -w+ --cpu Cortex-M3 -L$(OBJECTDIR)
|
||||
LDFLAGS += --redirect _Printf=_PrintfSmall --redirect _Scanf=_ScanfSmall --map=contiki-$(TARGET).map
|
||||
LDFLAGS += --semihosting --redirect _Printf=_PrintfSmall --redirect _Scanf=_ScanfSmall --map=contiki-$(TARGET).map
|
||||
ifndef COFFEE
|
||||
LDFLAGS+= --config $(CONTIKI_CPU)/iar-cfg.icf
|
||||
endif
|
||||
@ -97,19 +98,30 @@ ifndef DEBUG
|
||||
OPTI = -Os -ffunction-sections
|
||||
endif
|
||||
|
||||
ifeq ($(STM32W_CPUREV), CC)
|
||||
LD-EXT=-stm32w108CC
|
||||
${warning "using stm32w108CC specific ld file"}
|
||||
else ifeq ($(STM32W_CPUREV), xB)
|
||||
LD-EXT=-stm32w108xB
|
||||
${warning "using stm32w108xB specific ld file"}
|
||||
else
|
||||
${error "No STM32W_CPUREV specified. Cpu revision should be specified. Please read cpu/stm32w108/README.txt for more details."}
|
||||
endif
|
||||
|
||||
CFLAGSNO = -mthumb -mcpu=cortex-m3 -D "PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/gnu.h\"" \
|
||||
-D BOARD_HEADER=\"board.h\" -g -Wall -Wno-strict-aliasing -mlittle-endian \
|
||||
-D BOARD_MB851 -D CORTEXM3 -D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
|
||||
-D CORTEXM3 -D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
|
||||
-D __SOURCEFILE__=\"$*.c\"
|
||||
CFLAGS += $(CFLAGSNO) $(OPTI)
|
||||
ASFLAGS = -mthumb -mcpu=cortex-m3 -c -g -Wall -Os -ffunction-sections \
|
||||
-mlittle-endian -fshort-enums -x assembler-with-cpp -Wa,-EL
|
||||
|
||||
ifndef CPU_LD_CONFIG
|
||||
CPU_LD_CONFIG=$(CONTIKI_CPU)/gnu.ld
|
||||
CPU_LD_CONFIG=$(CONTIKI_CPU)/gnu$(LD-EXT).ld
|
||||
endif # CPU_LD_CONFIG
|
||||
|
||||
LDFLAGS += -mcpu=cortex-m3 \
|
||||
LDFLAGS += -L$(CONTIKI_CPU)\
|
||||
-mcpu=cortex-m3 \
|
||||
-mthumb \
|
||||
-Wl,-T -Xlinker $(CPU_LD_CONFIG) \
|
||||
-Wl,-static \
|
||||
@ -302,8 +314,8 @@ endif
|
||||
|
||||
# a target that gives a user-friendly memory profile, taking into account the RAM
|
||||
# that is statically occupied by the stack as defined in cpu/stm32w108/gnu.ld
|
||||
RAM_SIZE = 8192
|
||||
FLASH_SIZE = 128*1024
|
||||
RAM_SIZE = 2*8192
|
||||
FLASH_SIZE = 2*128*1024
|
||||
STACK_SIZE = 1280
|
||||
%.size: %.$(TARGET)
|
||||
@size -A $< | egrep "data|bss" | awk '{s+=$$2} END {s=s+$(STACK_SIZE); f=$(RAM_SIZE)-s; printf "[RAM] used %6d, free %6d\n",s,f;}'
|
||||
|
22
cpu/stm32w108/README.txt
Normal file
22
cpu/stm32w108/README.txt
Normal file
@ -0,0 +1,22 @@
|
||||
Building instructions.
|
||||
|
||||
In order to build your applications you need to find out the right cpu revision for the board you are using.
|
||||
|
||||
Valid STM32W_CPUREV values are CC or xB
|
||||
|
||||
Examples:
|
||||
|
||||
The MB851RevD board has a cpu with code
|
||||
stm32w 108CCU7
|
||||
so CC is your STM32W_CPUREV value and the command is
|
||||
make TARGET=mbxxx STM32W_CPUREV=CC ...
|
||||
|
||||
or
|
||||
|
||||
The MB851RevC board has a cpu with code
|
||||
stm32w 108CBU6
|
||||
so xB is your STM32W_CPUREV value.
|
||||
make TARGET=mbxxx STM32W_CPUREV=xB ...
|
||||
|
||||
|
||||
NOTE: if the last word is B you need to use x as wildcard.
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
177
cpu/stm32w108/gnu-stm32w108.ld
Normal file
177
cpu/stm32w108/gnu-stm32w108.ld
Normal file
@ -0,0 +1,177 @@
|
||||
/* default stack sizes.
|
||||
|
||||
These are used by the startup in order to allocate stacks for the different modes.
|
||||
*/
|
||||
|
||||
__Stack_Size = 0x500 ;
|
||||
|
||||
PROVIDE ( _Stack_Size = __Stack_Size ) ;
|
||||
|
||||
__Stack_Init = 0x20000000;
|
||||
|
||||
_estack = __Stack_Init + __Stack_Size;
|
||||
|
||||
/*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
|
||||
PROVIDE ( _Stack_Init = __Stack_Init ) ;
|
||||
|
||||
|
||||
/* Sections management for FLASH mode */
|
||||
|
||||
/* Sections Definitions */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
/* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
|
||||
|
||||
.isr_vector (DEFINED(ST_BTL) ? (0x08000000 + _BOOTLOADER_SIZE) : 0x08000000) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ApplicationFlashStart = . ;
|
||||
/* . = . + _ROM_base ;*/
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >ROM_region
|
||||
|
||||
/* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */
|
||||
.flashtext :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.flashtext) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >ROM_region
|
||||
|
||||
/* the program code is stored in the .text section, which goes to Flash */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.text) /* remaining code */
|
||||
*(.text.*) /* remaining code */
|
||||
*(.rodata) /* read-only data (constants) */
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
_sidata = _etext;
|
||||
} >ROM_region
|
||||
/*
|
||||
NVM (NOLOAD):
|
||||
{
|
||||
. = ALIGN(1024);
|
||||
*(NVM)
|
||||
. = ALIGN(4);
|
||||
} > NVM_region
|
||||
*/
|
||||
/* This is to emulate place at end of IAR linker */
|
||||
NVM (ORIGIN(ROM_region) + LENGTH(ROM_region) - _NVM_size) (NOLOAD):
|
||||
{
|
||||
*(NVM)
|
||||
} > ROM_region
|
||||
FAT (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(FAT))
|
||||
. = ALIGN(4);
|
||||
} > FIB_region
|
||||
|
||||
/*
|
||||
.FAT (NOLOAD):
|
||||
{
|
||||
KEEP(*(.FAT))
|
||||
} > FIB_region
|
||||
*/
|
||||
/* after that it's only debugging information. */
|
||||
|
||||
|
||||
/* This is the initialized data section
|
||||
The program executes knowing that the data is in the RAM
|
||||
but the loader puts the initial values in the FLASH (inidata).
|
||||
It is one task of the startup to copy the initial values from FLASH to RAM. */
|
||||
.data _estack : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
_sdata = . ;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
_edata = . ;
|
||||
} >RAM_region
|
||||
|
||||
|
||||
/* This is the uninitialized data section */
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
_sbss = .;
|
||||
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
_ebss = . ;
|
||||
} >RAM_region
|
||||
|
||||
PROVIDE ( end = _ebss );
|
||||
PROVIDE ( _end = _ebss );
|
||||
|
||||
__exidx_start = .;
|
||||
__exidx_end = .;
|
||||
|
||||
/* remove the debugging information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
}
|
||||
|
||||
__ApplicationFlashEnd = _sidata + (_edata - _sdata);
|
||||
__RAMStart = __Stack_Init;
|
||||
__RAMEnd = _ebss;
|
||||
|
16
cpu/stm32w108/gnu-stm32w108CC.ld
Normal file
16
cpu/stm32w108/gnu-stm32w108CC.ld
Normal file
@ -0,0 +1,16 @@
|
||||
/******************************************************************************/
|
||||
/* Peripheral memory map */
|
||||
/******************************************************************************/
|
||||
_BOOTLOADER_SIZE = 0 ;
|
||||
/* This value needs to be fine tuned if the NVM section grows */
|
||||
_NVM_size = 0x1000;
|
||||
|
||||
/* include the memory spaces definitions sub-script */
|
||||
MEMORY
|
||||
{
|
||||
RAM_region (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
|
||||
ROM_region (rx) : ORIGIN = 0x08000000, LENGTH = 256K
|
||||
FIB_region (ra) : ORIGIN = 0x08040000, LENGTH = 2K
|
||||
}
|
||||
|
||||
INCLUDE "gnu-stm32w108.ld"
|
17
cpu/stm32w108/gnu-stm32w108xB.ld
Normal file
17
cpu/stm32w108/gnu-stm32w108xB.ld
Normal file
@ -0,0 +1,17 @@
|
||||
/******************************************************************************/
|
||||
/* Peripheral memory map */
|
||||
/******************************************************************************/
|
||||
/* Size of IAP bootloader */
|
||||
_BOOTLOADER_SIZE = 0x3000 ;
|
||||
/* This value needs to be fine tuned if the NVM section grows */
|
||||
_NVM_size = 0x800;
|
||||
/* include the memory spaces definitions sub-script */
|
||||
MEMORY
|
||||
{
|
||||
RAM_region (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
|
||||
ROM_region (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
||||
FIB_region (ra) : ORIGIN = 0x08040000, LENGTH = 2K
|
||||
}
|
||||
|
||||
INCLUDE "gnu-stm32w108.ld"
|
||||
|
@ -21,7 +21,6 @@ __Stack_Init = 0x20000000;
|
||||
|
||||
_estack = __Stack_Init + __Stack_Size;
|
||||
|
||||
|
||||
/*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
|
||||
PROVIDE ( _Stack_Init = __Stack_Init ) ;
|
||||
|
||||
|
149
cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s
Normal file
149
cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s
Normal file
@ -0,0 +1,149 @@
|
||||
/**************************************************
|
||||
*
|
||||
* Part one of the system initialization code, contains low-level
|
||||
* initialization, plain thumb variant.
|
||||
*
|
||||
|
||||
* Customized by St Corporation for STM32W
|
||||
*<!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
|
||||
*
|
||||
**************************************************/
|
||||
|
||||
;
|
||||
; The modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
;
|
||||
; Cortex-M version
|
||||
;
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
PUBLIC __vector_table
|
||||
|
||||
DATA
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD __iar_program_start
|
||||
|
||||
;; Standard Cortex-M3 Vectors
|
||||
DCD NMI_Handler ;;NMI Handler
|
||||
DCD HardFault_Handler ;;Hard Fault Handler
|
||||
DCD MemManage_Handler ;;Memory Fault Handler
|
||||
DCD BusFault_Handler ;;Bus Fault Handler
|
||||
DCD UsageFault_Handler ;;Usage Fault Handler
|
||||
DCD 0 ;;Reserved
|
||||
DCD 0 ;;Reserved
|
||||
DCD 0 ;;Reserved
|
||||
DCD 0 ;;Reserved
|
||||
DCD SVC_Handler ;;SVCall Handler
|
||||
DCD DebugMon_Handler ;;Debug Monitor Handler
|
||||
DCD 0 ;;Reserved
|
||||
DCD PendSV_Handler ;;PendSV Handler
|
||||
DCD SysTick_Handler ;;SysTick Handler
|
||||
|
||||
;; STM32W Vectors
|
||||
DCD halTimer1Isr ;;Timer 1 Handler
|
||||
DCD halTimer2Isr ;;Timer 2 Handler
|
||||
DCD halManagementIsr ;;Management Handler
|
||||
DCD halBaseBandIsr ;;BaseBand Handler
|
||||
DCD halSleepTimerIsr ;;Sleep Timer Handler
|
||||
DCD halSc1Isr ;;SC1 Handler
|
||||
DCD halSc2Isr ;;SC2 Handler
|
||||
DCD halSecurityIsr ;;Security Handler
|
||||
DCD halStackMacTimerIsr ;;MAC Timer Handler
|
||||
DCD stmRadioTransmitIsr ;;MAC TX Handler
|
||||
DCD stmRadioReceiveIsr ;;MAC RX Handler
|
||||
DCD halAdcIsr ;;ADC Handler
|
||||
DCD halIrqAIsr ;;GPIO IRQA Handler
|
||||
DCD halIrqBIsr ;;GPIO IRQB Handler
|
||||
DCD halIrqCIsr ;;GPIO IRQC Handler
|
||||
DCD halIrqDIsr ;;GPIO IRQD Handler
|
||||
DCD halDebugIsr ;;Debug Handler
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Default interrupt handlers.
|
||||
;;
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
PUBWEAK HardFault_Handler
|
||||
PUBWEAK MemManage_Handler
|
||||
PUBWEAK BusFault_Handler
|
||||
PUBWEAK UsageFault_Handler
|
||||
PUBWEAK SVC_Handler
|
||||
PUBWEAK DebugMon_Handler
|
||||
PUBWEAK PendSV_Handler
|
||||
PUBWEAK SysTick_Handler
|
||||
|
||||
PUBWEAK halTimer1Isr
|
||||
PUBWEAK halTimer2Isr
|
||||
PUBWEAK halManagementIsr
|
||||
PUBWEAK halBaseBandIsr
|
||||
PUBWEAK halSleepTimerIsr
|
||||
PUBWEAK halSc1Isr
|
||||
PUBWEAK halSc2Isr
|
||||
PUBWEAK halSecurityIsr
|
||||
PUBWEAK halStackMacTimerIsr
|
||||
PUBWEAK stmRadioTransmitIsr
|
||||
PUBWEAK stmRadioReceiveIsr
|
||||
PUBWEAK halAdcIsr
|
||||
PUBWEAK halIrqAIsr
|
||||
PUBWEAK halIrqBIsr
|
||||
PUBWEAK halIrqCIsr
|
||||
PUBWEAK halIrqDIsr
|
||||
PUBWEAK halDebugIsr
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SECTION .text:CODE:REORDER(1)
|
||||
THUMB
|
||||
|
||||
NMI_Handler
|
||||
HardFault_Handler
|
||||
MemManage_Handler
|
||||
BusFault_Handler
|
||||
UsageFault_Handler
|
||||
SVC_Handler
|
||||
DebugMon_Handler
|
||||
PendSV_Handler
|
||||
SysTick_Handler
|
||||
halTimer1Isr
|
||||
halTimer2Isr
|
||||
halManagementIsr
|
||||
halBaseBandIsr
|
||||
halSleepTimerIsr
|
||||
halSc1Isr
|
||||
halSc2Isr
|
||||
halSecurityIsr
|
||||
halStackMacTimerIsr
|
||||
stmRadioTransmitIsr
|
||||
stmRadioReceiveIsr
|
||||
halAdcIsr
|
||||
halIrqAIsr
|
||||
halIrqBIsr
|
||||
halIrqCIsr
|
||||
halIrqDIsr
|
||||
halDebugIsr
|
||||
Default_Handler
|
||||
B Default_Handler
|
||||
|
||||
END
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1,49 +0,0 @@
|
||||
ELFloader and shell command 'exec' example for MB851 (STM32W) platform
|
||||
-----------------------------------------------------------
|
||||
|
||||
Compiles the Contiki hello-world application as a Contiki executable (.ce).
|
||||
The Contiki executable is then uploaded to the MB851 platform via serial, and
|
||||
is stored in the filesystem. Finally, the executable is loaded via the shell
|
||||
command 'exec'.
|
||||
|
||||
NOTE:
|
||||
You may have to reduce the ELF loader memory usage (/platform/sky/contiki-conf.h).
|
||||
Since hello-world uses very little memory:
|
||||
#define ELFLOADER_CONF_DATAMEMORY_SIZE 0x100
|
||||
#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x100
|
||||
|
||||
1. Upload Sky shell with 'exec' command and symbols (requires several
|
||||
recompilations to generate correct symbols):
|
||||
|
||||
make
|
||||
make CORE=shell-exec-test.mb851
|
||||
make shell-exec-test.flash CORE=shell-exec-test.mb851 PORT=AUTO
|
||||
|
||||
2. Verify access to the shell and the filesystem:
|
||||
|
||||
> make login DEV=/dev/comX
|
||||
SHELL> echo hello shell
|
||||
SHELL> echo test | write mytest.txt
|
||||
SHELL> ls
|
||||
SHELL> read mytest.txt
|
||||
[CTRL-C] to exit the shell
|
||||
|
||||
3. Upload Contiki executable hello-world.ce:
|
||||
|
||||
> make upload-executable DEV=/dev/comX
|
||||
[CTRL-C] to exit the shell when the entire file has been uploaded (after ~30 sec)
|
||||
|
||||
4. Verify that hello-world.ce exists in CFS:
|
||||
|
||||
> make login DEV=/dev/comX
|
||||
SHELL> ls
|
||||
SHELL> read hello-world.ce | size
|
||||
|
||||
The last command output should equal the size of hello-world.ce in this
|
||||
directory!
|
||||
|
||||
5. Load and start hello world:
|
||||
|
||||
SHELL> exec hello-world.ce
|
||||
|
||||
The program should now start: the output 'Hello, World' appears.
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1,10 +0,0 @@
|
||||
UDP IPV6 sleep
|
||||
==============
|
||||
|
||||
Thi is an example based on the UDP-IPv6 example. A client periodically sends
|
||||
UDP packets to a fixed server. The client will also go in a deep sleep state
|
||||
during which all system peripherals are turned off to save as more energy as
|
||||
possible.
|
||||
|
||||
To avoid blocking the entire OS for too long time, the system periodically
|
||||
wakes up to let the OS poll processes and dispatch events.
|
@ -1 +0,0 @@
|
||||
TARGET = mb851
|
@ -1,37 +0,0 @@
|
||||
Compile with WITH_RIME 1 for neighbor discovery and with ENERGEST_CONF_ON for
|
||||
energy estimation.
|
||||
|
||||
Estimated consumption with batteries (2.4 V):
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>Curr</td>
|
||||
<td>Power</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>ENERGEST_TYPE_CPU</td>
|
||||
<td>7.5 mA</td>
|
||||
<td>18 mW</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>ENERGEST_TYPE_LPM</td>
|
||||
<td>3 mA</td>
|
||||
<td>7.2 mW</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>ENERGEST_TYPE_TRANSMIT</td>
|
||||
<td>21 mA</td>
|
||||
<td>50.4 mW</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>ENERGEST_TYPE_LISTEN</td>
|
||||
<td>19 mA</td>
|
||||
<td>45.6 mW</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
1
examples/mbxxx/acc-sensor/Makefile.target
Normal file
1
examples/mbxxx/acc-sensor/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
@ -41,6 +41,7 @@
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/acc-sensor.h"
|
||||
#include "board.h"
|
||||
|
||||
#include <stdio.h> /* For printf() */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -54,7 +55,7 @@ PROCESS_THREAD(acc_process, ev, data)
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Starting measuring acceleration\r\n");
|
||||
|
||||
boardPrintStringDescription();
|
||||
SENSORS_ACTIVATE(acc_sensor);
|
||||
|
||||
// Enable High Range.
|
1
examples/mbxxx/button/Makefile.target
Normal file
1
examples/mbxxx/button/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
@ -42,6 +42,8 @@
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/leds.h"
|
||||
#include <stdio.h>
|
||||
#include "board.h"
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(test_button_process, "Test button");
|
||||
@ -52,7 +54,7 @@ PROCESS_THREAD(test_button_process, ev, data)
|
||||
PROCESS_BEGIN();
|
||||
|
||||
SENSORS_ACTIVATE(button_sensor);
|
||||
|
||||
boardPrintStringDescription();
|
||||
printf("Press the button to toggle the leds.");
|
||||
|
||||
while(1) {
|
1
examples/mbxxx/coffee-test/Makefile.target
Normal file
1
examples/mbxxx/coffee-test/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
@ -40,6 +40,7 @@
|
||||
#include "contiki.h"
|
||||
#include "cfs-coffee-arch.h"
|
||||
#include "cfs-coffee.h"
|
||||
#include "board.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -51,6 +52,7 @@ PROCESS_THREAD(coffee_test_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
boardPrintStringDescription();
|
||||
printf("Testing coffee...\n");
|
||||
|
||||
cfs_coffee_format();
|
@ -1,6 +1,6 @@
|
||||
CONTIKI_PROJECT = mb851-shell
|
||||
CONTIKI_PROJECT = mbxxx-shell
|
||||
|
||||
PROJECTDIRS = $(CONTIKI)/platform/mb851/apps
|
||||
PROJECTDIRS = $(CONTIKI)/platform/mbxxx/apps
|
||||
|
||||
APPS = serial-shell
|
||||
|
1
examples/mbxxx/mbxxx-shell/Makefile.target
Normal file
1
examples/mbxxx/mbxxx-shell/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
@ -32,7 +32,7 @@
|
||||
|
||||
/**
|
||||
* \file
|
||||
* MB851-specific Contiki shell
|
||||
* mbxxx-specific Contiki shell
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*
|
||||
@ -44,10 +44,10 @@
|
||||
#include "shell-sensors.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(mb851_shell_process, "MB851 Contiki shell");
|
||||
AUTOSTART_PROCESSES(&mb851_shell_process);
|
||||
PROCESS(mbxxx_shell_process, "MBXXX Contiki shell");
|
||||
AUTOSTART_PROCESSES(&mbxxx_shell_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(mb851_shell_process, ev, data)
|
||||
PROCESS_THREAD(mbxxx_shell_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
@ -1,4 +1,4 @@
|
||||
all: mb851-websense
|
||||
all: mbxxx-websense
|
||||
|
||||
CONTIKI=../../..
|
||||
|
1
examples/mbxxx/mbxxx-websense/Makefile.target
Normal file
1
examples/mbxxx/mbxxx-websense/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
@ -1 +1,4 @@
|
||||
webserver IPv6
|
||||
==============
|
||||
|
||||
See sky-websense example for more info.
|
@ -1,7 +1,7 @@
|
||||
CONTIKI_PROJECT = shell-exec-test
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
TARGET=mb851
|
||||
TARGET=mbxxx
|
||||
COFFEE=1
|
||||
ELF_LOADER=1
|
||||
|
47
examples/mbxxx/shell-exec/README.md
Normal file
47
examples/mbxxx/shell-exec/README.md
Normal file
@ -0,0 +1,47 @@
|
||||
ELFloader and shell command 'exec' example for mbxxx (STM32W) platform
|
||||
======================================================================
|
||||
|
||||
|
||||
Compiles the Contiki hello-world application as a Contiki executable (.ce).
|
||||
The Contiki executable is then uploaded to the mbxxx platform via serial, and
|
||||
is stored in the filesystem.
|
||||
Finally, the executable is loaded via the shell command 'exec'.
|
||||
|
||||
NOTE:
|
||||
You may have to reduce the ELF loader memory usage (/platform/sky/contiki-conf.h).
|
||||
Since hello-world uses very little memory:
|
||||
#define ELFLOADER_CONF_DATAMEMORY_SIZE 0x100
|
||||
#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x100
|
||||
|
||||
|
||||
1. Upload Sky shell with 'exec' command and symbols (requires several recompilations to generate correct symbols):
|
||||
> make
|
||||
> make CORE=shell-exec-test.mbxxx
|
||||
> make shell-exec-test.flash CORE=shell-exec-test.mbxxx PORT=AUTO
|
||||
|
||||
|
||||
2. Verify access to the shell and the filesystem:
|
||||
> make login DEV=/dev/comX
|
||||
SHELL> echo hello shell
|
||||
SHELL> echo test | write mytest.txt
|
||||
SHELL> ls
|
||||
SHELL> read mytest.txt
|
||||
[CTRL-C] to exit the shell
|
||||
|
||||
|
||||
3. Upload Contiki executable hello-world.ce:
|
||||
> make upload-executable DEV=/dev/comX
|
||||
[CTRL-C] to exit the shell when the entire file has been uploaded (after ~30 sec)
|
||||
|
||||
|
||||
4. Verify that hello-world.ce exists in CFS:
|
||||
> make login DEV=/dev/comX
|
||||
SHELL> ls
|
||||
SHELL> read hello-world.ce | size
|
||||
The last command output should equal the size of hello-world.ce in this directory!
|
||||
|
||||
|
||||
5. Load and start hello world:
|
||||
SHELL> exec hello-world.ce
|
||||
The program should now start: the output 'Hello, World' appears.
|
||||
|
@ -4,7 +4,7 @@ UIP_CONF_IPV6=1
|
||||
|
||||
APPS = telnetd
|
||||
|
||||
PROJECTDIRS = $(CONTIKI)/platform/mb851/apps
|
||||
PROJECTDIRS = $(CONTIKI)/platform/mbxxx/apps
|
||||
PROJECT_SOURCEFILES = shell-sensors.c
|
||||
|
||||
|
1
examples/mbxxx/telnet-server/Makefile.target
Normal file
1
examples/mbxxx/telnet-server/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
1
examples/mbxxx/temperature/Makefile.target
Normal file
1
examples/mbxxx/temperature/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
@ -42,6 +42,7 @@
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/temperature-sensor.h"
|
||||
#include "board.h"
|
||||
|
||||
#include <stdio.h> /* For printf() */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -54,6 +55,7 @@ PROCESS_THREAD(temp_process, ev, data)
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
boardPrintStringDescription();
|
||||
printf("Starting measuring temperature\r\n");
|
||||
|
||||
while(1) {
|
||||
@ -63,7 +65,6 @@ PROCESS_THREAD(temp_process, ev, data)
|
||||
|
||||
unsigned int temp = temperature_sensor.value(0);
|
||||
printf("Temp: %d.%d °C \r",temp/10,temp-(temp/10)*10);
|
||||
|
||||
}
|
||||
|
||||
|
1
examples/mbxxx/udp-ipv6-sleep/Makefile.target
Normal file
1
examples/mbxxx/udp-ipv6-sleep/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
10
examples/mbxxx/udp-ipv6-sleep/README.md
Normal file
10
examples/mbxxx/udp-ipv6-sleep/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
UDP-IPv6 Client and Server
|
||||
=========================
|
||||
|
||||
This is an example based on the udp-ipv6 example. A client periodically sends
|
||||
UDP packets to a fixed server. The client will also go in a deep sleep state
|
||||
during wich all system peripherals are turned off to save as more energy as
|
||||
possible.
|
||||
|
||||
To avoid blocking the entire OS for too long time, the system periocally
|
||||
wakes up to let the OS poll processes and dispatch events.
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "sleep.h"
|
||||
#include "board-sensors.h"
|
||||
#include "board.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -165,9 +166,9 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
||||
PROCESS_YIELD();
|
||||
if(etimer_expired(&wake_timer)){ // if timer hasn't expired do not go in deep sleep, in order to receive a response.
|
||||
printf("Sleeping...\r\n");
|
||||
sensorsPowerDown();
|
||||
halBoardPowerDown();//sensorsPowerDown();
|
||||
sleep_seconds(SLEEP_INTERVAL_SECONDS); // Put system in deep sleep mode for a while.
|
||||
sensorsPowerUp();
|
||||
halBoardPowerUp();//sensorsPowerUp();
|
||||
printf("Awake\r\n");
|
||||
}
|
||||
if(etimer_expired(&et)) {
|
@ -1,4 +1,4 @@
|
||||
CONTIKI_PROJECT = mb851-webserver
|
||||
CONTIKI_PROJECT = mbxxx-webserver
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
DEFINES=PROJECT_CONF_H=\"webserver-ajax-conf.h\"
|
1
examples/mbxxx/webserver-ajax/Makefile.target
Normal file
1
examples/mbxxx/webserver-ajax/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = mbxxx
|
12
examples/mbxxx/webserver-ajax/README.md
Normal file
12
examples/mbxxx/webserver-ajax/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
webserver ajax
|
||||
==============
|
||||
|
||||
Compile with WITH_RIME 1 for neighbor discovery and with ENERGEST_CONF_ON
|
||||
for energy estimation.
|
||||
|
||||
Estimated consumption with batteries (2.4 V):
|
||||
Curr Power
|
||||
ENERGEST_TYPE_CPU: 7.5 mA 18 mW
|
||||
ENERGEST_TYPE_LPM: 3 mA 7.2 mW
|
||||
ENERGEST_TYPE_TRANSMIT: 21 mA 50.4 mW
|
||||
ENERGEST_TYPE_LISTEN: 19 mA 45.6 mW
|
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
@ -37,7 +37,7 @@
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
/*
|
||||
* salvopitru: example adapted to MB851.
|
||||
* salvopitru: example adapted to mbxxx.
|
||||
*/
|
||||
|
||||
|
4
examples/mbxxx/webserver-ajax/symbols.c
Normal file
4
examples/mbxxx/webserver-ajax/symbols.c
Normal file
@ -0,0 +1,4 @@
|
||||
#include "symbols.h"
|
||||
|
||||
const int symbols_nelts = 0;
|
||||
const struct symbols symbols[] = {{0,0}};
|
3
examples/mbxxx/webserver-ajax/symbols.h
Normal file
3
examples/mbxxx/webserver-ajax/symbols.h
Normal file
@ -0,0 +1,3 @@
|
||||
#include "loader/symbols.h"
|
||||
|
||||
extern const struct symbols symbols[1];
|
@ -1,21 +0,0 @@
|
||||
ARCH= irq.c sensors.c acc-sensor.c button-sensor.c temperature-sensor.c mems.c
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev
|
||||
ifndef CONTIKI_TARGET_MAIN
|
||||
CONTIKI_TARGET_MAIN = contiki-main.c board-mb851.c
|
||||
endif
|
||||
|
||||
ifeq ($(UIP_CONF_IPV6),1)
|
||||
CFLAGS += -DWITH_UIP6=1
|
||||
endif
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(CONTIKI_TARGET_MAIN)
|
||||
|
||||
MCU=STM32W108
|
||||
include $(CONTIKI)/cpu/stm32w108/Makefile.stm32w108
|
||||
|
||||
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-linux
|
||||
|
||||
ifeq ($(HOST_OS),Windows)
|
||||
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-windows
|
||||
endif
|
@ -1,93 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Shell function for temp and acc sensors.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "shell.h"
|
||||
#include "contiki-net.h"
|
||||
#include "dev/temperature-sensor.h"
|
||||
#include "dev/acc-sensor.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(shell_sensors_process, "sensors");
|
||||
SHELL_COMMAND(sensors_command,
|
||||
"sensors",
|
||||
"sensors {temp|acc}: get sensor value", &shell_sensors_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(shell_sensors_process, ev, data)
|
||||
{
|
||||
char str_buf[22];
|
||||
|
||||
PROCESS_BEGIN();
|
||||
if(data == NULL) {
|
||||
shell_output_str(&sensors_command,
|
||||
"sensors {temp|acc}: a sensor must be specified", "");
|
||||
PROCESS_EXIT();
|
||||
}
|
||||
|
||||
if(strcmp(data, "temp") == 0) {
|
||||
unsigned int temp = temperature_sensor.value(0);
|
||||
snprintf(str_buf, sizeof(str_buf), "%d.%d degC", temp / 10,
|
||||
temp - (temp / 10) * 10);
|
||||
shell_output_str(&sensors_command, "Temp: ", str_buf);
|
||||
} else {
|
||||
if(strcmp(data, "acc") == 0) {
|
||||
snprintf(str_buf, sizeof(str_buf), "%d,%d,%d) mg",
|
||||
acc_sensor.value(ACC_X_AXIS), acc_sensor.value(ACC_Y_AXIS),
|
||||
acc_sensor.value(ACC_Z_AXIS));
|
||||
shell_output_str(&sensors_command, "(X,Y,Z): (", str_buf);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
shell_sensors_init(void)
|
||||
{
|
||||
SENSORS_ACTIVATE(acc_sensor);
|
||||
shell_register_command(&sensors_command);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Header file for Contik shell sensors command.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef __SHELL_SENSORS_H__
|
||||
#define __SHELL_SENSORS_H__
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
void shell_sensors_init(void);
|
||||
|
||||
#endif /* __SHELL_SENSORS_H__ */
|
||||
/** @} */
|
@ -1,174 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
#include BOARD_HEADER
|
||||
#include "hal/micro/micro-common.h"
|
||||
#include "hal/micro/cortexm3/micro-common.h"
|
||||
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/temperature-sensor.h"
|
||||
#include "dev/acc-sensor.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint8_t sensors_status;
|
||||
|
||||
#define BUTTON_STATUS_ACTIVE (1 << 0)
|
||||
#define TEMP_STATUS_ACTIVE (1 << 1)
|
||||
#define ACC_STATUS_ACTIVE (1 << 2)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init board (currently does nothing)
|
||||
*/
|
||||
void
|
||||
board_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Power down board
|
||||
*/
|
||||
void
|
||||
board_power_down(void)
|
||||
{
|
||||
/* Set everything except LEDs to input */
|
||||
GPIO_PACFGL = (GPIOCFG_IN << PA0_CFG_BIT) |
|
||||
(GPIOCFG_IN << PA1_CFG_BIT) |
|
||||
(GPIOCFG_IN << PA2_CFG_BIT) | (GPIOCFG_IN << PA3_CFG_BIT);
|
||||
GPIO_PACFGH = (GPIOCFG_IN << PA4_CFG_BIT) | /* PTI EN */
|
||||
(GPIOCFG_IN << PA5_CFG_BIT) | /* PTI_DATA */
|
||||
(GPIOCFG_IN << PA6_CFG_BIT) | (GPIOCFG_IN << PA7_CFG_BIT);
|
||||
GPIO_PBCFGL = (GPIOCFG_IN << PB0_CFG_BIT) | (GPIOCFG_IN << PB1_CFG_BIT) |
|
||||
(GPIOCFG_IN << PB2_CFG_BIT) | /* Uart Tx, RX */
|
||||
(GPIOCFG_IN << PB3_CFG_BIT);
|
||||
GPIO_PBCFGH = (GPIOCFG_IN << PB4_CFG_BIT) |
|
||||
(GPIOCFG_IN << PB5_CFG_BIT) |
|
||||
(GPIOCFG_IN << PB6_CFG_BIT) | (GPIOCFG_IN << PB7_CFG_BIT);
|
||||
GPIO_PCCFGL = (GPIOCFG_IN << PC0_CFG_BIT) |
|
||||
(GPIOCFG_IN << PC1_CFG_BIT) |
|
||||
(GPIOCFG_IN << PC2_CFG_BIT) | (GPIOCFG_IN << PC3_CFG_BIT);
|
||||
GPIO_PCCFGH = (GPIOCFG_IN << PC4_CFG_BIT) | (GPIOCFG_IN << PC5_CFG_BIT) |
|
||||
(GPIOCFG_IN << PC6_CFG_BIT) | (GPIOCFG_IN << PC7_CFG_BIT); /* OSC32K */
|
||||
|
||||
leds_init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Power down sensors
|
||||
*/
|
||||
void
|
||||
board_sensors_power_down(void)
|
||||
{
|
||||
/*
|
||||
* Remember state of sensors (if active or not), in order to
|
||||
* resume their original state after calling powerUpSensors().
|
||||
* Useful when entering in sleep mode, since all system
|
||||
* peripherals have to be reinitialized.
|
||||
*/
|
||||
sensors_status = 0;
|
||||
|
||||
if(button_sensor.status(SENSORS_READY)) {
|
||||
sensors_status |= BUTTON_STATUS_ACTIVE;
|
||||
}
|
||||
if(temperature_sensor.status(SENSORS_READY)) {
|
||||
sensors_status |= TEMP_STATUS_ACTIVE;
|
||||
}
|
||||
if(acc_sensor.status(SENSORS_READY)) {
|
||||
sensors_status |= ACC_STATUS_ACTIVE;
|
||||
/* Power down accelerometer to save power */
|
||||
SENSORS_DEACTIVATE(acc_sensor);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Power up sensors
|
||||
*/
|
||||
void
|
||||
board_sensors_power_up(void)
|
||||
{
|
||||
button_sensor.configure(SENSORS_HW_INIT, 0);
|
||||
temperature_sensor.configure(SENSORS_HW_INIT, 0);
|
||||
acc_sensor.configure(SENSORS_HW_INIT, 0);
|
||||
|
||||
if(sensors_status & BUTTON_STATUS_ACTIVE) {
|
||||
SENSORS_ACTIVATE(button_sensor);
|
||||
}
|
||||
if(sensors_status & TEMP_STATUS_ACTIVE) {
|
||||
SENSORS_ACTIVATE(temperature_sensor);
|
||||
}
|
||||
if(sensors_status & ACC_STATUS_ACTIVE) {
|
||||
SENSORS_ACTIVATE(acc_sensor);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Power up board
|
||||
*/
|
||||
void
|
||||
board_power_up(void)
|
||||
{
|
||||
/* Set everything to inputs */
|
||||
GPIO_PACFGL = (GPIOCFG_IN << PA0_CFG_BIT) |
|
||||
(GPIOCFG_IN << PA1_CFG_BIT) |
|
||||
(GPIOCFG_IN << PA2_CFG_BIT) | (GPIOCFG_IN << PA3_CFG_BIT);
|
||||
GPIO_PACFGH = (GPIOCFG_IN << PA4_CFG_BIT) | /* PTI EN */
|
||||
(GPIOCFG_IN << PA5_CFG_BIT) | /* PTI_DATA */
|
||||
(GPIOCFG_IN << PA6_CFG_BIT) | (GPIOCFG_IN << PA7_CFG_BIT);
|
||||
GPIO_PBCFGL = (GPIOCFG_IN << PB0_CFG_BIT) | (GPIOCFG_OUT_ALT << PB1_CFG_BIT) |
|
||||
(GPIOCFG_IN << PB2_CFG_BIT) | /* Uart Rx, Tx */
|
||||
(GPIOCFG_IN << PB3_CFG_BIT);
|
||||
GPIO_PBCFGH = (GPIOCFG_IN << PB4_CFG_BIT) |
|
||||
(GPIOCFG_IN << PB5_CFG_BIT) |
|
||||
(GPIOCFG_IN << PB6_CFG_BIT) | (GPIOCFG_IN << PB7_CFG_BIT);
|
||||
GPIO_PCCFGL = (GPIOCFG_IN << PC0_CFG_BIT) |
|
||||
(GPIOCFG_IN << PC1_CFG_BIT) |
|
||||
(GPIOCFG_IN << PC2_CFG_BIT) | (GPIOCFG_IN << PC3_CFG_BIT);
|
||||
GPIO_PCCFGH = (GPIOCFG_IN << PC4_CFG_BIT) | (GPIOCFG_IN << PC5_CFG_BIT) |
|
||||
(GPIOCFG_IN << PC6_CFG_BIT) | (GPIOCFG_IN << PC7_CFG_BIT); /* OSC32K */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* STM32W108 HAL functions needed to get use the
|
||||
hal/micro/cortexm3/micro.c functionality. */
|
||||
void halBoardInit(void) { board_init(); }
|
||||
void halBoardPowerUp(void) { board_power_up(); }
|
||||
void halBoardPowerDown(void) { board_power_down(); }
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
@ -1,172 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* contiki-conf.h for MB851.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __CONTIKI_CONF_H__
|
||||
#define __CONTIKI_CONF_H__
|
||||
|
||||
#ifdef PLATFORM_CONF_H
|
||||
#include PLATFORM_CONF_H
|
||||
#else
|
||||
#include "platform-conf.h"
|
||||
#endif /* PLATFORM_CONF_H */
|
||||
|
||||
/* Radio and 802.15.4 params */
|
||||
/* 802.15.4 radio channel */
|
||||
#define RF_CHANNEL 26
|
||||
/* 802.15.4 PAN ID */
|
||||
#define IEEE802154_CONF_PANID 0xabcd
|
||||
/* Use EID 64, enable hardware autoack and address filtering */
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
#define UIP_CONF_LL_802154 1
|
||||
#define ST_CONF_RADIO_AUTOACK 1
|
||||
/* Number of buffers for incoming frames */
|
||||
#define RADIO_RXBUFS 2
|
||||
/* Set to 0 for non ethernet links */
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
|
||||
/* RDC params */
|
||||
/* TX routine passes the cca/ack result in the return parameter */
|
||||
#define RDC_CONF_HARDWARE_ACK 1
|
||||
/* TX routine does automatic cca and optional backoff */
|
||||
#define RDC_CONF_HARDWARE_CSMA 0
|
||||
/* RDC debug with LED */
|
||||
#define RDC_CONF_DEBUG_LED 0
|
||||
/* Channel check rate (per second) */
|
||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
|
||||
/* Use ACK for optimization (LPP, XMAC) */
|
||||
#define WITH_ACK_OPTIMIZATION 0
|
||||
|
||||
/* Netstack config */
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
#define NETSTACK_CONF_RADIO stm32w_radio_driver
|
||||
|
||||
/* ContikiMAC config */
|
||||
#define CONTIKIMAC_CONF_COMPOWER 0
|
||||
#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0
|
||||
#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0
|
||||
|
||||
/* CXMAC config */
|
||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define CXMAC_CONF_COMPOWER 1
|
||||
|
||||
/* XMAC config */
|
||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define XMAC_CONF_COMPOWER 1
|
||||
|
||||
/* Other (RAM saving) */
|
||||
#define ENERGEST_CONF_ON 0
|
||||
#define QUEUEBUF_CONF_NUM 2
|
||||
#define QUEUEBUF_CONF_REF_NUM 0
|
||||
#define UIP_CONF_DS6_NBR_NBU 4
|
||||
#define UIP_CONF_MAX_ROUTES 4
|
||||
#define RPL_CONF_MAX_PARENTS_PER_DAG 4
|
||||
#define RPL_CONF_MAX_INSTANCES 1
|
||||
#define RPL_CONF_MAX_DAG_PER_INSTANCE 1
|
||||
#define PROCESS_CONF_NUMEVENTS 16
|
||||
|
||||
#if WITH_UIP6
|
||||
|
||||
/* Network setup for IPv6 */
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
|
||||
/*
|
||||
* Specify a minimum packet size for 6lowpan compression to be
|
||||
* enabled. This is needed for ContikiMAC, which needs packets to be
|
||||
* larger than a specified size, if no ContikiMAC header should
|
||||
* be used.
|
||||
*/
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_THRESHOLD 63
|
||||
#define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0
|
||||
|
||||
#define UIP_CONF_ROUTER 1
|
||||
#define UIP_CONF_IPV6_RPL 1
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
|
||||
#define UIP_CONF_BUFFER_SIZE 140
|
||||
|
||||
#define UIP_CONF_IPV6 1
|
||||
#define UIP_CONF_IPV6_QUEUE_PKT 0
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||
#define UIP_CONF_ND6_MAX_PREFIXES 2
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 2
|
||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 1
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#define UIP_CONF_MAX_CONNECTIONS 4
|
||||
#define UIP_CONF_MAX_LISTENPORTS 8
|
||||
#define UIP_CONF_UDP_CONNS 4
|
||||
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
#ifndef SICSLOWPAN_CONF_FRAG
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#endif /* SICSLOWPAN_CONF_FRAG */
|
||||
#ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
|
||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||
#endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS */
|
||||
#ifndef SICSLOWPAN_CONF_MAXAGE
|
||||
#define SICSLOWPAN_CONF_MAXAGE 2
|
||||
#endif /* SICSLOWPAN_CONF_MAXAGE */
|
||||
|
||||
#else /* WITH_UIP6 */
|
||||
|
||||
/* Network setup for non-IPv6 (rime). */
|
||||
#define NETSTACK_CONF_NETWORK rime_driver
|
||||
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#ifdef PROJECT_CONF_H
|
||||
#include PROJECT_CONF_H
|
||||
#endif /* PROJECT_CONF_H */
|
||||
|
||||
#ifdef PLATFORM_CONF
|
||||
#include PLATFORM_CONF
|
||||
#endif /* PLATFORM_CONF */
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
||||
/** @} */
|
@ -1,332 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Contiki main file.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
*/
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
#include "hal/error.h"
|
||||
#include "hal/hal.h"
|
||||
#include BOARD_HEADER
|
||||
#include "micro/adc.h"
|
||||
#include <stdio.h>
|
||||
#include "contiki.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/temperature-sensor.h"
|
||||
#include "dev/acc-sensor.h"
|
||||
#include "dev/uart1.h"
|
||||
#include "dev/serial-line.h"
|
||||
|
||||
#include "dev/stm32w-radio.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/rime/rimeaddr.h"
|
||||
#include "net/rime.h"
|
||||
#include "net/rime/rime-udp.h"
|
||||
#include "net/uip.h"
|
||||
|
||||
#if WITH_UIP6
|
||||
#include "net/uip-ds6.h"
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#define DEBUG 1
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
|
||||
#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",lladdr.u8[0], lladdr.u8[1], lladdr.u8[2], lladdr.u8[3],lladdr.u8[4], lladdr.u8[5], lladdr.u8[6], lladdr.u8[7])
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINT6ADDR(addr)
|
||||
#define PRINTLLADDR(addr)
|
||||
#endif
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
PROCINIT(&tcpip_process, &sensors_process);
|
||||
#else
|
||||
PROCINIT(&sensors_process);
|
||||
#warning "No TCP/IP process!"
|
||||
#endif
|
||||
|
||||
SENSORS(&button_sensor, &temperature_sensor, &acc_sensor);
|
||||
|
||||
/* The default CCA threshold is set to -77, which is the same as the
|
||||
default setting on the TI CC2420. */
|
||||
#define DEFAULT_RADIO_CCA_THRESHOLD (-77)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_processes(struct process * const processes[])
|
||||
{
|
||||
#if !PROCESS_CONF_NO_PROCESS_NAMES
|
||||
/* const struct process * const * p = processes;*/
|
||||
printf("Starting");
|
||||
while(*processes != NULL) {
|
||||
printf(" '%s'", (*processes)->name);
|
||||
processes++;
|
||||
}
|
||||
printf("\n");
|
||||
#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_rime_addr(void)
|
||||
{
|
||||
int i;
|
||||
union {
|
||||
uint8_t u8[8];
|
||||
} eui64;
|
||||
|
||||
uint8_t *stm32w_eui64 = ST_RadioGetEui64();
|
||||
{
|
||||
uint8_t c;
|
||||
/* Copy the EUI-64 to lladdr converting from Little-Endian to
|
||||
Big-Endian. */
|
||||
for(c = 0; c < 8; c++) {
|
||||
eui64.u8[c] = stm32w_eui64[7 - c];
|
||||
}
|
||||
}
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr));
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
rimeaddr_set_node_addr((rimeaddr_t *) &eui64);
|
||||
#else
|
||||
rimeaddr_set_node_addr((rimeaddr_t *) &eui64.u8[8 - RIMEADDR_SIZE]);
|
||||
#endif
|
||||
|
||||
printf("Rime started with address ");
|
||||
for(i = 0; i < sizeof(rimeaddr_t) - 1; i++) {
|
||||
printf("%d.", rimeaddr_node_addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", rimeaddr_node_addr.u8[i]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/*
|
||||
* Initalize hardware.
|
||||
*/
|
||||
halInit();
|
||||
clock_init();
|
||||
uart1_init(115200);
|
||||
|
||||
/* LED initialization */
|
||||
leds_init();
|
||||
|
||||
INTERRUPTS_ON();
|
||||
|
||||
PRINTF("\r\nStarting ");
|
||||
PRINTF(CONTIKI_VERSION_STRING);
|
||||
PRINTF(" on MB851\r\n");
|
||||
|
||||
/*
|
||||
* Initialize Contiki and our processes.
|
||||
*/
|
||||
process_init();
|
||||
|
||||
#if WITH_SERIAL_LINE_INPUT
|
||||
uart1_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
#endif
|
||||
/* rtimer and ctimer should be initialized before radio duty cycling
|
||||
layers */
|
||||
rtimer_init();
|
||||
/* etimer_process should be initialized before ctimer */
|
||||
process_start(&etimer_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
netstack_init();
|
||||
|
||||
set_rime_addr();
|
||||
|
||||
printf("%s %s, channel check rate %lu Hz\n",
|
||||
NETSTACK_MAC.name, NETSTACK_RDC.name,
|
||||
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 :
|
||||
NETSTACK_RDC.channel_check_interval()));
|
||||
printf("802.15.4 PAN ID 0x%x, EUI-%d:",
|
||||
IEEE802154_CONF_PANID, UIP_CONF_LL_802154 ? 64 : 16);
|
||||
uip_debug_lladdr_print(&rimeaddr_node_addr);
|
||||
printf(", radio channel %u\n", RF_CHANNEL);
|
||||
|
||||
procinit_init();
|
||||
|
||||
energest_init();
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
/* Set the Clear Channel Assessment (CCA) threshold of the
|
||||
radio. The CCA threshold is used both for sending packets and for
|
||||
waking up ContikiMAC nodes. If the CCA threshold is too high,
|
||||
ContikiMAC will not wake up from neighbor transmissions. If the
|
||||
CCA threshold is too low, transmissions will be too restrictive
|
||||
and no packets will be sent. DEFAULT_RADIO_CCA_THRESHOLD is
|
||||
defined in this file. */
|
||||
ST_RadioSetEdCcaThreshold(DEFAULT_RADIO_CCA_THRESHOLD);
|
||||
|
||||
print_processes(autostart_processes);
|
||||
autostart_start(autostart_processes);
|
||||
#if UIP_CONF_IPV6
|
||||
printf("Tentative link-local IPv6 address ");
|
||||
{
|
||||
uip_ds6_addr_t *lladdr;
|
||||
|
||||
int i;
|
||||
|
||||
lladdr = uip_ds6_get_link_local(-1);
|
||||
for(i = 0; i < 7; ++i) {
|
||||
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
|
||||
lladdr->ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
|
||||
}
|
||||
|
||||
|
||||
if(!UIP_CONF_IPV6_RPL) {
|
||||
uip_ipaddr_t ipaddr;
|
||||
|
||||
int i;
|
||||
|
||||
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
||||
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
|
||||
printf("Tentative global IPv6 address ");
|
||||
for(i = 0; i < 7; ++i) {
|
||||
printf("%02x%02x:", ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
printf("%02x%02x\n", ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
watchdog_start();
|
||||
|
||||
while(1) {
|
||||
int r;
|
||||
|
||||
do {
|
||||
/* Reset watchdog. */
|
||||
watchdog_periodic();
|
||||
r = process_run();
|
||||
} while(r > 0);
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
||||
/* watchdog_stop(); */
|
||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
||||
/* Go to idle mode. */
|
||||
halSleepWithOptions(SLEEPMODE_IDLE, 0);
|
||||
/* We are awake. */
|
||||
/* watchdog_start(); */
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#if 0
|
||||
uint8_t errcode __attribute__(( section(".noinit") ));
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
halBaseBandIsr(void)
|
||||
{
|
||||
errcode = 1;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
BusFault_Handler(void)
|
||||
{
|
||||
errcode = 2;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
halDebugIsr(void)
|
||||
{
|
||||
errcode = 3;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
DebugMon_Handler(void)
|
||||
{
|
||||
errcode = 4;
|
||||
/* leds_on(LEDS_RED); */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
HardFault_Handler(void)
|
||||
{
|
||||
errcode = 5;
|
||||
/* leds_on(LEDS_RED); */
|
||||
/* halReboot(); */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
MemManage_Handler(void)
|
||||
{
|
||||
errcode = 6;
|
||||
/* leds_on(LEDS_RED); */
|
||||
/* halReboot(); */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
UsageFault_Handler(void)
|
||||
{
|
||||
errcode = 7;
|
||||
/* leds_on(LEDS_RED); */
|
||||
/* halReboot(); */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
Default_Handler()
|
||||
{
|
||||
/* errcode = 8; */
|
||||
leds_on(LEDS_RED);
|
||||
halReboot();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#endif
|
||||
/** @} */
|
@ -1,137 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Accelerometer driver.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include "dev/acc-sensor.h"
|
||||
#include "mems.h"
|
||||
#include "sys/clock.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
active(void)
|
||||
{
|
||||
uint8_t reg;
|
||||
|
||||
if(!i2c_read_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, ®, 1)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (reg & 0x40) ? TRUE : FALSE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
int8_t i2c_data = 0;
|
||||
uint8_t reg_addr;
|
||||
|
||||
switch (type) {
|
||||
case ACC_X_AXIS:
|
||||
reg_addr = OUTX_H;
|
||||
break;
|
||||
|
||||
case ACC_Y_AXIS:
|
||||
reg_addr = OUTY_H;
|
||||
break;
|
||||
|
||||
case ACC_Z_AXIS:
|
||||
reg_addr = OUTZ_H;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
i2c_read_reg(KLIS3L02DQ_SLAVE_ADDR, reg_addr, (uint8_t *) &i2c_data, 1);
|
||||
|
||||
if(mems_get_fullscale() == ACC_HIGH_RANGE) {
|
||||
return ((int16_t) i2c_data) * HIGH_RANGE_SENSITIVITY;
|
||||
} else {
|
||||
return ((int16_t) i2c_data) * LOW_RANGE_SENSITIVITY;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int value)
|
||||
{
|
||||
switch (type) {
|
||||
case SENSORS_HW_INIT:
|
||||
return mems_init();
|
||||
|
||||
case SENSORS_ACTIVE:
|
||||
if(value) {
|
||||
if(mems_on()) {
|
||||
clock_wait(8);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return mems_off();
|
||||
}
|
||||
|
||||
case ACC_RANGE:
|
||||
return mems_set_fullscale((boolean) value);
|
||||
|
||||
case ACC_HPF:
|
||||
if(value < ACC_HPF_DISABLE) {
|
||||
return i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG2,
|
||||
(1 << 4) | (uint8_t) value);
|
||||
} else {
|
||||
return i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG2, 0x00);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case SENSORS_READY:
|
||||
return active();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(acc_sensor, ACC_SENSOR, value, configure, status);
|
||||
/** @} */
|
@ -1,77 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Accelerometer header file.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef __ACC_SENSOR_H__
|
||||
#define __ACC_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "mems.h"
|
||||
|
||||
extern const struct sensors_sensor acc_sensor;
|
||||
|
||||
#define ACC_SENSOR "Acc"
|
||||
|
||||
/* The type values used in the configure() function. */
|
||||
/* Full-scale */
|
||||
#define ACC_RANGE 1
|
||||
#define ACC_LOW_RANGE MEMS_LOW_RANGE
|
||||
#define ACC_HIGH_RANGE MEMS_HIGH_RANGE
|
||||
|
||||
/* High pass filter and cut-off frequencies */
|
||||
#define ACC_HPF 2
|
||||
|
||||
#define ACC_HPF_DISABLE 4
|
||||
#define ACC_1HZ 3
|
||||
#define ACC_2HZ 2
|
||||
#define ACC_4HZ 1
|
||||
#define ACC_8HZ 0
|
||||
|
||||
/*
|
||||
* The type values used in the value() function.
|
||||
* The returned value is expressed in mg units and can be negative.
|
||||
*/
|
||||
#define ACC_X_AXIS 1
|
||||
#define ACC_Y_AXIS 2
|
||||
#define ACC_Z_AXIS 3
|
||||
|
||||
#endif /* __ACC_SENSOR_H__ */
|
||||
/** @} */
|
@ -1,186 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Button sensor.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include "dev/button-sensor.h"
|
||||
#include "hal/micro/micro-common.h"
|
||||
#include "hal/micro/cortexm3/micro-common.h"
|
||||
|
||||
#include BOARD_HEADER
|
||||
#define DEBOUNCE 1
|
||||
|
||||
/**
|
||||
* \brief Port and pin for BUTTON0.
|
||||
*/
|
||||
#undef BUTTON_S1
|
||||
#define BUTTON_S1 PORTA_PIN(7)
|
||||
#define BUTTON_S1_INPUT_GPIO BUTTON_INPUT_GPIO(PORTA)
|
||||
#define BUTTON_S1_GPIO_PIN 7
|
||||
#define BUTTON_S1_OUTPUT_GPIO GPIO_PAOUT
|
||||
|
||||
/**
|
||||
* \brief Point the proper IRQ at the desired pin for BUTTON0.
|
||||
*/
|
||||
#define BUTTON_S1_SEL() do { GPIO_IRQCSEL = BUTTON_S1; } while(0)
|
||||
/**
|
||||
* \brief The interrupt service routine for BUTTON_S1.
|
||||
*/
|
||||
#define BUTTON_S1_ISR halIrqCIsr
|
||||
/**
|
||||
* \brief The interrupt configuration register for BUTTON_S1.
|
||||
*/
|
||||
#define BUTTON_S1_INTCFG GPIO_INTCFGC
|
||||
/**
|
||||
* \brief The interrupt bit for BUTTON_S1.
|
||||
*/
|
||||
#define BUTTON_S1_INT_EN_BIT INT_IRQC
|
||||
/**
|
||||
* \brief The interrupt bit for BUTTON_S1.
|
||||
*/
|
||||
#define BUTTON_S1_FLAG_BIT INT_IRQCFLAG
|
||||
/**
|
||||
* \brief The missed interrupt bit for BUTTON_S1.
|
||||
*/
|
||||
#define BUTTON_S1_MISS_BIT INT_MISSIRQC
|
||||
|
||||
#if DEBOUNCE
|
||||
static struct timer debouncetimer;
|
||||
#endif
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
#if DEBOUNCE
|
||||
timer_set(&debouncetimer, 0);
|
||||
#endif
|
||||
|
||||
/* Configure GPIO */
|
||||
/* Input, pulled up or down (selected by GPIO_PxOUT: 0 = pull-down). */
|
||||
halGpioConfig(BUTTON_S1, GPIOCFG_IN_PUD);
|
||||
BUTTON_S1_OUTPUT_GPIO |= GPIOOUT_PULLUP << BUTTON_S1_GPIO_PIN;
|
||||
BUTTON_S1_SEL();
|
||||
BUTTON_S1_INTCFG = 0x40; /* Falling edge triggered. */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
activate(void)
|
||||
{
|
||||
INT_CFGSET = BUTTON_S1_INT_EN_BIT;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
deactivate(void)
|
||||
{
|
||||
INT_CFGCLR = BUTTON_S1_INT_EN_BIT;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
active(void)
|
||||
{
|
||||
return (INT_CFGSET & BUTTON_S1_INT_EN_BIT) ? TRUE : FALSE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
#if DEBOUNCE
|
||||
return (BUTTON_S1_INPUT_GPIO & (1 << BUTTON_S1_GPIO_PIN)) ||
|
||||
!timer_expired(&debouncetimer);
|
||||
#else
|
||||
return BUTTON_S1_INPUT_GPIO & (1 << BUTTON_S1_GPIO_PIN);
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int value)
|
||||
{
|
||||
switch (type) {
|
||||
case SENSORS_HW_INIT:
|
||||
init();
|
||||
return 1;
|
||||
case SENSORS_ACTIVE:
|
||||
if(value) {
|
||||
activate();
|
||||
} else {
|
||||
deactivate();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case SENSORS_READY:
|
||||
return active();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
BUTTON_S1_ISR(void)
|
||||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
/* sensors_handle_irq(IRQ_BUTTON); */
|
||||
|
||||
if(INT_GPIOFLAG & BUTTON_S1_FLAG_BIT) {
|
||||
#if DEBOUNCE
|
||||
if(timer_expired(&debouncetimer)) {
|
||||
timer_set(&debouncetimer, CLOCK_SECOND / 5);
|
||||
sensors_changed(&button_sensor);
|
||||
}
|
||||
#else
|
||||
sensors_changed(&button_sensor);
|
||||
#endif
|
||||
}
|
||||
|
||||
INT_GPIOFLAG = BUTTON_S1_FLAG_BIT;
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, value, configure, status);
|
||||
/** @} */
|
@ -1,123 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
* File Name : mems-regs.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V1.0
|
||||
* Date : January 2010
|
||||
* Description : stm32w108 mems registers
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _MEMS_REGS_H_
|
||||
#define _MEMS_REGS_H_
|
||||
#include <stdint.h>
|
||||
|
||||
/* Size of MEMs data */
|
||||
#define MEMS_DATA_SIZE 6
|
||||
|
||||
/* address of slave */
|
||||
#define KLIS3L02DQ_SLAVE_ADDR 0x38
|
||||
|
||||
/* accelerometer register addresses */
|
||||
#define OFFSET_X 0x16
|
||||
#define OFFSET_Y 0x17
|
||||
#define OFFSET_Z 0x18
|
||||
#define GAIN_X 0x19
|
||||
#define GAIN_Y 0x1A
|
||||
#define GAIN_Z 0x1B
|
||||
#define CTRL_REG1 0x20
|
||||
#define CTRL_REG2 0x21
|
||||
#define STATUS_REG 0x27
|
||||
#define OUTX_L 0x28
|
||||
#define OUTX_H 0x29
|
||||
#define OUTY_L 0x2A
|
||||
#define OUTY_H 0x2B
|
||||
#define OUTZ_L 0x2C
|
||||
#define OUTZ_H 0x2D
|
||||
#define FF_WU_CFG 0x30
|
||||
#define FF_WU_SRC 0x31
|
||||
#define FF_WU_ACK 0x32
|
||||
#define FF_WU_THS_L 0x34
|
||||
#define FF_WU_THS_H 0x35
|
||||
#define FF_WU_DURATION 0x36
|
||||
#define DD_CFG 0x38
|
||||
#define DD_SRC 0x39
|
||||
#define DD_ACK 0x3A
|
||||
#define DD_THSI_L 0x3C
|
||||
#define DD_THSI_H 0x3D
|
||||
#define DD_THSE_L 0x3E
|
||||
#define DD_THSE_H 0x3F
|
||||
|
||||
/* Communication control settings */
|
||||
/* I2C */
|
||||
#define REPETIR 0x80
|
||||
/* SPI */
|
||||
#define MEMS_SPI_WRITE 0x00
|
||||
#define MEMS_SPI_READ 0x80
|
||||
#define MEMS_SPI_MULTIPLE_BYTES 0x40
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Settings for CTRL_REG1 */
|
||||
/* Power Down Control (PD) */
|
||||
#define LIS_PD_OFF 0x00
|
||||
#define LIS_PD_ON 0x40
|
||||
|
||||
/* Decimation Factor Control (DF) */
|
||||
#define LIS_DF_BY128 0x00
|
||||
#define LIS_DF_BY64 0x10
|
||||
#define LIS_DF_BY32 0x20
|
||||
#define LIS_DF_BY8 0x30
|
||||
|
||||
/* Self Test */
|
||||
#define LIS_ST_NORMAL 0x00
|
||||
#define LIS_ST_TEST 0x08
|
||||
|
||||
/* Enable Axis */
|
||||
#define LIS_EA_ALL 0x07
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Settings for CTRL_REG2 */
|
||||
|
||||
/* Full Scale (FS) */
|
||||
#define LIS_FS_2G 0x00
|
||||
#define LIS_FS_6G 0x80
|
||||
|
||||
/* Block Data Update (BDU) */
|
||||
#define LIS_BDU_CONTINUOUS 0x00
|
||||
#define LIS_BDU_WAIT 0x40
|
||||
|
||||
/* Big/Little Endian Selection (BLE) */
|
||||
#define LIS_BLE_LE 0x00
|
||||
#define LIS_BLE_BE 0x20
|
||||
#define LIS_BLE_XX LIS_BLE_BE
|
||||
|
||||
/* Data Alignment Selection DAS */
|
||||
#define LIS_DAS_12BIT 0x00
|
||||
#define LIS_DAS_16BIT 0x01
|
||||
|
||||
/* Interrupt Enable */
|
||||
#define LIS_INTR_DISABLE 0x00
|
||||
#define LIS_INTR_ENABLE 0x08
|
||||
|
||||
/* Data Ready Enable */
|
||||
#define LIS_DRDY_DISABLE 0x00
|
||||
#define LIS_DRDY_ENABLE 0x04
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
uint8_t i2c_write_reg(uint8_t slave_addr, uint8_t reg_addr,
|
||||
uint8_t reg_value);
|
||||
uint8_t i2c_read_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *p_buf,
|
||||
uint8_t len);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#endif /* _MEMS_REGS_H_ */
|
||||
/** @} */
|
@ -1,348 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
* File Name : hal_led.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V1.0
|
||||
* Date : September 2009
|
||||
* Description : Driver for leds management on STM32W108 MB851 board
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
#include "mems.h"
|
||||
#include "timer.h"
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#define TIMEOUT 20000
|
||||
#define SUCCESS 1
|
||||
#define FAIL 0
|
||||
|
||||
#define SEND_BYTE(data) do { SC2_DATA=(data); SC2_TWICTRL1 |= SC_TWISEND; \
|
||||
} while(0)
|
||||
|
||||
#define WAIT_CMD_FIN() { \
|
||||
struct timer t; \
|
||||
timer_set(&t, CLOCK_SECOND/100); \
|
||||
while((SC2_TWISTAT&SC_TWICMDFIN)!=SC_TWICMDFIN){ \
|
||||
if(timer_expired(&t)){ \
|
||||
return FAIL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WAIT_TX_FIN() { \
|
||||
struct timer t; \
|
||||
timer_set(&t, CLOCK_SECOND/100); \
|
||||
while((SC2_TWISTAT&SC_TWITXFIN)!=SC_TWITXFIN){ \
|
||||
if(timer_expired(&t)){ \
|
||||
return FAIL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define WAIT_RX_FIN() { \
|
||||
struct timer t; \
|
||||
timer_set(&t, CLOCK_SECOND/100); \
|
||||
while((SC2_TWISTAT&SC_TWIRXFIN)!=SC_TWIRXFIN){ \
|
||||
if(timer_expired(&t)){ \
|
||||
return FAIL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static boolean fullscale_state;
|
||||
|
||||
static uint8_t i2c_mems_init(void);
|
||||
|
||||
static uint8_t i2c_send_frame(uint8_t address, uint8_t *p_buf, uint8_t len);
|
||||
|
||||
uint8_t i2c_write_reg(uint8_t slave_addr, uint8_t reg_addr,
|
||||
uint8_t reg_value);
|
||||
|
||||
/* static uint8_t i2c_mems_read (mems_data_t *mems_data); */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init MEMS
|
||||
* \return None
|
||||
*/
|
||||
uint8_t
|
||||
mems_init(void)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
|
||||
/* GPIO assignments */
|
||||
/* PA1: SC2SDA (Serial Data) */
|
||||
/* PA2: SC2SCL (Serial Clock) */
|
||||
/* -----SC2 I2C Master GPIO configuration */
|
||||
TIM2_CCER &= 0xFFFFEEEE;
|
||||
SC2_MODE = SC2_MODE_I2C;
|
||||
GPIO_PACFGL &= 0xFFFFF00F;
|
||||
GPIO_PACFGL |= 0x00000DD0;
|
||||
|
||||
SC2_RATELIN = 14; /* generates standard 100kbps or 400kbps */
|
||||
SC2_RATEEXP = 1; /* 3 yields 100kbps; 1 yields 400kbps */
|
||||
SC2_TWICTRL1 = 0; /* start from a clean state */
|
||||
SC2_TWICTRL2 = 0; /* start from a clean state */
|
||||
|
||||
ret = i2c_mems_init();
|
||||
fullscale_state = MEMS_LOW_RANGE;
|
||||
|
||||
/* Add later if really needed */
|
||||
#ifdef ST_DBG
|
||||
if(!ret)
|
||||
I2C_DeInit(MEMS_I2C);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Returns the 3 mems acceleration values related to x,y,z axes
|
||||
* \param mems_data pointer to mems_data_t that will be filled with the values
|
||||
* \return None
|
||||
*/
|
||||
#if 0
|
||||
uint8_t mems_get_value(mems_data_t *mems_data)
|
||||
{
|
||||
uint8_t i;
|
||||
i = i2c_mems_read(mems_data);
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Send I2C frame
|
||||
* \param address destination device address
|
||||
* \param p_buf pointer to data buffer
|
||||
* \param len length of data
|
||||
* \retval 0 frame has not been successfully sent
|
||||
* \retval 1 frame has been successfully sent
|
||||
*/
|
||||
static uint8_t
|
||||
i2c_send_frame(uint8_t address, uint8_t *p_buf, uint8_t len)
|
||||
{
|
||||
uint8_t i, data;
|
||||
|
||||
SC2_TWICTRL1 |= SC_TWISTART; /* send start */
|
||||
WAIT_CMD_FIN();
|
||||
SEND_BYTE(address); /* send the address low byte */
|
||||
WAIT_TX_FIN();
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
halInternalResetWatchDog();
|
||||
data = *(p_buf + i);
|
||||
SEND_BYTE(data);
|
||||
WAIT_TX_FIN();
|
||||
}
|
||||
|
||||
SC2_TWICTRL1 |= SC_TWISTOP;
|
||||
WAIT_CMD_FIN();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Receive I2C frame
|
||||
* \param address slave device address
|
||||
* \param p_buf pointer to data buffer
|
||||
* \param len length of data
|
||||
* \retval 0 frame has not been successfully received
|
||||
* \retval 1 frame has been successfully received
|
||||
*/
|
||||
static uint8_t
|
||||
i2c_receive_frame(uint8_t slave_addr, uint8_t reg_addr, uint8_t *p_buf,
|
||||
uint8_t len)
|
||||
{
|
||||
uint8_t i, addr = reg_addr;
|
||||
|
||||
if(len > 1) {
|
||||
addr += REPETIR;
|
||||
}
|
||||
|
||||
SC2_TWICTRL1 |= SC_TWISTART; /* send start */
|
||||
WAIT_CMD_FIN();
|
||||
|
||||
SEND_BYTE(slave_addr | 0x00); /* send the address low byte */
|
||||
WAIT_TX_FIN();
|
||||
|
||||
SEND_BYTE(addr);
|
||||
WAIT_TX_FIN();
|
||||
|
||||
SC2_TWICTRL1 |= SC_TWISTART; /* send start */
|
||||
WAIT_CMD_FIN();
|
||||
|
||||
SEND_BYTE(slave_addr | 0x01); /* send the address low byte */
|
||||
WAIT_TX_FIN();
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
halInternalResetWatchDog();
|
||||
if(i < (len - 1)) {
|
||||
SC2_TWICTRL2 |= SC_TWIACK; /* ack on receipt of data */
|
||||
} else {
|
||||
SC2_TWICTRL2 &= ~SC_TWIACK; /* don't ack if last one */
|
||||
}
|
||||
SC2_TWICTRL1 |= SC_TWIRECV; /* set to receive */
|
||||
WAIT_RX_FIN();
|
||||
*(p_buf + i) = SC2_DATA; /* receive data */
|
||||
}
|
||||
|
||||
SC2_TWICTRL1 |= SC_TWISTOP; /* send STOP */
|
||||
WAIT_CMD_FIN();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief write a register on the I2C target
|
||||
* \param slave_addr slave device address
|
||||
* \param reg_addr address of the register to be written
|
||||
* \param reg_value value of the register to be written
|
||||
* \retval 0 register has not been successfully written
|
||||
* \retval 1 register has been successfully written
|
||||
*/
|
||||
uint8_t
|
||||
i2c_write_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t reg_value)
|
||||
{
|
||||
uint8_t i2c_buffer[2];
|
||||
|
||||
i2c_buffer[0] = reg_addr;
|
||||
i2c_buffer[1] = reg_value;
|
||||
return i2c_send_frame(slave_addr, i2c_buffer, 2);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief read a register from the I2C target
|
||||
* \param slave_addr slave device address
|
||||
* \param reg_addr address of the register
|
||||
* \param p_buf storage destination for the read data
|
||||
* \retval 0 register has not been successfully read
|
||||
* \retval 1 register has been successfully read
|
||||
*/
|
||||
uint8_t
|
||||
i2c_read_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *p_buf,
|
||||
uint8_t len)
|
||||
{
|
||||
return i2c_receive_frame(slave_addr, reg_addr, p_buf, len);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Init MEMS
|
||||
* \return None
|
||||
* \retval 0 the device has not been successfully initialized
|
||||
* \retval 1 the device has been successfully initialized
|
||||
*/
|
||||
static uint8_t
|
||||
i2c_mems_init(void)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
i += i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, STATUS_REG, 0x00); /* no flag */
|
||||
i += i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, FF_WU_CFG, 0x00); /* all off */
|
||||
i += i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, DD_CFG, 0x00); /* all off */
|
||||
/* i += i2c_write_reg (KLIS3L02DQ_SLAVE_ADDR, CTRL_REG2, (1<<4) | (1<<1) | (1 << 0)); */
|
||||
|
||||
i += i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG2, 0x00);
|
||||
/* i += i2c_write_reg (KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, 0xC7); */
|
||||
i += i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, 0x87);
|
||||
|
||||
if(i != 5) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief turn on the MEMS device
|
||||
* \retval 0 the device has not been successfully set to normal mode
|
||||
* \retval 1 the device has been successfully set to normal mode
|
||||
*/
|
||||
uint8_t
|
||||
mems_on(void)
|
||||
{
|
||||
return i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, 0xC7);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief turn off the MEMS device
|
||||
* \retval 0 the device has not been successfully turned off
|
||||
* \retval 1 the device has been successfully turned off
|
||||
*/
|
||||
uint8_t
|
||||
mems_off(void)
|
||||
{
|
||||
return i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, 0x87);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief set full-scale range of the device
|
||||
* \param range HIGH for high scale selection, LOW for low range.
|
||||
* \retval 0 the device has not been successfully set to full scale mode
|
||||
* \retval 1 the device has been successfully set to full scale mode
|
||||
*/
|
||||
uint8_t
|
||||
mems_set_fullscale(boolean range)
|
||||
{
|
||||
uint8_t i2c_buffer;
|
||||
if (!i2c_read_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, &i2c_buffer, 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(range == MEMS_HIGH_RANGE) {
|
||||
i2c_buffer |= 0x20;
|
||||
} else {
|
||||
i2c_buffer &= ~0x20;
|
||||
}
|
||||
|
||||
if (!i2c_write_reg(KLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, i2c_buffer)) {
|
||||
return 0;
|
||||
}
|
||||
fullscale_state = range;
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Get full-scale range of the device
|
||||
* \retval HIGH high scale selection
|
||||
* \retval LOW low range
|
||||
*/
|
||||
boolean
|
||||
mems_get_fullscale(void)
|
||||
{
|
||||
return fullscale_state;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Returns the 3 mems acceleration values related to x,y,z axes
|
||||
* \param mems_data pointer to mems_data_t that will be filled with the values
|
||||
* \retval 0 acceleration data has not been successfully read
|
||||
* \retval 1 acceleration data has been successfully read
|
||||
*/
|
||||
#if 0
|
||||
static uint8_t
|
||||
i2c_mems_read(mems_data_t *mems_data)
|
||||
{
|
||||
uint8_t i, i2c_buffer[8];
|
||||
|
||||
i = i2c_read_reg (KLIS3L02DQ_SLAVE_ADDR, OUTX_L, i2c_buffer, 8);
|
||||
mems_data->outx_h = i2c_buffer[0];
|
||||
mems_data->outx_l = i2c_buffer[1];
|
||||
mems_data->outy_h = i2c_buffer[2];
|
||||
mems_data->outy_l = i2c_buffer[3];
|
||||
mems_data->outz_h = i2c_buffer[4];
|
||||
mems_data->outz_l = i2c_buffer[5];
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/** @} */
|
@ -1,61 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
* File Name : mems.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V1.0
|
||||
* Date : January 2010
|
||||
* Description : header file for mems driver
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _MEMS_H_
|
||||
#define _MEMS_H_
|
||||
#include "mems-regs.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* Sensitivity values in mg/digit */
|
||||
#define HIGH_RANGE_SENSITIVITY 72
|
||||
#define LOW_RANGE_SENSITIVITY 18
|
||||
|
||||
#define MEMS_LOW_RANGE 0
|
||||
#define MEMS_HIGH_RANGE 1
|
||||
|
||||
/*
|
||||
* Mems data type: three acceleration values each related to a specific
|
||||
* direction.
|
||||
* Watch out: only lower data values (e.g. those terminated by the _l) are
|
||||
* currently used by the device.
|
||||
*/
|
||||
typedef struct mems_data_s {
|
||||
int8_t outx_l;
|
||||
int8_t outx_h;
|
||||
int8_t outy_l;
|
||||
int8_t outy_h;
|
||||
int8_t outz_l;
|
||||
int8_t outz_h;
|
||||
} mems_data_t;
|
||||
|
||||
uint8_t mems_init(void);
|
||||
|
||||
uint8_t mems_on(void);
|
||||
|
||||
uint8_t mems_off(void);
|
||||
|
||||
uint8_t mems_set_fullscale(boolean range);
|
||||
|
||||
boolean mems_get_fullscale(void);
|
||||
|
||||
uint8_t mems_get_value(mems_data_t * mems_data);
|
||||
|
||||
#endif /* _MEMS_H_ */
|
||||
/** @} */
|
@ -1,66 +0,0 @@
|
||||
/**
|
||||
* \addtogroup mb851-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Temperature sensor.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef __TEMPERATURE_SENSOR_H__
|
||||
#define __TEMPERATURE_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
/*
|
||||
* Value returned by temperature_sensor.value() is expressed in units of 0.1 degC.
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
* For the temperature measurement, the ADC extended range mode is needed;
|
||||
* but this is inaccurate due to the high voltage mode bug of the general purpose ADC
|
||||
* (see STM32W108 errata).
|
||||
*
|
||||
* For the temperature measurement, the ADC extended range mode is needed;
|
||||
* but this is inaccurate due to the high voltage mode bug of the general purpose ADC
|
||||
* (see STM32W108 errata).
|
||||
*/
|
||||
extern const struct sensors_sensor temperature_sensor;
|
||||
|
||||
#define TEMPERATURE_SENSOR "Temperature"
|
||||
|
||||
#endif /* __TEMPERATURE_SENSOR_H__ */
|
||||
/** @} */
|
@ -1,96 +0,0 @@
|
||||
/**
|
||||
* \defgroup mb851-platform The STM32W MB851 platform.
|
||||
*
|
||||
* The STM32W MB851 platform.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* platform-conf.h for MB851.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PLATFORM_CONF_H__
|
||||
#define __PLATFORM_CONF_H__
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h> /* For memcpm() */
|
||||
|
||||
/* Platform-dependent definitions */
|
||||
#define CC_CONF_REGISTER_ARGS 0
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
#define CC_CONF_FASTCALL
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
typedef unsigned long clock_time_t;
|
||||
typedef unsigned long rtimer_clock_t;
|
||||
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
||||
/* rtimer_second = 11719 */
|
||||
#define RT_CONF_RESOLUTION 2
|
||||
|
||||
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
||||
#define WITH_SERIAL_LINE_INPUT 1
|
||||
|
||||
/* A trick to resolve a compilation error with IAR. */
|
||||
#ifdef __ICCARM__
|
||||
#define UIP_CONF_DS6_AADDR_NBU 1
|
||||
#endif /* __ICCARM__ */
|
||||
|
||||
/* LEDs ports MB851 */
|
||||
#define LEDS_CONF_RED_PIN 0
|
||||
#define LEDS_CONF_GREEN_PIN 5
|
||||
#define LEDS_CONF_PORT PORTA
|
||||
#define LEDS_CONF_RED (1<<LEDS_CONF_RED_PIN)
|
||||
#define LEDS_CONF_GREEN (1<<LEDS_CONF_GREEN_PIN)
|
||||
|
||||
#define UIP_ARCH_ADD32 1
|
||||
#define UIP_ARCH_CHKSUM 0
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
|
||||
#endif /* __PLATFORM_CONF_H__ */
|
||||
/** @} */
|
@ -1,13 +1,12 @@
|
||||
ARCH= irq.c sensors.c acc-sensor.c button-sensor.c temperature-sensor.c mems.c contact-sensor.c
|
||||
|
||||
|
||||
ARCH= irq.c sensors.c acc-sensor.c button-sensor.c temperature-sensor.c mems.c
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev
|
||||
ifndef CONTIKI_TARGET_MAIN
|
||||
CONTIKI_TARGET_MAIN = contiki-main.c led.c button.c board.c board-mbxxx.c
|
||||
CONTIKI_TARGET_MAIN = contiki-main.c board.c
|
||||
endif
|
||||
|
||||
ifeq ($(UIP_CONF_IPV6),1)
|
||||
ifdef UIP_CONF_IPV6
|
||||
CFLAGS += -DWITH_UIP6=1
|
||||
endif
|
||||
|
||||
@ -21,4 +20,3 @@ SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-linux
|
||||
ifeq ($(HOST_OS),Windows)
|
||||
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-windows
|
||||
endif
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
@ -94,3 +99,4 @@ shell_sensors_init(void)
|
||||
shell_register_command(&sensors_command);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
@ -45,3 +50,4 @@
|
||||
void shell_sensors_init(void);
|
||||
|
||||
#endif /* __SHELL_SENSORS_H__ */
|
||||
/** @} */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user