Commit bb4ed5e2 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Added USB CDC example files

parent 262afb56
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
####################################################################
# Definitions #
####################################################################
# uniq is a function which remove duplicate elements from a list
uniq = $(strip $(if $1,$(firstword $1) \
$(call uniq,$(filter-out $(firstword $1),$1))))
DEVICE = EFM32GG330F1024
PROJECTNAME = usbdcdc
OOCD_IFACE ?= stlink-v2-1
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
# Change path to the tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= GNU Tools ARM Embedded\4.8 2013q4
LINUXCS ?= /opt/gcc-arm-none-eabi-4_8-2014q1
RMDIRS := rm -rf
RMFILES := rm -rf
ALLFILES := /*.*
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# Try autodetecting the environment
ifeq ($(SHELLNAMES),)
# Assume we are making on a Linux platform
TOOLDIR := $(LINUXCS)
else
QUOTE :="
ifneq ($(COMSPEC),)
# Assume we are making on a mingw/msys/cygwin platform running on Windows
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
TOOLDIR := $(PROGRAMFILES)/$(WINDOWSCS)
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else
# Assume we are making on a Windows platform
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
SHELL := $(SHELLNAMES)
TOOLDIR := $(ProgramFiles)/$(WINDOWSCS)
RMDIRS := rd /s /q
RMFILES := del /s /q
ALLFILES := \*.*
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RMFILES) $(OBJ_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(EXE_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(LST_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
endif
endif
CC = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-gcc$(QUOTE)
LD = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ld$(QUOTE)
AR = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ar$(QUOTE)
OBJCOPY = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objcopy$(QUOTE)
DUMP = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objdump$(QUOTE)
SIZE = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-size$(QUOTE)
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb \
-mfix-cortex-m3-ldrd -ffunction-sections \
-fdata-sections -fomit-frame-pointer -DDEBUG_EFM_USER \
$(DEPFLAGS)
override ASMFLAGS += -x assembler-with-cpp -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -DDEBUG_EFM_USER
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -T../../common/Device/EnergyMicro/EFM32GG/Source/GCC/efm32gg.ld \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I../src \
-I../src \
-I../../common/CMSIS/Include \
-I../../common/Device/EnergyMicro/EFM32GG/Include \
-I../../common/emlib/inc \
-I../usb/inc \
-I../kits/common/drivers \
-I../kits/common/bsp \
-I../kits/EFM32GG_DK3750/config
####################################################################
# Files #
####################################################################
C_SRC += \
../../common/Device/EnergyMicro/EFM32GG/Source/system_efm32gg.c \
../../common/emlib/src/em_assert.c \
../../common/emlib/src/em_cmu.c \
../../common/emlib/src/em_dma.c \
../../common/emlib/src/em_ebi.c \
../../common/emlib/src/em_emu.c \
../../common/emlib/src/em_gpio.c \
../../common/emlib/src/em_int.c \
../../common/emlib/src/em_system.c \
../../common/emlib/src/em_timer.c \
../../common/emlib/src/em_leuart.c \
../usb/src/em_usbd.c \
../usb/src/em_usbdch9.c \
../usb/src/em_usbhal.c \
../usb/src/em_usbdep.c \
../usb/src/em_usbdint.c \
../usb/src/em_usbtimer.c \
../kits/common/drivers/dmactrl.c \
../src/main.c
s_SRC +=
S_SRC += \
../../common/Device/EnergyMicro/EFM32GG/Source/GCC/startup_efm32gg.S
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, uniq removes duplicate paths
C_PATHS = $(call uniq, $(dir $(C_SRC) ) )
S_PATHS = $(call uniq, $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O0 -g
release: $(EXE_DIR)/$(PROJECTNAME).bin
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
$(SIZE) $<
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RMDIRS) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)
endif
flash: $(EXE_DIR)/$(PROJECTNAME).bin
openocd -s ../../common/openocd -f interface/$(OOCD_IFACE).cfg -f init.cfg -c "program $(EXE_DIR)/$(PROJECTNAME).bin 0 verify reset"
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
####################################################################
# Definitions #
####################################################################
# uniq is a function which remove duplicate elements from a list
uniq = $(strip $(if $1,$(firstword $1) \
$(call uniq,$(filter-out $(firstword $1),$1))))
DEVICE = EFM32GG990F1024
PROJECTNAME = usbdcdc
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
# Change path to the tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= GNU Tools ARM Embedded\4.8 2013q4
LINUXCS ?= /cad/arm-embedded/gcc-arm-none-eabi-4_7-2012q4
RMDIRS := rm -rf
RMFILES := rm -rf
ALLFILES := /*.*
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# Try autodetecting the environment
ifeq ($(SHELLNAMES),)
# Assume we are making on a Linux platform
TOOLDIR := $(LINUXCS)
else
QUOTE :="
ifneq ($(COMSPEC),)
# Assume we are making on a mingw/msys/cygwin platform running on Windows
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
TOOLDIR := $(PROGRAMFILES)/$(WINDOWSCS)
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else
# Assume we are making on a Windows platform
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
SHELL := $(SHELLNAMES)
TOOLDIR := $(ProgramFiles)/$(WINDOWSCS)
RMDIRS := rd /s /q
RMFILES := del /s /q
ALLFILES := \*.*
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RMFILES) $(OBJ_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(EXE_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(LST_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
endif
endif
CC = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-gcc$(QUOTE)
LD = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ld$(QUOTE)
AR = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ar$(QUOTE)
OBJCOPY = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objcopy$(QUOTE)
DUMP = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objdump$(QUOTE)
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb \
-mfix-cortex-m3-ldrd -ffunction-sections \
-fdata-sections -fomit-frame-pointer -DDEBUG_EFM_USER \
$(DEPFLAGS)
override ASMFLAGS += -x assembler-with-cpp -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -DDEBUG_EFM_USER
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -T../Device/SiliconLabs/EFM32GG/Source/GCC/efm32gg.ld \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I../src \
-I../src \
-I../CMSIS/Include \
-I../Device/SiliconLabs/EFM32GG/Include \
-I../emlib/inc \
-I../usb/inc \
-I../kits/common/drivers \
-I../kits/common/bsp \
-I../kits/EFM32GG_DK3750/config
####################################################################
# Files #
####################################################################
C_SRC += \
../Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c \
../kits/common/bsp/bsp_dk_3201.c \
../kits/common/bsp/bsp_trace.c \
../kits/common/drivers/dmactrl.c \
../emlib/src/em_assert.c \
../emlib/src/em_cmu.c \
../emlib/src/em_dma.c \
../emlib/src/em_ebi.c \
../emlib/src/em_emu.c \
../emlib/src/em_gpio.c \
../emlib/src/em_int.c \
../emlib/src/em_system.c \
../emlib/src/em_timer.c \
../emlib/src/em_usart.c \
../usb/src/em_usbd.c \
../usb/src/em_usbdch9.c \
../usb/src/em_usbhal.c \
../usb/src/em_usbdep.c \
../usb/src/em_usbdint.c \
../usb/src/em_usbtimer.c \
../src/main.c
s_SRC +=
S_SRC += \
../Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.S
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, uniq removes duplicate paths
C_PATHS = $(call uniq, $(dir $(C_SRC) ) )
S_PATHS = $(call uniq, $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O0 -g
release: $(EXE_DIR)/$(PROJECTNAME).bin
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RMDIRS) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
/***************************************************************************//**
* @file
* @brief Provide BSP (board support package) configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSPCONFIG_H
#define __BSPCONFIG_H
#define BSP_DK
#define BSP_DK_3201
#define BSP_MCUBOARD_3600
#define BSP_MCUBOARD_USB
#define BSP_USB_STATUSLED_PORT gpioPortE
#define BSP_USB_STATUSLED_PIN 1
#define BSP_USB_OCFLAG_PORT gpioPortE
#define BSP_USB_OCFLAG_PIN 2
#define BSP_USB_VBUSEN_PORT gpioPortF
#define BSP_USB_VBUSEN_PIN 5
#include "bsp_dk_bcreg_3201.h"
#define BSP_DK_LEDS
#define BSP_NO_OF_LEDS 16
#define BSP_LED_MASK 0xFFFF
#define BSP_LED_PORT (&BC_REGISTER->UIF_LEDS)
#define BSP_INIT_DEFAULT BSP_INIT_DK_EBI
#endif
/***************************************************************************//**
* @file
* @brief Provide I2CDRV configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __I2CDRVCONFIG_H
#define __I2CDRVCONFIG_H
/// I2C pin/port configuration. Note that this driver supports only one
/// driver instance.
#define I2CDRV_PORT_LOCATION 3 /// Location used on DK
#define I2CDRV_SCL_PORT gpioPortD
#define I2CDRV_SCL_PIN 15
#define I2CDRV_SDA_PORT gpioPortD
#define I2CDRV_SDA_PIN 14
#define I2CDRV_TRANSFER_TIMEOUT 300000
#endif
/***************************************************************************//**
* @file
* @brief Provide MicroSD SPI configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __MICROSDCONFIG_H
#define __MICROSDCONFIG_H
/* Don't increase MICROSD_HI_SPI_FREQ beyond 12MHz. Next step will be 24MHz */
/* which is out of spec. */
#define MICROSD_HI_SPI_FREQ 12000000
#define MICROSD_LO_SPI_FREQ 100000
#define MICROSD_USART USART0
#define MICROSD_LOC USART_ROUTE_LOCATION_LOC1
#define MICROSD_CMUCLOCK cmuClock_USART0
#define MICROSD_GPIOPORT gpioPortE
#define MICROSD_MOSIPIN 7
#define MICROSD_MISOPIN 6
#define MICROSD_CSPIN 4
#define MICROSD_CLKPIN 5
#endif /* __MICROSDCONFIG_H */
/***************************************************************************//**
* @file
* @brief Provide stdio retargeting configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __RETARGETSERIALCONFIG_H
#define __RETARGETSERIALCONFIG_H
#include "bsp.h"
/* Override if needed with commandline parameter -DRETARGET_xxx */
#if !defined(RETARGET_UART1) && !defined(RETARGET_LEUART1)
#define RETARGET_UART1 /* Use UART1 by default. */
#endif
#if defined(RETARGET_UART1)
#define RETARGET_IRQ_NAME UART1_RX_IRQHandler /* UART IRQ Handler */
#define RETARGET_CLK cmuClock_UART1 /* HFPER Clock */
#define RETARGET_IRQn UART1_RX_IRQn /* IRQ number */
#define RETARGET_UART UART1 /* UART instance */
#define RETARGET_TX USART_Tx /* Set TX to USART_Tx */
#define RETARGET_RX USART_Rx /* Set RX to USART_Rx */
#define RETARGET_LOCATION USART_ROUTE_LOCATION_LOC2 /* Location of of the USART I/O pins */
#define RETARGET_TXPORT gpioPortB /* UART transmission port */
#define RETARGET_TXPIN 9 /* UART transmission pin */
#define RETARGET_RXPORT gpioPortB /* UART reception port */
#define RETARGET_RXPIN 10 /* UART reception pin */
#define RETARGET_USART 1 /* Includes em_usart.h */
#define RETARGET_PERIPHERAL_ENABLE() BSP_PeripheralAccess(BSP_RS232_UART, true)
#elif defined(RETARGET_LEUART1)
#define RETARGET_IRQ_NAME LEUART1_IRQHandler /* LEUART IRQ Handler */
#define RETARGET_CLK cmuClock_LEUART1 /* LFB Clock */
#define RETARGET_IRQn LEUART1_IRQn /* IRQ number */
#define RETARGET_UART LEUART1 /* LEUART instance */
#define RETARGET_TX LEUART_Tx /* Set TX to LEUART_Tx */
#define RETARGET_RX LEUART_Rx /* Set RX to LEUART_Rx */
#define RETARGET_TXPORT gpioPortC /* LEUART transmission port */
#define RETARGET_TXPIN 6 /* LEUART transmission pin */
#define RETARGET_RXPORT gpioPortC /* LEUART reception port */
#define RETARGET_RXPIN 7 /* LEUART reception pin */
#define RETARGET_LOCATION LEUART_ROUTE_LOCATION_LOC0 /* Location of of the LEUART I/O pins */
#define RETARGET_LEUART 1 /* Includes em_leuart.h */
#define RETARGET_PERIPHERAL_ENABLE() BSP_PeripheralAccess(BSP_RS232_LEUART, true)
#else
#error "Illegal UART/LEUART selection."
#endif
#endif
/***************************************************************************//**
* @file
* @brief Provide SWO/ETM TRACE configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __TRACECONFIG_H
#define __TRACECONFIG_H
#define BSP_TRACE_SWO_LOCATION GPIO_ROUTE_SWLOCATION_LOC0
/* Enable output on pin - GPIO Port F, Pin 2. */
#define TRACE_ENABLE_PINS() \
GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK); \
GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL
#define BSP_ETM_TRACE /* This DK supports ETM trace. */
#endif
/***************************************************************************//**
* @file
* @brief Board support package API definitions.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSP_H
#define __BSP_H
#include <stdbool.h>
#include "bspconfig.h"
#if defined( BSP_STK )
#include "em_usart.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BSPCOMMON API common for all kits */ /** @{ */
#define BSP_STATUS_OK 0 /**< BSP API return code, no errors. */
#define BSP_STATUS_ILLEGAL_PARAM (-1) /**< BSP API return code, illegal input parameter. */
#define BSP_STATUS_NOT_IMPLEMENTED (-2) /**< BSP API return code, function not implemented (dummy). */
#define BSP_STATUS_UNSUPPORTED_MODE (-3) /**< BSP API return code, unsupported BSP mode. */
/* Initialization flag bitmasks for BSP_Init(). */
#define BSP_INIT_DK_SPI 0x01 /**< Mode flag for @ref BSP_Init(), init DK in SPI mode (DK3x50 only). */
#define BSP_INIT_DK_EBI 0x02 /**< Mode flag for @ref BSP_Init(), init DK in EBI mode (DK3x50 only). */
#define BSP_INIT_BCC 0x04 /**< Mode flag for @ref BSP_Init(), init board controller communication. */
/** @} */
#if defined( BSP_DK )
/** @addtogroup BSP_DK API for DK's */ /** @{ */
/** Display Control */
typedef enum
{
BSP_Display_EBI, /**< SSD2119 TFT controller driven by EFM32 EBI interface */
BSP_Display_SPI, /**< SSD2119 TFT controller driven by EFM32 SPI interface */
BSP_Display_BC, /**< SSD2119 TFT controller driven by board controller (AEM) */
BSP_Display_PowerEnable, /**< SSD2119 Enable power */
BSP_Display_PowerDisable, /**< SSD2119 Disable power */
BSP_Display_ResetAssert, /**< Hold SSD2119 in reset */
BSP_Display_ResetRelease, /**< Release SSD2119 in reset */
BSP_Display_Mode8080, /**< Configure SSD2119 for 8080 mode of operation */
BSP_Display_ModeGeneric, /**< Configure SSD2119 for Generic+SPI mode of operation */
} BSP_Display_TypeDef;
/** Bus control access mode */
typedef enum
{
BSP_BusControl_Undefined=0, /**< Board control mode unknown (not set) */
BSP_BusControl_OFF, /**< Board control disable */
BSP_BusControl_DIRECT, /**< GPIO direct drive (n/a) */
BSP_BusControl_SPI, /**< Configure Board controller for SPI mode */
BSP_BusControl_EBI, /**< Configure Board controller for EBI mode */
} BSP_BusControl_TypeDef;
#if defined( BSP_DK_3200 ) /* Gxxx_DK */
/** Peripherals control structure for Gxxx_DK's. */
typedef enum
{
BSP_ACCEL = BC_PERCTRL_ACCEL, /**< Accelerometer */
BSP_AMBIENT = BC_PERCTRL_AMBIENT, /**< Light sensor */
BSP_POTMETER = BC_PERCTRL_POTMETER, /**< Potentiometer */
BSP_RS232A = BC_PERCTRL_RS232A, /**< Serial port A */
BSP_RS232B = BC_PERCTRL_RS232B, /**< Serial port B */
BSP_SPI = BC_PERCTRL_SPI, /**< SPI interface */
BSP_I2C = BC_PERCTRL_I2C, /**< I2C interface */
BSP_IRDA = BC_PERCTRL_IRDA, /**< IrDA interface */
BSP_ANALOG_SE = BC_PERCTRL_ANALOG_SE, /**< Single ended analog input */
BSP_ANALOG_DIFF = BC_PERCTRL_ANALOG_DIFF, /**< Differential analog input */
BSP_AUDIO_OUT = BC_PERCTRL_AUDIO_OUT, /**< Audio Out */
BSP_AUDIO_IN = BC_PERCTRL_AUDIO_IN, /**< Audio In */
BSP_ACCEL_GSEL = BC_PERCTRL_ACCEL_GSEL, /**< Accelerometer range select */
BSP_ACCEL_SELFTEST = BC_PERCTRL_ACCEL_SELFTEST, /**< Accelerometer selftest mode */
BSP_RS232_SHUTDOWN = BC_PERCTRL_RS232_SHUTDOWN, /**< Disable RS232 */
BSP_IRDA_SHUTDOWN = BC_PERCTRL_IRDA_SHUTDOWN /**< Disable IrDA */
#ifdef DOXY_DOC_ONLY
} BSP_Peripheral_Typedef; /* Hack for doxygen doc ! */
#else
} BSP_Peripheral_TypeDef;
#endif
#endif /* BSP_DK_3200 */
#if defined( BSP_DK_3201 ) /* DK3x50 DK's */
/** Peripherals control structure for DK3x50 DK's. */
typedef enum
{
BSP_RS232_SHUTDOWN, /**< Disable RS232 */
BSP_RS232_UART, /**< UART control of RS232 */
BSP_RS232_LEUART, /**< LEUART control of RS232 */
BSP_I2C, /**< I2C interface */
BSP_ETH, /**< Ethernet */
BSP_I2S, /**< Audio I2S */
BSP_TRACE, /**< ETM Trace */
BSP_TOUCH, /**< Display touch interface */
BSP_AUDIO_IN, /**< Audio In */
BSP_AUDIO_OUT, /**< Audio Out */
BSP_ANALOG_DIFF, /**< Differential analog input */
BSP_ANALOG_SE, /**< Single ended analog input */
BSP_MICROSD, /**< MicroSD SPI interace */
BSP_TFT, /**< SSD2119 TFT controller */
} BSP_Peripheral_TypeDef;
#endif /* BSP_DK_3201 */
/** @} */
#endif /* BSP_DK */
/************************** The BSP API *******************************/
int BSP_Disable ( void );
int BSP_Init ( uint32_t flags );
int BSP_LedClear ( int ledNo );
int BSP_LedGet ( int ledNo );
int BSP_LedSet ( int ledNo );
uint32_t BSP_LedsGet ( void );
int BSP_LedsInit ( void );
int BSP_LedsSet ( uint32_t leds );
int BSP_LedToggle ( int ledNo );
#if defined( BSP_DK )
BSP_BusControl_TypeDef BSP_BusControlModeGet( void );
int BSP_BusControlModeSet ( BSP_BusControl_TypeDef mode );
uint32_t BSP_DipSwitchGet ( void );
int BSP_DisplayControl ( BSP_Display_TypeDef option );
int BSP_EbiExtendedAddressRange ( bool enable );
int BSP_EnergyModeSet ( uint16_t energyMode );
int BSP_InterruptDisable ( uint16_t flags );
int BSP_InterruptEnable ( uint16_t flags );
int BSP_InterruptFlagsClear ( uint16_t flags );
int BSP_InterruptFlagsSet ( uint16_t flags );
uint16_t BSP_InterruptFlagsGet ( void );
uint16_t BSP_JoystickGet ( void );
int BSP_McuBoard_DeInit ( void );
int BSP_McuBoard_Init ( void );
int BSP_McuBoard_UsbStatusLedEnable ( bool enable );
bool BSP_McuBoard_UsbVbusOcFlagGet ( void );
int BSP_McuBoard_UsbVbusPowerEnable ( bool enable );
int BSP_PeripheralAccess ( BSP_Peripheral_TypeDef perf, bool enable );
uint16_t BSP_PushButtonsGet ( void );
uint16_t BSP_RegisterRead ( volatile uint16_t *addr );
int BSP_RegisterWrite ( volatile uint16_t *addr, uint16_t data );
#endif
#if defined( BSP_STK )
int BSP_BccDeInit ( void );
int BSP_BccInit ( void );
bool BSP_BccPacketReceive ( BCP_Packet *pkt );
int BSP_BccPacketSend ( BCP_Packet *pkt );
void BSP_BccPinsEnable ( bool enable );
float BSP_CurrentGet ( void );
int BSP_EbiDeInit ( void );
int BSP_EbiInit ( void );
float BSP_VoltageGet ( void );
#endif
#ifdef __cplusplus
}
#endif
#endif /* __BSP_H */
/***************************************************************************//**
* @file
* @brief Board Controller Communications (BCC) definitions
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include <string.h>
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "bsp.h"
#if defined( BSP_BCC_LEUART )
#include "em_leuart.h"
#else
#include "em_usart.h"
#endif
#if defined( BSP_STK )
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/* Module local variables */
static uint32_t rxByteCount;
static uint32_t txByteCount;
/* Module local prototypes */
static void TxByte( uint8_t data );
static uint8_t RxByte( void );
/** @endcond */
/***************************************************************************//**
* @addtogroup BSP
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup BSP_STK API for STK's
* @{
******************************************************************************/
/**************************************************************************//**
* @brief Deinitialize board controller communication support (BCC)
* functionality. Reverse actions performed by @ref BSP_BccInit().
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_BccDeInit( void )
{
/* Reset counters */
rxByteCount = 0xFFFFFFFFUL;
txByteCount = 0xFFFFFFFFUL;
BSP_BccPinsEnable( false );
#if defined( BSP_BCC_LEUART )
/* Reset LEUART */
LEUART_Reset( BSP_BCC_LEUART );
#else
/* Reset USART */
USART_Reset( BSP_BCC_USART );
#endif
/* Disable clock */
CMU_ClockEnable( BSP_BCC_CLK, false );
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Initialize board controller communication support (BCC)
* functionality.
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_BccInit( void )
{
#if defined( BSP_BCC_LEUART )
LEUART_Init_TypeDef leuartInit = LEUART_INIT_DEFAULT;
#else
USART_InitAsync_TypeDef usartInit = USART_INITASYNC_DEFAULT;
#endif
rxByteCount = 0;
txByteCount = 0;
/* Enable High Frequency Peripherals */
CMU_ClockEnable(cmuClock_HFPER, true);
/* Enable clocks to GPIO */
CMU_ClockEnable(cmuClock_GPIO, true);
/* Enable UART clock */
CMU_ClockEnable( BSP_BCC_CLK, true );
#if defined( BSP_BCC_LEUART )
/* Enable CORE LE clock in order to access LE modules */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Select CORE LE clock for LE modules */
CMU_ClockSelectSet( cmuClock_LFB, cmuSelect_CORELEDIV2 );
/* Initialize LEUART */
leuartInit.baudrate = 115200;
LEUART_Init( BSP_BCC_LEUART, &leuartInit );
#else
/* Initialize USART */
USART_InitAsync( BSP_BCC_USART, &usartInit );
#endif
/* Initialize UART pins */
BSP_BccPinsEnable( true );
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Get a packet from the board controller.
*
* @param[in] pkt Pointer to a @ref BCP_Packet instance.
*
* @return True if packet received without errors, false otherwise.
*****************************************************************************/
bool BSP_BccPacketReceive( BCP_Packet *pkt )
{
int i;
int length;
uint8_t *bptr;
/* Setup a byte pointer to start of packet buffer */
bptr = (uint8_t *) pkt;
/* Receive packet magic */
*bptr++ = RxByte();
if (pkt->magic != BSP_BCP_MAGIC)
{
return false;
}
/* Receive packet type */
*bptr++ = RxByte();
if ( (pkt->type < BSP_BCP_FIRST) || (pkt->type > BSP_BCP_LAST) )
{
return false;
}
/* Receive packet length */
*bptr++ = RxByte();
if (pkt->payloadLength > BSP_BCP_PACKET_SIZE)
{
return false;
}
#if ( BSP_BCP_VERSION == 2 )
/* Receive reserved byte */
*bptr++ = RxByte();
#endif
/* Receive packet data length field and sanity check it */
length = pkt->payloadLength;
if (length > BSP_BCP_PACKET_SIZE)
{
length = BSP_BCP_PACKET_SIZE;
}
/* Receive packet payload */
for( i=0; i<length; i++ )
{
*bptr++ = RxByte();
}
return true;
}
/**************************************************************************//**
* @brief Send a packet to the board controller.
*
* @param[in] pkt Pointer to a @ref BCP_Packet instance.
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_BccPacketSend( BCP_Packet *pkt )
{
int i;
/* Apply magic */
pkt->magic = BSP_BCP_MAGIC;
/* Transmit packet magic */
TxByte( pkt->magic );
/* Transmit packet type */
TxByte( pkt->type );
/* Transmit packet length */
TxByte( pkt->payloadLength );
#if ( BSP_BCP_VERSION == 2 )
/* Transmit reserved byte */
TxByte( pkt->reserved );
#endif
/* Transmit packet payload */
for ( i=0; i<pkt->payloadLength; i++ )
{
TxByte( pkt->data[i] );
}
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Enable GPIO pins for the USART/LEUART used for board communication.
*
* @param[in] enable Set to true to enable pins, set to false to disable.
*****************************************************************************/
void BSP_BccPinsEnable( bool enable )
{
if (enable)
{
/* Configure GPIO pin for UART TX */
/* To avoid false start, configure output as high. */
GPIO_PinModeSet( BSP_BCC_TXPORT, BSP_BCC_TXPIN, gpioModePushPull, 1 );
/* Configure GPIO pin for UART RX */
GPIO_PinModeSet( BSP_BCC_RXPORT, BSP_BCC_RXPIN, gpioModeInput, 1 );
/* Enable the switch that enables UART communication. */
GPIO_PinModeSet( BSP_BCC_ENABLE_PORT, BSP_BCC_ENABLE_PIN, gpioModePushPull, 1 );
#if defined( BSP_BCC_LEUART )
BSP_BCC_LEUART->ROUTE |= LEUART_ROUTE_RXPEN | LEUART_ROUTE_TXPEN | BSP_BCC_LOCATION;
#else
BSP_BCC_USART->ROUTE |= USART_ROUTE_RXPEN | USART_ROUTE_TXPEN | BSP_BCC_LOCATION;
#endif
}
else
{
GPIO_PinModeSet( BSP_BCC_ENABLE_PORT, BSP_BCC_ENABLE_PIN, gpioModeDisabled, 0 );
#if defined( BSP_BCC_LEUART )
BSP_BCC_LEUART->ROUTE &= ~(LEUART_ROUTE_RXPEN | LEUART_ROUTE_TXPEN);
#else
BSP_BCC_USART->ROUTE &= ~(USART_ROUTE_RXPEN | USART_ROUTE_TXPEN);
#endif
GPIO_PinModeSet( BSP_BCC_TXPORT, BSP_BCC_TXPIN, gpioModeDisabled, 0 );
GPIO_PinModeSet( BSP_BCC_RXPORT, BSP_BCC_RXPIN, gpioModeDisabled, 0 );
}
}
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
static uint8_t RxByte( void )
{
uint8_t byte;
/* Poll RX data available flag and return a character when one is available */
#if defined( BSP_BCC_LEUART )
while (!(BSP_BCC_LEUART->IF & LEUART_IF_RXDATAV)) ;
byte = BSP_BCC_LEUART->RXDATA;
#else
while (!(BSP_BCC_USART->STATUS & USART_STATUS_RXDATAV)) ;
byte = BSP_BCC_USART->RXDATA;
#endif
rxByteCount++;
return byte;
}
static void TxByte( uint8_t data )
{
/* Check TX buffer and allow for a pending transfer to complete */
#if defined( BSP_BCC_LEUART )
while (!(BSP_BCC_LEUART->STATUS & LEUART_STATUS_TXBL)) ;
BSP_BCC_LEUART->TXDATA = (uint32_t) data;
#else
while (!(BSP_BCC_USART->STATUS & USART_STATUS_TXBL)) ;
BSP_BCC_USART->TXDATA = (uint32_t) data;
#endif
txByteCount++;
}
/** @endcond */
/** @} (end group BSP_STK) */
/** @} (end group BSP) */
#endif /* BSP_STK */
/**************************************************************************//**
* @file
* @brief Board Controller Communications Protocol (BCP) definitions
* @version 3.20.5
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSP_BCP_H
#define __BSP_BCP_H
#include <stdint.h>
#include "bspconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup BSP_STK API for STK's
* @{
******************************************************************************/
/* BCP Packet Types */
#define BSP_BCP_INVALID 0 /**< Invalid packet received */
#define BSP_BCP_FIRST 1 /**< Smallest numerical value of message type */
#define BSP_BCP_ACK 5 /**< Generic ACK for one way packages */
#define BSP_BCP_ECHO_REQ 10 /**< EFM32 BC alive request */
#define BSP_BCP_ECHO_REPLY 11 /**< BC alive response */
#define BSP_BCP_CURRENT_REQ 14 /**< EFM32 Request AEM current */
#define BSP_BCP_CURRENT_REPLY 16 /**< BC Response AEM current */
#define BSP_BCP_VOLTAGE_REQ 18 /**< EFM32 Request AEM voltage */
#define BSP_BCP_VOLTAGE_REPLY 20 /**< BC Response AEM voltage */
#define BSP_BCP_ENERGYMODE 22 /**< EFM32 Report Energy Mode (for AEM) */
#define BSP_BCP_STDOUT 24 /**< Debug packet (not used) */
#define BSP_BCP_STDERR 26 /**< Debug packet (not used) */
#define BSP_BCP_TEST 32 /**< Reserved type for test */
#define BSP_BCP_TEST_REPLY 33 /**< Reserved type for test (reply) */
#define BSP_BCP_NET_REQUEST 64 /**< Net gateway request packet */
#define BSP_BCP_NET_REPLY 65 /**< Net gateway reply packet */
#define BSP_BCP_LAST 100 /**< Last defined message type */
#define BSP_BCP_MAGIC 0xF1 /**< Magic byte to indicate start of packet */
#if ( ( BSP_BCP_VERSION == 1 ) || DOXY_DOC_ONLY )
#ifdef DOXY_DOC_ONLY
/* Hack for doxygen doc ! */
#define BSP_BCP_PACKET_SIZe 30 /**< Max packet size for version 1 of the protocol. */
#else
#define BSP_BCP_PACKET_SIZE 30 /**< Max packet size for version 1 of the protocol. */
#endif
/** @brief BCP Packet Structure - Board controller communication protocol version 1. */
typedef struct
{
uint8_t magic; /**< Magic - start of packet - must be BSP_BCP_MAGIC */
uint8_t type; /**< Type of packet */
uint8_t payloadLength; /**< Length of data segment >=0 and <=BSP_BCP_PACKET_SIZE */
uint8_t data[BSP_BCP_PACKET_SIZE]; /**< BCP Packet Data payload */
#ifdef DOXY_DOC_ONLY
} BCP_Packet_; /* Hack for doxygen doc ! */
#else
} BCP_Packet;
#endif
#endif
#if ( ( BSP_BCP_VERSION == 2 ) || DOXY_DOC_ONLY )
#define BSP_BCP_PACKET_SIZE 132 /**< Max packet size for version 2 of the protocol. */
/** @brief BCP Packet Structure - Board controller communication protocol version 2. */
typedef struct
{
uint8_t magic; /**< Magic - start of packet - must be BSP_BCP_MAGIC */
uint8_t type; /**< Type - packet type */
uint8_t payloadLength; /**< Length of data segment >=0 and <=BSP_BCP_PACKET_SIZE */
uint8_t reserved; /**< Reserved for future expansion */
uint8_t data[BSP_BCP_PACKET_SIZE]; /**< BCP Packet Data payload */
} BCP_Packet;
/** @brief BCP Packet Header definition */
typedef struct
{
uint8_t magic; /**< Magic - start of packet - must be BSP_BCP_MAGIC */
uint8_t type; /**< Type - packet type */
uint8_t payloadLength; /**< Length of data segment >=0 and <=BSP_BCP_PACKET_SIZE */
uint8_t reserved; /**< Reserved for future expansion */
} BCP_PacketHeader;
#endif
#if ( ( BSP_BCP_VERSION != 1 ) && ( BSP_BCP_VERSION != 2 ) )
#error "BSP BCP Board Controller communications protocol version error."
#endif
#if ( BSP_BCP_PACKET_SIZE >= 255 )
#error "BSP BCP Board Controller communications packets must be less than 255 bytes in size!"
#endif
/** @} (end group BSP_STK) */
#ifdef __cplusplus
}
#endif
#endif /* __BSP_BCP_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/***************************************************************************//**
* @file
* @brief Board support package API for GPIO leds on STK's.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include "bsp.h"
#if defined( BSP_DK_LEDS )
/***************************************************************************//**
* @addtogroup BSPCOMMON API common for all kits
* @{
******************************************************************************/
/**************************************************************************//**
* @brief Initialize LED drivers.
* @note LED's are initially turned off.
* @return
* @ref BSP_STATUS_OK
*****************************************************************************/
int BSP_LedsInit(void)
{
BSP_RegisterWrite(BSP_LED_PORT, 0);
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Get status of all LED's.
* @return
* Bitmask with current status for all LED's.
*****************************************************************************/
uint32_t BSP_LedsGet(void)
{
return BSP_RegisterRead(BSP_LED_PORT) & BSP_LED_MASK;
}
/**************************************************************************//**
* @brief Update all LED's.
* @param[in] leds Bitmask representing new status for all LED's. A 1 turns
* a LED on, a 0 turns a LED off.
* @return
* @ref BSP_STATUS_OK
*****************************************************************************/
int BSP_LedsSet(uint32_t leds)
{
BSP_RegisterWrite(BSP_LED_PORT, leds & BSP_LED_MASK);
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Turn off a single LED.
* @param[in] ledNo The number of the LED (counting from zero) to turn off.
* @return
* @ref BSP_STATUS_OK or @ref BSP_STATUS_ILLEGAL_PARAM if illegal LED number.
*****************************************************************************/
int BSP_LedClear(int ledNo)
{
uint32_t tmp;
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
tmp = BSP_RegisterRead(BSP_LED_PORT) & BSP_LED_MASK;
tmp &= ~( 1 << ledNo );
BSP_RegisterWrite(BSP_LED_PORT, tmp);
return BSP_STATUS_OK;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
/**************************************************************************//**
* @brief Get current status of a single LED.
* @param[in] ledNo The number of the LED (counting from zero) to check.
* @return
* 1 if LED is on, 0 if LED is off, @ref BSP_STATUS_ILLEGAL_PARAM if illegal
* LED number.
*****************************************************************************/
int BSP_LedGet(int ledNo)
{
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
if ( BSP_RegisterRead(BSP_LED_PORT) & BSP_LED_MASK & (1 << ledNo) )
return 1;
return 0;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
/**************************************************************************//**
* @brief Turn on a single LED.
* @param[in] ledNo The number of the LED (counting from zero) to turn on.
* @return
* @ref BSP_STATUS_OK or @ref BSP_STATUS_ILLEGAL_PARAM if illegal LED number.
*****************************************************************************/
int BSP_LedSet(int ledNo)
{
uint32_t tmp;
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
tmp = BSP_RegisterRead(BSP_LED_PORT) & BSP_LED_MASK;
tmp |= 1 << ledNo;
BSP_RegisterWrite(BSP_LED_PORT, tmp);
return BSP_STATUS_OK;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
/**************************************************************************//**
* @brief Toggle a single LED.
* @param[in] ledNo The number of the LED (counting from zero) to toggle.
* @return
* @ref BSP_STATUS_OK or @ref BSP_STATUS_ILLEGAL_PARAM if illegal LED number.
*****************************************************************************/
int BSP_LedToggle(int ledNo)
{
uint32_t tmp;
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
tmp = BSP_RegisterRead(BSP_LED_PORT) & BSP_LED_MASK;
tmp ^= 1 << ledNo;
BSP_RegisterWrite(BSP_LED_PORT, tmp);
return BSP_STATUS_OK;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
/** @} */
#endif /* BSP_DK_LEDS */
/***************************************************************************//**
* @file
* @brief Board support package API for functions on MCU plugin boards.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include <stdbool.h>
#include "bsp.h"
#include "em_gpio.h"
#include "em_cmu.h"
/***************************************************************************//**
* @addtogroup BSP
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup BSP_DK API for DK's
* @{
******************************************************************************/
/**************************************************************************//**
* @brief Disable MCU plugin board peripherals.
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_McuBoard_DeInit( void )
{
#ifdef BSP_MCUBOARD_USB
/* Disable GPIO port pin mode. */
GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModeDisabled, 0 );
GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeDisabled, 0 );
GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModeDisabled, 0 );
#endif
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Enable MCU plugin board peripherals.
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_McuBoard_Init( void )
{
#ifdef BSP_MCUBOARD_USB
/* Make sure that the CMU clock to the GPIO peripheral is enabled */
CMU_ClockEnable( cmuClock_GPIO, true );
/* USB status LED - configure PE1 as push pull */
GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModePushPull, 0 );
/* USB PHY overcurrent status input */
GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeInput, 0 );
/* USB VBUS switch - configure PF5 as push pull - Default OFF */
GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, 0 );
#endif
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Set state of MCU plugin board USB status LED.
* @param[in] enable Set to true to turn on LED, false to turn off.
* @return @ref BSP_STATUS_OK on plugin boards with USB capability,
* @ref BSP_STATUS_NOT_IMPLEMENTED otherwise.
*****************************************************************************/
int BSP_McuBoard_UsbStatusLedEnable( bool enable )
{
#ifdef BSP_MCUBOARD_USB
if ( enable )
{
GPIO_PinOutSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
}
else
{
GPIO_PinOutClear( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
}
return BSP_STATUS_OK;
#else
(void)enable;
return BSP_STATUS_NOT_IMPLEMENTED;
#endif
}
/**************************************************************************//**
* @brief Get state MCU plugin board VBUS overcurrent flag.
* @return True if overcurrent situation exist, false otherwise.
*****************************************************************************/
bool BSP_McuBoard_UsbVbusOcFlagGet( void )
{
#ifdef BSP_MCUBOARD_USB
bool flag;
if ( !GPIO_PinInGet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN ) )
{
flag = true;
}
else
{
flag = false;
}
return flag;
#else
return false;
#endif
}
/**************************************************************************//**
* @brief Enable MCU plugin board VBUS power switch.
* @param[in] enable Set to true to turn on VBUS power, false to turn off.
* @return @ref BSP_STATUS_OK on plugin boards with USB capability,
* @ref BSP_STATUS_NOT_IMPLEMENTED otherwise.
*****************************************************************************/
int BSP_McuBoard_UsbVbusPowerEnable( bool enable )
{
#ifdef BSP_MCUBOARD_USB
GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, enable );
return BSP_STATUS_OK;
#else
(void)enable;
return BSP_STATUS_NOT_IMPLEMENTED;
#endif
}
/** @} (end group BSP_DK) */
/** @} (end group BSP) */
/***************************************************************************//**
* @file
* @brief Board support package API implementation STK's.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include <string.h>
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "bsp.h"
#if defined( BSP_STK_USE_EBI )
#include "em_ebi.h"
#endif
#if defined( BSP_STK )
/***************************************************************************//**
* @addtogroup BSP
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup BSP_STK API for STK's
* @{
******************************************************************************/
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/**************************************************************************//**
* @brief Deinitialize board support package functionality.
* Reverse actions performed by @ref BSP_Init().
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_Disable(void)
{
BSP_BccDeInit();
BSP_EbiDeInit();
return BSP_STATUS_OK;
}
/** @endcond */
/**************************************************************************//**
* @brief Initialize the EBI interface for accessing the onboard nandflash.
*
* @note This function is not relevant for Gxxx_STK's.
*
* @return
* @ref BSP_STATUS_OK or @ref BSP_STATUS_NOT_IMPLEMENTED
*****************************************************************************/
int BSP_EbiInit(void)
{
#if defined( BSP_STK_USE_EBI )
/* ------------------------------------------ */
/* NAND Flash, Bank0, Base Address 0x80000000 */
/* Micron flash NAND256W3A */
/* ------------------------------------------ */
EBI_Init_TypeDef ebiConfig =
{ ebiModeD8A8, /* 8 bit address, 8 bit data */
ebiActiveLow, /* ARDY polarity */
ebiActiveLow, /* ALE polarity */
ebiActiveLow, /* WE polarity */
ebiActiveLow, /* RE polarity */
ebiActiveLow, /* CS polarity */
ebiActiveLow, /* BL polarity */
false, /* disble BL */
true, /* enable NOIDLE */
false, /* disable ARDY */
true, /* disable ARDY timeout */
EBI_BANK0, /* enable bank 0 */
0, /* no chip select */
0, /* addr setup cycles */
0, /* addr hold cycles */
false, /* disable half cycle ALE strobe */
0, /* read setup cycles */
2, /* read strobe cycles */
1, /* read hold cycles */
false, /* disable page mode */
false, /* disable prefetch */
false, /* disable half cycle REn strobe */
0, /* write setup cycles */
2, /* write strobe cycles */
1, /* write hold cycles */
false, /* enable the write buffer */
false, /* disable half cycle WEn strobe */
ebiALowA24, /* ALB - Low bound, address lines */
ebiAHighA26, /* APEN - High bound, address lines */
ebiLocation1, /* Use Location 1 */
true, /* enable EBI */
};
/* Enable clocks */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_EBI, true);
/* Enable GPIO's */
/* ALE and CLE */
GPIO_PinModeSet(gpioPortC, 1, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortC, 2, gpioModePushPull, 0);
/* WP, CE and R/B */
GPIO_PinModeSet(gpioPortD, 13, gpioModePushPull, 0); /* active low write-protect */
GPIO_PinModeSet(gpioPortD, 14, gpioModePushPull, 1); /* active low chip-enable */
GPIO_PinModeSet(gpioPortD, 15, gpioModeInput, 0); /* ready/busy */
/* IO pins */
GPIO_PinModeSet(gpioPortE, 8, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 9, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 14, gpioModePushPull, 0);
GPIO_PinModeSet(gpioPortE, 15, gpioModePushPull, 0);
/* WE and RE */
GPIO_PinModeSet(gpioPortF, 8, gpioModePushPull, 1);
GPIO_PinModeSet(gpioPortF, 9, gpioModePushPull, 1);
/* NAND Power Enable */
GPIO_PinModeSet(gpioPortB, 15, gpioModePushPull, 1);
EBI_Init(&ebiConfig);
EBI->NANDCTRL = (EBI_NANDCTRL_BANKSEL_BANK0 | EBI_NANDCTRL_EN);
return BSP_STATUS_OK;
#else
return BSP_STATUS_NOT_IMPLEMENTED;
#endif
}
/**************************************************************************//**
* @brief Deinitialize the EBI interface for accessing the onboard nandflash.
*
* @note This function is not relevant for Gxxx_STK's.
* This function is provided for API completeness, it does not perform
* an actual EBI deinitialization.
*
* @return
* @ref BSP_STATUS_OK or @ref BSP_STATUS_NOT_IMPLEMENTED
*****************************************************************************/
int BSP_EbiDeInit( void )
{
#if defined( BSP_STK_USE_EBI )
return BSP_STATUS_OK;
#else
return BSP_STATUS_NOT_IMPLEMENTED;
#endif
}
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/**************************************************************************//**
* @brief Initialize board support package functionality.
*
* @param[in] flags Initialization mask, use 0 or @ref BSP_INIT_BCC.
*
* @return
* @ref BSP_STATUS_OK
*****************************************************************************/
int BSP_Init( uint32_t flags )
{
if ( flags & BSP_INIT_BCC )
{
BSP_BccInit();
}
return BSP_STATUS_OK;
}
/** @endcond */
/**************************************************************************//**
* @brief Request AEM (Advanced Energy Monitoring) current from board controller.
*
* @note Assumes that BSP_Init() has been called with @ref BSP_INIT_BCC
* bitmask.
*
* @return
* The current expressed in milliamperes. Returns 0.0 on board controller
* communication error.
*****************************************************************************/
float BSP_CurrentGet( void )
{
BCP_Packet pkt;
float *pcurrent;
pkt.type = BSP_BCP_CURRENT_REQ;
pkt.payloadLength = 0;
/* Send Request/Get reply */
BSP_BccPacketSend( &pkt );
BSP_BccPacketReceive( &pkt );
/* Process reply */
pcurrent = (float *)pkt.data;
if ( pkt.type != BSP_BCP_CURRENT_REPLY )
{
*pcurrent = 0.0f;
}
return *pcurrent;
}
/**************************************************************************//**
* @brief Request AEM (Advanced Energy Monitoring) voltage from board controller.
*
* @note Assumes that BSP_Init() has been called with @ref BSP_INIT_BCC
* bitmask.
*
* @return
* The voltage. Returns 0.0 on board controller communication
* error.
*****************************************************************************/
float BSP_VoltageGet( void )
{
BCP_Packet pkt;
float *pvoltage;
pkt.type = BSP_BCP_VOLTAGE_REQ;
pkt.payloadLength = 0;
/* Send Request/Get reply */
BSP_BccPacketSend( &pkt );
BSP_BccPacketReceive( &pkt );
/* Process reply */
pvoltage = (float *)pkt.data;
if ( pkt.type != BSP_BCP_VOLTAGE_REPLY )
{
*pvoltage = 0.0f;
}
return *pvoltage;
}
/** @} (end group BSP_STK) */
/** @} (end group BSP) */
#endif /* BSP_STK */
/***************************************************************************//**
* @file
* @brief Board support package API for GPIO leds on STK's.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "bsp.h"
#if defined( BSP_GPIO_LEDS )
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
typedef struct
{
GPIO_Port_TypeDef port;
unsigned int pin;
} tLedArray;
static const tLedArray ledArray[ BSP_NO_OF_LEDS ] = BSP_GPIO_LEDARRAY_INIT;
int BSP_LedsInit(void)
{
int i;
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
for ( i=0; i<BSP_NO_OF_LEDS; i++ )
{
GPIO_PinModeSet(ledArray[i].port, ledArray[i].pin, gpioModePushPull, 0);
}
return BSP_STATUS_OK;
}
uint32_t BSP_LedsGet(void)
{
int i;
uint32_t retVal, mask;
for ( i=0, retVal=0, mask=0x1; i<BSP_NO_OF_LEDS; i++, mask <<= 1 )
{
if (GPIO_PinOutGet(ledArray[i].port, ledArray[i].pin))
retVal |= mask;
}
return retVal;
}
int BSP_LedsSet(uint32_t leds)
{
int i;
uint32_t mask;
for ( i=0, mask=0x1; i<BSP_NO_OF_LEDS; i++, mask <<= 1 )
{
if ( leds & mask )
GPIO_PinOutSet(ledArray[i].port, ledArray[i].pin);
else
GPIO_PinOutClear(ledArray[i].port, ledArray[i].pin);
}
return BSP_STATUS_OK;
}
int BSP_LedClear(int ledNo)
{
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
GPIO_PinOutClear(ledArray[ledNo].port, ledArray[ledNo].pin);
return BSP_STATUS_OK;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
int BSP_LedGet(int ledNo)
{
int retVal = BSP_STATUS_ILLEGAL_PARAM;
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
retVal = (int)GPIO_PinOutGet(ledArray[ledNo].port, ledArray[ledNo].pin);
}
return retVal;
}
int BSP_LedSet(int ledNo)
{
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
GPIO_PinOutSet(ledArray[ledNo].port, ledArray[ledNo].pin);
return BSP_STATUS_OK;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
int BSP_LedToggle(int ledNo)
{
if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
{
GPIO_PinOutToggle(ledArray[ledNo].port, ledArray[ledNo].pin);
return BSP_STATUS_OK;
}
return BSP_STATUS_ILLEGAL_PARAM;
}
/** @endcond */
#endif /* BSP_GPIO_LEDS */
/**************************************************************************//**
* @file
* @brief API for enabling SWO and ETM trace.
* @version 3.20.5
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include <stdbool.h>
#include "em_device.h"
#include "em_gpio.h"
#include "em_cmu.h"
#include "bsp_trace.h"
#include "bsp.h"
#if defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )
/**************************************************************************//**
* @brief Configure EFM32 for ETM trace output.
* @note You need to configure ETM trace on kit config menu as well!
*****************************************************************************/
void BSP_TraceEtmSetup(void)
{
/* Enable peripheral clocks */
CMU->HFCORECLKEN0 |= CMU_HFCORECLKEN0_LE;
CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
/* Wait until AUXHFRCO clock is ready */
while (!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY)) ;
/* Enable Port D, pins 3,4,5,6 for ETM Trace Data output */
GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE3_MASK) | GPIO_P_MODEL_MODE3_PUSHPULL;
GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE4_MASK) | GPIO_P_MODEL_MODE4_PUSHPULL;
GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE5_MASK) | GPIO_P_MODEL_MODE5_PUSHPULL;
GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE6_MASK) | GPIO_P_MODEL_MODE6_PUSHPULL;
/* Enable Port D, pin 7 for DBG_TCLK */
GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE7_MASK) | GPIO_P_MODEL_MODE7_PUSHPULL;
/* Configure trace output for alternate location */
GPIO->ROUTE = GPIO->ROUTE | GPIO_ROUTE_TCLKPEN | GPIO_ROUTE_TD0PEN | GPIO_ROUTE_TD1PEN
| GPIO_ROUTE_TD2PEN | GPIO_ROUTE_TD3PEN
| GPIO_ROUTE_ETMLOCATION_LOC0;
}
#endif
#if defined( GPIO_ROUTE_SWOPEN )
/**************************************************************************//**
* @brief Configure trace output for energyAware Profiler
* @note Enabling trace will add 80uA current for the EFM32_Gxxx_STK.
* DK's needs to be initialized with SPI-mode:
* @verbatim BSP_Init(BSP_INIT_DK_SPI); @endverbatim
*****************************************************************************/
void BSP_TraceSwoSetup(void)
{
/* Enable GPIO clock */
CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
/* Enable Serial wire output pin */
GPIO->ROUTE |= GPIO_ROUTE_SWOPEN;
/* Set correct location */
GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | BSP_TRACE_SWO_LOCATION;
/* Enable output on correct pin. */
TRACE_ENABLE_PINS();
/* Enable debug clock AUXHFRCO */
CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
/* Wait until clock is ready */
while (!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY)) ;
// Check if trace already enabled, if so assume that an external debugger
// is in control and skip further setup.
if ( !( CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk ) ) {
/* Enable trace in core debug */
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
/* Enable PC and IRQ sampling output */
DWT->CTRL = 0x400113FF;
/* Set TPIU prescaler to 16. */
TPI->ACPR = 0xf;
/* Set protocol to NRZ */
TPI->SPPR = 2;
/* Disable continuous formatting */
TPI->FFCR = 0x100;
/* Unlock ITM and output data */
ITM->LAR = 0xC5ACCE55;
ITM->TCR = 0x10009;
}
}
#endif
#if defined( GPIO_ROUTE_SWOPEN )
/**************************************************************************//**
* @brief Profiler configuration.
* @return true if energyAware Profiler/SWO is enabled, false if not
* @note If first word of the user page is zero, this will not
* enable SWO profiler output.
*****************************************************************************/
bool BSP_TraceProfilerSetup(void)
{
volatile uint32_t *userData = (uint32_t *) USER_PAGE;
/* Check magic "trace" word in user page */
if (*userData == 0x00000000UL)
{
return false;
}
else
{
BSP_TraceSwoSetup();
return true;
}
}
#endif
/**************************************************************************//**
* @file
* @brief SWO Trace API (for eAProfiler)
* @version 3.20.5
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSP_TRACE_H
#define __BSP_TRACE_H
#include "em_device.h"
#if (defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )) || defined( GPIO_ROUTE_SWOPEN )
#include <stdint.h>
#include <stdbool.h>
#include "em_msc.h"
#include "traceconfig.h"
/***************************************************************************//**
* @addtogroup BSP
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup BSPCOMMON API common for all kits
* @{
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )
void BSP_TraceEtmSetup(void);
#endif
#if defined( GPIO_ROUTE_SWOPEN )
bool BSP_TraceProfilerSetup(void);
void BSP_TraceSwoSetup(void);
#endif
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
#define USER_PAGE 0x0FE00000UL /* Address to flash memory */
/** @endcond */
/**************************************************************************//**
* @brief Set or clear word in user page which enables or disables SWO
* in BSP_TraceProfilerSetup. If BSP_TraceProfilerEnable(false) has been run,
* no example project will enable SWO trace.
* @param[in] enable
* @note Add "em_msc.c" to build to use this function.
*****************************************************************************/
__STATIC_INLINE void BSP_TraceProfilerEnable(bool enable)
{
uint32_t data;
volatile uint32_t *userpage = (uint32_t *) USER_PAGE;
/* Check that configuration needs to change */
data = *userpage;
if (enable)
{
if (data == 0xFFFFFFFF)
{
return;
}
}
else
{
if (data == 0x00000000)
{
return;
}
}
/* Initialize MSC */
MSC_Init();
/* Write enable or disable trigger word into flash */
if (enable)
{
data = 0xFFFFFFFF;
MSC_ErasePage((uint32_t *) USER_PAGE);
MSC_WriteWord((uint32_t *) USER_PAGE, (void *) &data, 4);
}
else
{
data = 0x00000000;
MSC_ErasePage((uint32_t *) USER_PAGE);
MSC_WriteWord((uint32_t *) USER_PAGE, (void *) &data, 4);
}
}
#ifdef __cplusplus
}
#endif
/** @} (end group BSP) */
/** @} (end group BSP) */
#endif /* (defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )) || defined( GPIO_ROUTE_SWOPEN ) */
#endif /* __BSP_TRACE_H */
This diff is collapsed.
/*
*
* Copyright (c) 2001, Carlos E. Vidales. All rights reserved.
*
* This sample program was written and put in the public domain
* by Carlos E. Vidales. The program is provided "as is"
* without warranty of any kind, either expressed or implied.
* If you choose to use the program within your own products
* you do so at your own risk, and assume the responsibility
* for servicing, repairing or correcting the program should
* it prove defective in any manner.
* You may copy and distribute the program's source code in any
* medium, provided that you also include in each copy an
* appropriate copyright notice and disclaimer of warranty.
* You may also modify this program and distribute copies of
* it provided that you include prominent notices stating
* that you changed the file(s) and the date of any change,
* and that you do not charge any royalties or licenses for
* its use.
*
*
* File Name: calibrate.h
*
*
* Definition of constants and structures, and declaration of functions
* in Calibrate.c
*
*/
#ifndef _CALIBRATE_H_
#define _CALIBRATE_H_
/****************************************************/
/* */
/* Included files */
/* */
/****************************************************/
#include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************/
/* */
/* Definitions */
/* */
/****************************************************/
#ifndef _CALIBRATE_C_
#define EXTERN extern
#else
#define EXTERN
#endif
#ifndef OK
#define OK 0
#define NOT_OK -1
#endif
#define INT32 long
/****************************************************/
/* */
/* Structures */
/* */
/****************************************************/
typedef struct Point {
INT32 x,
y ;
} POINT ;
typedef struct Matrix {
/* This arrangement of values facilitates
* calculations within getDisplayPoint()
*/
INT32 An, /* A = An/Divider */
Bn, /* B = Bn/Divider */
Cn, /* C = Cn/Divider */
Dn, /* D = Dn/Divider */
En, /* E = En/Divider */
Fn, /* F = Fn/Divider */
Divider ;
} MATRIX ;
/****************************************************/
/* */
/* Function declarations */
/* */
/****************************************************/
EXTERN int setCalibrationMatrix( POINT * display,
POINT * screen,
MATRIX * matrix) ;
EXTERN int getDisplayPoint( POINT * display,
POINT * screen,
MATRIX * matrix ) ;
#ifdef __cplusplus
}
#endif
#endif /* _CALIBRATE_H_ */
This diff is collapsed.
/**************************************************************************//**
* @file
* @brief Capacitive sense driver
* @version 3.20.5
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __CAPLESENSE_H_
#define __CAPLESENSE_H_
#include <stdint.h>
#include <stdbool.h>
/***************************************************************************//**
* @addtogroup Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup CapSense
* @{
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
uint8_t CAPLESENSE_getSegmentChannel(uint8_t capSegment);
uint32_t CAPLESENSE_getVal(uint8_t channel);
uint32_t CAPLESENSE_getNormalizedVal(uint8_t channel);
int32_t CAPLESENSE_getSliderPosition(void);
void CAPLESENSE_Init(bool sleep);
void CAPLESENSE_setupLESENSE(bool sleep);
void CAPLESENSE_setupCallbacks(void (*scanCb)(void), void (*chCb)(void));
void CAPLESENSE_Sleep(void);
#ifdef __cplusplus
}
#endif
/** @} (end group CapSense) */
/** @} (end group Drivers) */
#endif /* __CAPSENSE_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment