Add testhal for LPC43xx DAC, DMA memory transfer and IRQ_STORM.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6742 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
98da8365ea
commit
3356d32039
|
@ -0,0 +1,233 @@
|
||||||
|
##############################################################################
|
||||||
|
# Build global options
|
||||||
|
# NOTE: Can be overridden externally.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Compiler options here.
|
||||||
|
ifeq ($(USE_OPT),)
|
||||||
|
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_COPT),)
|
||||||
|
USE_COPT =
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C++ specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_CPPOPT),)
|
||||||
|
USE_CPPOPT = -fno-rtti
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want the linker to remove unused code and data
|
||||||
|
ifeq ($(USE_LINK_GC),)
|
||||||
|
USE_LINK_GC = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If enabled, this option allows to compile the application in THUMB mode.
|
||||||
|
ifeq ($(USE_THUMB),)
|
||||||
|
USE_THUMB = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want to see the full log while compiling.
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),)
|
||||||
|
USE_VERBOSE_COMPILE = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build global options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Architecture or project specific options
|
||||||
|
#
|
||||||
|
|
||||||
|
# Enables the use of FPU on Cortex-M4.
|
||||||
|
ifeq ($(USE_FPU),)
|
||||||
|
USE_FPU = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enables the use of Cortex-M4 by LPC43xx in LPC43xx.h.
|
||||||
|
ifeq ($(USE_CORE_M4),)
|
||||||
|
USE_CORE_M4 = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# LPC43xx boot select: ram, spifi_flash_debug, flash.
|
||||||
|
ifeq ($(LPC_BOOT_SELECT),)
|
||||||
|
LPC_BOOT_SELECT = ram
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Architecture or project specific options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Project, sources and paths
|
||||||
|
#
|
||||||
|
|
||||||
|
# Define project name here
|
||||||
|
PROJECT = ch
|
||||||
|
|
||||||
|
# Imported source files
|
||||||
|
CHIBIOS = ../../..
|
||||||
|
include $(CHIBIOS)/boards/NONSTANDARD_LPC4330_SBC/board.mk
|
||||||
|
include $(CHIBIOS)/os/hal/platforms/LPC43xx/platform.mk
|
||||||
|
include $(CHIBIOS)/os/hal/hal.mk
|
||||||
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/LPC43xx/port.mk
|
||||||
|
include $(CHIBIOS)/os/kernel/kernel.mk
|
||||||
|
include $(CHIBIOS)/test/test.mk
|
||||||
|
|
||||||
|
# Define linker script file here
|
||||||
|
LDSCRIPT= $(PORTLD)/LPC4330_RAM_DEBUG.ld
|
||||||
|
|
||||||
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CSRC = $(PORTSRC) \
|
||||||
|
$(KERNSRC) \
|
||||||
|
$(TESTSRC) \
|
||||||
|
$(HALSRC) \
|
||||||
|
$(PLATFORMSRC) \
|
||||||
|
$(BOARDSRC) \
|
||||||
|
$(CHIBIOS)/os/various/evtimer.c \
|
||||||
|
$(CHIBIOS)/os/various/syscalls.c \
|
||||||
|
main.c
|
||||||
|
|
||||||
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACSRC =
|
||||||
|
|
||||||
|
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCPPSRC =
|
||||||
|
|
||||||
|
# List ASM source files here
|
||||||
|
ASMSRC = $(PORTASM)
|
||||||
|
|
||||||
|
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
||||||
|
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
||||||
|
$(CHIBIOS)/os/various
|
||||||
|
|
||||||
|
#
|
||||||
|
# Project, sources and paths
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Compiler settings
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = cortex-m4
|
||||||
|
|
||||||
|
#TRGT = arm-elf-
|
||||||
|
TRGT = arm-none-eabi-
|
||||||
|
CC = $(TRGT)gcc
|
||||||
|
CPPC = $(TRGT)g++
|
||||||
|
# Enable loading with g++ only if you need C++ runtime support.
|
||||||
|
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||||
|
# runtime support makes code size explode.
|
||||||
|
LD = $(TRGT)gcc
|
||||||
|
#LD = $(TRGT)g++
|
||||||
|
CP = $(TRGT)objcopy
|
||||||
|
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||||
|
OD = $(TRGT)objdump
|
||||||
|
HEX = $(CP) -O ihex
|
||||||
|
BIN = $(CP) -O binary
|
||||||
|
|
||||||
|
# ARM-specific options here
|
||||||
|
AOPT =
|
||||||
|
|
||||||
|
# THUMB-specific options here
|
||||||
|
TOPT = -mthumb -DTHUMB
|
||||||
|
|
||||||
|
# Define C warning options here
|
||||||
|
CWARN = -Wall -Wextra -Wstrict-prototypes
|
||||||
|
|
||||||
|
# Define C++ warning options here
|
||||||
|
CPPWARN = -Wall -Wextra
|
||||||
|
|
||||||
|
#
|
||||||
|
# Compiler settings
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of default section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all default C defines here, like -D_DEBUG=1
|
||||||
|
DDEFS = -D__NEWLIB__
|
||||||
|
|
||||||
|
# List all default ASM defines here, like -D_DEBUG=1
|
||||||
|
DADEFS =
|
||||||
|
|
||||||
|
# List all default directories to look for include files here
|
||||||
|
DINCDIR =
|
||||||
|
|
||||||
|
# List the default directory to look for the libraries here
|
||||||
|
DLIBDIR =
|
||||||
|
|
||||||
|
# List all default libraries here
|
||||||
|
DLIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of default section
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of user section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all user C define here, like -D_DEBUG=1
|
||||||
|
UDEFS =
|
||||||
|
|
||||||
|
# Define ASM defines here
|
||||||
|
UADEFS =
|
||||||
|
|
||||||
|
# List all user directories here
|
||||||
|
UINCDIR =
|
||||||
|
|
||||||
|
# List the user directory to look for the libraries here
|
||||||
|
ULIBDIR =
|
||||||
|
|
||||||
|
# List all user libraries here
|
||||||
|
ULIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of user defines
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
ifeq ($(USE_FPU),yes)
|
||||||
|
USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
||||||
|
DDEFS += -DCORTEX_USE_FPU=TRUE
|
||||||
|
else
|
||||||
|
DDEFS += -DCORTEX_USE_FPU=FALSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_CORE_M4),yes)
|
||||||
|
DDEFS += -DCORE_M4
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LPC_BOOT_SELECT), ram)
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x10000000
|
||||||
|
else
|
||||||
|
ifeq ($(LPC_BOOT_SELECT), spifi_flash_debug)
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x14000000
|
||||||
|
else
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x00000000
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
|
|
@ -0,0 +1,531 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/chconf.h
|
||||||
|
* @brief Configuration file template.
|
||||||
|
* @details A copy of this file must be placed in each project directory, it
|
||||||
|
* contains the application specific kernel settings.
|
||||||
|
*
|
||||||
|
* @addtogroup config
|
||||||
|
* @details Kernel related settings and hooks.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CHCONF_H_
|
||||||
|
#define _CHCONF_H_
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Kernel parameters and options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System tick frequency.
|
||||||
|
* @details Frequency of the system timer that drives the system ticks. This
|
||||||
|
* setting also defines the system tick time unit.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_FREQUENCY 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Round robin interval.
|
||||||
|
* @details This constant is the number of system ticks allowed for the
|
||||||
|
* threads before preemption occurs. Setting this value to zero
|
||||||
|
* disables the preemption for threads with equal priority and the
|
||||||
|
* round robin becomes cooperative. Note that higher priority
|
||||||
|
* threads can still preempt, the kernel is always preemptive.
|
||||||
|
*
|
||||||
|
* @note Disabling the round robin preemption makes the kernel more compact
|
||||||
|
* and generally faster.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
|
||||||
|
#define CH_TIME_QUANTUM 20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Managed RAM size.
|
||||||
|
* @details Size of the RAM area to be managed by the OS. If set to zero
|
||||||
|
* then the whole available RAM is used. The core memory is made
|
||||||
|
* available to the heap allocator and/or can be used directly through
|
||||||
|
* the simplified core memory allocator.
|
||||||
|
*
|
||||||
|
* @note In order to let the OS manage the whole RAM the linker script must
|
||||||
|
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||||
|
* @note Requires @p CH_USE_MEMCORE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_MEMCORE_SIZE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Idle thread automatic spawn suppression.
|
||||||
|
* @details When this option is activated the function @p chSysInit()
|
||||||
|
* does not spawn the idle thread automatically. The application has
|
||||||
|
* then the responsibility to do one of the following:
|
||||||
|
* - Spawn a custom idle thread at priority @p IDLEPRIO.
|
||||||
|
* - Change the main() thread priority to @p IDLEPRIO then enter
|
||||||
|
* an endless loop. In this scenario the @p main() thread acts as
|
||||||
|
* the idle thread.
|
||||||
|
* .
|
||||||
|
* @note Unless an idle thread is spawned the @p main() thread must not
|
||||||
|
* enter a sleep state.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
|
||||||
|
#define CH_NO_IDLE_THREAD FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Performance options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief OS optimization.
|
||||||
|
* @details If enabled then time efficient rather than space efficient code
|
||||||
|
* is used when two possible implementations exist.
|
||||||
|
*
|
||||||
|
* @note This is not related to the compiler optimization options.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
|
||||||
|
#define CH_OPTIMIZE_SPEED TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Subsystem options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads registry APIs.
|
||||||
|
* @details If enabled then the registry APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_REGISTRY TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads synchronization APIs.
|
||||||
|
* @details If enabled then the @p chThdWait() function is included in
|
||||||
|
* the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_WAITEXIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Semaphores APIs.
|
||||||
|
* @details If enabled then the Semaphores APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Semaphores queuing mode.
|
||||||
|
* @details If enabled then the threads are enqueued on semaphores by
|
||||||
|
* priority rather than in FIFO order.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Atomic semaphore API.
|
||||||
|
* @details If enabled then the semaphores the @p chSemSignalWait() API
|
||||||
|
* is included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMSW TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mutexes APIs.
|
||||||
|
* @details If enabled then the mutexes APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MUTEXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conditional Variables APIs.
|
||||||
|
* @details If enabled then the conditional variables APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MUTEXES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conditional Variables APIs with timeout.
|
||||||
|
* @details If enabled then the conditional variables APIs with timeout
|
||||||
|
* specification are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_CONDVARS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Events Flags APIs.
|
||||||
|
* @details If enabled then the event flags APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Events Flags APIs with timeout.
|
||||||
|
* @details If enabled then the events APIs with timeout specification
|
||||||
|
* are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_EVENTS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronous Messages APIs.
|
||||||
|
* @details If enabled then the synchronous messages APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronous Messages queuing mode.
|
||||||
|
* @details If enabled then messages are served by priority rather than in
|
||||||
|
* FIFO order.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_MESSAGES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mailboxes APIs.
|
||||||
|
* @details If enabled then the asynchronous messages (mailboxes) APIs are
|
||||||
|
* included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MAILBOXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I/O Queues APIs.
|
||||||
|
* @details If enabled then the I/O queues APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_QUEUES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Core Memory Manager APIs.
|
||||||
|
* @details If enabled then the core memory manager APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMCORE TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Heap Allocator APIs.
|
||||||
|
* @details If enabled then the memory heap allocator APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
|
||||||
|
* @p CH_USE_SEMAPHORES.
|
||||||
|
* @note Mutexes are recommended.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_HEAP TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief C-runtime allocator.
|
||||||
|
* @details If enabled the the heap allocator APIs just wrap the C-runtime
|
||||||
|
* @p malloc() and @p free() functions.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note Requires @p CH_USE_HEAP.
|
||||||
|
* @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
|
||||||
|
* appropriate documentation.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MALLOC_HEAP FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Memory Pools Allocator APIs.
|
||||||
|
* @details If enabled then the memory pools allocator APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMPOOLS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dynamic Threads APIs.
|
||||||
|
* @details If enabled then the dynamic threads creation APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_WAITEXIT.
|
||||||
|
* @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_DYNAMIC TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Debug options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, system state check.
|
||||||
|
* @details If enabled the correct call protocol for system APIs is checked
|
||||||
|
* at runtime.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_SYSTEM_STATE_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, parameters checks.
|
||||||
|
* @details If enabled then the checks on the API functions input
|
||||||
|
* parameters are activated.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, consistency checks.
|
||||||
|
* @details If enabled then all the assertions in the kernel code are
|
||||||
|
* activated. This includes consistency checks inside the kernel,
|
||||||
|
* runtime anomalies and port-defined checks.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_ASSERTS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, trace buffer.
|
||||||
|
* @details If enabled then the context switch circular trace buffer is
|
||||||
|
* activated.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_TRACE FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, stack checks.
|
||||||
|
* @details If enabled then a runtime stack check is performed.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note The stack check is performed in a architecture/port dependent way.
|
||||||
|
* It may not be implemented or some ports.
|
||||||
|
* @note The default failure mode is to halt the system with the global
|
||||||
|
* @p panic_msg variable set to @p NULL.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_STACK_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, stacks initialization.
|
||||||
|
* @details If enabled then the threads working area is filled with a byte
|
||||||
|
* value when a thread is created. This can be useful for the
|
||||||
|
* runtime measurement of the used stack.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_FILL_THREADS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, threads profiling.
|
||||||
|
* @details If enabled then a field is added to the @p Thread structure that
|
||||||
|
* counts the system ticks occurred while executing the thread.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note This debug option is defaulted to TRUE because it is required by
|
||||||
|
* some test cases into the test suite.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_THREADS_PROFILING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Kernel hooks
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads descriptor structure extension.
|
||||||
|
* @details User fields added to the end of the @p Thread structure.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_FIELDS \
|
||||||
|
/* Add threads custom fields here.*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads initialization hook.
|
||||||
|
* @details User initialization code added to the @p chThdInit() API.
|
||||||
|
*
|
||||||
|
* @note It is invoked from within @p chThdInit() and implicitly from all
|
||||||
|
* the threads creation APIs.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_INIT_HOOK(tp) { \
|
||||||
|
/* Add threads initialization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads finalization hook.
|
||||||
|
* @details User finalization code added to the @p chThdExit() API.
|
||||||
|
*
|
||||||
|
* @note It is inserted into lock zone.
|
||||||
|
* @note It is also invoked when the threads simply return in order to
|
||||||
|
* terminate.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_EXIT_HOOK(tp) { \
|
||||||
|
/* Add threads finalization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Context switch hook.
|
||||||
|
* @details This hook is invoked just before switching between threads.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
|
||||||
|
/* System halt code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Idle Loop hook.
|
||||||
|
* @details This hook is continuously invoked by the idle thread loop.
|
||||||
|
*/
|
||||||
|
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define IDLE_LOOP_HOOK() { \
|
||||||
|
/* Idle loop code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System tick event hook.
|
||||||
|
* @details This hook is invoked in the system tick handler immediately
|
||||||
|
* after processing the virtual timers queue.
|
||||||
|
*/
|
||||||
|
#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define SYSTEM_TICK_EVENT_HOOK() { \
|
||||||
|
/* System tick event code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System halt hook.
|
||||||
|
* @details This hook is invoked in case to a system halting error before
|
||||||
|
* the system is halted.
|
||||||
|
*/
|
||||||
|
#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define SYSTEM_HALT_HOOK() { \
|
||||||
|
/* System halt code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Port-specific settings (override port settings defaulted in chcore.h). */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#endif /* _CHCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,346 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/halconf.h
|
||||||
|
* @brief HAL configuration header.
|
||||||
|
* @details HAL configuration file, this file allows to enable or disable the
|
||||||
|
* various device drivers from your application. You may also use
|
||||||
|
* this file in order to override the device drivers default settings.
|
||||||
|
*
|
||||||
|
* @addtogroup HAL_CONF
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HALCONF_H_
|
||||||
|
#define _HALCONF_H_
|
||||||
|
|
||||||
|
#include "mcuconf.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the TM subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_TM) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_TM FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_PAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ADC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_ADC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the CAN subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_CAN FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the DAC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_DAC TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the EXT subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_EXT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the GPT subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_GPT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the I2C subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_I2C FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ICU subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_ICU FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MAC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_MAC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MMC_SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_MMC_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PWM subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_PWM FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the RTC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_RTC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SDC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SDC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SERIAL FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL over USB subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SERIAL_USB FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the UART subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_UART FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the USB subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_USB FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the DAC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_DAC TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* ADC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define ADC_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define ADC_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* CAN driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sleep mode related APIs inclusion switch.
|
||||||
|
*/
|
||||||
|
#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
|
||||||
|
#define CAN_USE_SLEEP_MODE TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* I2C driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the mutual exclusion APIs on the I2C bus.
|
||||||
|
*/
|
||||||
|
#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define I2C_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* MAC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables an event sources for incoming packets.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_USE_ZERO_COPY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables an event sources for incoming packets.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* MMC_SPI driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delays insertions.
|
||||||
|
* @details If enabled this options inserts delays into the MMC waiting
|
||||||
|
* routines releasing some extra CPU time for the threads with
|
||||||
|
* lower priority, this may slow down the driver a bit however.
|
||||||
|
* This option is recommended also if the SPI driver does not
|
||||||
|
* use a DMA channel and heavily loads the CPU.
|
||||||
|
*/
|
||||||
|
#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
|
#define MMC_NICE_WAITING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SDC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of initialization attempts before rejecting the card.
|
||||||
|
* @note Attempts are performed at 10mS intervals.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_INIT_RETRY 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Include support for MMC cards.
|
||||||
|
* @note MMC support is not yet implemented so this option must be kept
|
||||||
|
* at @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_MMC_SUPPORT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delays insertions.
|
||||||
|
* @details If enabled this options inserts delays into the MMC waiting
|
||||||
|
* routines releasing some extra CPU time for the threads with
|
||||||
|
* lower priority, this may slow down the driver a bit however.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_NICE_WAITING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SERIAL driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default bit rate.
|
||||||
|
* @details Configuration parameter, this is the baud rate selected for the
|
||||||
|
* default configuration.
|
||||||
|
*/
|
||||||
|
#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
|
||||||
|
#define SERIAL_DEFAULT_BITRATE 38400
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Serial buffers size.
|
||||||
|
* @details Configuration parameter, you can change the depth of the queue
|
||||||
|
* buffers depending on the requirements of your application.
|
||||||
|
* @note The default is 64 bytes for both the transmission and receive
|
||||||
|
* buffers.
|
||||||
|
*/
|
||||||
|
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define SERIAL_BUFFERS_SIZE 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SPI driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define SPI_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define SPI_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* DAC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define DAC_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define DAC_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _HALCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ch.h"
|
||||||
|
#include "hal.h"
|
||||||
|
|
||||||
|
#define NSAMPLES 255
|
||||||
|
|
||||||
|
const uint32_t sine_wave[NSAMPLES] = {
|
||||||
|
512 << 6, 524 << 6, 537 << 6, 549 << 6, 562 << 6, 574 << 6, 587 << 6, 599 << 6, 612 << 6, 624 << 6,
|
||||||
|
636 << 6, 649 << 6, 661 << 6, 673 << 6, 685 << 6, 696 << 6, 708 << 6, 720 << 6, 731 << 6, 743 << 6,
|
||||||
|
754 << 6, 765 << 6, 776 << 6, 786 << 6, 797 << 6, 807 << 6, 818 << 6, 828 << 6, 837 << 6, 847 << 6,
|
||||||
|
856 << 6, 866 << 6, 875 << 6, 883 << 6, 892 << 6, 900 << 6, 908 << 6, 916 << 6, 924 << 6, 931 << 6,
|
||||||
|
938 << 6, 945 << 6, 952 << 6, 958 << 6, 964 << 6, 970 << 6, 975 << 6, 981 << 6, 985 << 6, 990 << 6,
|
||||||
|
994 << 6, 998 << 6, 1002 << 6, 1006 << 6, 1009 << 6, 1012 << 6, 1014 << 6, 1016 << 6, 1018 << 6, 1020 << 6,
|
||||||
|
1021 << 6, 1022 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1022 << 6, 1021 << 6, 1019 << 6,
|
||||||
|
1017 << 6, 1015 << 6, 1013 << 6, 1010 << 6, 1007 << 6, 1004 << 6, 1000 << 6, 996 << 6, 992 << 6, 988 << 6,
|
||||||
|
983 << 6, 978 << 6, 973 << 6, 967 << 6, 961 << 6, 955 << 6, 948 << 6, 942 << 6, 935 << 6, 928 << 6,
|
||||||
|
920 << 6, 912 << 6, 904 << 6, 896 << 6, 888 << 6, 879 << 6, 870 << 6, 861 << 6, 852 << 6, 842 << 6,
|
||||||
|
832 << 6, 823 << 6, 812 << 6, 802 << 6, 792 << 6, 781 << 6, 770 << 6, 759 << 6, 748 << 6, 737 << 6,
|
||||||
|
725 << 6, 714 << 6, 702 << 6, 691 << 6, 679 << 6, 667 << 6, 655 << 6, 642 << 6, 630 << 6, 618 << 6,
|
||||||
|
606 << 6, 593 << 6, 581 << 6, 568 << 6, 556 << 6, 543 << 6, 530 << 6, 518 << 6, 505 << 6, 493 << 6,
|
||||||
|
480 << 6, 467 << 6, 455 << 6, 442 << 6, 430 << 6, 417 << 6, 405 << 6, 393 << 6, 381 << 6, 368 << 6,
|
||||||
|
356 << 6, 344 << 6, 332 << 6, 321 << 6, 309 << 6, 298 << 6, 286 << 6, 275 << 6, 264 << 6, 253 << 6,
|
||||||
|
242 << 6, 231 << 6, 221 << 6, 211 << 6, 200 << 6, 191 << 6, 181 << 6, 171 << 6, 162 << 6, 153 << 6,
|
||||||
|
144 << 6, 135 << 6, 127 << 6, 119 << 6, 111 << 6, 103 << 6, 95 << 6, 88 << 6, 81 << 6, 75 << 6,
|
||||||
|
68 << 6, 62 << 6, 56 << 6, 50 << 6, 45 << 6, 40 << 6, 35 << 6, 31 << 6, 27 << 6, 23 << 6,
|
||||||
|
19 << 6, 16 << 6, 13 << 6, 10 << 6, 8 << 6, 6 << 6, 4 << 6, 2 << 6, 1 << 6, 0 << 6,
|
||||||
|
0 << 6, 0 << 6, 0 << 6, 0 << 6, 1 << 6, 2 << 6, 3 << 6, 5 << 6, 7 << 6, 9 << 6,
|
||||||
|
11 << 6, 14 << 6, 17 << 6, 21 << 6, 25 << 6, 29 << 6, 33 << 6, 38 << 6, 42 << 6, 48 << 6,
|
||||||
|
53 << 6, 59 << 6, 65 << 6, 71 << 6, 78 << 6, 85 << 6, 92 << 6, 99 << 6, 107 << 6, 115 << 6,
|
||||||
|
123 << 6, 131 << 6, 140 << 6, 148 << 6, 157 << 6, 167 << 6, 176 << 6, 186 << 6, 195 << 6, 205 << 6,
|
||||||
|
216 << 6, 226 << 6, 237 << 6, 247 << 6, 258 << 6, 269 << 6, 280 << 6, 292 << 6, 303 << 6, 315 << 6,
|
||||||
|
327 << 6, 338 << 6, 350 << 6, 362 << 6, 374 << 6, 387 << 6, 399 << 6, 411 << 6, 424 << 6, 436 << 6,
|
||||||
|
449 << 6, 461 << 6, 474 << 6, 486 << 6, 499 << 6};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Red LEDs blinker thread, times are in milliseconds.
|
||||||
|
*/
|
||||||
|
static WORKING_AREA(waThread1, 128);
|
||||||
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
|
(void)arg;
|
||||||
|
chRegSetThreadName("blinker");
|
||||||
|
while (TRUE) {
|
||||||
|
palTogglePad(GPIO2, GPIO2_LED);
|
||||||
|
chThdSleepMilliseconds(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DAC conversion groups, with callbacks.
|
||||||
|
*/
|
||||||
|
static const DACConversionGroup dacconvgrp1 = {
|
||||||
|
1, /* Channels */
|
||||||
|
NULL, /* End of transfer callback */
|
||||||
|
NULL, /* Error callback */
|
||||||
|
true /*circular mode */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DAC config
|
||||||
|
*/
|
||||||
|
static const DACConfig daccfg1 = {
|
||||||
|
1000*NSAMPLES, /* Multiply the buffer size to the desired frequency in Hz */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application entry point.
|
||||||
|
*/
|
||||||
|
int main(void) {
|
||||||
|
/*
|
||||||
|
* System initializations.
|
||||||
|
* - HAL initialization, this also initializes the configured device drivers
|
||||||
|
* and performs the board-specific initializations.
|
||||||
|
* - Kernel initialization, the main() function becomes a thread and the
|
||||||
|
* RTOS is active.
|
||||||
|
*/
|
||||||
|
halInit();
|
||||||
|
chSysInit();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates the blinker thread.
|
||||||
|
*/
|
||||||
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Starting the DAC driver.
|
||||||
|
*/
|
||||||
|
dacStart(&DACD1, &daccfg1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sending the dac_buffer
|
||||||
|
*/
|
||||||
|
dacStartConversion(&DACD1, &dacconvgrp1, sine_wave, NSAMPLES);
|
||||||
|
|
||||||
|
while (TRUE) {
|
||||||
|
|
||||||
|
chThdSleepMilliseconds(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LPC43xx drivers configuration.
|
||||||
|
* The following settings override the default settings present in
|
||||||
|
* the various device driver implementation headers.
|
||||||
|
* Note that the settings for each driver only have effect if the driver
|
||||||
|
* is enabled in halconf.h.
|
||||||
|
*
|
||||||
|
* IRQ priorities:
|
||||||
|
* 7...0 Lowest...highest.
|
||||||
|
*
|
||||||
|
* LPC base clock sources:
|
||||||
|
* 0x00 32 kHz oscillator
|
||||||
|
* 0x01 IRC (default)
|
||||||
|
* 0x02 ENET_RX_CLK
|
||||||
|
* 0x03 ENET_TX_CLK
|
||||||
|
* 0x04 GP_CLKIN
|
||||||
|
* 0x06 Crystal oscillator
|
||||||
|
* 0x07 PLL0USB
|
||||||
|
* 0x08 PLL0AUDIO
|
||||||
|
* 0x09 PLL1
|
||||||
|
* 0x0C IDIVA
|
||||||
|
* 0x0D IDIVB
|
||||||
|
* 0x0E IDIVC
|
||||||
|
* 0x0F IDIVD
|
||||||
|
* 0x10 IDIVE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HAL driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_XTAL_ENABLE TRUE
|
||||||
|
#define LPC_PLL1_ENABLE TRUE
|
||||||
|
#define LPC_PLL1_MUL 17
|
||||||
|
#define LPC_PLL1_PREDIV 1
|
||||||
|
#define LPC_PLL1_POSTDIV_ENABLE FALSE
|
||||||
|
#define LPC_PLL1_POSTDIV 2
|
||||||
|
#define LPC_PLL0USB_ENABLE FALSE
|
||||||
|
#define LPC_PLL0AUDIO_ENABLE FALSE
|
||||||
|
#define LPC_FLASHLESS TRUE
|
||||||
|
|
||||||
|
/* Clock dividers */
|
||||||
|
#define LPC_IDIVA_ENABLE FALSE
|
||||||
|
#define LPC_IDIVA_DIV 1
|
||||||
|
#define LPC_IDIVA_SRC 0x09
|
||||||
|
#define LPC_IDIVB_ENABLE FALSE
|
||||||
|
#define LPC_IDIVB_DIV 2
|
||||||
|
#define LPC_IDIVB_SRC 0x09
|
||||||
|
#define LPC_IDIVC_ENABLE FALSE
|
||||||
|
#define LPC_IDIVC_DIV 3
|
||||||
|
#define LPC_IDIVC_SRC 0x09
|
||||||
|
#define LPC_IDIVD_ENABLE FALSE
|
||||||
|
#define LPC_IDIVD_DIV 1
|
||||||
|
#define LPC_IDIVD_SRC 0x09
|
||||||
|
#define LPC_IDIVE_ENABLE FALSE
|
||||||
|
#define LPC_IDIVE_DIV 1
|
||||||
|
#define LPC_IDIVE_SRC 0x09
|
||||||
|
|
||||||
|
/* Base clocks */
|
||||||
|
#define LPC_BASE_USB0_CLK_ENABLE FALSE /* Base clock for USB0. */
|
||||||
|
#define LPC_BASE_PERIPH_CLK_ENABLE TRUE /* Base clock for Cortex-M0SUB subsystem, SGPIO. */
|
||||||
|
#define LPC_BASE_PERIPH_CLK_SRC 0x09
|
||||||
|
#define LPC_BASE_USB1_CLK_ENABLE TRUE /* Base clock for USB1. */
|
||||||
|
#define LPC_BASE_USB1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SPIFI_CLK_ENABLE FALSE /* Base clock for SPIFI. */
|
||||||
|
#define LPC_BASE_SPIFI_CLK_SRC 0x0D
|
||||||
|
#define LPC_BASE_SPI_CLK_ENABLE TRUE /* Base clock for SPI. */
|
||||||
|
#define LPC_BASE_SPI_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_PHY_RX_CLK_ENABLE FALSE /* Base clock for Ethernet PHY Receive clock. */
|
||||||
|
#define LPC_BASE_PHY_RX_CLK_SRC 0x0E
|
||||||
|
#define LPC_BASE_PHY_TX_CLK_ENABLE FALSE /* Base clock for Ethernet PHY Transmit clock. */
|
||||||
|
#define LPC_BASE_PHY_TX_CLK_SRC 0x0E
|
||||||
|
#define LPC_BASE_APB1_CLK_ENABLE TRUE /* Base clock for APB1: I2C0, I2S, CAN1. */
|
||||||
|
#define LPC_BASE_APB1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_APB3_CLK_ENABLE TRUE /* Base clock for APB3: I2C1, DAC, ADC0, ADC1, CAN0. */
|
||||||
|
#define LPC_BASE_APB3_CLK_SRC 0x09
|
||||||
|
#define LPC_BASE_LCD_CLK_ENABLE FALSE /* Base clock for LCD. */
|
||||||
|
#define LPC_BASE_LCD_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SDIO_CLK_ENABLE FALSE /* Base clock for SD/MMC. */
|
||||||
|
#define LPC_BASE_SDIO_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SSP0_CLK_ENABLE TRUE /* Base clock for SSP0. */
|
||||||
|
#define LPC_BASE_SSP0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SSP1_CLK_ENABLE TRUE /* Base clock for SSP1. */
|
||||||
|
#define LPC_BASE_SSP1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART0_CLK_ENABLE TRUE /* Base clock for UART0. */
|
||||||
|
#define LPC_BASE_UART0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART1_CLK_ENABLE TRUE /* Base clock for UART1. */
|
||||||
|
#define LPC_BASE_UART1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART2_CLK_ENABLE TRUE /* Base clock for UART2. */
|
||||||
|
#define LPC_BASE_UART2_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART3_CLK_ENABLE TRUE /* Base clock for UART3. */
|
||||||
|
#define LPC_BASE_UART3_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_OUT_CLK_ENABLE FALSE /* Base clock for UART0. */
|
||||||
|
#define LPC_BASE_OUT_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_APLL_CLK_ENABLE FALSE /* Base clock for audio system. */
|
||||||
|
#define LPC_BASE_APLL_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_CGU_OUT0_CLK_ENABLE FALSE /* Base clock for CGU_OUT0 clock output. */
|
||||||
|
#define LPC_BASE_CGU_OUT0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_CGU_OUT1_CLK_ENABLE FALSE /* Base clock for CGU_OUT1 clock output. */
|
||||||
|
#define LPC_BASE_CGU_OUT1_CLK_SRC 0x01
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_GPT_USE_TIM0 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM1 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM2 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM3 FALSE
|
||||||
|
#define LPC_GPT_TIM0_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM1_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM2_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM3_IRQ_PRIORITY 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SERIAL driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_SERIAL_USE_UART0 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART1 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART2 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART3 TRUE
|
||||||
|
#define LPC_SERIAL_FIFO_PRELOAD 16
|
||||||
|
#define LPC_SERIAL_UART0_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART1_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART2_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART3_IRQ_PRIORITY 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_I2C_USE_I2C0 FALSE
|
||||||
|
#define LPC_I2C_USE_I2C1 FALSE
|
||||||
|
#define LPC_I2C_I2C0_IRQ_PRIORITY 3
|
||||||
|
#define LPC_I2C_I2C1_IRQ_PRIORITY 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SPI driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_SPI_USE_SSP0 FALSE
|
||||||
|
#define LPC_SPI_USE_SSP1 FALSE
|
||||||
|
#define LPC_SPI_SSP0_IRQ_PRIORITY 5
|
||||||
|
#define LPC_SPI_SSP1_IRQ_PRIORITY 5
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DAC driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_DAC_DMA_CHANNEL DMA_CHANNEL5
|
|
@ -0,0 +1,234 @@
|
||||||
|
##############################################################################
|
||||||
|
# Build global options
|
||||||
|
# NOTE: Can be overridden externally.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Compiler options here.
|
||||||
|
ifeq ($(USE_OPT),)
|
||||||
|
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_COPT),)
|
||||||
|
USE_COPT =
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C++ specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_CPPOPT),)
|
||||||
|
USE_CPPOPT = -fno-rtti
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want the linker to remove unused code and data
|
||||||
|
ifeq ($(USE_LINK_GC),)
|
||||||
|
USE_LINK_GC = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If enabled, this option allows to compile the application in THUMB mode.
|
||||||
|
ifeq ($(USE_THUMB),)
|
||||||
|
USE_THUMB = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want to see the full log while compiling.
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),)
|
||||||
|
USE_VERBOSE_COMPILE = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build global options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Architecture or project specific options
|
||||||
|
#
|
||||||
|
|
||||||
|
# Enables the use of FPU on Cortex-M4.
|
||||||
|
ifeq ($(USE_FPU),)
|
||||||
|
USE_FPU = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enables the use of Cortex-M4 by LPC43xx in LPC43xx.h.
|
||||||
|
ifeq ($(USE_CORE_M4),)
|
||||||
|
USE_CORE_M4 = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# LPC43xx boot select: ram, spifi_flash_debug, flash.
|
||||||
|
ifeq ($(LPC_BOOT_SELECT),)
|
||||||
|
LPC_BOOT_SELECT = ram
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Architecture or project specific options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Project, sources and paths
|
||||||
|
#
|
||||||
|
|
||||||
|
# Define project name here
|
||||||
|
PROJECT = ch
|
||||||
|
|
||||||
|
# Imported source files
|
||||||
|
CHIBIOS = ../../..
|
||||||
|
include $(CHIBIOS)/boards/NONSTANDARD_LPC4330_SBC/board.mk
|
||||||
|
include $(CHIBIOS)/os/hal/platforms/LPC43xx/platform.mk
|
||||||
|
include $(CHIBIOS)/os/hal/hal.mk
|
||||||
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/LPC43xx/port.mk
|
||||||
|
include $(CHIBIOS)/os/kernel/kernel.mk
|
||||||
|
include $(CHIBIOS)/test/test.mk
|
||||||
|
|
||||||
|
# Define linker script file here
|
||||||
|
LDSCRIPT= $(PORTLD)/LPC4330_RAM_DEBUG.ld
|
||||||
|
|
||||||
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CSRC = $(PORTSRC) \
|
||||||
|
$(KERNSRC) \
|
||||||
|
$(TESTSRC) \
|
||||||
|
$(HALSRC) \
|
||||||
|
$(PLATFORMSRC) \
|
||||||
|
$(BOARDSRC) \
|
||||||
|
$(CHIBIOS)/os/various/evtimer.c \
|
||||||
|
$(CHIBIOS)/os/various/syscalls.c \
|
||||||
|
$(CHIBIOS)/os/various/chprintf.c \
|
||||||
|
main.c
|
||||||
|
|
||||||
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACSRC =
|
||||||
|
|
||||||
|
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCPPSRC =
|
||||||
|
|
||||||
|
# List ASM source files here
|
||||||
|
ASMSRC = $(PORTASM)
|
||||||
|
|
||||||
|
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
||||||
|
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
||||||
|
$(CHIBIOS)/os/various
|
||||||
|
|
||||||
|
#
|
||||||
|
# Project, sources and paths
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Compiler settings
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = cortex-m4
|
||||||
|
|
||||||
|
#TRGT = arm-elf-
|
||||||
|
TRGT = arm-none-eabi-
|
||||||
|
CC = $(TRGT)gcc
|
||||||
|
CPPC = $(TRGT)g++
|
||||||
|
# Enable loading with g++ only if you need C++ runtime support.
|
||||||
|
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||||
|
# runtime support makes code size explode.
|
||||||
|
LD = $(TRGT)gcc
|
||||||
|
#LD = $(TRGT)g++
|
||||||
|
CP = $(TRGT)objcopy
|
||||||
|
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||||
|
OD = $(TRGT)objdump
|
||||||
|
HEX = $(CP) -O ihex
|
||||||
|
BIN = $(CP) -O binary
|
||||||
|
|
||||||
|
# ARM-specific options here
|
||||||
|
AOPT =
|
||||||
|
|
||||||
|
# THUMB-specific options here
|
||||||
|
TOPT = -mthumb -DTHUMB
|
||||||
|
|
||||||
|
# Define C warning options here
|
||||||
|
CWARN = -Wall -Wextra -Wstrict-prototypes
|
||||||
|
|
||||||
|
# Define C++ warning options here
|
||||||
|
CPPWARN = -Wall -Wextra
|
||||||
|
|
||||||
|
#
|
||||||
|
# Compiler settings
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of default section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all default C defines here, like -D_DEBUG=1
|
||||||
|
DDEFS = -DLPC43XX -D__NEWLIB__
|
||||||
|
|
||||||
|
# List all default ASM defines here, like -D_DEBUG=1
|
||||||
|
DADEFS =
|
||||||
|
|
||||||
|
# List all default directories to look for include files here
|
||||||
|
DINCDIR =
|
||||||
|
|
||||||
|
# List the default directory to look for the libraries here
|
||||||
|
DLIBDIR =
|
||||||
|
|
||||||
|
# List all default libraries here
|
||||||
|
DLIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of default section
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of user section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all user C define here, like -D_DEBUG=1
|
||||||
|
UDEFS =
|
||||||
|
|
||||||
|
# Define ASM defines here
|
||||||
|
UADEFS =
|
||||||
|
|
||||||
|
# List all user directories here
|
||||||
|
UINCDIR =
|
||||||
|
|
||||||
|
# List the user directory to look for the libraries here
|
||||||
|
ULIBDIR =
|
||||||
|
|
||||||
|
# List all user libraries here
|
||||||
|
ULIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of user defines
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
ifeq ($(USE_FPU),yes)
|
||||||
|
USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
||||||
|
DDEFS += -DCORTEX_USE_FPU=TRUE
|
||||||
|
else
|
||||||
|
DDEFS += -DCORTEX_USE_FPU=FALSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_CORE_M4),yes)
|
||||||
|
DDEFS += -DCORE_M4
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LPC_BOOT_SELECT), ram)
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x10000000
|
||||||
|
else
|
||||||
|
ifeq ($(LPC_BOOT_SELECT), spifi_flash_debug)
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x14000000
|
||||||
|
else
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x00000000
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
|
|
@ -0,0 +1,531 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/chconf.h
|
||||||
|
* @brief Configuration file template.
|
||||||
|
* @details A copy of this file must be placed in each project directory, it
|
||||||
|
* contains the application specific kernel settings.
|
||||||
|
*
|
||||||
|
* @addtogroup config
|
||||||
|
* @details Kernel related settings and hooks.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CHCONF_H_
|
||||||
|
#define _CHCONF_H_
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Kernel parameters and options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System tick frequency.
|
||||||
|
* @details Frequency of the system timer that drives the system ticks. This
|
||||||
|
* setting also defines the system tick time unit.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_FREQUENCY 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Round robin interval.
|
||||||
|
* @details This constant is the number of system ticks allowed for the
|
||||||
|
* threads before preemption occurs. Setting this value to zero
|
||||||
|
* disables the preemption for threads with equal priority and the
|
||||||
|
* round robin becomes cooperative. Note that higher priority
|
||||||
|
* threads can still preempt, the kernel is always preemptive.
|
||||||
|
*
|
||||||
|
* @note Disabling the round robin preemption makes the kernel more compact
|
||||||
|
* and generally faster.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
|
||||||
|
#define CH_TIME_QUANTUM 20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Managed RAM size.
|
||||||
|
* @details Size of the RAM area to be managed by the OS. If set to zero
|
||||||
|
* then the whole available RAM is used. The core memory is made
|
||||||
|
* available to the heap allocator and/or can be used directly through
|
||||||
|
* the simplified core memory allocator.
|
||||||
|
*
|
||||||
|
* @note In order to let the OS manage the whole RAM the linker script must
|
||||||
|
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||||
|
* @note Requires @p CH_USE_MEMCORE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_MEMCORE_SIZE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Idle thread automatic spawn suppression.
|
||||||
|
* @details When this option is activated the function @p chSysInit()
|
||||||
|
* does not spawn the idle thread automatically. The application has
|
||||||
|
* then the responsibility to do one of the following:
|
||||||
|
* - Spawn a custom idle thread at priority @p IDLEPRIO.
|
||||||
|
* - Change the main() thread priority to @p IDLEPRIO then enter
|
||||||
|
* an endless loop. In this scenario the @p main() thread acts as
|
||||||
|
* the idle thread.
|
||||||
|
* .
|
||||||
|
* @note Unless an idle thread is spawned the @p main() thread must not
|
||||||
|
* enter a sleep state.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
|
||||||
|
#define CH_NO_IDLE_THREAD FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Performance options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief OS optimization.
|
||||||
|
* @details If enabled then time efficient rather than space efficient code
|
||||||
|
* is used when two possible implementations exist.
|
||||||
|
*
|
||||||
|
* @note This is not related to the compiler optimization options.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
|
||||||
|
#define CH_OPTIMIZE_SPEED TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Subsystem options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads registry APIs.
|
||||||
|
* @details If enabled then the registry APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_REGISTRY TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads synchronization APIs.
|
||||||
|
* @details If enabled then the @p chThdWait() function is included in
|
||||||
|
* the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_WAITEXIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Semaphores APIs.
|
||||||
|
* @details If enabled then the Semaphores APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Semaphores queuing mode.
|
||||||
|
* @details If enabled then the threads are enqueued on semaphores by
|
||||||
|
* priority rather than in FIFO order.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Atomic semaphore API.
|
||||||
|
* @details If enabled then the semaphores the @p chSemSignalWait() API
|
||||||
|
* is included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMSW TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mutexes APIs.
|
||||||
|
* @details If enabled then the mutexes APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MUTEXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conditional Variables APIs.
|
||||||
|
* @details If enabled then the conditional variables APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MUTEXES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conditional Variables APIs with timeout.
|
||||||
|
* @details If enabled then the conditional variables APIs with timeout
|
||||||
|
* specification are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_CONDVARS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Events Flags APIs.
|
||||||
|
* @details If enabled then the event flags APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Events Flags APIs with timeout.
|
||||||
|
* @details If enabled then the events APIs with timeout specification
|
||||||
|
* are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_EVENTS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronous Messages APIs.
|
||||||
|
* @details If enabled then the synchronous messages APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronous Messages queuing mode.
|
||||||
|
* @details If enabled then messages are served by priority rather than in
|
||||||
|
* FIFO order.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_MESSAGES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mailboxes APIs.
|
||||||
|
* @details If enabled then the asynchronous messages (mailboxes) APIs are
|
||||||
|
* included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MAILBOXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I/O Queues APIs.
|
||||||
|
* @details If enabled then the I/O queues APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_QUEUES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Core Memory Manager APIs.
|
||||||
|
* @details If enabled then the core memory manager APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMCORE TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Heap Allocator APIs.
|
||||||
|
* @details If enabled then the memory heap allocator APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
|
||||||
|
* @p CH_USE_SEMAPHORES.
|
||||||
|
* @note Mutexes are recommended.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_HEAP TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief C-runtime allocator.
|
||||||
|
* @details If enabled the the heap allocator APIs just wrap the C-runtime
|
||||||
|
* @p malloc() and @p free() functions.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note Requires @p CH_USE_HEAP.
|
||||||
|
* @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
|
||||||
|
* appropriate documentation.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MALLOC_HEAP FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Memory Pools Allocator APIs.
|
||||||
|
* @details If enabled then the memory pools allocator APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMPOOLS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dynamic Threads APIs.
|
||||||
|
* @details If enabled then the dynamic threads creation APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_WAITEXIT.
|
||||||
|
* @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_DYNAMIC TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Debug options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, system state check.
|
||||||
|
* @details If enabled the correct call protocol for system APIs is checked
|
||||||
|
* at runtime.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_SYSTEM_STATE_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, parameters checks.
|
||||||
|
* @details If enabled then the checks on the API functions input
|
||||||
|
* parameters are activated.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, consistency checks.
|
||||||
|
* @details If enabled then all the assertions in the kernel code are
|
||||||
|
* activated. This includes consistency checks inside the kernel,
|
||||||
|
* runtime anomalies and port-defined checks.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_ASSERTS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, trace buffer.
|
||||||
|
* @details If enabled then the context switch circular trace buffer is
|
||||||
|
* activated.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_TRACE FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, stack checks.
|
||||||
|
* @details If enabled then a runtime stack check is performed.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note The stack check is performed in a architecture/port dependent way.
|
||||||
|
* It may not be implemented or some ports.
|
||||||
|
* @note The default failure mode is to halt the system with the global
|
||||||
|
* @p panic_msg variable set to @p NULL.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_STACK_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, stacks initialization.
|
||||||
|
* @details If enabled then the threads working area is filled with a byte
|
||||||
|
* value when a thread is created. This can be useful for the
|
||||||
|
* runtime measurement of the used stack.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_FILL_THREADS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, threads profiling.
|
||||||
|
* @details If enabled then a field is added to the @p Thread structure that
|
||||||
|
* counts the system ticks occurred while executing the thread.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note This debug option is defaulted to TRUE because it is required by
|
||||||
|
* some test cases into the test suite.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_THREADS_PROFILING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Kernel hooks
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads descriptor structure extension.
|
||||||
|
* @details User fields added to the end of the @p Thread structure.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_FIELDS \
|
||||||
|
/* Add threads custom fields here.*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads initialization hook.
|
||||||
|
* @details User initialization code added to the @p chThdInit() API.
|
||||||
|
*
|
||||||
|
* @note It is invoked from within @p chThdInit() and implicitly from all
|
||||||
|
* the threads creation APIs.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_INIT_HOOK(tp) { \
|
||||||
|
/* Add threads initialization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads finalization hook.
|
||||||
|
* @details User finalization code added to the @p chThdExit() API.
|
||||||
|
*
|
||||||
|
* @note It is inserted into lock zone.
|
||||||
|
* @note It is also invoked when the threads simply return in order to
|
||||||
|
* terminate.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_EXIT_HOOK(tp) { \
|
||||||
|
/* Add threads finalization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Context switch hook.
|
||||||
|
* @details This hook is invoked just before switching between threads.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
|
||||||
|
/* System halt code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Idle Loop hook.
|
||||||
|
* @details This hook is continuously invoked by the idle thread loop.
|
||||||
|
*/
|
||||||
|
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define IDLE_LOOP_HOOK() { \
|
||||||
|
/* Idle loop code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System tick event hook.
|
||||||
|
* @details This hook is invoked in the system tick handler immediately
|
||||||
|
* after processing the virtual timers queue.
|
||||||
|
*/
|
||||||
|
#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define SYSTEM_TICK_EVENT_HOOK() { \
|
||||||
|
/* System tick event code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System halt hook.
|
||||||
|
* @details This hook is invoked in case to a system halting error before
|
||||||
|
* the system is halted.
|
||||||
|
*/
|
||||||
|
#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define SYSTEM_HALT_HOOK() { \
|
||||||
|
/* System halt code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Port-specific settings (override port settings defaulted in chcore.h). */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#endif /* _CHCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,312 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/halconf.h
|
||||||
|
* @brief HAL configuration header.
|
||||||
|
* @details HAL configuration file, this file allows to enable or disable the
|
||||||
|
* various device drivers from your application. You may also use
|
||||||
|
* this file in order to override the device drivers default settings.
|
||||||
|
*
|
||||||
|
* @addtogroup HAL_CONF
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HALCONF_H_
|
||||||
|
#define _HALCONF_H_
|
||||||
|
|
||||||
|
#include "mcuconf.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the TM subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_TM) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_TM FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_PAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ADC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_ADC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the CAN subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_CAN FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the EXT subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_EXT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the GPT subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_GPT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the I2C subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_I2C FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ICU subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_ICU FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MAC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_MAC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MMC_SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_MMC_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PWM subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_PWM FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the RTC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_RTC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SDC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SDC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SERIAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL over USB subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SERIAL_USB FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the UART subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_UART FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the USB subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_USB FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* ADC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define ADC_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define ADC_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* CAN driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sleep mode related APIs inclusion switch.
|
||||||
|
*/
|
||||||
|
#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
|
||||||
|
#define CAN_USE_SLEEP_MODE TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* I2C driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the mutual exclusion APIs on the I2C bus.
|
||||||
|
*/
|
||||||
|
#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define I2C_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* MAC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables an event sources for incoming packets.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_USE_ZERO_COPY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables an event sources for incoming packets.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* MMC_SPI driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delays insertions.
|
||||||
|
* @details If enabled this options inserts delays into the MMC waiting
|
||||||
|
* routines releasing some extra CPU time for the threads with
|
||||||
|
* lower priority, this may slow down the driver a bit however.
|
||||||
|
* This option is recommended also if the SPI driver does not
|
||||||
|
* use a DMA channel and heavily loads the CPU.
|
||||||
|
*/
|
||||||
|
#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
|
#define MMC_NICE_WAITING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SDC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of initialization attempts before rejecting the card.
|
||||||
|
* @note Attempts are performed at 10mS intervals.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_INIT_RETRY 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Include support for MMC cards.
|
||||||
|
* @note MMC support is not yet implemented so this option must be kept
|
||||||
|
* at @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_MMC_SUPPORT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delays insertions.
|
||||||
|
* @details If enabled this options inserts delays into the MMC waiting
|
||||||
|
* routines releasing some extra CPU time for the threads with
|
||||||
|
* lower priority, this may slow down the driver a bit however.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_NICE_WAITING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SERIAL driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default bit rate.
|
||||||
|
* @details Configuration parameter, this is the baud rate selected for the
|
||||||
|
* default configuration.
|
||||||
|
*/
|
||||||
|
#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
|
||||||
|
#define SERIAL_DEFAULT_BITRATE 38400
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Serial buffers size.
|
||||||
|
* @details Configuration parameter, you can change the depth of the queue
|
||||||
|
* buffers depending on the requirements of your application.
|
||||||
|
* @note The default is 64 bytes for both the transmission and receive
|
||||||
|
* buffers.
|
||||||
|
*/
|
||||||
|
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define SERIAL_BUFFERS_SIZE 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SPI driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define SPI_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define SPI_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _HALCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ch.h"
|
||||||
|
#include "hal.h"
|
||||||
|
#include "chprintf.h"
|
||||||
|
|
||||||
|
#define MEM_SIZE 50
|
||||||
|
|
||||||
|
BaseSequentialStream * chp = (BaseSequentialStream *)&SD4;
|
||||||
|
|
||||||
|
uint32_t mem_src[MEM_SIZE];
|
||||||
|
uint32_t mem_dst[MEM_SIZE];
|
||||||
|
|
||||||
|
static void dma_mem_callback(void * dummy, uint32_t flags) {
|
||||||
|
(void)dummy;
|
||||||
|
(void)flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Red LEDs blinker thread, times are in milliseconds.
|
||||||
|
*/
|
||||||
|
static WORKING_AREA(waThread1, 128);
|
||||||
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
|
(void)arg;
|
||||||
|
chRegSetThreadName("blinker");
|
||||||
|
while (TRUE) {
|
||||||
|
palTogglePad(GPIO2, GPIO2_LED);
|
||||||
|
chThdSleepMilliseconds(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application entry point.
|
||||||
|
*/
|
||||||
|
int main(void) {
|
||||||
|
uint32_t i;
|
||||||
|
/*
|
||||||
|
* System initializations.
|
||||||
|
* - HAL initialization, this also initializes the configured device drivers
|
||||||
|
* and performs the board-specific initializations.
|
||||||
|
* - Kernel initialization, the main() function becomes a thread and the
|
||||||
|
* RTOS is active.
|
||||||
|
*/
|
||||||
|
halInit();
|
||||||
|
chSysInit();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates the blinker thread.
|
||||||
|
*/
|
||||||
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activates the SD driver 1.
|
||||||
|
*/
|
||||||
|
sdStart(&SD4, NULL); /* Default is 38400-8-N-1.*/
|
||||||
|
|
||||||
|
chprintf(chp, "Data before dma transfer.\r\n");
|
||||||
|
chprintf(chp, "source \t destination\r\n");
|
||||||
|
for (i = 0; i < MEM_SIZE; i++) {
|
||||||
|
mem_src[i] = i;
|
||||||
|
mem_dst[i] = 0;
|
||||||
|
chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dmaChannelAllocate(DMA_CHANNEL0, &dma_mem_callback, NULL);
|
||||||
|
dmaChannelSrcAddr(DMA_CHANNEL0, &mem_src[0]);
|
||||||
|
dmaChannelDstAddr(DMA_CHANNEL0, &mem_dst[0]);
|
||||||
|
dmaChannelControl(DMA_CHANNEL0, DMA_CTRL_TRANSFER_SIZE(MEM_SIZE) |
|
||||||
|
DMA_CTRL_SRC_BSIZE_16 |
|
||||||
|
DMA_CTRL_DST_BSIZE_16 |
|
||||||
|
DMA_CTRL_SRC_WIDTH_WORD |
|
||||||
|
DMA_CTRL_DST_WIDTH_WORD |
|
||||||
|
DMA_CTRL_SRC_AHBM0 |
|
||||||
|
DMA_CTRL_DST_AHBM0 |
|
||||||
|
DMA_CTRL_SRC_INC |
|
||||||
|
DMA_CTRL_DST_INC |
|
||||||
|
DMA_CTRL_INT);
|
||||||
|
|
||||||
|
dmaChannelConfig(DMA_CHANNEL0, DMA_CFG_CH_ENABLE |
|
||||||
|
DMA_CFG_FCTRL_M2M |
|
||||||
|
DMA_CFG_IE |
|
||||||
|
DMA_CFG_ITC);
|
||||||
|
|
||||||
|
chThdSleepMilliseconds(5000);
|
||||||
|
chprintf(chp, "Data after dma transfer.\r\n");
|
||||||
|
chprintf(chp, "source \t destination\r\n");
|
||||||
|
for (i = 0; i < MEM_SIZE; i++) {
|
||||||
|
chprintf(chp, "%x \t %x\r\n", mem_src[i], mem_dst[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MEM_SIZE; i++)
|
||||||
|
if (mem_src[i] != mem_dst[i])
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (i == MEM_SIZE)
|
||||||
|
chprintf(chp, "Data transfer ok.\r\n");
|
||||||
|
else
|
||||||
|
chprintf(chp, "Error.\r\n");
|
||||||
|
|
||||||
|
while (TRUE) {
|
||||||
|
|
||||||
|
chThdSleepMilliseconds(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LPC43xx drivers configuration.
|
||||||
|
* The following settings override the default settings present in
|
||||||
|
* the various device driver implementation headers.
|
||||||
|
* Note that the settings for each driver only have effect if the driver
|
||||||
|
* is enabled in halconf.h.
|
||||||
|
*
|
||||||
|
* IRQ priorities:
|
||||||
|
* 7...0 Lowest...highest.
|
||||||
|
*
|
||||||
|
* LPC base clock sources:
|
||||||
|
* 0x00 32 kHz oscillator
|
||||||
|
* 0x01 IRC (default)
|
||||||
|
* 0x02 ENET_RX_CLK
|
||||||
|
* 0x03 ENET_TX_CLK
|
||||||
|
* 0x04 GP_CLKIN
|
||||||
|
* 0x06 Crystal oscillator
|
||||||
|
* 0x07 PLL0USB
|
||||||
|
* 0x08 PLL0AUDIO
|
||||||
|
* 0x09 PLL1
|
||||||
|
* 0x0C IDIVA
|
||||||
|
* 0x0D IDIVB
|
||||||
|
* 0x0E IDIVC
|
||||||
|
* 0x0F IDIVD
|
||||||
|
* 0x10 IDIVE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HAL driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_XTAL_ENABLE TRUE
|
||||||
|
#define LPC_PLL1_ENABLE TRUE
|
||||||
|
#define LPC_PLL1_MUL 17
|
||||||
|
#define LPC_PLL1_PREDIV 1
|
||||||
|
#define LPC_PLL1_POSTDIV_ENABLE FALSE
|
||||||
|
#define LPC_PLL1_POSTDIV 2
|
||||||
|
#define LPC_PLL0USB_ENABLE FALSE
|
||||||
|
#define LPC_PLL0AUDIO_ENABLE FALSE
|
||||||
|
#define LPC_FLASHLESS TRUE
|
||||||
|
|
||||||
|
/* Clock dividers */
|
||||||
|
#define LPC_IDIVA_ENABLE FALSE
|
||||||
|
#define LPC_IDIVA_DIV 1
|
||||||
|
#define LPC_IDIVA_SRC 0x09
|
||||||
|
#define LPC_IDIVB_ENABLE FALSE
|
||||||
|
#define LPC_IDIVB_DIV 2
|
||||||
|
#define LPC_IDIVB_SRC 0x09
|
||||||
|
#define LPC_IDIVC_ENABLE FALSE
|
||||||
|
#define LPC_IDIVC_DIV 3
|
||||||
|
#define LPC_IDIVC_SRC 0x09
|
||||||
|
#define LPC_IDIVD_ENABLE FALSE
|
||||||
|
#define LPC_IDIVD_DIV 1
|
||||||
|
#define LPC_IDIVD_SRC 0x09
|
||||||
|
#define LPC_IDIVE_ENABLE FALSE
|
||||||
|
#define LPC_IDIVE_DIV 1
|
||||||
|
#define LPC_IDIVE_SRC 0x09
|
||||||
|
|
||||||
|
/* Base clocks */
|
||||||
|
#define LPC_BASE_USB0_CLK_ENABLE FALSE /* Base clock for USB0. */
|
||||||
|
#define LPC_BASE_PERIPH_CLK_ENABLE TRUE /* Base clock for Cortex-M0SUB subsystem, SGPIO. */
|
||||||
|
#define LPC_BASE_PERIPH_CLK_SRC 0x09
|
||||||
|
#define LPC_BASE_USB1_CLK_ENABLE TRUE /* Base clock for USB1. */
|
||||||
|
#define LPC_BASE_USB1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SPIFI_CLK_ENABLE FALSE /* Base clock for SPIFI. */
|
||||||
|
#define LPC_BASE_SPIFI_CLK_SRC 0x0D
|
||||||
|
#define LPC_BASE_SPI_CLK_ENABLE TRUE /* Base clock for SPI. */
|
||||||
|
#define LPC_BASE_SPI_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_PHY_RX_CLK_ENABLE FALSE /* Base clock for Ethernet PHY Receive clock. */
|
||||||
|
#define LPC_BASE_PHY_RX_CLK_SRC 0x0E
|
||||||
|
#define LPC_BASE_PHY_TX_CLK_ENABLE FALSE /* Base clock for Ethernet PHY Transmit clock. */
|
||||||
|
#define LPC_BASE_PHY_TX_CLK_SRC 0x0E
|
||||||
|
#define LPC_BASE_APB1_CLK_ENABLE TRUE /* Base clock for APB1: I2C0, I2S, CAN1. */
|
||||||
|
#define LPC_BASE_APB1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_APB3_CLK_ENABLE TRUE /* Base clock for APB3: I2C1, DAC, ADC0, ADC1, CAN0. */
|
||||||
|
#define LPC_BASE_APB3_CLK_SRC 0x09
|
||||||
|
#define LPC_BASE_LCD_CLK_ENABLE FALSE /* Base clock for LCD. */
|
||||||
|
#define LPC_BASE_LCD_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SDIO_CLK_ENABLE FALSE /* Base clock for SD/MMC. */
|
||||||
|
#define LPC_BASE_SDIO_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SSP0_CLK_ENABLE TRUE /* Base clock for SSP0. */
|
||||||
|
#define LPC_BASE_SSP0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SSP1_CLK_ENABLE TRUE /* Base clock for SSP1. */
|
||||||
|
#define LPC_BASE_SSP1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART0_CLK_ENABLE TRUE /* Base clock for UART0. */
|
||||||
|
#define LPC_BASE_UART0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART1_CLK_ENABLE TRUE /* Base clock for UART1. */
|
||||||
|
#define LPC_BASE_UART1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART2_CLK_ENABLE TRUE /* Base clock for UART2. */
|
||||||
|
#define LPC_BASE_UART2_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART3_CLK_ENABLE TRUE /* Base clock for UART3. */
|
||||||
|
#define LPC_BASE_UART3_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_OUT_CLK_ENABLE FALSE /* Base clock for UART0. */
|
||||||
|
#define LPC_BASE_OUT_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_APLL_CLK_ENABLE FALSE /* Base clock for audio system. */
|
||||||
|
#define LPC_BASE_APLL_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_CGU_OUT0_CLK_ENABLE FALSE /* Base clock for CGU_OUT0 clock output. */
|
||||||
|
#define LPC_BASE_CGU_OUT0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_CGU_OUT1_CLK_ENABLE FALSE /* Base clock for CGU_OUT1 clock output. */
|
||||||
|
#define LPC_BASE_CGU_OUT1_CLK_SRC 0x01
|
||||||
|
|
||||||
|
#define LPC_DMA_REQUIRED
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_GPT_USE_TIM0 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM1 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM2 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM3 FALSE
|
||||||
|
#define LPC_GPT_TIM0_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM1_IRQ_PRIORITY 6
|
||||||
|
#define LPC_GPT_TIM2_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM3_IRQ_PRIORITY 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SERIAL driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_SERIAL_USE_UART0 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART1 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART2 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART3 TRUE
|
||||||
|
#define LPC_SERIAL_FIFO_PRELOAD 16
|
||||||
|
#define LPC_SERIAL_UART0_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART1_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART2_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART3_IRQ_PRIORITY 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_I2C_USE_I2C0 FALSE
|
||||||
|
#define LPC_I2C_USE_I2C1 FALSE
|
||||||
|
#define LPC_I2C_I2C0_IRQ_PRIORITY 3
|
||||||
|
#define LPC_I2C_I2C1_IRQ_PRIORITY 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SPI driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_SPI_USE_SSP0 FALSE
|
||||||
|
#define LPC_SPI_USE_SSP1 FALSE
|
||||||
|
#define LPC_SPI_SSP0_IRQ_PRIORITY 5
|
||||||
|
#define LPC_SPI_SSP1_IRQ_PRIORITY 5
|
|
@ -0,0 +1,233 @@
|
||||||
|
##############################################################################
|
||||||
|
# Build global options
|
||||||
|
# NOTE: Can be overridden externally.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Compiler options here.
|
||||||
|
ifeq ($(USE_OPT),)
|
||||||
|
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_COPT),)
|
||||||
|
USE_COPT =
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C++ specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_CPPOPT),)
|
||||||
|
USE_CPPOPT = -fno-rtti
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want the linker to remove unused code and data
|
||||||
|
ifeq ($(USE_LINK_GC),)
|
||||||
|
USE_LINK_GC = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If enabled, this option allows to compile the application in THUMB mode.
|
||||||
|
ifeq ($(USE_THUMB),)
|
||||||
|
USE_THUMB = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want to see the full log while compiling.
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),)
|
||||||
|
USE_VERBOSE_COMPILE = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build global options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Architecture or project specific options
|
||||||
|
#
|
||||||
|
|
||||||
|
# Enables the use of FPU on Cortex-M4.
|
||||||
|
ifeq ($(USE_FPU),)
|
||||||
|
USE_FPU = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enables the use of Cortex-M4 by LPC43xx in LPC43xx.h.
|
||||||
|
ifeq ($(USE_CORE_M4),)
|
||||||
|
USE_CORE_M4 = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# LPC43xx boot select: ram, spifi_flash_debug, flash.
|
||||||
|
ifeq ($(LPC_BOOT_SELECT),)
|
||||||
|
LPC_BOOT_SELECT = ram
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Architecture or project specific options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Project, sources and paths
|
||||||
|
#
|
||||||
|
|
||||||
|
# Define project name here
|
||||||
|
PROJECT = ch
|
||||||
|
|
||||||
|
# Imported source files
|
||||||
|
CHIBIOS = ../../..
|
||||||
|
include $(CHIBIOS)/boards/NONSTANDARD_LPC4330_SBC/board.mk
|
||||||
|
include $(CHIBIOS)/os/hal/platforms/LPC43xx/platform.mk
|
||||||
|
include $(CHIBIOS)/os/hal/hal.mk
|
||||||
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/LPC43xx/port.mk
|
||||||
|
include $(CHIBIOS)/os/kernel/kernel.mk
|
||||||
|
include $(CHIBIOS)/test/test.mk
|
||||||
|
|
||||||
|
# Define linker script file here
|
||||||
|
LDSCRIPT= $(PORTLD)/LPC4330_RAM_DEBUG.ld
|
||||||
|
|
||||||
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CSRC = $(PORTSRC) \
|
||||||
|
$(KERNSRC) \
|
||||||
|
$(TESTSRC) \
|
||||||
|
$(HALSRC) \
|
||||||
|
$(PLATFORMSRC) \
|
||||||
|
$(BOARDSRC) \
|
||||||
|
$(CHIBIOS)/os/various/evtimer.c \
|
||||||
|
$(CHIBIOS)/os/various/syscalls.c \
|
||||||
|
main.c
|
||||||
|
|
||||||
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACSRC =
|
||||||
|
|
||||||
|
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCPPSRC =
|
||||||
|
|
||||||
|
# List ASM source files here
|
||||||
|
ASMSRC = $(PORTASM)
|
||||||
|
|
||||||
|
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
||||||
|
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
||||||
|
$(CHIBIOS)/os/various
|
||||||
|
|
||||||
|
#
|
||||||
|
# Project, sources and paths
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Compiler settings
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = cortex-m4
|
||||||
|
|
||||||
|
#TRGT = arm-elf-
|
||||||
|
TRGT = arm-none-eabi-
|
||||||
|
CC = $(TRGT)gcc
|
||||||
|
CPPC = $(TRGT)g++
|
||||||
|
# Enable loading with g++ only if you need C++ runtime support.
|
||||||
|
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||||
|
# runtime support makes code size explode.
|
||||||
|
LD = $(TRGT)gcc
|
||||||
|
#LD = $(TRGT)g++
|
||||||
|
CP = $(TRGT)objcopy
|
||||||
|
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||||
|
OD = $(TRGT)objdump
|
||||||
|
HEX = $(CP) -O ihex
|
||||||
|
BIN = $(CP) -O binary
|
||||||
|
|
||||||
|
# ARM-specific options here
|
||||||
|
AOPT =
|
||||||
|
|
||||||
|
# THUMB-specific options here
|
||||||
|
TOPT = -mthumb -DTHUMB
|
||||||
|
|
||||||
|
# Define C warning options here
|
||||||
|
CWARN = -Wall -Wextra -Wstrict-prototypes
|
||||||
|
|
||||||
|
# Define C++ warning options here
|
||||||
|
CPPWARN = -Wall -Wextra
|
||||||
|
|
||||||
|
#
|
||||||
|
# Compiler settings
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of default section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all default C defines here, like -D_DEBUG=1
|
||||||
|
DDEFS = -D__NEWLIB__
|
||||||
|
|
||||||
|
# List all default ASM defines here, like -D_DEBUG=1
|
||||||
|
DADEFS =
|
||||||
|
|
||||||
|
# List all default directories to look for include files here
|
||||||
|
DINCDIR =
|
||||||
|
|
||||||
|
# List the default directory to look for the libraries here
|
||||||
|
DLIBDIR =
|
||||||
|
|
||||||
|
# List all default libraries here
|
||||||
|
DLIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of default section
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of user section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all user C define here, like -D_DEBUG=1
|
||||||
|
UDEFS =
|
||||||
|
|
||||||
|
# Define ASM defines here
|
||||||
|
UADEFS =
|
||||||
|
|
||||||
|
# List all user directories here
|
||||||
|
UINCDIR =
|
||||||
|
|
||||||
|
# List the user directory to look for the libraries here
|
||||||
|
ULIBDIR =
|
||||||
|
|
||||||
|
# List all user libraries here
|
||||||
|
ULIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of user defines
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
ifeq ($(USE_FPU),yes)
|
||||||
|
USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
||||||
|
DDEFS += -DCORTEX_USE_FPU=TRUE
|
||||||
|
else
|
||||||
|
DDEFS += -DCORTEX_USE_FPU=FALSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_CORE_M4),yes)
|
||||||
|
DDEFS += -DCORE_M4
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LPC_BOOT_SELECT), ram)
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x10000000
|
||||||
|
else
|
||||||
|
ifeq ($(LPC_BOOT_SELECT), spifi_flash_debug)
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x14000000
|
||||||
|
else
|
||||||
|
DDEFS += -DCORTEX_VTOR_INIT=0x00000000
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
|
|
@ -0,0 +1,531 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/chconf.h
|
||||||
|
* @brief Configuration file template.
|
||||||
|
* @details A copy of this file must be placed in each project directory, it
|
||||||
|
* contains the application specific kernel settings.
|
||||||
|
*
|
||||||
|
* @addtogroup config
|
||||||
|
* @details Kernel related settings and hooks.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CHCONF_H_
|
||||||
|
#define _CHCONF_H_
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Kernel parameters and options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System tick frequency.
|
||||||
|
* @details Frequency of the system timer that drives the system ticks. This
|
||||||
|
* setting also defines the system tick time unit.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_FREQUENCY 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Round robin interval.
|
||||||
|
* @details This constant is the number of system ticks allowed for the
|
||||||
|
* threads before preemption occurs. Setting this value to zero
|
||||||
|
* disables the preemption for threads with equal priority and the
|
||||||
|
* round robin becomes cooperative. Note that higher priority
|
||||||
|
* threads can still preempt, the kernel is always preemptive.
|
||||||
|
*
|
||||||
|
* @note Disabling the round robin preemption makes the kernel more compact
|
||||||
|
* and generally faster.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
|
||||||
|
#define CH_TIME_QUANTUM 20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Managed RAM size.
|
||||||
|
* @details Size of the RAM area to be managed by the OS. If set to zero
|
||||||
|
* then the whole available RAM is used. The core memory is made
|
||||||
|
* available to the heap allocator and/or can be used directly through
|
||||||
|
* the simplified core memory allocator.
|
||||||
|
*
|
||||||
|
* @note In order to let the OS manage the whole RAM the linker script must
|
||||||
|
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||||
|
* @note Requires @p CH_USE_MEMCORE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_MEMCORE_SIZE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Idle thread automatic spawn suppression.
|
||||||
|
* @details When this option is activated the function @p chSysInit()
|
||||||
|
* does not spawn the idle thread automatically. The application has
|
||||||
|
* then the responsibility to do one of the following:
|
||||||
|
* - Spawn a custom idle thread at priority @p IDLEPRIO.
|
||||||
|
* - Change the main() thread priority to @p IDLEPRIO then enter
|
||||||
|
* an endless loop. In this scenario the @p main() thread acts as
|
||||||
|
* the idle thread.
|
||||||
|
* .
|
||||||
|
* @note Unless an idle thread is spawned the @p main() thread must not
|
||||||
|
* enter a sleep state.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
|
||||||
|
#define CH_NO_IDLE_THREAD FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Performance options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief OS optimization.
|
||||||
|
* @details If enabled then time efficient rather than space efficient code
|
||||||
|
* is used when two possible implementations exist.
|
||||||
|
*
|
||||||
|
* @note This is not related to the compiler optimization options.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
|
||||||
|
#define CH_OPTIMIZE_SPEED TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Subsystem options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads registry APIs.
|
||||||
|
* @details If enabled then the registry APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_REGISTRY TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads synchronization APIs.
|
||||||
|
* @details If enabled then the @p chThdWait() function is included in
|
||||||
|
* the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_WAITEXIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Semaphores APIs.
|
||||||
|
* @details If enabled then the Semaphores APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Semaphores queuing mode.
|
||||||
|
* @details If enabled then the threads are enqueued on semaphores by
|
||||||
|
* priority rather than in FIFO order.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Atomic semaphore API.
|
||||||
|
* @details If enabled then the semaphores the @p chSemSignalWait() API
|
||||||
|
* is included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMSW TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mutexes APIs.
|
||||||
|
* @details If enabled then the mutexes APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MUTEXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conditional Variables APIs.
|
||||||
|
* @details If enabled then the conditional variables APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MUTEXES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conditional Variables APIs with timeout.
|
||||||
|
* @details If enabled then the conditional variables APIs with timeout
|
||||||
|
* specification are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_CONDVARS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Events Flags APIs.
|
||||||
|
* @details If enabled then the event flags APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Events Flags APIs with timeout.
|
||||||
|
* @details If enabled then the events APIs with timeout specification
|
||||||
|
* are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_EVENTS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronous Messages APIs.
|
||||||
|
* @details If enabled then the synchronous messages APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronous Messages queuing mode.
|
||||||
|
* @details If enabled then messages are served by priority rather than in
|
||||||
|
* FIFO order.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_MESSAGES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mailboxes APIs.
|
||||||
|
* @details If enabled then the asynchronous messages (mailboxes) APIs are
|
||||||
|
* included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MAILBOXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I/O Queues APIs.
|
||||||
|
* @details If enabled then the I/O queues APIs are included in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_QUEUES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Core Memory Manager APIs.
|
||||||
|
* @details If enabled then the core memory manager APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMCORE TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Heap Allocator APIs.
|
||||||
|
* @details If enabled then the memory heap allocator APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
|
||||||
|
* @p CH_USE_SEMAPHORES.
|
||||||
|
* @note Mutexes are recommended.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_HEAP TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief C-runtime allocator.
|
||||||
|
* @details If enabled the the heap allocator APIs just wrap the C-runtime
|
||||||
|
* @p malloc() and @p free() functions.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note Requires @p CH_USE_HEAP.
|
||||||
|
* @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
|
||||||
|
* appropriate documentation.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MALLOC_HEAP FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Memory Pools Allocator APIs.
|
||||||
|
* @details If enabled then the memory pools allocator APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMPOOLS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dynamic Threads APIs.
|
||||||
|
* @details If enabled then the dynamic threads creation APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_WAITEXIT.
|
||||||
|
* @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_DYNAMIC TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Debug options
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, system state check.
|
||||||
|
* @details If enabled the correct call protocol for system APIs is checked
|
||||||
|
* at runtime.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_SYSTEM_STATE_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, parameters checks.
|
||||||
|
* @details If enabled then the checks on the API functions input
|
||||||
|
* parameters are activated.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, consistency checks.
|
||||||
|
* @details If enabled then all the assertions in the kernel code are
|
||||||
|
* activated. This includes consistency checks inside the kernel,
|
||||||
|
* runtime anomalies and port-defined checks.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_ASSERTS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, trace buffer.
|
||||||
|
* @details If enabled then the context switch circular trace buffer is
|
||||||
|
* activated.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_TRACE FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, stack checks.
|
||||||
|
* @details If enabled then a runtime stack check is performed.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note The stack check is performed in a architecture/port dependent way.
|
||||||
|
* It may not be implemented or some ports.
|
||||||
|
* @note The default failure mode is to halt the system with the global
|
||||||
|
* @p panic_msg variable set to @p NULL.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_STACK_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, stacks initialization.
|
||||||
|
* @details If enabled then the threads working area is filled with a byte
|
||||||
|
* value when a thread is created. This can be useful for the
|
||||||
|
* runtime measurement of the used stack.
|
||||||
|
*
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_FILL_THREADS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Debug option, threads profiling.
|
||||||
|
* @details If enabled then a field is added to the @p Thread structure that
|
||||||
|
* counts the system ticks occurred while executing the thread.
|
||||||
|
*
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note This debug option is defaulted to TRUE because it is required by
|
||||||
|
* some test cases into the test suite.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_THREADS_PROFILING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/**
|
||||||
|
* @name Kernel hooks
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads descriptor structure extension.
|
||||||
|
* @details User fields added to the end of the @p Thread structure.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_FIELDS \
|
||||||
|
/* Add threads custom fields here.*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads initialization hook.
|
||||||
|
* @details User initialization code added to the @p chThdInit() API.
|
||||||
|
*
|
||||||
|
* @note It is invoked from within @p chThdInit() and implicitly from all
|
||||||
|
* the threads creation APIs.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_INIT_HOOK(tp) { \
|
||||||
|
/* Add threads initialization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Threads finalization hook.
|
||||||
|
* @details User finalization code added to the @p chThdExit() API.
|
||||||
|
*
|
||||||
|
* @note It is inserted into lock zone.
|
||||||
|
* @note It is also invoked when the threads simply return in order to
|
||||||
|
* terminate.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_EXIT_HOOK(tp) { \
|
||||||
|
/* Add threads finalization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Context switch hook.
|
||||||
|
* @details This hook is invoked just before switching between threads.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
|
||||||
|
/* System halt code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Idle Loop hook.
|
||||||
|
* @details This hook is continuously invoked by the idle thread loop.
|
||||||
|
*/
|
||||||
|
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define IDLE_LOOP_HOOK() { \
|
||||||
|
/* Idle loop code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System tick event hook.
|
||||||
|
* @details This hook is invoked in the system tick handler immediately
|
||||||
|
* after processing the virtual timers queue.
|
||||||
|
*/
|
||||||
|
#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define SYSTEM_TICK_EVENT_HOOK() { \
|
||||||
|
/* System tick event code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System halt hook.
|
||||||
|
* @details This hook is invoked in case to a system halting error before
|
||||||
|
* the system is halted.
|
||||||
|
*/
|
||||||
|
#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define SYSTEM_HALT_HOOK() { \
|
||||||
|
/* System halt code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Port-specific settings (override port settings defaulted in chcore.h). */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#endif /* _CHCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,312 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/halconf.h
|
||||||
|
* @brief HAL configuration header.
|
||||||
|
* @details HAL configuration file, this file allows to enable or disable the
|
||||||
|
* various device drivers from your application. You may also use
|
||||||
|
* this file in order to override the device drivers default settings.
|
||||||
|
*
|
||||||
|
* @addtogroup HAL_CONF
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HALCONF_H_
|
||||||
|
#define _HALCONF_H_
|
||||||
|
|
||||||
|
#include "mcuconf.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the TM subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_TM) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_TM FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_PAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ADC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_ADC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the CAN subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_CAN FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the EXT subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_EXT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the GPT subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_GPT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the I2C subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_I2C FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ICU subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_ICU FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MAC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_MAC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MMC_SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_MMC_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PWM subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_PWM FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the RTC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_RTC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SDC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SDC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SERIAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL over USB subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SERIAL_USB FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the UART subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_UART FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the USB subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
|
||||||
|
#define HAL_USE_USB FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* ADC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define ADC_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define ADC_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* CAN driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sleep mode related APIs inclusion switch.
|
||||||
|
*/
|
||||||
|
#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
|
||||||
|
#define CAN_USE_SLEEP_MODE TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* I2C driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the mutual exclusion APIs on the I2C bus.
|
||||||
|
*/
|
||||||
|
#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define I2C_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* MAC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables an event sources for incoming packets.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_USE_ZERO_COPY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables an event sources for incoming packets.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* MMC_SPI driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delays insertions.
|
||||||
|
* @details If enabled this options inserts delays into the MMC waiting
|
||||||
|
* routines releasing some extra CPU time for the threads with
|
||||||
|
* lower priority, this may slow down the driver a bit however.
|
||||||
|
* This option is recommended also if the SPI driver does not
|
||||||
|
* use a DMA channel and heavily loads the CPU.
|
||||||
|
*/
|
||||||
|
#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
|
#define MMC_NICE_WAITING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SDC driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of initialization attempts before rejecting the card.
|
||||||
|
* @note Attempts are performed at 10mS intervals.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_INIT_RETRY 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Include support for MMC cards.
|
||||||
|
* @note MMC support is not yet implemented so this option must be kept
|
||||||
|
* at @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_MMC_SUPPORT FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delays insertions.
|
||||||
|
* @details If enabled this options inserts delays into the MMC waiting
|
||||||
|
* routines releasing some extra CPU time for the threads with
|
||||||
|
* lower priority, this may slow down the driver a bit however.
|
||||||
|
*/
|
||||||
|
#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
|
#define SDC_NICE_WAITING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SERIAL driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default bit rate.
|
||||||
|
* @details Configuration parameter, this is the baud rate selected for the
|
||||||
|
* default configuration.
|
||||||
|
*/
|
||||||
|
#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
|
||||||
|
#define SERIAL_DEFAULT_BITRATE 38400
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Serial buffers size.
|
||||||
|
* @details Configuration parameter, you can change the depth of the queue
|
||||||
|
* buffers depending on the requirements of your application.
|
||||||
|
* @note The default is 64 bytes for both the transmission and receive
|
||||||
|
* buffers.
|
||||||
|
*/
|
||||||
|
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define SERIAL_BUFFERS_SIZE 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* SPI driver related settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables synchronous APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
|
||||||
|
#define SPI_USE_WAIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
|
||||||
|
* @note Disabling this option saves both code and data space.
|
||||||
|
*/
|
||||||
|
#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||||
|
#define SPI_USE_MUTUAL_EXCLUSION TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _HALCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,324 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "ch.h"
|
||||||
|
#include "hal.h"
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Configurable settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef RANDOMIZE
|
||||||
|
#define RANDOMIZE FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ITERATIONS
|
||||||
|
#define ITERATIONS 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NUM_THREADS
|
||||||
|
#define NUM_THREADS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAILBOX_SIZE
|
||||||
|
#define MAILBOX_SIZE 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Test related code. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#define MSG_SEND_LEFT 0
|
||||||
|
#define MSG_SEND_RIGHT 1
|
||||||
|
|
||||||
|
static bool_t saturated;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mailboxes and buffers.
|
||||||
|
*/
|
||||||
|
static Mailbox mb[NUM_THREADS];
|
||||||
|
static msg_t b[NUM_THREADS][MAILBOX_SIZE];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test worker threads.
|
||||||
|
*/
|
||||||
|
static WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
|
||||||
|
static msg_t WorkerThread(void *arg) {
|
||||||
|
static volatile unsigned x = 0;
|
||||||
|
static unsigned cnt = 0;
|
||||||
|
unsigned me = (unsigned)arg;
|
||||||
|
unsigned target;
|
||||||
|
unsigned r;
|
||||||
|
msg_t msg;
|
||||||
|
|
||||||
|
chRegSetThreadName("worker");
|
||||||
|
|
||||||
|
/* Work loop.*/
|
||||||
|
while (TRUE) {
|
||||||
|
/* Waiting for a message.*/
|
||||||
|
chMBFetch(&mb[me], &msg, TIME_INFINITE);
|
||||||
|
|
||||||
|
#if RANDOMIZE
|
||||||
|
/* Pseudo-random delay.*/
|
||||||
|
{
|
||||||
|
chSysLock();
|
||||||
|
r = rand() & 15;
|
||||||
|
chSysUnlock();
|
||||||
|
while (r--)
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* Fixed delay.*/
|
||||||
|
{
|
||||||
|
r = me >> 4;
|
||||||
|
while (r--)
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Deciding in which direction to re-send the message.*/
|
||||||
|
if (msg == MSG_SEND_LEFT)
|
||||||
|
target = me - 1;
|
||||||
|
else
|
||||||
|
target = me + 1;
|
||||||
|
|
||||||
|
if (target < NUM_THREADS) {
|
||||||
|
/* If this thread is not at the end of a chain re-sending the message,
|
||||||
|
note this check works because the variable target is unsigned.*/
|
||||||
|
msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
|
||||||
|
if (msg != RDY_OK)
|
||||||
|
saturated = TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Provides a visual feedback about the system.*/
|
||||||
|
if (++cnt >= 500) {
|
||||||
|
cnt = 0;
|
||||||
|
palTogglePad(GPIO2, GPIO2_LED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT1 callback.
|
||||||
|
*/
|
||||||
|
static void gpt1cb(GPTDriver *gptp) {
|
||||||
|
msg_t msg;
|
||||||
|
|
||||||
|
(void)gptp;
|
||||||
|
chSysLockFromIsr();
|
||||||
|
msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
|
||||||
|
if (msg != RDY_OK)
|
||||||
|
saturated = TRUE;
|
||||||
|
chSysUnlockFromIsr();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT2 callback.
|
||||||
|
*/
|
||||||
|
static void gpt2cb(GPTDriver *gptp) {
|
||||||
|
msg_t msg;
|
||||||
|
|
||||||
|
(void)gptp;
|
||||||
|
chSysLockFromIsr();
|
||||||
|
msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
|
||||||
|
if (msg != RDY_OK)
|
||||||
|
saturated = TRUE;
|
||||||
|
chSysUnlockFromIsr();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT1 configuration.
|
||||||
|
*/
|
||||||
|
static const GPTConfig gpt1cfg = {
|
||||||
|
1000000, /* 1MHz timer clock.*/
|
||||||
|
gpt1cb /* Timer callback.*/
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT2 configuration.
|
||||||
|
*/
|
||||||
|
static const GPTConfig gpt2cfg = {
|
||||||
|
1000000, /* 1MHz timer clock.*/
|
||||||
|
gpt2cb /* Timer callback.*/
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Generic demo code. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
static void print(char *p) {
|
||||||
|
|
||||||
|
while (*p) {
|
||||||
|
chSequentialStreamPut(&SD4, *p++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void println(char *p) {
|
||||||
|
|
||||||
|
while (*p) {
|
||||||
|
chSequentialStreamPut(&SD4, *p++);
|
||||||
|
}
|
||||||
|
chSequentialStreamWrite(&SD4, (uint8_t *)"\r\n", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void printn(uint32_t n) {
|
||||||
|
char buf[16], *p;
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
chSequentialStreamPut(&SD4, '0');
|
||||||
|
else {
|
||||||
|
p = buf;
|
||||||
|
while (n)
|
||||||
|
*p++ = (n % 10) + '0', n /= 10;
|
||||||
|
while (p > buf)
|
||||||
|
chSequentialStreamPut(&SD4, *--p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application entry point.
|
||||||
|
*/
|
||||||
|
int main(void) {
|
||||||
|
unsigned i;
|
||||||
|
gptcnt_t interval, threshold, worst;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System initializations.
|
||||||
|
* - HAL initialization, this also initializes the configured device drivers
|
||||||
|
* and performs the board-specific initializations.
|
||||||
|
* - Kernel initialization, the main() function becomes a thread and the
|
||||||
|
* RTOS is active.
|
||||||
|
*/
|
||||||
|
halInit();
|
||||||
|
chSysInit();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prepares the Serial driver 2 and GPT drivers 1 and 2.
|
||||||
|
*/
|
||||||
|
sdStart(&SD4, NULL); /* Default is 38400-8-N-1.*/
|
||||||
|
gptStart(&GPTD1, &gpt1cfg);
|
||||||
|
gptStart(&GPTD2, &gpt2cfg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initializes the mailboxes and creates the worker threads.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < NUM_THREADS; i++) {
|
||||||
|
chMBInit(&mb[i], b[i], MAILBOX_SIZE);
|
||||||
|
chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
|
||||||
|
NORMALPRIO - 20, WorkerThread, (void *)i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test procedure.
|
||||||
|
*/
|
||||||
|
println("");
|
||||||
|
println("*** ChibiOS/RT IRQ-STORM long duration test");
|
||||||
|
println("***");
|
||||||
|
print("*** Kernel: ");
|
||||||
|
println(CH_KERNEL_VERSION);
|
||||||
|
#ifdef CH_COMPILER_NAME
|
||||||
|
print("*** Compiler: ");
|
||||||
|
println(CH_COMPILER_NAME);
|
||||||
|
#endif
|
||||||
|
print("*** Architecture: ");
|
||||||
|
println(CH_ARCHITECTURE_NAME);
|
||||||
|
#ifdef CH_CORE_VARIANT_NAME
|
||||||
|
print("*** Core Variant: ");
|
||||||
|
println(CH_CORE_VARIANT_NAME);
|
||||||
|
#endif
|
||||||
|
#ifdef CH_PORT_INFO
|
||||||
|
print("*** Port Info: ");
|
||||||
|
println(CH_PORT_INFO);
|
||||||
|
#endif
|
||||||
|
#ifdef PLATFORM_NAME
|
||||||
|
print("*** Platform: ");
|
||||||
|
println(PLATFORM_NAME);
|
||||||
|
#endif
|
||||||
|
#ifdef BOARD_NAME
|
||||||
|
print("*** Test Board: ");
|
||||||
|
println(BOARD_NAME);
|
||||||
|
#endif
|
||||||
|
println("***");
|
||||||
|
print("*** System Clock: ");
|
||||||
|
printn(LPC_BASE_M4_CLK);
|
||||||
|
println("");
|
||||||
|
print("*** Iterations: ");
|
||||||
|
printn(ITERATIONS);
|
||||||
|
println("");
|
||||||
|
print("*** Randomize: ");
|
||||||
|
printn(RANDOMIZE);
|
||||||
|
println("");
|
||||||
|
print("*** Threads: ");
|
||||||
|
printn(NUM_THREADS);
|
||||||
|
println("");
|
||||||
|
print("*** Mailbox size: ");
|
||||||
|
printn(MAILBOX_SIZE);
|
||||||
|
println("");
|
||||||
|
|
||||||
|
println("");
|
||||||
|
worst = 0;
|
||||||
|
for (i = 1; i <= ITERATIONS; i++){
|
||||||
|
print("Iteration ");
|
||||||
|
printn(i);
|
||||||
|
println("");
|
||||||
|
saturated = FALSE;
|
||||||
|
threshold = 0;
|
||||||
|
for (interval = 2000; interval >= 20; interval -= interval / 10) {
|
||||||
|
gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/
|
||||||
|
gptStartContinuous(&GPTD2, interval + 1); /* Slightly out of phase.*/
|
||||||
|
chThdSleepMilliseconds(1000);
|
||||||
|
gptStopTimer(&GPTD1);
|
||||||
|
gptStopTimer(&GPTD2);
|
||||||
|
if (!saturated)
|
||||||
|
print(".");
|
||||||
|
else {
|
||||||
|
print("#");
|
||||||
|
if (threshold == 0)
|
||||||
|
threshold = interval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Gives the worker threads a chance to empty the mailboxes before next
|
||||||
|
cycle.*/
|
||||||
|
chThdSleepMilliseconds(20);
|
||||||
|
println("");
|
||||||
|
print("Saturated at ");
|
||||||
|
printn(threshold);
|
||||||
|
println(" uS");
|
||||||
|
println("");
|
||||||
|
if (threshold > worst)
|
||||||
|
worst = threshold;
|
||||||
|
}
|
||||||
|
gptStopTimer(&GPTD1);
|
||||||
|
gptStopTimer(&GPTD2);
|
||||||
|
|
||||||
|
print("Worst case at ");
|
||||||
|
printn(worst);
|
||||||
|
println(" uS");
|
||||||
|
println("");
|
||||||
|
println("Test Complete");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Normal main() thread activity, nothing in this test.
|
||||||
|
*/
|
||||||
|
while (TRUE) {
|
||||||
|
chThdSleepMilliseconds(5000);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LPC43xx drivers configuration.
|
||||||
|
* The following settings override the default settings present in
|
||||||
|
* the various device driver implementation headers.
|
||||||
|
* Note that the settings for each driver only have effect if the driver
|
||||||
|
* is enabled in halconf.h.
|
||||||
|
*
|
||||||
|
* IRQ priorities:
|
||||||
|
* 7...0 Lowest...highest.
|
||||||
|
*
|
||||||
|
* LPC base clock sources:
|
||||||
|
* 0x00 32 kHz oscillator
|
||||||
|
* 0x01 IRC (default)
|
||||||
|
* 0x02 ENET_RX_CLK
|
||||||
|
* 0x03 ENET_TX_CLK
|
||||||
|
* 0x04 GP_CLKIN
|
||||||
|
* 0x06 Crystal oscillator
|
||||||
|
* 0x07 PLL0USB
|
||||||
|
* 0x08 PLL0AUDIO
|
||||||
|
* 0x09 PLL1
|
||||||
|
* 0x0C IDIVA
|
||||||
|
* 0x0D IDIVB
|
||||||
|
* 0x0E IDIVC
|
||||||
|
* 0x0F IDIVD
|
||||||
|
* 0x10 IDIVE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HAL driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_XTAL_ENABLE TRUE
|
||||||
|
#define LPC_PLL1_ENABLE TRUE
|
||||||
|
#define LPC_PLL1_MUL 17
|
||||||
|
#define LPC_PLL1_PREDIV 1
|
||||||
|
#define LPC_PLL1_POSTDIV_ENABLE FALSE
|
||||||
|
#define LPC_PLL1_POSTDIV 2
|
||||||
|
#define LPC_PLL0USB_ENABLE FALSE
|
||||||
|
#define LPC_PLL0AUDIO_ENABLE FALSE
|
||||||
|
#define LPC_FLASHLESS TRUE
|
||||||
|
|
||||||
|
/* Clock dividers */
|
||||||
|
#define LPC_IDIVA_ENABLE FALSE
|
||||||
|
#define LPC_IDIVA_DIV 1
|
||||||
|
#define LPC_IDIVA_SRC 0x09
|
||||||
|
#define LPC_IDIVB_ENABLE FALSE
|
||||||
|
#define LPC_IDIVB_DIV 2
|
||||||
|
#define LPC_IDIVB_SRC 0x09
|
||||||
|
#define LPC_IDIVC_ENABLE FALSE
|
||||||
|
#define LPC_IDIVC_DIV 3
|
||||||
|
#define LPC_IDIVC_SRC 0x09
|
||||||
|
#define LPC_IDIVD_ENABLE FALSE
|
||||||
|
#define LPC_IDIVD_DIV 1
|
||||||
|
#define LPC_IDIVD_SRC 0x09
|
||||||
|
#define LPC_IDIVE_ENABLE FALSE
|
||||||
|
#define LPC_IDIVE_DIV 1
|
||||||
|
#define LPC_IDIVE_SRC 0x09
|
||||||
|
|
||||||
|
/* Base clocks */
|
||||||
|
#define LPC_BASE_USB0_CLK_ENABLE FALSE /* Base clock for USB0. */
|
||||||
|
#define LPC_BASE_PERIPH_CLK_ENABLE TRUE /* Base clock for Cortex-M0SUB subsystem, SGPIO. */
|
||||||
|
#define LPC_BASE_PERIPH_CLK_SRC 0x09
|
||||||
|
#define LPC_BASE_USB1_CLK_ENABLE TRUE /* Base clock for USB1. */
|
||||||
|
#define LPC_BASE_USB1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SPIFI_CLK_ENABLE FALSE /* Base clock for SPIFI. */
|
||||||
|
#define LPC_BASE_SPIFI_CLK_SRC 0x0D
|
||||||
|
#define LPC_BASE_SPI_CLK_ENABLE TRUE /* Base clock for SPI. */
|
||||||
|
#define LPC_BASE_SPI_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_PHY_RX_CLK_ENABLE FALSE /* Base clock for Ethernet PHY Receive clock. */
|
||||||
|
#define LPC_BASE_PHY_RX_CLK_SRC 0x0E
|
||||||
|
#define LPC_BASE_PHY_TX_CLK_ENABLE FALSE /* Base clock for Ethernet PHY Transmit clock. */
|
||||||
|
#define LPC_BASE_PHY_TX_CLK_SRC 0x0E
|
||||||
|
#define LPC_BASE_APB1_CLK_ENABLE TRUE /* Base clock for APB1: I2C0, I2S, CAN1. */
|
||||||
|
#define LPC_BASE_APB1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_APB3_CLK_ENABLE TRUE /* Base clock for APB3: I2C1, DAC, ADC0, ADC1, CAN0. */
|
||||||
|
#define LPC_BASE_APB3_CLK_SRC 0x09
|
||||||
|
#define LPC_BASE_LCD_CLK_ENABLE FALSE /* Base clock for LCD. */
|
||||||
|
#define LPC_BASE_LCD_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SDIO_CLK_ENABLE FALSE /* Base clock for SD/MMC. */
|
||||||
|
#define LPC_BASE_SDIO_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SSP0_CLK_ENABLE TRUE /* Base clock for SSP0. */
|
||||||
|
#define LPC_BASE_SSP0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_SSP1_CLK_ENABLE TRUE /* Base clock for SSP1. */
|
||||||
|
#define LPC_BASE_SSP1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART0_CLK_ENABLE TRUE /* Base clock for UART0. */
|
||||||
|
#define LPC_BASE_UART0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART1_CLK_ENABLE TRUE /* Base clock for UART1. */
|
||||||
|
#define LPC_BASE_UART1_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART2_CLK_ENABLE TRUE /* Base clock for UART2. */
|
||||||
|
#define LPC_BASE_UART2_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_UART3_CLK_ENABLE TRUE /* Base clock for UART3. */
|
||||||
|
#define LPC_BASE_UART3_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_OUT_CLK_ENABLE FALSE /* Base clock for UART0. */
|
||||||
|
#define LPC_BASE_OUT_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_APLL_CLK_ENABLE FALSE /* Base clock for audio system. */
|
||||||
|
#define LPC_BASE_APLL_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_CGU_OUT0_CLK_ENABLE FALSE /* Base clock for CGU_OUT0 clock output. */
|
||||||
|
#define LPC_BASE_CGU_OUT0_CLK_SRC 0x01
|
||||||
|
#define LPC_BASE_CGU_OUT1_CLK_ENABLE FALSE /* Base clock for CGU_OUT1 clock output. */
|
||||||
|
#define LPC_BASE_CGU_OUT1_CLK_SRC 0x01
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPT driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_GPT_USE_TIM0 TRUE
|
||||||
|
#define LPC_GPT_USE_TIM1 TRUE
|
||||||
|
#define LPC_GPT_USE_TIM2 FALSE
|
||||||
|
#define LPC_GPT_USE_TIM3 FALSE
|
||||||
|
#define LPC_GPT_TIM0_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM1_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM2_IRQ_PRIORITY 2
|
||||||
|
#define LPC_GPT_TIM3_IRQ_PRIORITY 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SERIAL driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_SERIAL_USE_UART0 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART1 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART2 FALSE
|
||||||
|
#define LPC_SERIAL_USE_UART3 TRUE
|
||||||
|
#define LPC_SERIAL_FIFO_PRELOAD 16
|
||||||
|
#define LPC_SERIAL_UART0_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART1_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART2_IRQ_PRIORITY 3
|
||||||
|
#define LPC_SERIAL_UART3_IRQ_PRIORITY 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_I2C_USE_I2C0 FALSE
|
||||||
|
#define LPC_I2C_USE_I2C1 FALSE
|
||||||
|
#define LPC_I2C_I2C0_IRQ_PRIORITY 3
|
||||||
|
#define LPC_I2C_I2C1_IRQ_PRIORITY 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SPI driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_SPI_USE_SSP0 FALSE
|
||||||
|
#define LPC_SPI_USE_SSP1 FALSE
|
||||||
|
#define LPC_SPI_SSP0_IRQ_PRIORITY 5
|
||||||
|
#define LPC_SPI_SSP1_IRQ_PRIORITY 5
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RTC driver system settings.
|
||||||
|
*/
|
||||||
|
#define LPC_RTC_IS_CALENDAR TRUE
|
||||||
|
#define LPC_RTC_USE_ALARM TRUE
|
||||||
|
#define LPC_RTC_IRQ_PRIORITY 3
|
Loading…
Reference in New Issue