From fcb09d5d3090307e7731be978072aff34df35b78 Mon Sep 17 00:00:00 2001 From: stefano pascali Date: Thu, 11 Jul 2013 17:50:15 +0200 Subject: [PATCH 1/3] Fixed mbxxx platform --- cpu/stm32w108/Makefile.stm32w108 | 28 +- cpu/stm32w108/README.txt | 22 + cpu/stm32w108/gnu-stm32w108.ld | 177 ++++++ cpu/stm32w108/gnu-stm32w108CC.ld | 16 + cpu/stm32w108/gnu-stm32w108xB.ld | 17 + cpu/stm32w108/gnu.ld | 1 - cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s | 149 +++++ examples/mb851/acc-sensor/Makefile.target | 1 - examples/mb851/button/Makefile.target | 1 - examples/mb851/coffee-test/Makefile.target | 1 - examples/mb851/mb851-shell/Makefile.target | 1 - examples/mb851/mb851-websense/Makefile.target | 1 - examples/mb851/shell-exec/README.md | 49 -- examples/mb851/telnet-server/Makefile.target | 1 - examples/mb851/temperature/Makefile.target | 1 - examples/mb851/udp-ipv6-sleep/Makefile.target | 1 - examples/mb851/udp-ipv6-sleep/README.md | 10 - examples/mb851/webserver-ajax/Makefile.target | 1 - examples/mb851/webserver-ajax/README.md | 37 -- examples/{mb851 => mbxxx}/acc-sensor/Makefile | 0 examples/mbxxx/acc-sensor/Makefile.target | 1 + .../{mb851 => mbxxx}/acc-sensor/acc-example.c | 5 +- examples/{mb851 => mbxxx}/button/Makefile | 0 examples/mbxxx/button/Makefile.target | 1 + .../{mb851 => mbxxx}/button/test-button.c | 4 +- .../{mb851 => mbxxx}/coffee-test/Makefile | 0 examples/mbxxx/coffee-test/Makefile.target | 1 + .../coffee-test/coffee-test.c | 4 +- .../mbxxx-shell}/Makefile | 4 +- examples/mbxxx/mbxxx-shell/Makefile.target | 1 + .../mbxxx-shell/mbxxx-shell.c} | 8 +- .../mbxxx-websense}/Makefile | 8 +- examples/mbxxx/mbxxx-websense/Makefile.target | 1 + .../mbxxx-websense}/README.md | 3 + .../mbxxx-websense/mbxxx-websense.c} | 0 .../mbxxx-websense}/project-conf.h | 0 examples/{mb851 => mbxxx}/shell-exec/Makefile | 2 +- examples/mbxxx/shell-exec/README.md | 47 ++ .../{mb851 => mbxxx}/shell-exec/hello-world.c | 0 .../shell-exec/shell-exec-test.c | 0 .../{mb851 => mbxxx}/telnet-server/Makefile | 2 +- examples/mbxxx/telnet-server/Makefile.target | 1 + .../telnet-server/telnet-server.c | 0 .../{mb851 => mbxxx}/temperature/Makefile | 0 examples/mbxxx/temperature/Makefile.target | 1 + .../temperature/temp-sensor.c | 9 +- .../{mb851 => mbxxx}/udp-ipv6-sleep/Makefile | 0 examples/mbxxx/udp-ipv6-sleep/Makefile.target | 1 + examples/mbxxx/udp-ipv6-sleep/README.md | 10 + .../udp-ipv6-sleep/udp-client.c | 5 +- .../udp-ipv6-sleep/udp-server.c | 0 .../{mb851 => mbxxx}/webserver-ajax/Makefile | 2 +- examples/mbxxx/webserver-ajax/Makefile.target | 1 + examples/mbxxx/webserver-ajax/README.md | 12 + .../webserver-ajax/ajax-cgi.c | 0 .../webserver-ajax/httpd-fs.c | 0 .../webserver-ajax/httpd-fs/404.html | 0 .../webserver-ajax/httpd-fs/footer.html | 0 .../webserver-ajax/httpd-fs/header.html | 0 .../webserver-ajax/httpd-fs/index.html | 0 .../webserver-ajax/httpd-fs/neighbors.shtml | 0 .../webserver-ajax/httpd-fs/sensordata.shtml | 0 .../webserver-ajax/httpd-fs/sensors.shtml | 0 .../webserver-ajax/httpd-fs/spin.gif | Bin .../webserver-ajax/httpd-fsdata.c | 0 .../webserver-ajax/mbxxx-webserver.c} | 2 +- examples/mbxxx/webserver-ajax/symbols.c | 4 + examples/mbxxx/webserver-ajax/symbols.h | 3 + .../webserver-ajax/webserver-ajax-conf.h | 0 platform/mb851/Makefile.mb851 | 21 - platform/mb851/apps/shell-sensors.c | 93 --- platform/mb851/apps/shell-sensors.h | 52 -- platform/mb851/board-mb851.c | 174 ----- platform/mb851/contiki-conf.h | 172 ----- platform/mb851/contiki-main.c | 332 ---------- platform/mb851/dev/acc-sensor.c | 137 ---- platform/mb851/dev/acc-sensor.h | 77 --- platform/mb851/dev/button-sensor.c | 186 ------ platform/mb851/dev/mems-regs.h | 123 ---- platform/mb851/dev/mems.c | 348 ---------- platform/mb851/dev/mems.h | 61 -- platform/mb851/dev/temperature-sensor.h | 66 -- platform/mb851/platform-conf.h | 96 --- platform/mbxxx/Makefile.mbxxx | 8 +- platform/mbxxx/apps/shell-sensors.c | 10 +- platform/mbxxx/apps/shell-sensors.h | 6 + platform/mbxxx/board-mbxxx.c | 54 -- platform/mbxxx/board.c | 596 ++++++++++++++++++ platform/mbxxx/board.h | 354 +++++++++++ platform/mbxxx/clock.c | 191 ------ platform/mbxxx/contiki-conf.h | 134 ++-- platform/{mb851 => mbxxx}/contiki-init-net.c | 90 +-- platform/{mb851 => mbxxx}/contiki-init-net.h | 13 +- platform/mbxxx/contiki-main.c | 177 ++++-- platform/mbxxx/dev/acc-sensor.c | 20 +- platform/mbxxx/dev/acc-sensor.h | 6 + platform/mbxxx/dev/button-sensor.c | 112 ++-- .../dev/contact-sensor.c} | 118 ++-- .../dev/irq.c => mbxxx/dev/contact-sensor.h} | 27 +- platform/mbxxx/dev/irq.c | 6 + platform/mbxxx/dev/leds-arch.c | 109 ---- platform/mbxxx/dev/mems.c | 52 +- platform/mbxxx/dev/mems.h | 28 +- platform/mbxxx/dev/mems_regs.h | 10 +- platform/mbxxx/dev/temperature-sensor.c | 30 +- platform/mbxxx/dev/temperature-sensor.h | 6 + platform/mbxxx/platform-conf.h | 25 +- 107 files changed, 2018 insertions(+), 2760 deletions(-) create mode 100644 cpu/stm32w108/README.txt create mode 100644 cpu/stm32w108/gnu-stm32w108.ld create mode 100644 cpu/stm32w108/gnu-stm32w108CC.ld create mode 100644 cpu/stm32w108/gnu-stm32w108xB.ld create mode 100644 cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s delete mode 100644 examples/mb851/acc-sensor/Makefile.target delete mode 100644 examples/mb851/button/Makefile.target delete mode 100644 examples/mb851/coffee-test/Makefile.target delete mode 100644 examples/mb851/mb851-shell/Makefile.target delete mode 100644 examples/mb851/mb851-websense/Makefile.target delete mode 100644 examples/mb851/shell-exec/README.md delete mode 100644 examples/mb851/telnet-server/Makefile.target delete mode 100644 examples/mb851/temperature/Makefile.target delete mode 100644 examples/mb851/udp-ipv6-sleep/Makefile.target delete mode 100644 examples/mb851/udp-ipv6-sleep/README.md delete mode 100644 examples/mb851/webserver-ajax/Makefile.target delete mode 100644 examples/mb851/webserver-ajax/README.md rename examples/{mb851 => mbxxx}/acc-sensor/Makefile (100%) create mode 100644 examples/mbxxx/acc-sensor/Makefile.target rename examples/{mb851 => mbxxx}/acc-sensor/acc-example.c (98%) rename examples/{mb851 => mbxxx}/button/Makefile (100%) create mode 100644 examples/mbxxx/button/Makefile.target rename examples/{mb851 => mbxxx}/button/test-button.c (97%) rename examples/{mb851 => mbxxx}/coffee-test/Makefile (100%) create mode 100644 examples/mbxxx/coffee-test/Makefile.target rename examples/{mb851 => mbxxx}/coffee-test/coffee-test.c (97%) rename examples/{mb851/mb851-shell => mbxxx/mbxxx-shell}/Makefile (65%) create mode 100644 examples/mbxxx/mbxxx-shell/Makefile.target rename examples/{mb851/mb851-shell/mb851-shell.c => mbxxx/mbxxx-shell/mbxxx-shell.c} (92%) rename examples/{mb851/mb851-websense => mbxxx/mbxxx-websense}/Makefile (68%) create mode 100644 examples/mbxxx/mbxxx-websense/Makefile.target rename examples/{mb851/mb851-websense => mbxxx/mbxxx-websense}/README.md (56%) rename examples/{mb851/mb851-websense/mb851-websense.c => mbxxx/mbxxx-websense/mbxxx-websense.c} (100%) rename examples/{mb851/mb851-websense => mbxxx/mbxxx-websense}/project-conf.h (100%) rename examples/{mb851 => mbxxx}/shell-exec/Makefile (98%) create mode 100644 examples/mbxxx/shell-exec/README.md rename examples/{mb851 => mbxxx}/shell-exec/hello-world.c (100%) rename examples/{mb851 => mbxxx}/shell-exec/shell-exec-test.c (100%) rename examples/{mb851 => mbxxx}/telnet-server/Makefile (80%) create mode 100644 examples/mbxxx/telnet-server/Makefile.target rename examples/{mb851 => mbxxx}/telnet-server/telnet-server.c (100%) rename examples/{mb851 => mbxxx}/temperature/Makefile (100%) create mode 100644 examples/mbxxx/temperature/Makefile.target rename examples/{mb851 => mbxxx}/temperature/temp-sensor.c (96%) rename examples/{mb851 => mbxxx}/udp-ipv6-sleep/Makefile (100%) create mode 100644 examples/mbxxx/udp-ipv6-sleep/Makefile.target create mode 100644 examples/mbxxx/udp-ipv6-sleep/README.md rename examples/{mb851 => mbxxx}/udp-ipv6-sleep/udp-client.c (98%) rename examples/{mb851 => mbxxx}/udp-ipv6-sleep/udp-server.c (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/Makefile (90%) create mode 100644 examples/mbxxx/webserver-ajax/Makefile.target create mode 100644 examples/mbxxx/webserver-ajax/README.md rename examples/{mb851 => mbxxx}/webserver-ajax/ajax-cgi.c (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs.c (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/404.html (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/footer.html (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/header.html (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/index.html (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/neighbors.shtml (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/sensordata.shtml (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/sensors.shtml (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fs/spin.gif (100%) rename examples/{mb851 => mbxxx}/webserver-ajax/httpd-fsdata.c (100%) rename examples/{mb851/webserver-ajax/mb851-webserver.c => mbxxx/webserver-ajax/mbxxx-webserver.c} (98%) create mode 100644 examples/mbxxx/webserver-ajax/symbols.c create mode 100644 examples/mbxxx/webserver-ajax/symbols.h rename examples/{mb851 => mbxxx}/webserver-ajax/webserver-ajax-conf.h (100%) delete mode 100644 platform/mb851/Makefile.mb851 delete mode 100644 platform/mb851/apps/shell-sensors.c delete mode 100644 platform/mb851/apps/shell-sensors.h delete mode 100644 platform/mb851/board-mb851.c delete mode 100644 platform/mb851/contiki-conf.h delete mode 100644 platform/mb851/contiki-main.c delete mode 100644 platform/mb851/dev/acc-sensor.c delete mode 100644 platform/mb851/dev/acc-sensor.h delete mode 100644 platform/mb851/dev/button-sensor.c delete mode 100644 platform/mb851/dev/mems-regs.h delete mode 100644 platform/mb851/dev/mems.c delete mode 100644 platform/mb851/dev/mems.h delete mode 100644 platform/mb851/dev/temperature-sensor.h delete mode 100644 platform/mb851/platform-conf.h delete mode 100644 platform/mbxxx/board-mbxxx.c create mode 100644 platform/mbxxx/board.c create mode 100644 platform/mbxxx/board.h delete mode 100644 platform/mbxxx/clock.c rename platform/{mb851 => mbxxx}/contiki-init-net.c (80%) rename platform/{mb851 => mbxxx}/contiki-init-net.h (82%) rename platform/{mb851/dev/temperature-sensor.c => mbxxx/dev/contact-sensor.c} (56%) rename platform/{mb851/dev/irq.c => mbxxx/dev/contact-sensor.h} (80%) delete mode 100644 platform/mbxxx/dev/leds-arch.c diff --git a/cpu/stm32w108/Makefile.stm32w108 b/cpu/stm32w108/Makefile.stm32w108 index 2b4c1b3b8..16bfbb728 100644 --- a/cpu/stm32w108/Makefile.stm32w108 +++ b/cpu/stm32w108/Makefile.stm32w108 @@ -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 ($(CPUREV), CC) + LD-EXT=-stm32w108CC + ${warning "using stm32w108CC specific ld file"} +else ifeq ($(CPUREV), xB) + LD-EXT=-stm32w108xB + ${warning "using stm32w108xB specific ld file"} +else + ${error "No 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;}' diff --git a/cpu/stm32w108/README.txt b/cpu/stm32w108/README.txt new file mode 100644 index 000000000..71c989222 --- /dev/null +++ b/cpu/stm32w108/README.txt @@ -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 CPUREV values are CC or xB + +Examples: + +The MB851RevD board has a cpu with code +stm32w 108CCU7 +so CC is your CPUREV value and the command is +make TARGET=mbxxx CPUREV=CC ... + +or + +The MB851RevC board has a cpu with code +stm32w 108CBU6 +so xB is your CPUREV value. +make TARGET=mbxxx CPUREV=xB ... + + +NOTE: if the last word is B you need to use x as wildcard. diff --git a/cpu/stm32w108/gnu-stm32w108.ld b/cpu/stm32w108/gnu-stm32w108.ld new file mode 100644 index 000000000..fc9059ee8 --- /dev/null +++ b/cpu/stm32w108/gnu-stm32w108.ld @@ -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; + diff --git a/cpu/stm32w108/gnu-stm32w108CC.ld b/cpu/stm32w108/gnu-stm32w108CC.ld new file mode 100644 index 000000000..4ef8833eb --- /dev/null +++ b/cpu/stm32w108/gnu-stm32w108CC.ld @@ -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" diff --git a/cpu/stm32w108/gnu-stm32w108xB.ld b/cpu/stm32w108/gnu-stm32w108xB.ld new file mode 100644 index 000000000..e6b80e65a --- /dev/null +++ b/cpu/stm32w108/gnu-stm32w108xB.ld @@ -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" + diff --git a/cpu/stm32w108/gnu.ld b/cpu/stm32w108/gnu.ld index 3845d0899..801cc033b 100644 --- a/cpu/stm32w108/gnu.ld +++ b/cpu/stm32w108/gnu.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 ) ; diff --git a/cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s b/cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s new file mode 100644 index 000000000..e28e353b7 --- /dev/null +++ b/cpu/stm32w108/hal/micro/cortexm3/cstartup-m.s @@ -0,0 +1,149 @@ +/************************************************** + * + * Part one of the system initialization code, contains low-level + * initialization, plain thumb variant. + * + + * Customized by St Corporation for STM32W + * + * + **************************************************/ + +; +; 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 diff --git a/examples/mb851/acc-sensor/Makefile.target b/examples/mb851/acc-sensor/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/acc-sensor/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/button/Makefile.target b/examples/mb851/button/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/button/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/coffee-test/Makefile.target b/examples/mb851/coffee-test/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/coffee-test/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/mb851-shell/Makefile.target b/examples/mb851/mb851-shell/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/mb851-shell/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/mb851-websense/Makefile.target b/examples/mb851/mb851-websense/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/mb851-websense/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/shell-exec/README.md b/examples/mb851/shell-exec/README.md deleted file mode 100644 index c2c5e925c..000000000 --- a/examples/mb851/shell-exec/README.md +++ /dev/null @@ -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. diff --git a/examples/mb851/telnet-server/Makefile.target b/examples/mb851/telnet-server/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/telnet-server/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/temperature/Makefile.target b/examples/mb851/temperature/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/temperature/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/udp-ipv6-sleep/Makefile.target b/examples/mb851/udp-ipv6-sleep/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/udp-ipv6-sleep/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/udp-ipv6-sleep/README.md b/examples/mb851/udp-ipv6-sleep/README.md deleted file mode 100644 index c8ad05d31..000000000 --- a/examples/mb851/udp-ipv6-sleep/README.md +++ /dev/null @@ -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. diff --git a/examples/mb851/webserver-ajax/Makefile.target b/examples/mb851/webserver-ajax/Makefile.target deleted file mode 100644 index 3c56fcd9a..000000000 --- a/examples/mb851/webserver-ajax/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = mb851 diff --git a/examples/mb851/webserver-ajax/README.md b/examples/mb851/webserver-ajax/README.md deleted file mode 100644 index 3dfc5a998..000000000 --- a/examples/mb851/webserver-ajax/README.md +++ /dev/null @@ -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): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CurrPower
ENERGEST_TYPE_CPU7.5 mA18 mW
ENERGEST_TYPE_LPM3 mA7.2 mW
ENERGEST_TYPE_TRANSMIT21 mA50.4 mW
ENERGEST_TYPE_LISTEN19 mA45.6 mW
diff --git a/examples/mb851/acc-sensor/Makefile b/examples/mbxxx/acc-sensor/Makefile similarity index 100% rename from examples/mb851/acc-sensor/Makefile rename to examples/mbxxx/acc-sensor/Makefile diff --git a/examples/mbxxx/acc-sensor/Makefile.target b/examples/mbxxx/acc-sensor/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/acc-sensor/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/acc-sensor/acc-example.c b/examples/mbxxx/acc-sensor/acc-example.c similarity index 98% rename from examples/mb851/acc-sensor/acc-example.c rename to examples/mbxxx/acc-sensor/acc-example.c index 21e197381..84d2fd117 100644 --- a/examples/mb851/acc-sensor/acc-example.c +++ b/examples/mbxxx/acc-sensor/acc-example.c @@ -41,6 +41,7 @@ #include "contiki.h" #include "dev/acc-sensor.h" +#include "board.h" #include /* 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. @@ -63,7 +64,7 @@ PROCESS_THREAD(acc_process, ev, data) // Enable High Pass Filter. //acc_sensor.configure(ACC_HPF, ACC_1HZ); - + while(1) { etimer_set(&etimer, CLOCK_SECOND/2); diff --git a/examples/mb851/button/Makefile b/examples/mbxxx/button/Makefile similarity index 100% rename from examples/mb851/button/Makefile rename to examples/mbxxx/button/Makefile diff --git a/examples/mbxxx/button/Makefile.target b/examples/mbxxx/button/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/button/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/button/test-button.c b/examples/mbxxx/button/test-button.c similarity index 97% rename from examples/mb851/button/test-button.c rename to examples/mbxxx/button/test-button.c index e427ab2ff..a116b2edc 100644 --- a/examples/mb851/button/test-button.c +++ b/examples/mbxxx/button/test-button.c @@ -42,6 +42,8 @@ #include "dev/button-sensor.h" #include "dev/leds.h" #include +#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) { diff --git a/examples/mb851/coffee-test/Makefile b/examples/mbxxx/coffee-test/Makefile similarity index 100% rename from examples/mb851/coffee-test/Makefile rename to examples/mbxxx/coffee-test/Makefile diff --git a/examples/mbxxx/coffee-test/Makefile.target b/examples/mbxxx/coffee-test/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/coffee-test/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/coffee-test/coffee-test.c b/examples/mbxxx/coffee-test/coffee-test.c similarity index 97% rename from examples/mb851/coffee-test/coffee-test.c rename to examples/mbxxx/coffee-test/coffee-test.c index 49d0823a3..860cf7c93 100644 --- a/examples/mb851/coffee-test/coffee-test.c +++ b/examples/mbxxx/coffee-test/coffee-test.c @@ -40,6 +40,7 @@ #include "contiki.h" #include "cfs-coffee-arch.h" #include "cfs-coffee.h" +#include "board.h" #include @@ -50,7 +51,8 @@ AUTOSTART_PROCESSES(&coffee_test_process); PROCESS_THREAD(coffee_test_process, ev, data) { PROCESS_BEGIN(); - + + boardPrintStringDescription(); printf("Testing coffee...\n"); cfs_coffee_format(); diff --git a/examples/mb851/mb851-shell/Makefile b/examples/mbxxx/mbxxx-shell/Makefile similarity index 65% rename from examples/mb851/mb851-shell/Makefile rename to examples/mbxxx/mbxxx-shell/Makefile index 4c25d524b..08d2e6541 100644 --- a/examples/mb851/mb851-shell/Makefile +++ b/examples/mbxxx/mbxxx-shell/Makefile @@ -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 diff --git a/examples/mbxxx/mbxxx-shell/Makefile.target b/examples/mbxxx/mbxxx-shell/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/mbxxx-shell/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/mb851-shell/mb851-shell.c b/examples/mbxxx/mbxxx-shell/mbxxx-shell.c similarity index 92% rename from examples/mb851/mb851-shell/mb851-shell.c rename to examples/mbxxx/mbxxx-shell/mbxxx-shell.c index 26a1c8ba4..729530afa 100644 --- a/examples/mb851/mb851-shell/mb851-shell.c +++ b/examples/mbxxx/mbxxx-shell/mbxxx-shell.c @@ -32,7 +32,7 @@ /** * \file - * MB851-specific Contiki shell + * mbxxx-specific Contiki shell * \author * Salvatore Pitrulli * @@ -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(); diff --git a/examples/mb851/mb851-websense/Makefile b/examples/mbxxx/mbxxx-websense/Makefile similarity index 68% rename from examples/mb851/mb851-websense/Makefile rename to examples/mbxxx/mbxxx-websense/Makefile index d65c6556a..f59f6251f 100644 --- a/examples/mb851/mb851-websense/Makefile +++ b/examples/mbxxx/mbxxx-websense/Makefile @@ -1,4 +1,4 @@ -all: mb851-websense +all: mbxxx-websense CONTIKI=../../.. @@ -14,11 +14,11 @@ PROJECT_SOURCEFILES += httpd-simple.c include $(CONTIKI)/Makefile.include -$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c +$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) -connect-router: $(CONTIKI)/tools/tunslip6 +connect-router: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64 -connect-router-cooja: $(CONTIKI)/tools/tunslip6 +connect-router-cooja: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64 diff --git a/examples/mbxxx/mbxxx-websense/Makefile.target b/examples/mbxxx/mbxxx-websense/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/mbxxx-websense/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/mb851-websense/README.md b/examples/mbxxx/mbxxx-websense/README.md similarity index 56% rename from examples/mb851/mb851-websense/README.md rename to examples/mbxxx/mbxxx-websense/README.md index ce46a040a..4590eab04 100644 --- a/examples/mb851/mb851-websense/README.md +++ b/examples/mbxxx/mbxxx-websense/README.md @@ -1 +1,4 @@ +webserver IPv6 +============== + See sky-websense example for more info. diff --git a/examples/mb851/mb851-websense/mb851-websense.c b/examples/mbxxx/mbxxx-websense/mbxxx-websense.c similarity index 100% rename from examples/mb851/mb851-websense/mb851-websense.c rename to examples/mbxxx/mbxxx-websense/mbxxx-websense.c diff --git a/examples/mb851/mb851-websense/project-conf.h b/examples/mbxxx/mbxxx-websense/project-conf.h similarity index 100% rename from examples/mb851/mb851-websense/project-conf.h rename to examples/mbxxx/mbxxx-websense/project-conf.h diff --git a/examples/mb851/shell-exec/Makefile b/examples/mbxxx/shell-exec/Makefile similarity index 98% rename from examples/mb851/shell-exec/Makefile rename to examples/mbxxx/shell-exec/Makefile index c4371dbef..763e2e003 100644 --- a/examples/mb851/shell-exec/Makefile +++ b/examples/mbxxx/shell-exec/Makefile @@ -1,7 +1,7 @@ CONTIKI_PROJECT = shell-exec-test all: $(CONTIKI_PROJECT) -TARGET=mb851 +TARGET=mbxxx COFFEE=1 ELF_LOADER=1 diff --git a/examples/mbxxx/shell-exec/README.md b/examples/mbxxx/shell-exec/README.md new file mode 100644 index 000000000..a860591f8 --- /dev/null +++ b/examples/mbxxx/shell-exec/README.md @@ -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. + diff --git a/examples/mb851/shell-exec/hello-world.c b/examples/mbxxx/shell-exec/hello-world.c similarity index 100% rename from examples/mb851/shell-exec/hello-world.c rename to examples/mbxxx/shell-exec/hello-world.c diff --git a/examples/mb851/shell-exec/shell-exec-test.c b/examples/mbxxx/shell-exec/shell-exec-test.c similarity index 100% rename from examples/mb851/shell-exec/shell-exec-test.c rename to examples/mbxxx/shell-exec/shell-exec-test.c diff --git a/examples/mb851/telnet-server/Makefile b/examples/mbxxx/telnet-server/Makefile similarity index 80% rename from examples/mb851/telnet-server/Makefile rename to examples/mbxxx/telnet-server/Makefile index 0ec33a0a9..122054910 100644 --- a/examples/mb851/telnet-server/Makefile +++ b/examples/mbxxx/telnet-server/Makefile @@ -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 diff --git a/examples/mbxxx/telnet-server/Makefile.target b/examples/mbxxx/telnet-server/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/telnet-server/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/telnet-server/telnet-server.c b/examples/mbxxx/telnet-server/telnet-server.c similarity index 100% rename from examples/mb851/telnet-server/telnet-server.c rename to examples/mbxxx/telnet-server/telnet-server.c diff --git a/examples/mb851/temperature/Makefile b/examples/mbxxx/temperature/Makefile similarity index 100% rename from examples/mb851/temperature/Makefile rename to examples/mbxxx/temperature/Makefile diff --git a/examples/mbxxx/temperature/Makefile.target b/examples/mbxxx/temperature/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/temperature/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mb851/temperature/temp-sensor.c b/examples/mbxxx/temperature/temp-sensor.c similarity index 96% rename from examples/mb851/temperature/temp-sensor.c rename to examples/mbxxx/temperature/temp-sensor.c index 05cf68b0f..a62f63232 100644 --- a/examples/mb851/temperature/temp-sensor.c +++ b/examples/mbxxx/temperature/temp-sensor.c @@ -42,6 +42,7 @@ #include "contiki.h" #include "dev/temperature-sensor.h" +#include "board.h" #include /* For printf() */ /*---------------------------------------------------------------------------*/ @@ -53,9 +54,10 @@ PROCESS_THREAD(temp_process, ev, data) static struct etimer etimer; PROCESS_BEGIN(); - - printf("Starting measuring temperature\r\n"); - + + boardPrintStringDescription(); + printf("Starting measuring temperature\r\n"); + while(1) { etimer_set(&etimer, CLOCK_SECOND); @@ -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); - } diff --git a/examples/mb851/udp-ipv6-sleep/Makefile b/examples/mbxxx/udp-ipv6-sleep/Makefile similarity index 100% rename from examples/mb851/udp-ipv6-sleep/Makefile rename to examples/mbxxx/udp-ipv6-sleep/Makefile diff --git a/examples/mbxxx/udp-ipv6-sleep/Makefile.target b/examples/mbxxx/udp-ipv6-sleep/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/udp-ipv6-sleep/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mbxxx/udp-ipv6-sleep/README.md b/examples/mbxxx/udp-ipv6-sleep/README.md new file mode 100644 index 000000000..f0968460f --- /dev/null +++ b/examples/mbxxx/udp-ipv6-sleep/README.md @@ -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. diff --git a/examples/mb851/udp-ipv6-sleep/udp-client.c b/examples/mbxxx/udp-ipv6-sleep/udp-client.c similarity index 98% rename from examples/mb851/udp-ipv6-sleep/udp-client.c rename to examples/mbxxx/udp-ipv6-sleep/udp-client.c index 73518dadb..f19e36c7c 100644 --- a/examples/mb851/udp-ipv6-sleep/udp-client.c +++ b/examples/mbxxx/udp-ipv6-sleep/udp-client.c @@ -33,6 +33,7 @@ #include "sleep.h" #include "board-sensors.h" +#include "board.h" #include @@ -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)) { diff --git a/examples/mb851/udp-ipv6-sleep/udp-server.c b/examples/mbxxx/udp-ipv6-sleep/udp-server.c similarity index 100% rename from examples/mb851/udp-ipv6-sleep/udp-server.c rename to examples/mbxxx/udp-ipv6-sleep/udp-server.c diff --git a/examples/mb851/webserver-ajax/Makefile b/examples/mbxxx/webserver-ajax/Makefile similarity index 90% rename from examples/mb851/webserver-ajax/Makefile rename to examples/mbxxx/webserver-ajax/Makefile index fb5e5ab08..06962bae8 100644 --- a/examples/mb851/webserver-ajax/Makefile +++ b/examples/mbxxx/webserver-ajax/Makefile @@ -1,4 +1,4 @@ -CONTIKI_PROJECT = mb851-webserver +CONTIKI_PROJECT = mbxxx-webserver all: $(CONTIKI_PROJECT) DEFINES=PROJECT_CONF_H=\"webserver-ajax-conf.h\" diff --git a/examples/mbxxx/webserver-ajax/Makefile.target b/examples/mbxxx/webserver-ajax/Makefile.target new file mode 100644 index 000000000..6658a6c15 --- /dev/null +++ b/examples/mbxxx/webserver-ajax/Makefile.target @@ -0,0 +1 @@ +TARGET = mbxxx diff --git a/examples/mbxxx/webserver-ajax/README.md b/examples/mbxxx/webserver-ajax/README.md new file mode 100644 index 000000000..f09873ead --- /dev/null +++ b/examples/mbxxx/webserver-ajax/README.md @@ -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 diff --git a/examples/mb851/webserver-ajax/ajax-cgi.c b/examples/mbxxx/webserver-ajax/ajax-cgi.c similarity index 100% rename from examples/mb851/webserver-ajax/ajax-cgi.c rename to examples/mbxxx/webserver-ajax/ajax-cgi.c diff --git a/examples/mb851/webserver-ajax/httpd-fs.c b/examples/mbxxx/webserver-ajax/httpd-fs.c similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs.c rename to examples/mbxxx/webserver-ajax/httpd-fs.c diff --git a/examples/mb851/webserver-ajax/httpd-fs/404.html b/examples/mbxxx/webserver-ajax/httpd-fs/404.html similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/404.html rename to examples/mbxxx/webserver-ajax/httpd-fs/404.html diff --git a/examples/mb851/webserver-ajax/httpd-fs/footer.html b/examples/mbxxx/webserver-ajax/httpd-fs/footer.html similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/footer.html rename to examples/mbxxx/webserver-ajax/httpd-fs/footer.html diff --git a/examples/mb851/webserver-ajax/httpd-fs/header.html b/examples/mbxxx/webserver-ajax/httpd-fs/header.html similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/header.html rename to examples/mbxxx/webserver-ajax/httpd-fs/header.html diff --git a/examples/mb851/webserver-ajax/httpd-fs/index.html b/examples/mbxxx/webserver-ajax/httpd-fs/index.html similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/index.html rename to examples/mbxxx/webserver-ajax/httpd-fs/index.html diff --git a/examples/mb851/webserver-ajax/httpd-fs/neighbors.shtml b/examples/mbxxx/webserver-ajax/httpd-fs/neighbors.shtml similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/neighbors.shtml rename to examples/mbxxx/webserver-ajax/httpd-fs/neighbors.shtml diff --git a/examples/mb851/webserver-ajax/httpd-fs/sensordata.shtml b/examples/mbxxx/webserver-ajax/httpd-fs/sensordata.shtml similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/sensordata.shtml rename to examples/mbxxx/webserver-ajax/httpd-fs/sensordata.shtml diff --git a/examples/mb851/webserver-ajax/httpd-fs/sensors.shtml b/examples/mbxxx/webserver-ajax/httpd-fs/sensors.shtml similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/sensors.shtml rename to examples/mbxxx/webserver-ajax/httpd-fs/sensors.shtml diff --git a/examples/mb851/webserver-ajax/httpd-fs/spin.gif b/examples/mbxxx/webserver-ajax/httpd-fs/spin.gif similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fs/spin.gif rename to examples/mbxxx/webserver-ajax/httpd-fs/spin.gif diff --git a/examples/mb851/webserver-ajax/httpd-fsdata.c b/examples/mbxxx/webserver-ajax/httpd-fsdata.c similarity index 100% rename from examples/mb851/webserver-ajax/httpd-fsdata.c rename to examples/mbxxx/webserver-ajax/httpd-fsdata.c diff --git a/examples/mb851/webserver-ajax/mb851-webserver.c b/examples/mbxxx/webserver-ajax/mbxxx-webserver.c similarity index 98% rename from examples/mb851/webserver-ajax/mb851-webserver.c rename to examples/mbxxx/webserver-ajax/mbxxx-webserver.c index 737dbf257..18b2fd085 100644 --- a/examples/mb851/webserver-ajax/mb851-webserver.c +++ b/examples/mbxxx/webserver-ajax/mbxxx-webserver.c @@ -37,7 +37,7 @@ * Adam Dunkels */ /* - * salvopitru: example adapted to MB851. + * salvopitru: example adapted to mbxxx. */ diff --git a/examples/mbxxx/webserver-ajax/symbols.c b/examples/mbxxx/webserver-ajax/symbols.c new file mode 100644 index 000000000..023e490f2 --- /dev/null +++ b/examples/mbxxx/webserver-ajax/symbols.c @@ -0,0 +1,4 @@ +#include "symbols.h" + +const int symbols_nelts = 0; +const struct symbols symbols[] = {{0,0}}; diff --git a/examples/mbxxx/webserver-ajax/symbols.h b/examples/mbxxx/webserver-ajax/symbols.h new file mode 100644 index 000000000..9d384211f --- /dev/null +++ b/examples/mbxxx/webserver-ajax/symbols.h @@ -0,0 +1,3 @@ +#include "loader/symbols.h" + +extern const struct symbols symbols[1]; diff --git a/examples/mb851/webserver-ajax/webserver-ajax-conf.h b/examples/mbxxx/webserver-ajax/webserver-ajax-conf.h similarity index 100% rename from examples/mb851/webserver-ajax/webserver-ajax-conf.h rename to examples/mbxxx/webserver-ajax/webserver-ajax-conf.h diff --git a/platform/mb851/Makefile.mb851 b/platform/mb851/Makefile.mb851 deleted file mode 100644 index 40971e8ab..000000000 --- a/platform/mb851/Makefile.mb851 +++ /dev/null @@ -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 diff --git a/platform/mb851/apps/shell-sensors.c b/platform/mb851/apps/shell-sensors.c deleted file mode 100644 index a0d223838..000000000 --- a/platform/mb851/apps/shell-sensors.c +++ /dev/null @@ -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 - */ - -#include -#include - -#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); -} -/*---------------------------------------------------------------------------*/ -/** @} */ diff --git a/platform/mb851/apps/shell-sensors.h b/platform/mb851/apps/shell-sensors.h deleted file mode 100644 index 08edd2bfb..000000000 --- a/platform/mb851/apps/shell-sensors.h +++ /dev/null @@ -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 - */ - -#ifndef __SHELL_SENSORS_H__ -#define __SHELL_SENSORS_H__ - -#include "shell.h" - -void shell_sensors_init(void); - -#endif /* __SHELL_SENSORS_H__ */ -/** @} */ diff --git a/platform/mb851/board-mb851.c b/platform/mb851/board-mb851.c deleted file mode 100644 index d08640fc9..000000000 --- a/platform/mb851/board-mb851.c +++ /dev/null @@ -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(); } -/*---------------------------------------------------------------------------*/ -/** @} */ diff --git a/platform/mb851/contiki-conf.h b/platform/mb851/contiki-conf.h deleted file mode 100644 index 19245faad..000000000 --- a/platform/mb851/contiki-conf.h +++ /dev/null @@ -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 -* Chi-Anh La -* Simon Duquennoy -*/ - -#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__ */ -/** @} */ diff --git a/platform/mb851/contiki-main.c b/platform/mb851/contiki-main.c deleted file mode 100644 index 9a093263b..000000000 --- a/platform/mb851/contiki-main.c +++ /dev/null @@ -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 -* Chi-Anh La -*/ - -#include PLATFORM_HEADER -#include "hal/error.h" -#include "hal/hal.h" -#include BOARD_HEADER -#include "micro/adc.h" -#include -#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 -#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 -/** @} */ diff --git a/platform/mb851/dev/acc-sensor.c b/platform/mb851/dev/acc-sensor.c deleted file mode 100644 index d10dd52f6..000000000 --- a/platform/mb851/dev/acc-sensor.c +++ /dev/null @@ -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 -*/ - -#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); -/** @} */ diff --git a/platform/mb851/dev/acc-sensor.h b/platform/mb851/dev/acc-sensor.h deleted file mode 100644 index 091403950..000000000 --- a/platform/mb851/dev/acc-sensor.h +++ /dev/null @@ -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 -*/ - -#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__ */ -/** @} */ diff --git a/platform/mb851/dev/button-sensor.c b/platform/mb851/dev/button-sensor.c deleted file mode 100644 index 4ae22b2e0..000000000 --- a/platform/mb851/dev/button-sensor.c +++ /dev/null @@ -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 -*/ - -#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); -/** @} */ diff --git a/platform/mb851/dev/mems-regs.h b/platform/mb851/dev/mems-regs.h deleted file mode 100644 index 198655248..000000000 --- a/platform/mb851/dev/mems-regs.h +++ /dev/null @@ -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 - -/* 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_ */ -/** @} */ diff --git a/platform/mb851/dev/mems.c b/platform/mb851/dev/mems.c deleted file mode 100644 index fe945ea1a..000000000 --- a/platform/mb851/dev/mems.c +++ /dev/null @@ -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 -/*--------------------------------------------------------------------------*/ -/** @} */ diff --git a/platform/mb851/dev/mems.h b/platform/mb851/dev/mems.h deleted file mode 100644 index 2b38384fb..000000000 --- a/platform/mb851/dev/mems.h +++ /dev/null @@ -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 - -/* 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_ */ -/** @} */ diff --git a/platform/mb851/dev/temperature-sensor.h b/platform/mb851/dev/temperature-sensor.h deleted file mode 100644 index af954f76f..000000000 --- a/platform/mb851/dev/temperature-sensor.h +++ /dev/null @@ -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 -*/ - -#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__ */ -/** @} */ diff --git a/platform/mb851/platform-conf.h b/platform/mb851/platform-conf.h deleted file mode 100644 index f211fc82d..000000000 --- a/platform/mb851/platform-conf.h +++ /dev/null @@ -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 -* Chi-Anh La -* Simon Duquennoy -*/ - -#ifndef __PLATFORM_CONF_H__ -#define __PLATFORM_CONF_H__ - -#include PLATFORM_HEADER - -#include -#include /* 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< + * Salvatore Pitrulli */ #include @@ -94,3 +99,4 @@ shell_sensors_init(void) shell_register_command(&sensors_command); } /*---------------------------------------------------------------------------*/ +/** @} */ diff --git a/platform/mbxxx/apps/shell-sensors.h b/platform/mbxxx/apps/shell-sensors.h index 4c4fc8fff..23d50585a 100644 --- a/platform/mbxxx/apps/shell-sensors.h +++ b/platform/mbxxx/apps/shell-sensors.h @@ -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__ */ +/** @} */ diff --git a/platform/mbxxx/board-mbxxx.c b/platform/mbxxx/board-mbxxx.c deleted file mode 100644 index db008df86..000000000 --- a/platform/mbxxx/board-mbxxx.c +++ /dev/null @@ -1,54 +0,0 @@ -/*#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" - -static uint8_t sensors_status; - -#define BUTTON_STATUS_ACTIVE (1 << 0) -#define TEMP_STATUS_ACTIVE (1 << 1) -#define ACC_STATUS_ACTIVE (1 << 2) - -/* 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. */ - -void sensorsPowerDown(){ - - 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); - } -} - -/**/ -void sensorsPowerUp(){ - - 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); - } -} diff --git a/platform/mbxxx/board.c b/platform/mbxxx/board.c new file mode 100644 index 000000000..277a377c5 --- /dev/null +++ b/platform/mbxxx/board.c @@ -0,0 +1,596 @@ +/** + * \addtogroup mbxxx-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. + * + * This file is part of the Contiki OS + * + */ +/*---------------------------------------------------------------------------*/ +/** +* \file +* Software layer to support all the ST kits boards +* +* \brief +* Board file x STM32W108 Kits boards +* +* This file implements a software layer to support all the ST kits boards +* and deal with the difference in leds, buttons and sensors connected +* to the board. This a bit too complex for customer boards adaptation +* and customer can simplify it to adapt it to their hardware environment +* as they normally don't need to have the software running on several boards. +* The boards supported are: +* - MB851 A +* - MB851 B +* - MB851 C +* - MB851 D +* - MB954 A +* - MB954 B +* - MB954 C +* - MB950 A +* - MB951 A +* - IDZ401V1 +*/ +/*---------------------------------------------------------------------------*/ + +#include PLATFORM_HEADER +#include BOARD_HEADER +#ifdef EMBERZNET_HAL +#include "stack/include/ember.h" +#include "stack/include/error.h" +#include "hal/hal.h" +#define PORTA (0 << 3) +#define PORTB (1 << 3) +#define PORTC (2 << 3) +#else +#include "error.h" +#include "hal/hal.h" +#include "hal/micro/cortexm3/mfg-token.h" +#endif +#include + +const LedResourceType LedsMB851A[] = { + { + "D1", /* Green LED */ + PORTB, + 6 + }, + { + "D3", /* Yellow LED */ + PORTB, + 5 + } +}; + +const InfraRedLedResourceType infraRedLedMB851A = { + "D5", /* Infrared LED */ + PORTB, + 4 +}; + +const LedResourceType LedsMB954A[] = { + { + "D1", /* Green LED */ + PORTA, + 5 + }, + { + "D3", /* Yellow LED */ + PORTA, + 0 + } +}; + +const LedResourceType LedsIDZ401V1[] = { + { + "D2", /* Yellow LED */ + PORTA, + 7 + } +}; + + +const ButtonResourceType ButtonsMB851A[] = { + { + "S1", + PORTA, + 7 + } +}; + +const ButtonResourceType ButtonsMB954A[] = { + { + "S1", + PORTB, + 3 + } +}; + +const ButtonResourceType ButtonsMB950A[] = { + { + "S1", + PORTB, + 3 + }, + { + "S2", + PORTA, + 7 + }, + { + "S3", + PORTB, + 7 + }, + { + "S4", + PORTB, + 0 + }, + { + "S5", + PORTB, + 6 + } +}; + +const ButtonResourceType ButtonsMB951A[] = { + { + "S1", + PORTA, + 3 + }, +}; + +const ButtonResourceType ButtonsIDZ401V1[] = { + +}; + + +const TempSensorResourceType stlm20PB7noDiv = { + "STLM20", + PORTB, + 7, + 1, + FALSE +}; + +const TempSensorResourceType stlm20PA4noDiv = { + "STLM20", + PORTA, + 4, + 1, + FALSE +}; + +const TempSensorResourceType stlm20PA4withDiv = { + "STLM20", + PORTA, + 4, + 2, + TRUE +}; + +const MemsResourceType memsSensor = { + "LIS302", + 0 +}; + +const BoardIOType ioMB851A = { + LedsMB851A, + ButtonsMB851A, +}; + +const BoardIOType ioMB954A = { + LedsMB954A, + ButtonsMB954A, +}; + +const BoardIOType ioMB950A = { + LedsMB954A, + ButtonsMB950A, +}; + +const BoardIOType ioMB951A = { + LedsMB954A, + ButtonsMB951A, +}; + +const BoardIOType ioIDZ401V1 = { + LedsIDZ401V1, + ButtonsIDZ401V1, +}; + +const BoardResourcesType MB851A = { + "MB851 A", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_FTDI), + BUTTONS_MB851A, + LEDS_MB851A, + &ioMB851A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PB7noDiv, +}; + +const BoardResourcesType MB851B = { + "MB851 B", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_FTDI), + BUTTONS_MB851B, + LEDS_MB851B, + &ioMB851A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PB7noDiv, +}; + +const BoardResourcesType MB851C = { + "MB851 C", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_STM32F | BOARD_HAS_EEPROM), + BUTTONS_MB851C, + LEDS_MB851C, + &ioMB954A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PA4withDiv, +}; + +const BoardResourcesType MB851D = { + "MB851 D", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_STM32F | BOARD_HAS_EEPROM), + BUTTONS_MB851D, + LEDS_MB851D, + &ioMB954A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PA4withDiv, +}; + +const BoardResourcesType MB954A = { + "MB954 A", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_FTDI | BOARD_HAS_PA), + BUTTONS_MB954A, + LEDS_MB954A, + &ioMB954A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PA4noDiv, +}; + +const BoardResourcesType MB954B = { + "MB954 B", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_STM32F | BOARD_HAS_EEPROM | BOARD_HAS_PA), + BUTTONS_MB954B, + LEDS_MB954B, + &ioMB954A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PA4withDiv, +}; + +const BoardResourcesType MB954C = { + "MB954 C", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_STM32F | BOARD_HAS_EEPROM | BOARD_HAS_PA), + BUTTONS_MB954C, + LEDS_MB954C, + &ioMB954A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PA4noDiv, +}; + +const BoardResourcesType MB950A = { + "MB950 A", + (BOARD_HAS_MEMS | BOARD_HAS_TEMP_SENSOR | BOARD_HAS_STM32F), + BUTTONS_MB950A, + LEDS_MB950A, + &ioMB950A, + &infraRedLedMB851A, + &memsSensor, + &stlm20PA4noDiv, +}; + +const BoardResourcesType MB951A = { + "MB951 A", + (BOARD_HAS_STM32F), + BUTTONS_MB951A, + LEDS_MB951A, + &ioMB951A, + NULL, + NULL, + NULL, +}; + +const BoardResourcesType IDZ401V1 = { + "IDZ401V1", + (BOARD_HAS_STM32F), + BUTTONS_IDZ401V1, + LEDS_IDZ401V1, + &ioIDZ401V1, + NULL, + NULL, + NULL, +}; + +static const BoardResourcesType *boardList [] = { + &MB851A, + &MB851B, + &MB851C, + &MB851D, + &MB954A, + &MB954B, + &MB954C, + &MB950A, + &MB951A, + &IDZ401V1 +}; + +BoardResourcesType const *boardDescription = NULL; + +#define PORT_NAME(x) ((x == PORTA) ? "A": ((x == PORTB) ? "B" : ((x == PORTC) ? "C": "?"))) + +void halBoardInit(void) +{ + char boardName[16]; + int8_t i; + boardDescription = NULL; +#ifdef EMBERZNET_HAL + halCommonGetToken(boardName, TOKEN_MFG_BOARD_NAME); +#else + halCommonGetMfgToken(boardName, TOKEN_MFG_BOARD_NAME); +#endif + + i = 15; + while ((i >= 0) && (boardName[i] == 0xFF)) { + boardName[i] = 0; + i--; + } + + for (i = 0; i < (sizeof(boardList)/4) ; i++) + if (strcmp(boardName, (boardList[i])->name) == 0) { + boardDescription = (BoardResourcesType *) boardList[i]; + break; + } + + if (boardDescription == NULL) { + /* Board type not identified default to MB851A also to support legacy boards */ + boardDescription = (BoardResourcesType *) &IDZ401V1; + } + return; +} + +BoardResourcesType const *halBoardGetDescription(void) +{ + return boardDescription; +} + +void halBoardPowerDown(void) +{ + /* Set everything to input value */ + GPIO_PACFGL = (GPIOCFG_IN <io->buttons; + uint8_t i; + for (i = 0; i < boardDescription->buttons; i++) { + halGpioConfig(PORTx_PIN(buttons[i].gpioPort, buttons[i].gpioPin), GPIOCFG_IN_PUD); + halGpioSet(PORTx_PIN(buttons[i].gpioPort, buttons[i].gpioPin), GPIOOUT_PULLUP); + } + } + + /* Configure GPIO for LEDs */ + { + LedResourceType *leds = (LedResourceType *) boardDescription->io->leds; + uint8_t i; + for (i = 0; i < boardDescription->leds; i++) { + /* LED default off */ + halGpioConfig(PORTx_PIN(leds[i].gpioPort, leds[i].gpioPin), GPIOCFG_OUT); + halGpioSet(PORTx_PIN(leds[i].gpioPort, leds[i].gpioPin), 1); + } + } + + /* Configure GPIO for power amplifier */ + if (boardDescription->flags & BOARD_HAS_PA) { + /* SiGe Ant Sel to output */ + halGpioConfig(PORTB_PIN(5), GPIOCFG_OUT); + halGpioSet(PORTB_PIN(5), 1); + /* SiGe Standby */ + halGpioConfig(PORTB_PIN(6), GPIOCFG_OUT); + halGpioSet(PORTB_PIN(6), 0); + } + +} +void halBoardPowerUp(void) +{ + + /* Set everything to input value */ + GPIO_PACFGL = (GPIOCFG_IN <flags & BOARD_HAS_MEMS) || (boardDescription->flags & BOARD_HAS_EEPROM)) { + halGpioConfig(PORTA_PIN(1), GPIOCFG_OUT_ALT_OD); + halGpioConfig(PORTA_PIN(2), GPIOCFG_OUT_ALT_OD); + } + /* Configure GPIO for ADC access (temp sensor) */ + if (boardDescription->flags & BOARD_HAS_TEMP_SENSOR) { + halGpioConfig(PORTx_PIN(boardDescription->temperatureSensor->gpioPort, + boardDescription->temperatureSensor->gpioPin), + GPIOCFG_ANALOG); + } + /* Configure GPIO for LEDs */ + { + LedResourceType *leds = (LedResourceType *) boardDescription->io->leds; + uint8_t i; + for (i = 0; i < boardDescription->leds; i++) { + /* LED default off */ + halGpioConfig(PORTx_PIN(leds[i].gpioPort, leds[i].gpioPin), GPIOCFG_OUT); + halGpioSet(PORTx_PIN(leds[i].gpioPort, leds[i].gpioPin), 1); + } + } + /* Configure GPIO for BUTTONSs */ + { + ButtonResourceType *buttons = (ButtonResourceType *) boardDescription->io->buttons; + uint8_t i; + for (i = 0; i < boardDescription->buttons; i++) { + halGpioConfig(PORTx_PIN(buttons[i].gpioPort, buttons[i].gpioPin), GPIOCFG_IN_PUD); + halGpioSet(PORTx_PIN(buttons[i].gpioPort, buttons[i].gpioPin), GPIOOUT_PULLUP); + } + } + + /* Configure GPIO for power amplifier */ + if (boardDescription->flags & BOARD_HAS_PA) { + /* SiGe Ant Sel (default ceramic antenna) */ + halGpioConfig(PORTB_PIN(5), GPIOCFG_OUT); + halGpioSet(PORTB_PIN(5), 1); + /* SiGe Standby (default out of standby) */ + halGpioConfig(PORTB_PIN(6), GPIOCFG_OUT); + halGpioSet(PORTB_PIN(6), 1); + /* SiGe LNA (default LNA off )*/ + halGpioConfig(PORTB_PIN(7), GPIOCFG_OUT); + halGpioSet(PORTB_PIN(7), 0); + /* SiGe nTX Active */ + halGpioConfig(PORTC_PIN(5), GPIOCFG_OUT_ALT); + } +} + + +#include +void printLeds (void) +{ + uint8_t i=0; + LedResourceType *leds; + leds = (LedResourceType *) boardDescription->io->leds; + while (i < boardDescription->leds) { + printf ("Led %s (port:%s, bit:%d)\r\n", leds->name, PORT_NAME(leds->gpioPort), leds->gpioPin); + leds++; i++; + } +} + +void printButtons (void) +{ + uint8_t i=0; + ButtonResourceType *buttons; + buttons = (ButtonResourceType *) boardDescription->io->buttons; + while (i < boardDescription->buttons) { + printf ("Button %s (port:%s, bit:%d)\r\n", buttons->name, PORT_NAME(buttons->gpioPort), buttons->gpioPin); + buttons++; i++; + } +} + +void boardPrintStringDescription(void) +{ + + if (boardDescription != NULL) { + printf ("*************************************\r\n"); + printf ("Board name = %s\r\n", boardDescription->name); + printf ("*************************************\r\n"); + printf("Number of leds on the board: %d\n", boardDescription->leds); + printf("Number of buttons on the board: %d\n", boardDescription->buttons); + printLeds(); + printButtons(); + if (boardDescription->mems) { + printf ("MEMS = %s\r\n", boardDescription->mems->name); + } + if (boardDescription->temperatureSensor) { + printf ("Temp sensor = %s, port:%s, pin:%d, div:%d, adcFix:%s\r\n", + boardDescription->temperatureSensor->name, + PORT_NAME(boardDescription->temperatureSensor->gpioPort), + boardDescription->temperatureSensor->gpioPin, + boardDescription->temperatureSensor->div, + boardDescription->temperatureSensor->adcFix ? "Yes" : "No" + ); + } + + printf ("EEProm:%s\r\n", (boardDescription->flags & BOARD_HAS_EEPROM) ? "Yes" : "No"); + printf ("PC i/f:%s\r\n", (boardDescription->flags & BOARD_HAS_FTDI) ? "FTDI" : "STM32F"); + printf ("Power Amplifier:%s\r\n", (boardDescription->flags & BOARD_HAS_PA) ? "Yes" : "No"); + + } +} +/** @} */ diff --git a/platform/mbxxx/board.h b/platform/mbxxx/board.h new file mode 100644 index 000000000..9c83ecd6b --- /dev/null +++ b/platform/mbxxx/board.h @@ -0,0 +1,354 @@ +/** + * \addtogroup mbxxx-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. + * + * This file is part of the Contiki OS + * + */ +/*---------------------------------------------------------------------------*/ +/** +* \file +* Header file x STM32W108 Kits boards abstraction. +* \brief +* Header file x STM32W108 Kits boards abstraction. +* See \ref board for documentation. +* +* +* See hal/micro/cortexm3/stm32w108/board.h for source code. +* +*/ +/*---------------------------------------------------------------------------*/ +#ifndef _BOARD_H_ +#define _BOARD_H_ + +char boardName[16]; + +/** @addtogroup board + * \brief ST board abstraction layer + * + * This header defines API and data structures to handle ST boards with thei associated resources + * on algorithm behavior. + * See hal/micro/cortexm3/stm32w108/board.h for source code. + *@{ + */ + +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB851A 2 +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB851B 2 +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB851C 2 +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB851D 2 + + + +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB954A 2 +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB954B 2 +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB954C 2 + + + +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB950A 2 +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_MB951A 2 + + + +/** + * \brief Define the number of LEDs in the specific board revision + */ +#define LEDS_IDZ401V1 1 + + + +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB851A 1 +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB851B 1 +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB851C 1 +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB851D 1 + + + +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB954A 1 +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB954B 1 +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB954C 1 + + + +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB950A 5 +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_MB951A 1 + + + +/** + * \brief Define the number of user buttons in the specific board revision + */ +#define BUTTONS_IDZ401V1 0 + + + +/** + * \brief Data structure for led description + */ +typedef struct LedResourceStruct { + /** Name of the LED as printed in the board */ + char *name; + /** GPIO port associated with the LED */ + uint8_t gpioPort; + /** GPIO pin associated with the LED */ + uint8_t gpioPin; +} LedResourceType; + +typedef LedResourceType InfraRedLedResourceType; + +/** + * \brief Data structure for button description + */ +typedef struct ButtonResourceStruct { + /** Name of the button as printed in the board */ + char *name; + /** GPIO port associated with the button */ + uint8_t gpioPort; + /** GPIO pin associated with the button */ + uint8_t gpioPin; +} ButtonResourceType; + +/** + * \brief Data structure for MEMS description + */ +typedef struct MemsResourceStruct { + /** Name of the MEMS device */ + char *name; + /** Serial communication port associated with the MEMS */ + uint8_t scPort; +} MemsResourceType; + +/** + * \brief Data structure for temperature sensor description + */ +typedef struct TempSensorResourceStruct { + /** Name of the temperature sensor device */ + char *name; + /** GPIO port associated with the sensor */ + uint8_t gpioPort; + /** GPIO pin associated with the sensor */ + uint8_t gpioPin; + /** Voltage divider network from sensor vout and GPIO */ + uint8_t div; + /** Flag to indicate whether the ADC range extension bug fix is implemented */ + boolean adcFix; +} TempSensorResourceType; + +/** + * \brief Data structure for board user I/O + */ +typedef struct BoardIOStruct { + /** Pointer to LED resources */ + const LedResourceType *leds; + /** Pointer to button resources */ + const ButtonResourceType *buttons; +} BoardIOType; + +/** + * \brief Flag to indicate if MEMS is present + */ +#define BOARD_HAS_MEMS (1 << 0) +/** + * \brief Flag to indicate if temeprature sensor is present + */ +#define BOARD_HAS_TEMP_SENSOR (1 << 1) +/** + * \brief Flag to indicate if external power amplifier is present + */ +#define BOARD_HAS_PA (1 << 2) +/** + * \brief Flag to indicate if EEPROM is present + */ +#define BOARD_HAS_EEPROM (1 << 3) +/** + * \brief Flag to indicate if FTDI is used as PC interface + */ +#define BOARD_HAS_FTDI (1 << 4) +/** + * \brief Flag to indicate if STM32F is used as PC interface + */ +#define BOARD_HAS_STM32F (1 << 5) + +/** + * \brief Data structure describing board features + */ +typedef struct BoardResourcesStruct { + const char *name; + const uint32_t flags; + /** Number of buttons */ + uint8_t buttons; + /** Number of leds */ + uint8_t leds; + /** Board I/O description */ + const BoardIOType *io; + /** Board infrared led description */ + const InfraRedLedResourceType* infraredLed; + /** Board infrared MEMS description */ + const MemsResourceType *mems; + /** Board infrared temeprature sensor description */ + const TempSensorResourceType *temperatureSensor; +} BoardResourcesType; + +extern BoardResourcesType const *boardDescription; + +// Generic definitions +#define GPIO_PxCLR_BASE (GPIO_PACLR_ADDR) +#define GPIO_PxSET_BASE (GPIO_PASET_ADDR) +#define GPIO_PxOUT_BASE (GPIO_PAOUT_ADDR) +#define GPIO_PxIN_BASE (GPIO_PAIN_ADDR) +// Each port is offset from the previous port by the same amount +#define GPIO_Px_OFFSET (GPIO_PBCFGL_ADDR-GPIO_PACFGL_ADDR) + + +/* leds definitions */ +#define LED_D1 PORTx_PIN(boardDescription->io->leds[0].gpioPort, boardDescription->io->leds[0].gpioPin) //PORTB_PIN(6) +#define LED_D3 PORTx_PIN(boardDescription->io->leds[1].gpioPort, boardDescription->io->leds[1].gpioPin) // PORTB_PIN(5) +#define DUMMY_LED 0xff + + +/** Description buttons definition */ +#define BUTTON_Sn(n) (PORTx_PIN(boardDescription->io->buttons[n].gpioPort, boardDescription->io->buttons[n].gpioPin)) +#define BUTTON_Sn_WAKE_SOURCE(n) (1 << ((boardDescription->io->buttons[n].gpioPin) + (8 * (boardDescription->io->buttons[n].gpioPort >> 3)))) +#define BUTTON_INPUT_GPIO(port) *((volatile uint32_t *) (GPIO_PxIN_BASE + GPIO_Px_OFFSET * port)) +#define DUMMY_BUTTON 0xff + +#define BUTTON_S1 (boardDescription->buttons>0 ? BUTTON_Sn(0): DUMMY_BUTTON) +#define BUTTON_S2 (boardDescription->buttons>1 ? BUTTON_Sn(1): DUMMY_BUTTON) +#define BUTTON_S3 (boardDescription->buttons>2 ? BUTTON_Sn(2): DUMMY_BUTTON) +#define BUTTON_S4 (boardDescription->buttons>3 ? BUTTON_Sn(3): DUMMY_BUTTON) +#define BUTTON_S5 (boardDescription->buttons>4 ? BUTTON_Sn(4): DUMMY_BUTTON) + +#define BUTTON_S1_WAKE_SOURCE (boardDescription->buttons>0 ? BUTTON_Sn_WAKE_SOURCE(0): 0) +#define BUTTON_S2_WAKE_SOURCE (boardDescription->buttons>1 ? BUTTON_Sn_WAKE_SOURCE(1): 0) +#define BUTTON_S3_WAKE_SOURCE (boardDescription->buttons>2 ? BUTTON_Sn_WAKE_SOURCE(2): 0) +#define BUTTON_S4_WAKE_SOURCE (boardDescription->buttons>3 ? BUTTON_Sn_WAKE_SOURCE(3): 0) +#define BUTTON_S5_WAKE_SOURCE (boardDescription->buttons>4 ? BUTTON_Sn_WAKE_SOURCE(4): 0) + +/** Description uart definition */ +#define UART_TX PORTB_PIN(1) +#define UART_RX PORTB_PIN(2) +#define UART_RX_WAKE_SOURCE 0x00000400 + +/** Description temperature sensor GPIO */ +#define TEMPERATURE_SENSOR_GPIO PORTx_PIN(boardDescription->temperatureSensor->gpioPort, boardDescription->temperatureSensor->gpioPin) // PORTB_PIN(7) + +/** \brief Return pointer to board description structure + * + * + * @return Pointer to board description structure + */ +BoardResourcesType const *halBoardGetDescription(void); +/** + * \brief Initialize the board description data structure after + * autodetect of the boards based on the CIB Board name field + * content. In case of invalid CIB data it will default to MB851A. + * Customer normally needs to modify this file to adapt it to their specific board. + */ +void halBoardInit(void); +/** + * \brief Perform board specific action to power up the system. + * This code depends on the actual board features and configure + * the stm32w and on board devices for proper operation. + * Customer normally needs to modify this file to adapt it to their specific board. + */ +void halBoardPowerUp(void); +/** + * \brief Perform board specific action to power down the system, usually before going to deep sleep. + * This code depends on the actual board features and configure + * the stm32w and on board devices for minimal power consumption. + * Customer normally needs to modify this file to adapt it to their specific board. + */ +void halBoardPowerDown(void); + + +void boardPrintStringDescription(void); + +#endif /* _BOARD_H_ */ + +/** @} // END addtogroup + */ +/** @} */ diff --git a/platform/mbxxx/clock.c b/platform/mbxxx/clock.c deleted file mode 100644 index 145a6fd07..000000000 --- a/platform/mbxxx/clock.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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. - * - * This file is part of the Contiki OS - * - */ -/*---------------------------------------------------------------------------*/ -/** -* \file -* Clock for STM32W. -* \author -* Salvatore Pitrulli -*/ -/*---------------------------------------------------------------------------*/ - -/* - * File customized for mbxxx platform. It uses systick timer to control button - * status without interrupts, as well as for system clock. - */ - -#include PLATFORM_HEADER -#include "hal/error.h" -#include "hal/hal.h" -#include "dev/stm32w_systick.h" - -#include "sys/clock.h" -#include "sys/etimer.h" -#include "dev/button-sensor.h" -#include "uart1.h" -#include "dev/leds.h" -#include "dev/stm32w-radio.h" - -#define DEBUG DEBUG_NONE -#include "net/uip-debug.h" - -// The value that will be load in the SysTick value register. -#define RELOAD_VALUE 24000-1 // 1 ms with a 24 MHz clock - -static volatile clock_time_t count; -static volatile unsigned long current_seconds = 0; -static unsigned int second_countdown = CLOCK_SECOND; - -/*---------------------------------------------------------------------------*/ -void SysTick_Handler(void) -{ - - count++; - - if(button_sensor.status(SENSORS_READY)){ - button_sensor.value(0); // sensors_changed is called inside this function. - } - - if(etimer_pending()) { - etimer_request_poll(); - } - - if (--second_countdown == 0) { - current_seconds++; - second_countdown = CLOCK_SECOND; - } - -} - -/*---------------------------------------------------------------------------*/ - -void clock_init(void) -{ - - ATOMIC( - - //Counts the number of ticks. - count = 0; - - SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); - SysTick_SetReload(RELOAD_VALUE); - SysTick_ITConfig(ENABLE); - SysTick_CounterCmd(SysTick_Counter_Enable); - - ) -} - -/*---------------------------------------------------------------------------*/ - -clock_time_t clock_time(void) -{ - return count; -} - -/*---------------------------------------------------------------------------*/ -/** - * Delay the CPU for a multiple of TODO - */ -void clock_delay(unsigned int i) -{ - for (; i > 0; i--) { /* Needs fixing XXX */ - unsigned j; - for (j = 50; j > 0; j--) - asm ("nop"); - } -} - -/*---------------------------------------------------------------------------*/ -/** - * Wait for a multiple of 1 ms. - * - */ -void clock_wait(clock_time_t i) -{ - clock_time_t start; - - start = clock_time(); - while(clock_time() - start < (clock_time_t)i); -} -/*---------------------------------------------------------------------------*/ - -unsigned long clock_seconds(void) -{ - return current_seconds; -} - -void sleep_seconds(int seconds) -{ - int32u quarter_seconds = seconds * 4; - uint8_t radio_on; - - - halPowerDown(); - radio_on = stm32w_radio_is_on(); - stm32w_radio_driver.off(); - - halSleepForQsWithOptions(&quarter_seconds, 0); - - - ATOMIC( - - halPowerUp(); - - // Update OS system ticks. - current_seconds += seconds - quarter_seconds / 4 ; // Passed seconds - count += seconds * CLOCK_SECOND - quarter_seconds * CLOCK_SECOND / 4 ; - - if(etimer_pending()) { - etimer_request_poll(); - } - - SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); - SysTick_SetReload(RELOAD_VALUE); - SysTick_ITConfig(ENABLE); - SysTick_CounterCmd(SysTick_Counter_Enable); - - ) - - stm32w_radio_driver.init(); - if(radio_on){ - stm32w_radio_driver.on(); - } - - uart1_init(115200); - leds_init(); - rtimer_init(); - - PRINTF("WakeInfo: %04x\r\n", halGetWakeInfo()); - - -} diff --git a/platform/mbxxx/contiki-conf.h b/platform/mbxxx/contiki-conf.h index a9edf3fb0..7331f32a7 100644 --- a/platform/mbxxx/contiki-conf.h +++ b/platform/mbxxx/contiki-conf.h @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -33,14 +38,16 @@ /*---------------------------------------------------------------------------*/ /** * \file -* contiki-conf.h for MBXXX. +* Contiki-conf.h for MBXXX. * \author -* Salvatore Pitrulli -* Chi-Anh La -* Simon Duquennoy +* Salvatore Pitrulli +* Chi-Anh La +* Simon Duquennoy */ /*---------------------------------------------------------------------------*/ + + #ifndef __CONTIKI_CONF_H__ #define __CONTIKI_CONF_H__ @@ -52,59 +59,61 @@ /* Radio and 802.15.4 params */ /* 802.15.4 radio channel */ -#define RF_CHANNEL 16 +#define RF_CHANNEL 16 /* 802.15.4 PAN ID */ -#define IEEE802154_CONF_PANID 0x1234 +#define IEEE802154_CONF_PANID 0x1234 /* 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 +#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 +#define RADIO_RXBUFS 2 /* Set to 0 for non ethernet links */ -#define UIP_CONF_LLH_LEN 0 +#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 +#define RDC_CONF_HARDWARE_ACK 1 /* TX routine does automatic cca and optional backoff */ -#define RDC_CONF_HARDWARE_CSMA 0 +#define RDC_CONF_HARDWARE_CSMA 0 /* RDC debug with LED */ -#define RDC_CONF_DEBUG_LED 1 +#define RDC_CONF_DEBUG_LED 1 /* Channel check rate (per second) */ -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 +#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 /* Use ACK for optimization (LPP, XMAC) */ -#define WITH_ACK_OPTIMIZATION 0 +#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 +//#define NETSTACK_CONF_MAC csma_driver +//#define NETSTACK_CONF_RDC contikimac_driver +#define NETSTACK_CONF_MAC nullmac_driver +#define NETSTACK_CONF_RDC sicslowmac_driver +#define NETSTACK_CONF_FRAMER framer_802154 +#define NETSTACK_CONF_RADIO stm32w_radio_driver /* ContikiMAC config */ -#define CONTIKIMAC_CONF_COMPOWER 1 -#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0 -#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0 +#define CONTIKIMAC_CONF_COMPOWER 1 +#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0 +#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0 /* CXMAC config */ -#define CXMAC_CONF_ANNOUNCEMENTS 0 -#define CXMAC_CONF_COMPOWER 1 +#define CXMAC_CONF_ANNOUNCEMENTS 0 +#define CXMAC_CONF_COMPOWER 1 /* XMAC config */ -#define XMAC_CONF_ANNOUNCEMENTS 0 -#define XMAC_CONF_COMPOWER 1 +#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 +#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_DS6_ROUTE_NBU 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 @@ -115,41 +124,49 @@ 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 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_UDP 1 -#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_BUFFER_SIZE 140 -#define UIP_CONF_MAX_CONNECTIONS 4 -#define UIP_CONF_MAX_LISTENPORTS 8 -#define UIP_CONF_UDP_CONNS 4 +#if (WITH_COAP==7) || (WITH_COAP==6) || (WITH_COAP==3) +#define UIP_CONF_TCP 0 +#else +#define UIP_CONF_TCP 1 +#endif /* WITH_COAP */ -#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 +#define UIP_CONF_ROUTER 1 +#define UIP_CONF_IPV6_RPL 1 +#define UIP_CONF_ND6_SEND_RA 0 + +#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_BUFFER_SIZE 140 +#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 +#define SICSLOWPAN_CONF_FRAG 1 #endif /* SICSLOWPAN_CONF_FRAG */ #ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS -#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2 +#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2 #endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS */ #ifndef SICSLOWPAN_CONF_MAXAGE -#define SICSLOWPAN_CONF_MAXAGE 2 +#define SICSLOWPAN_CONF_MAXAGE 2 #endif /* SICSLOWPAN_CONF_MAXAGE */ #else /* WITH_UIP6 */ /* Network setup for non-IPv6 (rime). */ -#define NETSTACK_CONF_NETWORK rime_driver +#define NETSTACK_CONF_NETWORK rime_driver #endif /* WITH_UIP6 */ @@ -158,3 +175,4 @@ #endif /* PROJECT_CONF_H */ #endif /* __CONTIKI_CONF_H__ */ +/** @} */ diff --git a/platform/mb851/contiki-init-net.c b/platform/mbxxx/contiki-init-net.c similarity index 80% rename from platform/mb851/contiki-init-net.c rename to platform/mbxxx/contiki-init-net.c index ef2e8a739..0f6eb0a64 100644 --- a/platform/mb851/contiki-init-net.c +++ b/platform/mbxxx/contiki-init-net.c @@ -1,9 +1,8 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ - /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -33,14 +32,17 @@ * 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 OS + * */ - +/*---------------------------------------------------------------------------*/ /** * \file -* Functions for net initialization. +* Functions for net initialization. * \author -* Salvatore Pitrulli +* Salvatore Pitrulli */ +/*---------------------------------------------------------------------------*/ #include "contiki-net.h" @@ -57,80 +59,82 @@ #define PRINT6ADDR(addr) #define PRINTLLADDR(addr) #endif -/*--------------------------------------------------------------------------*/ -void -print_address(uip_ds6_addr_t * lladdr) + +void print_address(uip_ds6_addr_t *lladdr) { int i; - + for(i = 0; i < 7; ++i) { - printf("%02x%02x:", lladdr->ipaddr.u8[i * 2], - lladdr->ipaddr.u8[i * 2 + 1]); + printf("%02x%02x:", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1]); } printf("%02x%02x", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); } + /*---------------------------------------------------------------------------*/ -void -print_addresses(void) +void print_addresses(void) { uip_ds6_addr_t *lladdr; + + printf("link-local IPv6 address: "); - + lladdr = uip_ds6_get_link_local(-1); - if(lladdr != NULL) { - print_address(lladdr); + if(lladdr != NULL){ + print_address(lladdr); printf("\r\n"); - } else { - printf("None\r\n"); } - + else + printf("None\r\n"); + printf("global IPv6 address: "); - + lladdr = uip_ds6_get_global(-1); - if(lladdr != NULL) { - print_address(lladdr); + if(lladdr != NULL){ + print_address(lladdr); printf("\r\n"); - } else { - printf("None\r\n"); } + else + printf("None\r\n"); + } -/*--------------------------------------------------------------------------*/ + #if FIXED_NET_ADDRESS + #include "net/rpl/rpl.h" -void -set_net_address(void) + +void set_net_address(void) { uip_ipaddr_t ipaddr; - #if RPL_BORDER_ROUTER rpl_dag_t *dag; #endif - uip_ip6addr(&ipaddr, NET_ADDR_A, NET_ADDR_B, NET_ADDR_C, NET_ADDR_D, 0, 0, - 0, 0); + uip_ip6addr(&ipaddr, NET_ADDR_A, NET_ADDR_B, NET_ADDR_C, NET_ADDR_D, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); - - - /* #if !UIP_CONF_ROUTER */ - /* uip_ds6_prefix_add(&ipaddr, 64, 0); For on-link determination. */ - /* #else */ - /* uip_ds6_prefix_add(&ipaddr, 64, 0, 0, 600, 600); */ - /* #endif */ + uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); + +//#if !UIP_CONF_ROUTER +// uip_ds6_prefix_add(&ipaddr, 64, 0); // For on-link determination. +//#else +// uip_ds6_prefix_add(&ipaddr, 64, 0, 0, 600, 600); +//#endif + print_addresses(); - + #if RPL_BORDER_ROUTER - dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr); + dag = rpl_set_root(RPL_DEFAULT_INSTANCE,&ipaddr); if(dag != NULL) { PRINTF("This node is setted as root of a DAG.\r\n"); - } else { + } + else { PRINTF("Error while setting this node as root of a DAG.\r\n"); } #endif - + } #endif /* FIXED_GLOBAL_ADDRESS */ -/*--------------------------------------------------------------------------*/ + + #endif /* UIP_CONF_IPV6 */ /** @} */ diff --git a/platform/mb851/contiki-init-net.h b/platform/mbxxx/contiki-init-net.h similarity index 82% rename from platform/mb851/contiki-init-net.h rename to platform/mbxxx/contiki-init-net.h index 9f47375ca..008ad2431 100644 --- a/platform/mb851/contiki-init-net.h +++ b/platform/mbxxx/contiki-init-net.h @@ -1,9 +1,8 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ - /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -33,7 +32,17 @@ * 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 OS + * */ +/*---------------------------------------------------------------------------*/ +/** +* \file +* Functions for net initialization. +* \author +* Salvatore Pitrulli +*/ +/*---------------------------------------------------------------------------*/ #ifndef __CONTIKI_INIT_NET_H__ #define __CONTIKI_INIT_NET_H__ diff --git a/platform/mbxxx/contiki-main.c b/platform/mbxxx/contiki-main.c index 1151a79c8..329c80f95 100644 --- a/platform/mbxxx/contiki-main.c +++ b/platform/mbxxx/contiki-main.c @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -33,10 +38,10 @@ /*---------------------------------------------------------------------------*/ /** * \file -* Contiki main file. +* Contiki main file. * \author -* Salvatore Pitrulli -* Chi-Anh La +* Salvatore Pitrulli +* Chi-Anh La */ /*---------------------------------------------------------------------------*/ @@ -57,6 +62,7 @@ #include "dev/button-sensor.h" #include "dev/temperature-sensor.h" #include "dev/acc-sensor.h" +#include "dev/contact-sensor.h" #include "dev/uart1.h" #include "dev/serial-line.h" @@ -66,6 +72,11 @@ #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 @@ -86,7 +97,11 @@ PROCINIT(&sensors_process); #warning "No TCP/IP process!" #endif -SENSORS(&button_sensor,&temperature_sensor,&acc_sensor); +SENSORS(&button_sensor, &temperature_sensor, &acc_sensor, &contact_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 @@ -95,16 +110,16 @@ set_rime_addr(void) int i; union { uint8_t u8[8]; - }eui64; - - //rimeaddr_t lladdr; - - int8u *stm32w_eui64 = ST_RadioGetEui64(); + } eui64; + + uint8_t *stm32w_eui64 = ST_RadioGetEui64(); { - int8u c; - for(c = 0; c < 8; c++) { // Copy the EUI-64 to lladdr converting from Little-Endian to Big-Endian. - eui64.u8[c] = stm32w_eui64[7 - c]; - } + 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 @@ -114,7 +129,7 @@ set_rime_addr(void) #if UIP_CONF_IPV6 rimeaddr_set_node_addr((rimeaddr_t *)&eui64); #else - rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8-RIMEADDR_SIZE]); + rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8 - RIMEADDR_SIZE]); #endif printf("Rime started with address "); @@ -122,48 +137,51 @@ set_rime_addr(void) printf("%d.", rimeaddr_node_addr.u8[i]); } printf("%d\n", rimeaddr_node_addr.u8[i]); - } /*---------------------------------------------------------------------------*/ int main(void) { - + /* - * Initialize hardware. + * Initalize hardware. */ halInit(); clock_init(); - + uart1_init(115200); - - // Led initialization + + /* Led initialization */ leds_init(); - - INTERRUPTS_ON(); + + INTERRUPTS_ON(); PRINTF("\r\nStarting "); PRINTF(CONTIKI_VERSION_STRING); - PRINTF(" on %s\r\n",boardDescription->name); + PRINTF(" on %s\r\n", boardDescription->name); + boardPrintStringDescription(); + PRINTF("\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 and ctimer should be initialized before radio duty cycling + layers */ rtimer_init(); /* etimer_process should be initialized before ctimer */ - process_start(&etimer_process, NULL); + process_start(&etimer_process, NULL); ctimer_init(); - rtimer_init(); netstack_init(); + set_rime_addr(); printf("%s %s, channel check rate %lu Hz\n", @@ -180,88 +198,127 @@ main(void) 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); + 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; - + + while(1) { + + int r; + do { /* Reset watchdog. */ watchdog_periodic(); r = process_run(); } while(r > 0); - - - + + + ENERGEST_OFF(ENERGEST_TYPE_CPU); - //watchdog_stop(); + /* watchdog_stop(); */ ENERGEST_ON(ENERGEST_TYPE_LPM); /* Go to idle mode. */ halSleepWithOptions(SLEEPMODE_IDLE,0); /* We are awake. */ - //watchdog_start(); + /* watchdog_start(); */ ENERGEST_OFF(ENERGEST_TYPE_LPM); - ENERGEST_ON(ENERGEST_TYPE_CPU); - + ENERGEST_ON(ENERGEST_TYPE_CPU); + } - + } -/*int8u errcode __attribute__(( section(".noinit") )); +/*uint8_t errcode __attribute__(( section(".noinit") )); void halBaseBandIsr(){ - + errcode = 1; leds_on(LEDS_RED); } void BusFault_Handler(){ - - errcode = 2; + + errcode = 2; leds_on(LEDS_RED); } void halDebugIsr(){ - + errcode = 3; - leds_on(LEDS_RED); + leds_on(LEDS_RED); } void DebugMon_Handler(){ - + errcode = 4; - //leds_on(LEDS_RED); + //leds_on(LEDS_RED); } void HardFault_Handler(){ - - errcode = 5; + + errcode = 5; //leds_on(LEDS_RED); //halReboot(); } void MemManage_Handler(){ - - errcode = 6; + + errcode = 6; //leds_on(LEDS_RED); //halReboot(); } void UsageFault_Handler(){ - - errcode = 7; + + errcode = 7; //leds_on(LEDS_RED); //halReboot(); -}*/ +} -void Default_Handler() -{ - //errcode = 8; +void Default_Handler() +{ + //errcode = 8; leds_on(LEDS_RED); halReboot(); -} +}*/ +/** @} */ diff --git a/platform/mbxxx/dev/acc-sensor.c b/platform/mbxxx/dev/acc-sensor.c index fc201a12a..fc3fe026b 100644 --- a/platform/mbxxx/dev/acc-sensor.c +++ b/platform/mbxxx/dev/acc-sensor.c @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -51,7 +56,7 @@ static int active(void) { - int8u reg; + uint8_t reg; if(!i2c_read_reg (kLIS3L02DQ_SLAVE_ADDR,CTRL_REG1, ®, 1)) return FALSE; @@ -62,8 +67,8 @@ static int value(int type) { - int8s i2c_data = 0; - int8u reg_addr; + int8_t i2c_data = 0; + uint8_t reg_addr; switch(type) { case ACC_X_AXIS: @@ -82,13 +87,13 @@ value(int type) return 0; } - i2c_read_reg(kLIS3L02DQ_SLAVE_ADDR, reg_addr, (int8u *)&i2c_data, 1); + i2c_read_reg(kLIS3L02DQ_SLAVE_ADDR, reg_addr, (uint8_t *)&i2c_data, 1); if(MEMS_GetFullScale()==ACC_HIGH_RANGE){ - return ((int16s)i2c_data)*HIGH_RANGE_SENSITIVITY; + return ((int16_t)i2c_data)*HIGH_RANGE_SENSITIVITY; } else { - return ((int16s)i2c_data)*LOW_RANGE_SENSITIVITY; + return ((int16_t)i2c_data)*LOW_RANGE_SENSITIVITY; } } @@ -117,7 +122,7 @@ configure(int type, int value) case ACC_HPF: if(value < ACC_HPF_DISABLE){ - return i2c_write_reg(kLIS3L02DQ_SLAVE_ADDR, CTRL_REG2, (1<<4) | (int8u)value); + 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); @@ -144,3 +149,4 @@ SENSORS_SENSOR(acc_sensor, ACC_SENSOR, +/** @} */ diff --git a/platform/mbxxx/dev/acc-sensor.h b/platform/mbxxx/dev/acc-sensor.h index 4809c192f..51ab20c72 100644 --- a/platform/mbxxx/dev/acc-sensor.h +++ b/platform/mbxxx/dev/acc-sensor.h @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -75,3 +80,4 @@ extern const struct sensors_sensor acc_sensor; #define ACC_Z_AXIS 3 #endif /* __ACC_SENSOR_H__ */ +/** @} */ diff --git a/platform/mbxxx/dev/button-sensor.c b/platform/mbxxx/dev/button-sensor.c index 562bad123..187f79f62 100644 --- a/platform/mbxxx/dev/button-sensor.c +++ b/platform/mbxxx/dev/button-sensor.c @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -40,7 +45,6 @@ /*---------------------------------------------------------------------------*/ #include "dev/button-sensor.h" -#include "hal.h" #include "hal/micro/micro-common.h" #include "hal/micro/cortexm3/micro-common.h" @@ -48,6 +52,49 @@ #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 +*/ + +#undef BUTTON_S1 +#define BUTTON_S1 PORTx_PIN(boardDescription->io->buttons[0].gpioPort, boardDescription->io->buttons[0].gpioPin) +#define BUTTON_S1_INPUT_GPIO BUTTON_INPUT_GPIO(boardDescription->io->buttons[0].gpioPort) +#define BUTTON_S1_GPIO_PIN boardDescription->io->buttons[0].gpioPin +#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 @@ -55,16 +102,6 @@ static struct timer debouncetimer; #define FALSE 0 #define TRUE 1 -uint8_t button_flags = 0; - -#define BUTTON_ACTIVE_FLG 0x01 -#define BUTTON_PRESSED_FLG 0x02 - -#define BUTTON_HAS_BEEN_PRESSED() (button_flags & BUTTON_PRESSED_FLG) -#define BUTTON_HAS_BEEN_RELEASED() (!(button_flags & BUTTON_PRESSED_FLG)) -#define BUTTON_SET_PRESSED() (button_flags |= BUTTON_PRESSED_FLG) -#define BUTTON_SET_RELEASED() (button_flags &= ~BUTTON_PRESSED_FLG) - /*---------------------------------------------------------------------------*/ static void init(void) @@ -74,67 +111,43 @@ init(void) #endif /* Configure GPIO for BUTTONSs */ - halInitButton(); + + //Input, pulled up or down (selected by GPIO_PxOUT: 0 = pull-down, 1 = pull-up). + 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) { - button_flags |= BUTTON_ACTIVE_FLG; + INT_CFGSET = BUTTON_S1_INT_EN_BIT; } /*---------------------------------------------------------------------------*/ static void deactivate(void) { - button_flags &= ~BUTTON_ACTIVE_FLG; + INT_CFGCLR = BUTTON_S1_INT_EN_BIT; } /*---------------------------------------------------------------------------*/ static int active(void) { - return (button_flags & BUTTON_ACTIVE_FLG)? 1 : 0; + return (INT_CFGSET & BUTTON_S1_INT_EN_BIT) ? TRUE : FALSE ; } /*---------------------------------------------------------------------------*/ static int value(int type) { - if(!active()){ - return 0; - } - - #if DEBOUNCE - if(timer_expired(&debouncetimer)) { - - if(halGetButtonStatus(BUTTON_S1) == BUTTON_PRESSED){ - - timer_set(&debouncetimer, CLOCK_SECOND / 10); - if(BUTTON_HAS_BEEN_RELEASED()){ // Button has been previously released. - sensors_changed(&button_sensor); - } - BUTTON_SET_PRESSED(); - - return 1; - } - else { - BUTTON_SET_RELEASED(); - return 0; - } - } - else { - return 0; - } + return (BUTTON_S1_INPUT_GPIO & (1< +* Stefano Pascali */ +/*---------------------------------------------------------------------------*/ #include PLATFORM_HEADER #include BOARD_HEADER + #include "hal/error.h" #include "hal/hal.h" -#include "micro/adc.h" +#include "dev/leds.h" -#include "dev/temperature-sensor.h" +#include "dev/contact-sensor.h" +void halIrqAIsr(void); -#undef TEMPERATURE_SENSOR_GPIO -#define TEMPERATURE_SENSOR_GPIO PORTB_PIN(7) - -/*---------------------------------------------------------------------------*/ static void init(void) +{ + + //PC0 configuration: push-pull output + halGpioConfig(PORTC_PIN(0), GPIOCFG_OUT); + GPIO_PCSET |= PC0; + + //PB0 (IRQA)configuration: input Pull Down. + //halGpioConfig(PORTB_PIN(0), GPIOCFG_IN_PUD); + //GPIO_PBOUT &= ~PB0; + + //PB0 (IRQA)configuration: input Pull Down. + halGpioConfig(PORTB_PIN(0), GPIOCFG_IN); + + //configure IRQA mode: Rising and Falling edge triggered, digital filter enabled + // GPIO_INTCFGA =0x00000160; + + GPIO_INTCFGA = GPIO_INTCFGA_RESET; + GPIO_INTCFGA|=GPIO_INTFILT; + GPIO_INTCFGA|=(0x03 < +* Stefano Pascali */ -/*--------------------------------------------------------------------------*/ -void -irq_init(void) -{ -} -/*--------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ + +#ifndef __CONTACT_SENSOR_H__ +#define __CONTACT_SENSOR_H__ + +#include "lib/sensors.h" + +extern const struct sensors_sensor contact_sensor; + +#define CONTACT_SENSOR "Contact" + +#endif /* __CONTACT_SENSOR_H__ */ /** @} */ diff --git a/platform/mbxxx/dev/irq.c b/platform/mbxxx/dev/irq.c index 160e0c1b7..f3169995d 100644 --- a/platform/mbxxx/dev/irq.c +++ b/platform/mbxxx/dev/irq.c @@ -1,5 +1,11 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ void irq_init(void) { } +/** @} */ diff --git a/platform/mbxxx/dev/leds-arch.c b/platform/mbxxx/dev/leds-arch.c deleted file mode 100644 index bfc685aeb..000000000 --- a/platform/mbxxx/dev/leds-arch.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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. - * - * This file is part of the Contiki OS - * - */ -/*---------------------------------------------------------------------------*/ -/** -* \file -* Leds. -* \author -* Salvatore Pitrulli -*/ -/*---------------------------------------------------------------------------*/ - -#include PLATFORM_HEADER -#include BOARD_HEADER -#include "hal/micro/led.h" -#include "hal/micro/micro-common.h" -#include "hal/micro/cortexm3/micro-common.h" - - -#include "contiki-conf.h" -#include "dev/leds.h" - -/** - * @brief Read single GPIO bit from PxOUT - * - * @param io The io pin to use, can be specified with the convenience macros - * PORTA_PIN(), PORTB_PIN(), PORTC_PIN() - * @return Bit value: 1 if bit is set, 0 otherwise. - * - */ - -int8u halGpioGetPxOUT(int32u gpio) -{ - if(gpio/8 < 3) { - return (*((volatile int32u *)(GPIO_PxOUT_BASE+(GPIO_Px_OFFSET*(gpio/8)))) & BIT(gpio&7) ) == 0 ? 0 : 1 ; - } - return 0; -} - -/** - * @brief Read single GPIO bit from PxIN - * - * @param io The io pin to use, can be specified with the convenience macros - * PORTA_PIN(), PORTB_PIN(), PORTC_PIN() - * @return Bit value: 1 if bit is set, 0 otherwise. - * - */ - -int8u halGpioGetPxIN(int32u gpio) -{ - if(gpio/8 < 3) { - return (*((volatile int32u *)(GPIO_PxIN_BASE+(GPIO_Px_OFFSET*(gpio/8)))) & BIT(gpio&7) ) == 0 ? 0 : 1 ; - } - return 0; -} - - -/*---------------------------------------------------------------------------*/ -void -leds_arch_init(void) -{ - halInitLed(); -} -/*---------------------------------------------------------------------------*/ -unsigned char -leds_arch_get(void) -{ - return (halGpioGetPxOUT(LEDS_CONF_GREEN) ? 0 : LEDS_GREEN) - | (halGpioGetPxOUT(LEDS_CONF_YELLOW) ? 0 : LEDS_YELLOW) - | (halGpioGetPxOUT(LEDS_CONF_RED) ? 0 : LEDS_RED); -} -/*---------------------------------------------------------------------------*/ -void -leds_arch_set(unsigned char leds) -{ - halGpioSet(LEDS_CONF_GREEN, !(leds & LEDS_GREEN)); - halGpioSet(LEDS_CONF_YELLOW, !(leds & LEDS_YELLOW)); - halGpioSet(LEDS_CONF_RED, !(leds & LEDS_RED)); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/mbxxx/dev/mems.c b/platform/mbxxx/dev/mems.c index 88dd3de26..ba1764b11 100644 --- a/platform/mbxxx/dev/mems.c +++ b/platform/mbxxx/dev/mems.c @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /******************** (C) COPYRIGHT 2009 STMicroelectronics ******************** * File Name : hal_led.c * Author : MCD Application Team @@ -61,11 +66,11 @@ static boolean fullscale_state; /* Private functions ---------------------------------------------------------*/ -static int8u I2C_MEMS_Init (void); +static uint8_t I2C_MEMS_Init (void); //extern void halInternalResetWatchDog(void); -static int8u I2C_Send_Frame (int8u DeviceAddress, int8u *pBuffer, int8u NoOfBytes); -int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value); -//static int8u I2C_MEMS_Read (t_mems_data *mems_data); +static uint8_t I2C_Send_Frame (uint8_t DeviceAddress, uint8_t *pBuffer, uint8_t NoOfBytes); +uint8_t i2c_write_reg (uint8_t slave_addr, uint8_t reg_addr, uint8_t reg_value); +//static uint8_t I2C_MEMS_Read (t_mems_data *mems_data); /* Functions -----------------------------------------------------------------*/ @@ -76,9 +81,9 @@ int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value); * Output : status * Return : None *******************************************************************************/ -int8u Mems_Init(void) +uint8_t Mems_Init(void) { - int8u ret = 0; + uint8_t ret = 0; // GPIO assignments // PA1: SC2SDA (Serial Data) @@ -117,9 +122,9 @@ int8u Mems_Init(void) * Output : status * Return : None *******************************************************************************/ -//int8u Mems_GetValue(t_mems_data *mems_data) +//uint8_t Mems_GetValue(t_mems_data *mems_data) //{ -// int8u i; +// uint8_t i; // i = I2C_MEMS_Read(mems_data); // return i; //} @@ -136,9 +141,9 @@ int8u Mems_Init(void) * Output : None * Return : 1 if the frame has been successfully sent, 0 otherwise. *******************************************************************************/ -static int8u I2C_Send_Frame (int8u DeviceAddress, int8u *pBuffer, int8u NoOfBytes) +static uint8_t I2C_Send_Frame (uint8_t DeviceAddress, uint8_t *pBuffer, uint8_t NoOfBytes) { - int8u i, data; + uint8_t i, data; SC2_TWICTRL1 |= SC_TWISTART; // send start WAIT_CMD_FIN(); @@ -172,9 +177,9 @@ static int8u I2C_Send_Frame (int8u DeviceAddress, int8u *pBuffer, int8u NoOfByte * Output : I2C frame in pBUffer * Return : 1 if the frame has been successfully received, 0 otherwise. *******************************************************************************/ -static int8u I2C_Receive_Frame (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOfBytes) +static uint8_t I2C_Receive_Frame (uint8_t slave_addr, uint8_t reg_addr, uint8_t *pBuffer, uint8_t NoOfBytes) { - int8u i, addr = reg_addr; + uint8_t i, addr = reg_addr; if (NoOfBytes > 1) addr += REPETIR; @@ -224,9 +229,9 @@ static int8u I2C_Receive_Frame (int8u slave_addr, int8u reg_addr, int8u *pBuffer * Output : None * Return : 1 if the register has been successfully written, 0 otherwise. *******************************************************************************/ -int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value) +uint8_t i2c_write_reg (uint8_t slave_addr, uint8_t reg_addr, uint8_t reg_value) { - int8u i2c_buffer[2]; + uint8_t i2c_buffer[2]; i2c_buffer[0] = reg_addr; i2c_buffer[1] = reg_value; @@ -244,7 +249,7 @@ int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value) * Output : I2C frame * Return : 1 if the register has been successfully read, 0 otherwise. *******************************************************************************/ -int8u i2c_read_reg (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOfBytes) +uint8_t i2c_read_reg (uint8_t slave_addr, uint8_t reg_addr, uint8_t *pBuffer, uint8_t NoOfBytes) { return I2C_Receive_Frame (slave_addr, reg_addr, pBuffer, NoOfBytes); }/* end i2c_read_reg() */ @@ -257,9 +262,9 @@ int8u i2c_read_reg (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOf * Output : None * Return : 1 if the device has been successfully initialized, 0 otherwise. *******************************************************************************/ -static int8u I2C_MEMS_Init (void) +static uint8_t I2C_MEMS_Init (void) { - int8u i = 0; + 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 @@ -283,7 +288,7 @@ static int8u I2C_MEMS_Init (void) * Output : None * Return : 1 if the device has been successfully set to normal mode, 0 otherwise. *******************************************************************************/ -int8u MEMS_On (void) +uint8_t MEMS_On (void) { return i2c_write_reg (kLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, 0xC7); } @@ -295,7 +300,7 @@ int8u MEMS_On (void) * Output : None * Return : 1 if the device has been successfully set to power-down mode, 0 otherwise. *******************************************************************************/ -int8u MEMS_Off (void) +uint8_t MEMS_Off (void) { return i2c_write_reg (kLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, 0x87); } @@ -307,9 +312,9 @@ int8u MEMS_Off (void) * Output : None * Return : 1 if the device has been successfully set to full scale mode, 0 otherwise. *******************************************************************************/ -int8u MEMS_SetFullScale (boolean range) +uint8_t MEMS_SetFullScale (boolean range) { - int8u i2c_buffer; + uint8_t i2c_buffer; if(!i2c_read_reg(kLIS3L02DQ_SLAVE_ADDR, CTRL_REG1, &i2c_buffer, 1)) return 0; @@ -349,9 +354,9 @@ boolean MEMS_GetFullScale (void) * Output : mems_data * Return : 1 if acceleration data has been successfully read, 0 otherwise *******************************************************************************/ -//static int8u I2C_MEMS_Read (t_mems_data *mems_data) +//static uint8_t I2C_MEMS_Read (t_mems_data *mems_data) //{ -// int8u i, i2c_buffer[8]; +// uint8_t i, i2c_buffer[8]; // // i = i2c_read_reg (kLIS3L02DQ_SLAVE_ADDR, OUTX_L, i2c_buffer, 8); // @@ -366,3 +371,4 @@ boolean MEMS_GetFullScale (void) //}/* end I2C_MEMS_Read() */ /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ +/** @} */ diff --git a/platform/mbxxx/dev/mems.h b/platform/mbxxx/dev/mems.h index 45fa920fc..4f72a2291 100644 --- a/platform/mbxxx/dev/mems.h +++ b/platform/mbxxx/dev/mems.h @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /******************** (C) COPYRIGHT 2009 STMicroelectronics ******************** * File Name : mems.h * Author : MCD Application Team @@ -33,27 +38,28 @@ currently used by the device */ typedef struct { - int8s outx_l; - int8s outx_h; - int8s outy_l; - int8s outy_h; - int8s outz_l; - int8s outz_h; + int8_t outx_l; + int8_t outx_h; + int8_t outy_l; + int8_t outy_h; + int8_t outz_l; + int8_t outz_h; } t_mems_data; /* Functions -----------------------------------------------------------------*/ /* Mems Initialization function */ -int8u Mems_Init(void); +uint8_t Mems_Init(void); -int8u MEMS_On(void); -int8u MEMS_Off(void); -int8u MEMS_SetFullScale(boolean range); +uint8_t MEMS_On(void); +uint8_t MEMS_Off(void); +uint8_t MEMS_SetFullScale(boolean range); boolean MEMS_GetFullScale(void); /* Get mems acceleration values */ -int8u Mems_GetValue(t_mems_data *mems_data); +uint8_t Mems_GetValue(t_mems_data *mems_data); #endif /* _MEMS_H_ */ /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ +/** @} */ diff --git a/platform/mbxxx/dev/mems_regs.h b/platform/mbxxx/dev/mems_regs.h index 9796339a4..ab0276846 100644 --- a/platform/mbxxx/dev/mems_regs.h +++ b/platform/mbxxx/dev/mems_regs.h @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /******************** (C) COPYRIGHT 2009 STMicroelectronics ******************** * File Name : mems_regs.h * Author : MCD Application Team @@ -125,15 +130,16 @@ //-reg_addr is the address of the register to be written--// //-pBuffer is the storage destination for the read data---// //-NoOfBytes is the amount of data to read----------------// -int8u i2c_read_reg (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOfBytes); +uint8_t i2c_read_reg (uint8_t slave_addr, uint8_t reg_addr, uint8_t *pBuffer, uint8_t NoOfBytes); //*********************i2c_write_reg**********************// //----------Writes a register on the I2C target-----------// //------slave addr is the is the I2C target device--------// //-reg_addr is the address of the register to be written--// //-reg_value is the value of the register to be written---// -int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value); +uint8_t i2c_write_reg (uint8_t slave_addr, uint8_t reg_addr, uint8_t reg_value); #endif /* _MEMS_REGS_H_ */ /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ +/** @} */ diff --git a/platform/mbxxx/dev/temperature-sensor.c b/platform/mbxxx/dev/temperature-sensor.c index 937582eeb..c4418c55a 100644 --- a/platform/mbxxx/dev/temperature-sensor.c +++ b/platform/mbxxx/dev/temperature-sensor.c @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -55,32 +60,36 @@ #include "dev/temperature-sensor.h" - +#define SUPPLY_OFFSET 500 /*---------------------------------------------------------------------------*/ static void init(void) { - halGpioConfig(TEMPERATURE_SENSOR_GPIO,GPIOCFG_ANALOG); + //halGpioConfig(TEMPERATURE_SENSOR_GPIO,GPIOCFG_ANALOG); halInternalInitAdc(); halAdcSetRange(TRUE); + } /*---------------------------------------------------------------------------*/ static int value(int type) { - static int16u ADCvalue; - static int16s volts; + static uint16_t ADCvalue; + static int16_t volts; + uint16_t scale=1; halStartAdcConversion(ADC_USER_APP, ADC_REF_INT, ADC_SOURCE(halGetADCChannelFromGPIO(TEMPERATURE_SENSOR_GPIO),ADC_MUX_VREF2), ADC_CONVERSION_TIME_US_4096); halReadAdcBlocking(ADC_USER_APP, &ADCvalue); // This blocks for a while, about 4ms. - + + // 100 uVolts - volts = halConvertValueToVolts(ADCvalue); - - //return ((18641 - (int32s)volts)*100)/1171; // +- 0.23 degC in the range (-10;65) degC - return ((18663 - (int32s)volts)*100)/1169; // +- 0.004 degC in the range (20;30) degC + volts = boardDescription->temperatureSensor->div*halConvertValueToVolts(ADCvalue) + SUPPLY_OFFSET; + + //return ((18641 - (int32_t)volts)*100)/1171; // +- 0.23 degC in the range (-10;65) degC + return ((18663 - (int32_t)volts)*100)/1169; // +- 0.004 degC in the range (20;30) degC + } /*---------------------------------------------------------------------------*/ static int @@ -93,7 +102,7 @@ configure(int type, int value) case SENSORS_ACTIVE: return 1; } - + return 0; } /*---------------------------------------------------------------------------*/ @@ -111,3 +120,4 @@ status(int type) /*---------------------------------------------------------------------------*/ SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR, value, configure, status); +/** @} */ diff --git a/platform/mbxxx/dev/temperature-sensor.h b/platform/mbxxx/dev/temperature-sensor.h index 56b58e487..48b218342 100644 --- a/platform/mbxxx/dev/temperature-sensor.h +++ b/platform/mbxxx/dev/temperature-sensor.h @@ -1,3 +1,8 @@ +/** + * \addtogroup mbxxx-platform + * + * @{ + */ /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -59,3 +64,4 @@ extern const struct sensors_sensor temperature_sensor; #define TEMPERATURE_SENSOR "Temperature" #endif /* __TEMPERATURE_SENSOR_H__ */ +/** @} */ diff --git a/platform/mbxxx/platform-conf.h b/platform/mbxxx/platform-conf.h index a0316cb75..9a1b9fb72 100644 --- a/platform/mbxxx/platform-conf.h +++ b/platform/mbxxx/platform-conf.h @@ -1,3 +1,11 @@ +/** + * \defgroup mbxxx-platform The STM32W MBXXX platform. + * + * The STM32W MBXXX platform. + * + * @{ + */ + /* * Copyright (c) 2010, STMicroelectronics. * All rights reserved. @@ -33,11 +41,9 @@ /*---------------------------------------------------------------------------*/ /** * \file -* platform-conf.h for MBXXX. +* Platform-conf.h for MBXXX. * \author -* Salvatore Pitrulli -* Chi-Anh La -* Simon Duquennoy +* Stefano Pascali */ /*---------------------------------------------------------------------------*/ @@ -79,10 +85,12 @@ typedef unsigned long clock_time_t; typedef unsigned long rtimer_clock_t; #define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0) -/* LEDs ports MB8xxx */ -#define LEDS_CONF_GREEN LED_D1 -#define LEDS_CONF_YELLOW LED_D3 -#define LEDS_CONF_RED LED_D3 +#define LEDS_CONF_RED_PIN boardDescription->io->leds[1].gpioPin +#define LEDS_CONF_GREEN_PIN boardDescription->io->leds[0].gpioPin +#define LEDS_CONF_PORT boardDescription->io->leds[1].gpioPort + +#define LEDS_CONF_RED (1< Date: Fri, 12 Jul 2013 09:53:53 +0200 Subject: [PATCH 2/3] Travis-ci tweaks, added CPUREV to 01 regression test, needed by mbxxx platform --- .gitignore | 2 +- cpu/stm32w108/board-sensors.h | 2 +- cpu/stm32w108/cfs-coffee-arch.c | 2 +- cpu/stm32w108/cfs-coffee-arch.h | 2 +- cpu/stm32w108/clock.c | 2 +- cpu/stm32w108/elfloader-arch.c | 2 +- cpu/stm32w108/leds-arch.c | 2 +- cpu/stm32w108/mtarch.h | 2 +- cpu/stm32w108/rand.c | 2 +- cpu/stm32w108/rtimer-arch.c | 2 +- cpu/stm32w108/rtimer-arch.h | 2 +- cpu/stm32w108/slip-uart1.c | 2 +- cpu/stm32w108/uip-arch.c | 2 +- cpu/stm32w108/watchdog.c | 2 +- platform/mbxxx/dev/mems.c | 2 +- regression-tests/01-compile/Makefile | 2 +- regression-tests/Makefile.compile-test | 2 +- tools/stm32w/uip6_bridge/Makefile | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 124880066..5729e7464 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ *.esb *.avr-raven *.exp5438 -*.mb851 +*.mbxxx *.win32 *.apple2enh *.atari diff --git a/cpu/stm32w108/board-sensors.h b/cpu/stm32w108/board-sensors.h index 9c773d4df..aab1c649d 100644 --- a/cpu/stm32w108/board-sensors.h +++ b/cpu/stm32w108/board-sensors.h @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/cfs-coffee-arch.c b/cpu/stm32w108/cfs-coffee-arch.c index 1b7a08d9a..c34aa293e 100644 --- a/cpu/stm32w108/cfs-coffee-arch.c +++ b/cpu/stm32w108/cfs-coffee-arch.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/cfs-coffee-arch.h b/cpu/stm32w108/cfs-coffee-arch.h index 7ce8473a7..5d9db96d2 100644 --- a/cpu/stm32w108/cfs-coffee-arch.h +++ b/cpu/stm32w108/cfs-coffee-arch.h @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/clock.c b/cpu/stm32w108/clock.c index 6df0ac5c0..65b8c4d64 100644 --- a/cpu/stm32w108/clock.c +++ b/cpu/stm32w108/clock.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/elfloader-arch.c b/cpu/stm32w108/elfloader-arch.c index 6a04d45f0..14af29a5a 100644 --- a/cpu/stm32w108/elfloader-arch.c +++ b/cpu/stm32w108/elfloader-arch.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/leds-arch.c b/cpu/stm32w108/leds-arch.c index 1d9bdb50b..1357c6a0f 100644 --- a/cpu/stm32w108/leds-arch.c +++ b/cpu/stm32w108/leds-arch.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/mtarch.h b/cpu/stm32w108/mtarch.h index f4da378ee..91615bda7 100644 --- a/cpu/stm32w108/mtarch.h +++ b/cpu/stm32w108/mtarch.h @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/rand.c b/cpu/stm32w108/rand.c index a9a33306e..6e881c9bd 100644 --- a/cpu/stm32w108/rand.c +++ b/cpu/stm32w108/rand.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/rtimer-arch.c b/cpu/stm32w108/rtimer-arch.c index 5599797be..e9ae5d3dc 100644 --- a/cpu/stm32w108/rtimer-arch.c +++ b/cpu/stm32w108/rtimer-arch.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/rtimer-arch.h b/cpu/stm32w108/rtimer-arch.h index cb5090617..638136d2f 100644 --- a/cpu/stm32w108/rtimer-arch.h +++ b/cpu/stm32w108/rtimer-arch.h @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/slip-uart1.c b/cpu/stm32w108/slip-uart1.c index 904fd964d..396881055 100644 --- a/cpu/stm32w108/slip-uart1.c +++ b/cpu/stm32w108/slip-uart1.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/uip-arch.c b/cpu/stm32w108/uip-arch.c index 4646dc919..15a27206c 100644 --- a/cpu/stm32w108/uip-arch.c +++ b/cpu/stm32w108/uip-arch.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/cpu/stm32w108/watchdog.c b/cpu/stm32w108/watchdog.c index 6591bfaa2..73cb3afda 100644 --- a/cpu/stm32w108/watchdog.c +++ b/cpu/stm32w108/watchdog.c @@ -1,5 +1,5 @@ /** - * \addtogroup mb851-platform + * \addtogroup mbxxx-platform * * @{ */ diff --git a/platform/mbxxx/dev/mems.c b/platform/mbxxx/dev/mems.c index ba1764b11..95409fac0 100644 --- a/platform/mbxxx/dev/mems.c +++ b/platform/mbxxx/dev/mems.c @@ -8,7 +8,7 @@ * Author : MCD Application Team * Version : V1.0 * Date : September 2009 -* Description : Driver for leds management on STM32W108 MB851 board +* Description : Driver for leds management on STM32W108 MBXXX boards ******************************************************************************** * 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. diff --git a/regression-tests/01-compile/Makefile b/regression-tests/01-compile/Makefile index 3b4c92335..4394abc73 100644 --- a/regression-tests/01-compile/Makefile +++ b/regression-tests/01-compile/Makefile @@ -6,7 +6,7 @@ hello-world/avr-raven \ hello-world/econotag \ hello-world/esb \ hello-world/exp5438 \ -hello-world/mb851 \ +hello-world/mbxxx \ hello-world/micaz \ hello-world/minimal-net \ hello-world/native \ diff --git a/regression-tests/Makefile.compile-test b/regression-tests/Makefile.compile-test index 1da37f804..f6d7aa087 100644 --- a/regression-tests/Makefile.compile-test +++ b/regression-tests/Makefile.compile-test @@ -40,7 +40,7 @@ addzero = $(if $(call gt,${nine},$(1)),$(words ${1}),0$(words ${1})) define dooneexample @echo Building example $(3): $(1) for target $(2) @((cd $(EXAMPLESDIR)/$(1); \ - make TARGET=$(2) clean && make TARGET=$(2)) > \ + make TARGET=$(2) CPUREV=xB clean && make CPUREV=xB TARGET=$(2)) > \ $(3)-$(subst /,-,$(1))$(2).report 2>&1 && \ (echo $(1) $(2): OK | tee $(3)-$(subst /,-,$(1))$(2).summary) || \ (echo $(1) $(2): FAIL ಠ.ಠ | tee $(3)-$(subst /,-,$(1))$(2).summary ; \ diff --git a/tools/stm32w/uip6_bridge/Makefile b/tools/stm32w/uip6_bridge/Makefile index eaafe7e53..a1116deca 100644 --- a/tools/stm32w/uip6_bridge/Makefile +++ b/tools/stm32w/uip6_bridge/Makefile @@ -10,7 +10,7 @@ DEFINES=PROJECT_CONF_H=\"bridge-conf.h\" UIP_CONF_IPV6=1 ifndef TARGET -TARGET=mb851 +TARGET=mbxxx endif PROJECTDIRS = dev From 36e7db42dea0fbd8387803e96428204f010e8802 Mon Sep 17 00:00:00 2001 From: stefano pascali Date: Mon, 15 Jul 2013 18:22:07 +0200 Subject: [PATCH 3/3] Some little refactor --- cpu/stm32w108/Makefile.stm32w108 | 6 +++--- cpu/stm32w108/README.txt | 10 +++++----- platform/mbxxx/dev/contact-sensor.c | 1 + platform/mbxxx/dev/contact-sensor.h | 1 + platform/mbxxx/platform-conf.h | 1 + regression-tests/Makefile.compile-test | 3 ++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cpu/stm32w108/Makefile.stm32w108 b/cpu/stm32w108/Makefile.stm32w108 index 16bfbb728..b7e835cab 100644 --- a/cpu/stm32w108/Makefile.stm32w108 +++ b/cpu/stm32w108/Makefile.stm32w108 @@ -98,14 +98,14 @@ ifndef DEBUG OPTI = -Os -ffunction-sections endif -ifeq ($(CPUREV), CC) +ifeq ($(STM32W_CPUREV), CC) LD-EXT=-stm32w108CC ${warning "using stm32w108CC specific ld file"} -else ifeq ($(CPUREV), xB) +else ifeq ($(STM32W_CPUREV), xB) LD-EXT=-stm32w108xB ${warning "using stm32w108xB specific ld file"} else - ${error "No CPUREV specified. Cpu revision should be specified. Please read cpu/stm32w108/README.txt for more details."} + ${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\"" \ diff --git a/cpu/stm32w108/README.txt b/cpu/stm32w108/README.txt index 71c989222..8027c22c5 100644 --- a/cpu/stm32w108/README.txt +++ b/cpu/stm32w108/README.txt @@ -2,21 +2,21 @@ Building instructions. In order to build your applications you need to find out the right cpu revision for the board you are using. -Valid CPUREV values are CC or xB +Valid STM32W_CPUREV values are CC or xB Examples: The MB851RevD board has a cpu with code stm32w 108CCU7 -so CC is your CPUREV value and the command is -make TARGET=mbxxx CPUREV=CC ... +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 CPUREV value. -make TARGET=mbxxx CPUREV=xB ... +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. diff --git a/platform/mbxxx/dev/contact-sensor.c b/platform/mbxxx/dev/contact-sensor.c index 6b9bb4876..0b6e83f56 100644 --- a/platform/mbxxx/dev/contact-sensor.c +++ b/platform/mbxxx/dev/contact-sensor.c @@ -41,6 +41,7 @@ * Contact sensor. * \author * Stefano Pascali +* Marco Grella */ /*---------------------------------------------------------------------------*/ diff --git a/platform/mbxxx/dev/contact-sensor.h b/platform/mbxxx/dev/contact-sensor.h index 96798afc3..d7ebc7412 100644 --- a/platform/mbxxx/dev/contact-sensor.h +++ b/platform/mbxxx/dev/contact-sensor.h @@ -41,6 +41,7 @@ * Contact magnetic sensor header file. * \author * Stefano Pascali +* Marco Grella */ /*---------------------------------------------------------------------------*/ diff --git a/platform/mbxxx/platform-conf.h b/platform/mbxxx/platform-conf.h index 9a1b9fb72..7c19a9e52 100644 --- a/platform/mbxxx/platform-conf.h +++ b/platform/mbxxx/platform-conf.h @@ -44,6 +44,7 @@ * Platform-conf.h for MBXXX. * \author * Stefano Pascali +* Marco Grella */ /*---------------------------------------------------------------------------*/ diff --git a/regression-tests/Makefile.compile-test b/regression-tests/Makefile.compile-test index f6d7aa087..4ca4e3fd7 100644 --- a/regression-tests/Makefile.compile-test +++ b/regression-tests/Makefile.compile-test @@ -40,7 +40,8 @@ addzero = $(if $(call gt,${nine},$(1)),$(words ${1}),0$(words ${1})) define dooneexample @echo Building example $(3): $(1) for target $(2) @((cd $(EXAMPLESDIR)/$(1); \ - make TARGET=$(2) CPUREV=xB clean && make CPUREV=xB TARGET=$(2)) > \ + export STM32W_CPUREV=CC; \ + make TARGET=$(2) clean && make TARGET=$(2)) > \ $(3)-$(subst /,-,$(1))$(2).report 2>&1 && \ (echo $(1) $(2): OK | tee $(3)-$(subst /,-,$(1))$(2).summary) || \ (echo $(1) $(2): FAIL ಠ.ಠ | tee $(3)-$(subst /,-,$(1))$(2).summary ; \