Skip to content

Commit

Permalink
Merge pull request contiki-os#175 from adamdunkels/feature-updated-st…
Browse files Browse the repository at this point in the history
…m32w

Cleanup and refactorization of the STM32w port
  • Loading branch information
Nicolas Tsiftes committed Mar 19, 2013
2 parents 199a89b + a5046e8 commit 8c25ed2
Show file tree
Hide file tree
Showing 118 changed files with 4,455 additions and 4,266 deletions.
36 changes: 20 additions & 16 deletions cpu/stm32w108/Makefile.stm32w108
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ CONTIKI_CPU=$(CONTIKI)/cpu/stm32w108

CONTIKI_CPU_DIRS = . dev hal simplemac hal/micro/cortexm3 hal/micro/cortexm3/stm32w108

STM32W_C = leds-arch.c leds.c clock.c watchdog.c uart1.c uart1-putchar.c slip_uart1.c slip.c\
stm32w-radio.c stm32w_systick.c uip_arch.c rtimer-arch.c adc.c micro.c sleep.c \
STM32W_C = leds-arch.c leds.c clock.c watchdog.c uart1.c uart1-putchar.c slip-uart1.c slip.c\
stm32w-radio.c stm32w-systick.c uip-arch.c rtimer-arch.c adc.c micro.c sleep.c \
micro-common.c micro-common-internal.c clocks.c mfg-token.c nvm.c flash.c rand.c system-timer.c

STM32W_S = spmr.s79 context-switch.s79

ifdef IAR
STM32W_C += low_level_init.c
STM32W_S += cstartup_M.s
STM32W_C += low-level-init.c
STM32W_S += cstartup-m.s
else
STM32W_C += crt_stm32w108.c
STM32W_C += crt-stm32w108.c
endif

ifdef ELF_LOADER
Expand Down Expand Up @@ -104,9 +104,14 @@ CFLAGSNO = -mthumb -mcpu=cortex-m3 -D "PLATFORM_HEADER=\"hal/micro/cortexm3/comp
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
endif # CPU_LD_CONFIG

LDFLAGS += -mcpu=cortex-m3 \
-mthumb \
-Wl,-T -Xlinker $(CONTIKI_CPU)/gnu.ld \
-Wl,-T -Xlinker $(CPU_LD_CONFIG) \
-Wl,-static \
-u Default_Handler \
-nostartfiles \
Expand Down Expand Up @@ -185,9 +190,8 @@ FLASHEROPTS = -f -i rs232 -p $(PORT) -r
ifdef BTM
#if already in bootloader mode
FLASHEROPTS += -b
endif
endif
endif


### Custom rules

Expand Down Expand Up @@ -216,7 +220,7 @@ $(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@
@$(SEDCOMMAND); rm -f $(@:.o=.P)
@$(FINALIZE_DEPENDENCY)

CUSTOM_RULE_C_TO_CO = 1
%.co: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
Expand All @@ -231,11 +235,11 @@ CUSTOM_RULE_LINK = 1

ifdef CORE
ifeq ($(wildcard $(CORE)),)
${error $(CORE) doesn't exist}
${error $(CORE) doesn\'t exist}
endif
.PHONY: symbols.c symbols.h
symbols.c:
$(NM) $(CORE) | awk -f $(CONTIKI)/tools/mknmlist > symbols.c
$(NM) $(CORE) | awk -f $(CONTIKI)/tools/mknmlist > symbols.c
else
symbols.c symbols.h:
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
Expand Down Expand Up @@ -268,18 +272,18 @@ stm-motes:

$(OBJECTDIR)/%.o: %.s79
$(AS) $(ASFLAGS) -o $@ $<

$(OBJECTDIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(AS) $(ASFLAGS) -o $@ $<

%.bin: %.$(TARGET)
$(OBJCOPY) $(OBJOPTS) $< $@
$(OBJCOPY) $(OBJOPTS) $< $@

# reset all stm32w devices sequentially, as stm32w_flasher cannot access different ports in parallel
stm-reset:
$(foreach PORT, $(MOTES), $(FLASHER) -r -p $(PORT);$(\n))
@echo Done

ifdef MOTE
%.upload: %.bin
$(FLASHER) $(FLASHEROPTS) $< -p $(word $(MOTE), $(MOTES))
Expand Down
49 changes: 45 additions & 4 deletions cpu/stm32w108/board-sensors.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
/**
* \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.
*
*/

/**
* \file
* Declarations for sensor-related functions that are
Expand All @@ -7,19 +43,24 @@
* \author Salvatore Pitrulli <[email protected]>
*/

#ifndef BOARD_SENSORS_H
#define BOARD_SENSORS_H

/**
* Remember state of sensors (if active or not), in order to
* resume their original state after calling powerUpSensors().
* resume their original state after calling board_sensors_power_up().
* Useful when entering in sleep mode, since all system
* peripherals have to be reinitialized.
*/
void sensorsPowerDown();
void board_sensors_power_down(void);

/**
* Resume the state of all on-board sensors on to the state
* that they had when sensorsPowerDown() was called.
* that they had when board_sensors_power_down() was called.
* Useful when sensors have to be used after the micro was put
* in deep sleep mode.
*/
void sensorsPowerUp();
void board_sensors_power_up(void);

#endif /* BOARD_SENSORS_H */
/** @} */
Loading

0 comments on commit 8c25ed2

Please sign in to comment.