diff options
Diffstat (limited to 'testhal/STM32F4xx/SDC')
-rw-r--r-- | testhal/STM32F4xx/SDC/.project | 7 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/Makefile | 97 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/chconf.h | 294 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/csd.txt | 7 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/ffconf.h | 193 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/halconf.h | 7 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/main.c | 471 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/mcuconf.h | 38 | ||||
-rw-r--r-- | testhal/STM32F4xx/SDC/readme.txt | 2 |
9 files changed, 357 insertions, 759 deletions
diff --git a/testhal/STM32F4xx/SDC/.project b/testhal/STM32F4xx/SDC/.project index 630877d95..665aec725 100644 --- a/testhal/STM32F4xx/SDC/.project +++ b/testhal/STM32F4xx/SDC/.project @@ -27,12 +27,7 @@ <link>
<name>board</name>
<type>2</type>
- <locationURI>CHIBIOS/boards/ST_STM32F4_DISCOVERY</locationURI>
- </link>
- <link>
- <name>fatfs</name>
- <type>2</type>
- <locationURI>CHIBIOS/ext/fatfs</locationURI>
+ <locationURI>CHIBIOS/os/hal/boards/OLIMEX_STM32_E407</locationURI>
</link>
<link>
<name>os</name>
diff --git a/testhal/STM32F4xx/SDC/Makefile b/testhal/STM32F4xx/SDC/Makefile index b22e616e5..c7a90fa3b 100644 --- a/testhal/STM32F4xx/SDC/Makefile +++ b/testhal/STM32F4xx/SDC/Makefile @@ -5,7 +5,7 @@ # Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
@@ -23,6 +23,16 @@ ifeq ($(USE_LINK_GC),) USE_LINK_GC = yes
endif
+# Linker extra options here.
+ifeq ($(USE_LDOPT),)
+ USE_LDOPT =
+endif
+
+# Enable this if you want link time optimizations (LTO)
+ifeq ($(USE_LTO),)
+ USE_LTO = yes
+endif
+
# If enabled, this option allows to compile the application in THUMB mode.
ifeq ($(USE_THUMB),)
USE_THUMB = yes
@@ -41,15 +51,21 @@ endif # Architecture or project specific options
#
-# Enables the use of FPU on Cortex-M4.
-# Enable this if you really want to use the STM FWLib.
-ifeq ($(USE_FPU),)
- USE_FPU = no
+# Stack size to be allocated to the Cortex-M process stack. This stack is
+# the stack used by the main() thread.
+ifeq ($(USE_PROCESS_STACKSIZE),)
+ USE_PROCESS_STACKSIZE = 0x400
endif
-# Enable this if you really want to use the STM FWLib.
-ifeq ($(USE_FWLIB),)
- USE_FWLIB = no
+# Stack size to the allocated to the Cortex-M main/exceptions stack. This
+# stack is used for processing interrupts and exceptions.
+ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
+ USE_EXCEPTIONS_STACKSIZE = 0x400
+endif
+
+# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
+ifeq ($(USE_FPU),)
+ USE_FPU = no
endif
#
@@ -63,18 +79,15 @@ endif # Define project name here
PROJECT = ch
-# Define linker script file here
-LDSCRIPT= ch.ld
-
# Imported source files and paths
CHIBIOS = ../../..
-include $(CHIBIOS)/boards/NONSTANDARD_STM32F4_BARTHESS1/board.mk
-include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk
include $(CHIBIOS)/os/hal/hal.mk
-include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk
-include $(CHIBIOS)/os/kernel/kernel.mk
-include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk
-#include $(CHIBIOS)/test/test.mk
+include $(CHIBIOS)/os/hal/boards/OLIMEX_STM32_E407/board.mk
+include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
+include $(CHIBIOS)/os/hal/osal/rt/osal.mk
+include $(CHIBIOS)/os/rt/rt.mk
+include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_stm32f4xx.mk
+#include $(CHIBIOS)/test/rt/test.mk
# Define linker script file here
LDSCRIPT= $(PORTLD)/STM32F407xG.ld
@@ -85,13 +98,11 @@ CSRC = $(PORTSRC) \ $(KERNSRC) \
$(TESTSRC) \
$(HALSRC) \
+ $(OSALSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
- $(FATFSSRC) \
- $(CHIBIOS)/os/various/evtimer.c \
- $(CHIBIOS)/os/various/syscalls.c \
- $(CHIBIOS)/os/various/shell.c \
$(CHIBIOS)/os/various/chprintf.c \
+ $(CHIBIOS)/os/various/shell.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -122,8 +133,7 @@ TCPPSRC = ASMSRC = $(PORTASM)
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
- $(HALINC) $(PLATFORMINC) $(BOARDINC) \
- $(CHIBIOS)/os/various $(FATFSINC) \
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(BOARDINC) \
$(CHIBIOS)/os/various
#
@@ -148,6 +158,7 @@ LD = $(TRGT)gcc CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
OD = $(TRGT)objdump
+SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
@@ -168,29 +179,6 @@ CPPWARN = -Wall -Wextra ##############################################################################
##############################################################################
-# Start of default section
-#
-
-# List all default C defines here, like -D_DEBUG=1
-DDEFS =
-
-# 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
#
@@ -213,18 +201,5 @@ 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_FWLIB),yes)
- include $(CHIBIOS)/ext/stm32lib/stm32lib.mk
- CSRC += $(STM32SRC)
- INCDIR += $(STM32INC)
- USE_OPT += -DUSE_STDPERIPH_DRIVER
-endif
-
-include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
+RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
+include $(RULESPATH)/rules.mk
diff --git a/testhal/STM32F4xx/SDC/chconf.h b/testhal/STM32F4xx/SDC/chconf.h index 868377751..b6ca0aa69 100644 --- a/testhal/STM32F4xx/SDC/chconf.h +++ b/testhal/STM32F4xx/SDC/chconf.h @@ -28,24 +28,44 @@ #ifndef _CHCONF_H_
#define _CHCONF_H_
-#define PORT_IDLE_THREAD_STACK_SIZE 32
-#define CORTEX_USE_FPU FALSE
-
/*===========================================================================*/
/**
- * @name Kernel parameters and options
+ * @name System timers settings
* @{
*/
/*===========================================================================*/
/**
+ * @brief System time counter resolution.
+ * @note Allowed values are 16 or 32 bits.
+ */
+#define CH_CFG_ST_RESOLUTION 32
+
+/**
* @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
+#define CH_CFG_ST_FREQUENCY 10000
+
+/**
+ * @brief Time delta constant for the tick-less mode.
+ * @note If this value is zero then the system uses the classic
+ * periodic tick. This value represents the minimum number
+ * of ticks that is safe to specify in a timeout directive.
+ * The value one is not valid, timeouts are rounded up to
+ * this value.
+ */
+#define CH_CFG_ST_TIMEDELTA 2
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Kernel parameters and options
+ * @{
+ */
+/*===========================================================================*/
/**
* @brief Round robin interval.
@@ -54,13 +74,12 @@ * 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.
+ * @note The round robin preemption is not supported in tickless mode and
+ * must be set to zero in that case.
*/
-#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
-#define CH_TIME_QUANTUM 20
-#endif
+#define CH_CFG_TIME_QUANTUM 0
/**
* @brief Managed RAM size.
@@ -71,28 +90,17 @@ *
* @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.
+ * @note Requires @p CH_CFG_USE_MEMCORE.
*/
-#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
-#define CH_MEMCORE_SIZE 0
-#endif
+#define CH_CFG_MEMCORE_SIZE 0
/**
* @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
+ * does not spawn the idle thread. The application @p main()
+ * function becomes the idle thread and must implement an
+ * infinite loop. */
+#define CH_CFG_NO_IDLE_THREAD FALSE
/** @} */
@@ -111,9 +119,7 @@ * @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
+#define CH_CFG_OPTIMIZE_SPEED TRUE
/** @} */
@@ -125,14 +131,21 @@ /*===========================================================================*/
/**
+ * @brief Time Measurement APIs.
+ * @details If enabled then the time measurement APIs are included in
+ * the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_TM TRUE
+
+/**
* @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
+#define CH_CFG_USE_REGISTRY TRUE
/**
* @brief Threads synchronization APIs.
@@ -141,9 +154,7 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
-#define CH_USE_WAITEXIT TRUE
-#endif
+#define CH_CFG_USE_WAITEXIT TRUE
/**
* @brief Semaphores APIs.
@@ -151,43 +162,36 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
-#define CH_USE_SEMAPHORES TRUE
-#endif
+#define CH_CFG_USE_SEMAPHORES TRUE
/**
* @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.
+ * @note The default is @p FALSE. Enable this if you have special
+ * requirements.
+ * @note Requires @p CH_CFG_USE_SEMAPHORES.
*/
-#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
-#define CH_USE_SEMAPHORES_PRIORITY FALSE
-#endif
+#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
/**
- * @brief Atomic semaphore API.
- * @details If enabled then the semaphores the @p chSemSignalWait() API
- * is included in the kernel.
+ * @brief Mutexes APIs.
+ * @details If enabled then the mutexes APIs are 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
+#define CH_CFG_USE_MUTEXES TRUE
/**
- * @brief Mutexes APIs.
- * @details If enabled then the mutexes APIs are included in the kernel.
+ * @brief Enables recursive behavior on mutexes.
+ * @note Recursive mutexes are heavier and have an increased
+ * memory footprint.
*
- * @note The default is @p TRUE.
+ * @note The default is @p FALSE.
+ * @note Requires @p CH_CFG_USE_MUTEXES.
*/
-#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
-#define CH_USE_MUTEXES TRUE
-#endif
+#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
/**
* @brief Conditional Variables APIs.
@@ -195,11 +199,9 @@ * in the kernel.
*
* @note The default is @p TRUE.
- * @note Requires @p CH_USE_MUTEXES.
+ * @note Requires @p CH_CFG_USE_MUTEXES.
*/
-#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
-#define CH_USE_CONDVARS TRUE
-#endif
+#define CH_CFG_USE_CONDVARS TRUE
/**
* @brief Conditional Variables APIs with timeout.
@@ -207,11 +209,9 @@ * specification are included in the kernel.
*
* @note The default is @p TRUE.
- * @note Requires @p CH_USE_CONDVARS.
+ * @note Requires @p CH_CFG_USE_CONDVARS.
*/
-#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
-#define CH_USE_CONDVARS_TIMEOUT TRUE
-#endif
+#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
/**
* @brief Events Flags APIs.
@@ -219,9 +219,7 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
-#define CH_USE_EVENTS TRUE
-#endif
+#define CH_CFG_USE_EVENTS TRUE
/**
* @brief Events Flags APIs with timeout.
@@ -229,11 +227,9 @@ * are included in the kernel.
*
* @note The default is @p TRUE.
- * @note Requires @p CH_USE_EVENTS.
+ * @note Requires @p CH_CFG_USE_EVENTS.
*/
-#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
-#define CH_USE_EVENTS_TIMEOUT TRUE
-#endif
+#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
/**
* @brief Synchronous Messages APIs.
@@ -242,21 +238,18 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
-#define CH_USE_MESSAGES TRUE
-#endif
+#define CH_CFG_USE_MESSAGES TRUE
/**
* @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.
+ * @note The default is @p FALSE. Enable this if you have special
+ * requirements.
+ * @note Requires @p CH_CFG_USE_MESSAGES.
*/
-#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
-#define CH_USE_MESSAGES_PRIORITY FALSE
-#endif
+#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
/**
* @brief Mailboxes APIs.
@@ -264,11 +257,9 @@ * included in the kernel.
*
* @note The default is @p TRUE.
- * @note Requires @p CH_USE_SEMAPHORES.
+ * @note Requires @p CH_CFG_USE_SEMAPHORES.
*/
-#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
-#define CH_USE_MAILBOXES TRUE
-#endif
+#define CH_CFG_USE_MAILBOXES TRUE
/**
* @brief I/O Queues APIs.
@@ -276,9 +267,7 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
-#define CH_USE_QUEUES TRUE
-#endif
+#define CH_CFG_USE_QUEUES TRUE
/**
* @brief Core Memory Manager APIs.
@@ -287,9 +276,7 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
-#define CH_USE_MEMCORE TRUE
-#endif
+#define CH_CFG_USE_MEMCORE TRUE
/**
* @brief Heap Allocator APIs.
@@ -297,27 +284,11 @@ * 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 Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
+ * @p CH_CFG_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
+#define CH_CFG_USE_HEAP TRUE
/**
* @brief Memory Pools Allocator APIs.
@@ -326,9 +297,7 @@ *
* @note The default is @p TRUE.
*/
-#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
-#define CH_USE_MEMPOOLS TRUE
-#endif
+#define CH_CFG_USE_MEMPOOLS TRUE
/**
* @brief Dynamic Threads APIs.
@@ -336,12 +305,10 @@ * 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.
+ * @note Requires @p CH_CFG_USE_WAITEXIT.
+ * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
*/
-#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
-#define CH_USE_DYNAMIC TRUE
-#endif
+#define CH_CFG_USE_DYNAMIC TRUE
/** @} */
@@ -353,15 +320,20 @@ /*===========================================================================*/
/**
+ * @brief Debug option, kernel statistics.
+ *
+ * @note The default is @p FALSE.
+ */
+#define CH_DBG_STATISTICS TRUE
+
+/**
* @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 TRUE
-#endif
+#define CH_DBG_SYSTEM_STATE_CHECK TRUE
/**
* @brief Debug option, parameters checks.
@@ -370,9 +342,7 @@ *
* @note The default is @p FALSE.
*/
-#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_CHECKS TRUE
-#endif
+#define CH_DBG_ENABLE_CHECKS TRUE
/**
* @brief Debug option, consistency checks.
@@ -382,9 +352,7 @@ *
* @note The default is @p FALSE.
*/
-#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_ASSERTS TRUE
-#endif
+#define CH_DBG_ENABLE_ASSERTS TRUE
/**
* @brief Debug option, trace buffer.
@@ -393,9 +361,7 @@ *
* @note The default is @p FALSE.
*/
-#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_TRACE TRUE
-#endif
+#define CH_DBG_ENABLE_TRACE TRUE
/**
* @brief Debug option, stack checks.
@@ -407,9 +373,7 @@ * @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 TRUE
-#endif
+#define CH_DBG_ENABLE_STACK_CHECK TRUE
/**
* @brief Debug option, stacks initialization.
@@ -419,22 +383,18 @@ *
* @note The default is @p FALSE.
*/
-#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
-#define CH_DBG_FILL_THREADS TRUE
-#endif
+#define CH_DBG_FILL_THREADS TRUE
/**
* @brief Debug option, threads profiling.
- * @details If enabled then a field is added to the @p Thread structure that
+ * @details If enabled then a field is added to the @p thread_t 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.
+ * @note The default is @p FALSE.
+ * @note This debug option is not currently compatible with the
+ * tickless mode.
*/
-#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
-#define CH_DBG_THREADS_PROFILING TRUE
-#endif
+#define CH_DBG_THREADS_PROFILING FALSE
/** @} */
@@ -447,12 +407,10 @@ /**
* @brief Threads descriptor structure extension.
- * @details User fields added to the end of the @p Thread structure.
+ * @details User fields added to the end of the @p thread_t structure.
*/
-#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
-#define THREAD_EXT_FIELDS \
+#define CH_CFG_THREAD_EXTRA_FIELDS \
/* Add threads custom fields here.*/
-#endif
/**
* @brief Threads initialization hook.
@@ -461,11 +419,9 @@ * @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) { \
+#define CH_CFG_THREAD_INIT_HOOK(tp) { \
/* Add threads initialization code here.*/ \
}
-#endif
/**
* @brief Threads finalization hook.
@@ -475,53 +431,61 @@ * @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) { \
+#define CH_CFG_THREAD_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) { \
+#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
/* System halt code here.*/ \
}
-#endif
+
+/**
+ * @brief Idle thread enter hook.
+ * @note This hook is invoked within a critical zone, no OS functions
+ * should be invoked from here.
+ * @note This macro can be used to activate a power saving mode.
+ */
+#define CH_CFG_IDLE_ENTER_HOOK() { \
+}
+
+/**
+ * @brief Idle thread leave hook.
+ * @note This hook is invoked within a critical zone, no OS functions
+ * should be invoked from here.
+ * @note This macro can be used to deactivate a power saving mode.
+ */
+#define CH_CFG_IDLE_LEAVE_HOOK() { \
+}
/**
* @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() { \
+#define CH_CFG_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() { \
+#define CH_CFG_SYSTEM_TICK_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() { \
+#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
/* System halt code here.*/ \
}
-#endif
/** @} */
diff --git a/testhal/STM32F4xx/SDC/csd.txt b/testhal/STM32F4xx/SDC/csd.txt deleted file mode 100644 index eefe5274c..000000000 --- a/testhal/STM32F4xx/SDC/csd.txt +++ /dev/null @@ -1,7 +0,0 @@ -127 ... ... 0
-
-00000000 00101110 00000000 00110010 - 01011011 01011010 10100011 10100000 - 11111111111111111111111110000000 - 00001010100000000000000010001110 kingmax 2 GB
-00000000 00101110 00000000 00110010 - 01011011 01011010 10000011 10101001 - 11111111111111111111111110000000 - 00010110100000000000000010010000 kingstone 2 GB
-01000000 00001110 00000000 00110010 - 01011011 01011001 00000000 00000000 - 00111011010010110111111110000000 - 00001010010000000100000001000000 samsung sdhc 8 GB
-00000000 00100110 00000000 00110010 - 01011111 01011010 10000011 10101110 - 11111110111110111100111111111111 - 10010010100000000100000011011110 noname 2 GB
-
diff --git a/testhal/STM32F4xx/SDC/ffconf.h b/testhal/STM32F4xx/SDC/ffconf.h deleted file mode 100644 index 9073f2286..000000000 --- a/testhal/STM32F4xx/SDC/ffconf.h +++ /dev/null @@ -1,193 +0,0 @@ -/* CHIBIOS FIX */
-#include "ch.h"
-
-/*---------------------------------------------------------------------------/
-/ FatFs - FAT file system module configuration file R0.09 (C)ChaN, 2011
-/----------------------------------------------------------------------------/
-/
-/ CAUTION! Do not forget to make clean the project after any changes to
-/ the configuration options.
-/
-/----------------------------------------------------------------------------*/
-#ifndef _FFCONF
-#define _FFCONF 6502 /* Revision ID */
-
-
-/*---------------------------------------------------------------------------/
-/ Functions and Buffer Configurations
-/----------------------------------------------------------------------------*/
-
-#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
-/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
-/ object instead of the sector buffer in the individual file object for file
-/ data transfer. This reduces memory consumption 512 bytes each file object. */
-
-
-#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
-/* Setting _FS_READONLY to 1 defines read only configuration. This removes
-/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
-/ f_truncate and useless f_getfree. */
-
-
-#define _FS_MINIMIZE 0 /* 0 to 3 */
-/* The _FS_MINIMIZE option defines minimization level to remove some functions.
-/
-/ 0: Full function.
-/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
-/ are removed.
-/ 2: f_opendir and f_readdir are removed in addition to 1.
-/ 3: f_lseek is removed in addition to 2. */
-
-
-#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
-/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
-
-
-#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
-/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
-
-
-#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
-/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
-
-
-#define _USE_FASTSEEK 0 /* 0:Disable or 1:Enable */
-/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
-
-
-
-/*---------------------------------------------------------------------------/
-/ Locale and Namespace Configurations
-/----------------------------------------------------------------------------*/
-
-#define _CODE_PAGE 1251
-/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
-/ Incorrect setting of the code page can cause a file open failure.
-/
-/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
-/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
-/ 949 - Korean (DBCS, OEM, Windows)
-/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
-/ 1250 - Central Europe (Windows)
-/ 1251 - Cyrillic (Windows)
-/ 1252 - Latin 1 (Windows)
-/ 1253 - Greek (Windows)
-/ 1254 - Turkish (Windows)
-/ 1255 - Hebrew (Windows)
-/ 1256 - Arabic (Windows)
-/ 1257 - Baltic (Windows)
-/ 1258 - Vietnam (OEM, Windows)
-/ 437 - U.S. (OEM)
-/ 720 - Arabic (OEM)
-/ 737 - Greek (OEM)
-/ 775 - Baltic (OEM)
-/ 850 - Multilingual Latin 1 (OEM)
-/ 858 - Multilingual Latin 1 + Euro (OEM)
-/ 852 - Latin 2 (OEM)
-/ 855 - Cyrillic (OEM)
-/ 866 - Russian (OEM)
-/ 857 - Turkish (OEM)
-/ 862 - Hebrew (OEM)
-/ 874 - Thai (OEM, Windows)
-/ 1 - ASCII only (Valid for non LFN cfg.)
-*/
-
-
-#define _USE_LFN 3 /* 0 to 3 */
-#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
-/* The _USE_LFN option switches the LFN support.
-/
-/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect.
-/ 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
-/ 2: Enable LFN with dynamic working buffer on the STACK.
-/ 3: Enable LFN with dynamic working buffer on the HEAP.
-/
-/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. To enable LFN,
-/ Unicode handling functions ff_convert() and ff_wtoupper() must be added
-/ to the project. When enable to use heap, memory control functions
-/ ff_memalloc() and ff_memfree() must be added to the project. */
-
-
-#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
-/* To switch the character code set on FatFs API to Unicode,
-/ enable LFN feature and set _LFN_UNICODE to 1. */
-
-
-#define _FS_RPATH 0 /* 0 to 2 */
-/* The _FS_RPATH option configures relative path feature.
-/
-/ 0: Disable relative path feature and remove related functions.
-/ 1: Enable relative path. f_chdrive() and f_chdir() are available.
-/ 2: f_getcwd() is available in addition to 1.
-/
-/ Note that output of the f_readdir fnction is affected by this option. */
-
-
-
-/*---------------------------------------------------------------------------/
-/ Physical Drive Configurations
-/----------------------------------------------------------------------------*/
-
-#define _VOLUMES 1
-/* Number of volumes (logical drives) to be used. */
-
-
-#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */
-/* Maximum sector size to be handled.
-/ Always set 512 for memory card and hard disk but a larger value may be
-/ required for on-board flash memory, floppy disk and optical disk.
-/ When _MAX_SS is larger than 512, it configures FatFs to variable sector size
-/ and GET_SECTOR_SIZE command must be implememted to the disk_ioctl function. */
-
-
-#define _MULTI_PARTITION 0 /* 0:Single partition, 1/2:Enable multiple partition */
-/* When set to 0, each volume is bound to the same physical drive number and
-/ it can mount only first primaly partition. When it is set to 1, each volume
-/ is tied to the partitions listed in VolToPart[]. */
-
-
-#define _USE_ERASE 1 /* 0:Disable or 1:Enable */
-/* To enable sector erase feature, set _USE_ERASE to 1. CTRL_ERASE_SECTOR command
-/ should be added to the disk_ioctl functio. */
-
-
-
-/*---------------------------------------------------------------------------/
-/ System Configurations
-/----------------------------------------------------------------------------*/
-
-#define _WORD_ACCESS 1 /* 0 or 1 */
-/* Set 0 first and it is always compatible with all platforms. The _WORD_ACCESS
-/ option defines which access method is used to the word data on the FAT volume.
-/
-/ 0: Byte-by-byte access.
-/ 1: Word access. Do not choose this unless following condition is met.
-/
-/ When the byte order on the memory is big-endian or address miss-aligned word
-/ access results incorrect behavior, the _WORD_ACCESS must be set to 0.
-/ If it is not the case, the value can also be set to 1 to improve the
-/ performance and code size.
-*/
-
-
-/* A header file that defines sync object types on the O/S, such as
-/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
-
-#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
-#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
-#define _SYNC_t Semaphore * /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
-
-/* The _FS_REENTRANT option switches the reentrancy (thread safe) of the FatFs module.
-/
-/ 0: Disable reentrancy. _SYNC_t and _FS_TIMEOUT have no effect.
-/ 1: Enable reentrancy. Also user provided synchronization handlers,
-/ ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj
-/ function must be added to the project. */
-
-
-#define _FS_SHARE 0 /* 0:Disable or >=1:Enable */
-/* To enable file shareing feature, set _FS_SHARE to 1 or greater. The value
- defines how many files can be opened simultaneously. */
-
-
-#endif /* _FFCONFIG */
diff --git a/testhal/STM32F4xx/SDC/halconf.h b/testhal/STM32F4xx/SDC/halconf.h index 7c79feea0..ec7ffc153 100644 --- a/testhal/STM32F4xx/SDC/halconf.h +++ b/testhal/STM32F4xx/SDC/halconf.h @@ -73,6 +73,13 @@ #endif
/**
+ * @brief Enables the I2S subsystem.
+ */
+#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
+#define HAL_USE_I2S FALSE
+#endif
+
+/**
* @brief Enables the ICU subsystem.
*/
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
diff --git a/testhal/STM32F4xx/SDC/main.c b/testhal/STM32F4xx/SDC/main.c index 721eac66b..264f31133 100644 --- a/testhal/STM32F4xx/SDC/main.c +++ b/testhal/STM32F4xx/SDC/main.c @@ -15,341 +15,160 @@ */
#include <string.h>
+
#include "ch.h"
#include "hal.h"
-#include "shell.h"
#include "chprintf.h"
+#include "shell.h"
-#include "ff.h"
-
-#define SDC_DATA_DESTRUCTIVE_TEST FALSE
-
-#define SDC_BURST_SIZE 8 /* how many sectors reads at once */
-static uint8_t outbuf[MMCSD_BLOCK_SIZE * SDC_BURST_SIZE + 1];
-static uint8_t inbuf[MMCSD_BLOCK_SIZE * SDC_BURST_SIZE + 1];
-
-/* FS object.*/
-static FATFS SDC_FS;
-
-/* FS mounted and ready.*/
-static bool_t fs_ready = FALSE;
+/*
+ * SDIO configuration.
+ */
+static const SDCConfig sdccfg = {
+ 0
+};
-/**
- * @brief Parody of UNIX badblocks program.
- *
- * @param[in] start first block to check
- * @param[in] end last block to check
- * @param[in] blockatonce number of blocks to check at once
- * @param[in] pattern check pattern
- *
- * @return The operation status.
- * @retval SDC_SUCCESS operation succeeded, the requested blocks have been
- * read.
- * @retval SDC_FAILED operation failed, the state of the buffer is uncertain.
+/*
+ * LED blinker thread, times are in milliseconds.
*/
-bool_t badblocks(uint32_t start, uint32_t end, uint32_t blockatonce, uint8_t pattern){
- uint32_t position = 0;
- uint32_t i = 0;
-
- chDbgCheck(blockatonce <= SDC_BURST_SIZE, "badblocks");
-
- /* fill control buffer */
- for (i=0; i < MMCSD_BLOCK_SIZE * blockatonce; i++)
- outbuf[i] = pattern;
-
- /* fill SD card with pattern. */
- position = start;
- while (position < end){
- if (sdcWrite(&SDCD1, position, outbuf, blockatonce))
- goto ERROR;
- position += blockatonce;
- }
+static THD_WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
- /* read and compare. */
- position = start;
- while (position < end){
- if (sdcRead(&SDCD1, position, inbuf, blockatonce))
- goto ERROR;
- if (memcmp(inbuf, outbuf, blockatonce * MMCSD_BLOCK_SIZE) != 0)
- goto ERROR;
- position += blockatonce;
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palSetPad(GPIOC, GPIOC_LED);
+ chThdSleepMilliseconds(500);
+ palClearPad(GPIOC, GPIOC_LED);
+ chThdSleepMilliseconds(500);
}
- return FALSE;
-
-ERROR:
- return TRUE;
}
-/**
- *
- */
-void fillbuffer(uint8_t pattern, uint8_t *b){
- uint32_t i = 0;
- for (i=0; i < MMCSD_BLOCK_SIZE * SDC_BURST_SIZE; i++)
- b[i] = pattern;
-}
+/*===========================================================================*/
+/* Command line related. */
+/*===========================================================================*/
-/**
- *
- */
-void fillbuffers(uint8_t pattern){
- fillbuffer(pattern, inbuf);
- fillbuffer(pattern, outbuf);
-}
+#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
-/**
- *
- */
-void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
- (void)argc;
- (void)argv;
- uint32_t i = 0;
-
- chprintf(chp, "Trying to connect SDIO... ");
- chThdSleepMilliseconds(100);
-
- if (!sdcConnect(&SDCD1)) {
-
- chprintf(chp, "OK\r\n");
- chprintf(chp, "*** Card CSD content is: ");
- chprintf(chp, "%X %X %X %X \r\n", (&SDCD1)->csd[3], (&SDCD1)->csd[2],
- (&SDCD1)->csd[1], (&SDCD1)->csd[0]);
-
- chprintf(chp, "Single aligned read...");
- chThdSleepMilliseconds(100);
- if (sdcRead(&SDCD1, 0, inbuf, 1))
- chSysHalt();
- chprintf(chp, " OK\r\n");
- chThdSleepMilliseconds(100);
-
-
- chprintf(chp, "Single unaligned read...");
- chThdSleepMilliseconds(100);
- if (sdcRead(&SDCD1, 0, inbuf + 1, 1))
- chSysHalt();
- if (sdcRead(&SDCD1, 0, inbuf + 2, 1))
- chSysHalt();
- if (sdcRead(&SDCD1, 0, inbuf + 3, 1))
- chSysHalt();
- chprintf(chp, " OK\r\n");
- chThdSleepMilliseconds(100);
-
-
- chprintf(chp, "Multiple aligned reads...");
- chThdSleepMilliseconds(100);
- fillbuffers(0x55);
- /* fill reference buffer from SD card */
- if (sdcRead(&SDCD1, 0, inbuf, SDC_BURST_SIZE))
- chSysHalt();
- for (i=0; i<1000; i++){
- if (sdcRead(&SDCD1, 0, outbuf, SDC_BURST_SIZE))
- chSysHalt();
- if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * MMCSD_BLOCK_SIZE) != 0)
- chSysHalt();
- }
- chprintf(chp, " OK\r\n");
- chThdSleepMilliseconds(100);
-
-
- chprintf(chp, "Multiple unaligned reads...");
- chThdSleepMilliseconds(100);
- fillbuffers(0x55);
- /* fill reference buffer from SD card */
- if (sdcRead(&SDCD1, 0, inbuf + 1, SDC_BURST_SIZE))
- chSysHalt();
- for (i=0; i<1000; i++){
- if (sdcRead(&SDCD1, 0, outbuf + 1, SDC_BURST_SIZE))
- chSysHalt();
- if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * MMCSD_BLOCK_SIZE) != 0)
- chSysHalt();
- }
- chprintf(chp, " OK\r\n");
- chThdSleepMilliseconds(100);
-
-#if SDC_DATA_DESTRUCTIVE_TEST
-
- chprintf(chp, "Single aligned write...");
- chThdSleepMilliseconds(100);
- fillbuffer(0xAA, inbuf);
- if (sdcWrite(&SDCD1, 0, inbuf, 1))
- chSysHalt();
- fillbuffer(0, outbuf);
- if (sdcRead(&SDCD1, 0, outbuf, 1))
- chSysHalt();
- if (memcmp(inbuf, outbuf, MMCSD_BLOCK_SIZE) != 0)
- chSysHalt();
- chprintf(chp, " OK\r\n");
-
- chprintf(chp, "Single unaligned write...");
- chThdSleepMilliseconds(100);
- fillbuffer(0xFF, inbuf);
- if (sdcWrite(&SDCD1, 0, inbuf+1, 1))
- chSysHalt();
- fillbuffer(0, outbuf);
- if (sdcRead(&SDCD1, 0, outbuf+1, 1))
- chSysHalt();
- if (memcmp(inbuf+1, outbuf+1, MMCSD_BLOCK_SIZE) != 0)
- chSysHalt();
- chprintf(chp, " OK\r\n");
-
- chprintf(chp, "Running badblocks at 0x10000 offset...");
- chThdSleepMilliseconds(100);
- if(badblocks(0x10000, 0x11000, SDC_BURST_SIZE, 0xAA))
- chSysHalt();
- chprintf(chp, " OK\r\n");
-#endif /* !SDC_DATA_DESTRUCTIVE_TEST */
-
-
- /**
- * Now perform some FS tests.
- */
-
- FRESULT err;
- uint32_t clusters;
- FATFS *fsp;
- FIL FileObject;
- uint32_t bytes_written;
- uint32_t bytes_read;
- FILINFO filinfo;
- uint8_t teststring[] = {"This is test file\r\n"};
-
- chprintf(chp, "Register working area for filesystem... ");
- chThdSleepMilliseconds(100);
- err = f_mount(0, &SDC_FS);
- if (err != FR_OK){
- chSysHalt();
- }
- else{
- fs_ready = TRUE;
- chprintf(chp, "OK\r\n");
- }
+#define SDC_BURST_SIZE 16
+/* Buffer for block read/write operations, note that an extra byte is
+ allocated in order to support unaligned operations.*/
+static uint8_t buf[MMCSD_BLOCK_SIZE * SDC_BURST_SIZE + 1];
-#if SDC_DATA_DESTRUCTIVE_TEST
- chprintf(chp, "Formatting... ");
- chThdSleepMilliseconds(100);
- err = f_mkfs (0,0,0);
- if (err != FR_OK){
- chSysHalt();
- }
- else{
- chprintf(chp, "OK\r\n");
- }
-#endif /* SDC_DATA_DESTRUCTIVE_TEST */
-
+void cmd_sdc(BaseSequentialStream *chp, int argc, char *argv[]) {
+ static const char *mode[] = {"SDV11", "SDV20", "MMC", NULL};
+ systime_t start, end;
+ uint32_t n, startblk;
- chprintf(chp, "Mount filesystem... ");
- chThdSleepMilliseconds(100);
- err = f_getfree("/", &clusters, &fsp);
- if (err != FR_OK) {
- chSysHalt();
- }
- chprintf(chp, "OK\r\n");
- chprintf(chp,
- "FS: %lu free clusters, %lu sectors per cluster, %lu bytes free\r\n",
- clusters, (uint32_t)SDC_FS.csize,
- clusters * (uint32_t)SDC_FS.csize * (uint32_t)MMCSD_BLOCK_SIZE);
-
-
- chprintf(chp, "Create file \"chtest.txt\"... ");
- chThdSleepMilliseconds(100);
- err = f_open(&FileObject, "0:chtest.txt", FA_WRITE | FA_OPEN_ALWAYS);
- if (err != FR_OK) {
- chSysHalt();
- }
- chprintf(chp, "OK\r\n");
- chprintf(chp, "Write some data in it... ");
- chThdSleepMilliseconds(100);
- err = f_write(&FileObject, teststring, sizeof(teststring), (void *)&bytes_written);
- if (err != FR_OK) {
- chSysHalt();
- }
- else
- chprintf(chp, "OK\r\n");
+ if (argc != 1) {
+ chprintf(chp, "Usage: sdiotest read|write|all\r\n");
+ return;
+ }
- chprintf(chp, "Close file \"chtest.txt\"... ");
- err = f_close(&FileObject);
- if (err != FR_OK) {
- chSysHalt();
- }
- else
- chprintf(chp, "OK\r\n");
-
- chprintf(chp, "Check file size \"chtest.txt\"... ");
- err = f_stat("0:chtest.txt", &filinfo);
- chThdSleepMilliseconds(100);
- if (err != FR_OK) {
- chSysHalt();
- }
- else{
- if (filinfo.fsize == sizeof(teststring))
- chprintf(chp, "OK\r\n");
- else
- chSysHalt();
- }
+ /* Card presence check.*/
+ if (!blkIsInserted(&SDCD1)) {
+ chprintf(chp, "Card not inserted, aborting.\r\n");
+ return;
+ }
- chprintf(chp, "Check file content \"chtest.txt\"... ");
- err = f_open(&FileObject, "0:chtest.txt", FA_READ | FA_OPEN_EXISTING);
- chThdSleepMilliseconds(100);
- if (err != FR_OK) {
- chSysHalt();
- }
- uint8_t buf[sizeof(teststring)];
- err = f_read(&FileObject, buf, sizeof(teststring), (void *)&bytes_read);
- if (err != FR_OK) {
- chSysHalt();
- }
- else{
- if (memcmp(teststring, buf, sizeof(teststring)) != 0){
- chSysHalt();
+ /* Connection to the card.*/
+ chprintf(chp, "Connecting... ");
+ if (sdcConnect(&SDCD1)) {
+ chprintf(chp, "failed\r\n");
+ return;
+ }
+ chprintf(chp, "OK\r\n\r\nCard Info\r\n");
+ chprintf(chp, "CSD : %08X %8X %08X %08X \r\n",
+ SDCD1.csd[3], SDCD1.csd[2], SDCD1.csd[1], SDCD1.csd[0]);
+ chprintf(chp, "CID : %08X %8X %08X %08X \r\n",
+ SDCD1.cid[3], SDCD1.cid[2], SDCD1.cid[1], SDCD1.cid[0]);
+ chprintf(chp, "Mode : %s\r\n", mode[SDCD1.cardmode]);
+ chprintf(chp, "Capacity : %DMB\r\n", SDCD1.capacity / 2048);
+
+ /* The test is performed in the middle of the flash area.*/
+ startblk = (SDCD1.capacity / MMCSD_BLOCK_SIZE) / 2;
+
+ if ((strcmp(argv[0], "read") == 0) ||
+ (strcmp(argv[0], "all") == 0)) {
+
+ /* Single block read performance, aligned.*/
+ chprintf(chp, "Single block aligned read performance: ");
+ start = chVTGetSystemTime();
+ end = start + MS2ST(1000);
+ n = 0;
+ do {
+ if (blkRead(&SDCD1, startblk, buf, 1)) {
+ chprintf(chp, "failed\r\n");
+ goto exittest;
}
- else{
- chprintf(chp, "OK\r\n");
+ n++;
+ } while (chVTIsSystemTimeWithin(start, end));
+ chprintf(chp, "%D blocks/S, %D bytes/S\r\n", n, n * MMCSD_BLOCK_SIZE);
+
+ /* Multiple sequential blocks read performance, aligned.*/
+ chprintf(chp, "16 sequential blocks aligned read performance: ");
+ start = chVTGetSystemTime();
+ end = start + MS2ST(1000);
+ n = 0;
+ do {
+ if (blkRead(&SDCD1, startblk, buf, SDC_BURST_SIZE)) {
+ chprintf(chp, "failed\r\n");
+ goto exittest;
}
- }
-
- chprintf(chp, "Umount filesystem... ");
- f_mount(0, NULL);
- chprintf(chp, "OK\r\n");
-
- chprintf(chp, "Disconnecting from SDIO...");
- chThdSleepMilliseconds(100);
- if (sdcDisconnect(&SDCD1))
- chSysHalt();
- chprintf(chp, " OK\r\n");
- chprintf(chp, "------------------------------------------------------\r\n");
- chprintf(chp, "All tests passed successfully.\r\n");
- chThdSleepMilliseconds(100);
- }
- else{
- chSysHalt();
+ n += SDC_BURST_SIZE;
+ } while (chVTIsSystemTimeWithin(start, end));
+ chprintf(chp, "%D blocks/S, %D bytes/S\r\n", n, n * MMCSD_BLOCK_SIZE);
+
+#if STM32_SDC_SDIO_UNALIGNED_SUPPORT
+ /* Single block read performance, unaligned.*/
+ chprintf(chp, "Single block unaligned read performance: ");
+ start = chVTGetSystemTime();
+ end = start + MS2ST(1000);
+ n = 0;
+ do {
+ if (blkRead(&SDCD1, startblk, buf + 1, 1)) {
+ chprintf(chp, "failed\r\n");
+ goto exittest;
+ }
+ n++;
+ } while (chVTIsSystemTimeWithin(start, end));
+ chprintf(chp, "%D blocks/S, %D bytes/S\r\n", n, n * MMCSD_BLOCK_SIZE);
+
+ /* Multiple sequential blocks read performance, unaligned.*/
+ chprintf(chp, "16 sequential blocks unaligned read performance: ");
+ start = chVTGetSystemTime();
+ end = start + MS2ST(1000);
+ n = 0;
+ do {
+ if (blkRead(&SDCD1, startblk, buf + 1, SDC_BURST_SIZE)) {
+ chprintf(chp, "failed\r\n");
+ goto exittest;
+ }
+ n += SDC_BURST_SIZE;
+ } while (chVTIsSystemTimeWithin(start, end));
+ chprintf(chp, "%D blocks/S, %D bytes/S\r\n", n, n * MMCSD_BLOCK_SIZE);
+#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
}
-}
+ if ((strcmp(argv[0], "write") == 0) ||
+ (strcmp(argv[0], "all") == 0)) {
-/*
- * SDIO configuration.
- */
-static const SDCConfig sdccfg = {
- 0
-};
+ }
+
+ /* Card disconnect and command end.*/
+exittest:
+ sdcDisconnect(&SDCD1);
+}
-/**
- *
- */
-static SerialConfig ser_cfg = {
- 115200,
- 0,
- 0,
- 0,
-};
static const ShellCommand commands[] = {
- {"sdiotest", cmd_sdiotest},
+ {"sdc", cmd_sdc},
{NULL, NULL}
};
+
static const ShellConfig shell_cfg1 = {
- (BaseSequentialStream *)&SD2,
+ (BaseSequentialStream *)&SD6,
commands
};
@@ -357,14 +176,27 @@ static const ShellConfig shell_cfg1 = { * Application entry point.
*/
int main(void) {
+ thread_t *shelltp = NULL;
+
+ /*
+ * 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();
- /* start debugging serial link */
- sdStart(&SD2, &ser_cfg);
+ /*
+ * Shell manager initialization.
+ */
shellInit();
- static WORKING_AREA(waShell, 2048);
- shellCreateStatic(&shell_cfg1, waShell, sizeof(waShell), NORMALPRIO);
+
+ /*
+ * Activates the serial driver 6 using the driver default configuration.
+ */
+ sdStart(&SD6, NULL);
/*
* Initializes the SDIO drivers.
@@ -372,11 +204,20 @@ int main(void) { sdcStart(&SDCD1, &sdccfg);
/*
- * Normal main() thread activity.
- * Blinking signaling about successful passing.
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Normal main() thread activity, in this demo it does nothing.
*/
while (TRUE) {
- palTogglePad(GPIOB, GPIOB_LED_R);
- chThdSleepMilliseconds(100);
+ if (!shelltp)
+ shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
+ else if (chThdTerminatedX(shelltp)) {
+ chThdRelease(shelltp); /* Recovers memory of the previous shell. */
+ shelltp = NULL; /* Triggers spawning of a new shell. */
+ }
+ chThdSleepMilliseconds(1000);
}
}
diff --git a/testhal/STM32F4xx/SDC/mcuconf.h b/testhal/STM32F4xx/SDC/mcuconf.h index 2a16dc0f0..62f693419 100644 --- a/testhal/STM32F4xx/SDC/mcuconf.h +++ b/testhal/STM32F4xx/SDC/mcuconf.h @@ -41,7 +41,7 @@ #define STM32_CLOCK48_REQUIRED TRUE
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSE
-#define STM32_PLLM_VALUE 8
+#define STM32_PLLM_VALUE 12
#define STM32_PLLN_VALUE 336
#define STM32_PLLP_VALUE 2
#define STM32_PLLQ_VALUE 7
@@ -65,9 +65,9 @@ * ADC driver system settings.
*/
#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
-#define STM32_ADC_USE_ADC1 FALSE
-#define STM32_ADC_USE_ADC2 FALSE
-#define STM32_ADC_USE_ADC3 FALSE
+#define STM32_ADC_USE_ADC1 TRUE
+#define STM32_ADC_USE_ADC2 TRUE
+#define STM32_ADC_USE_ADC3 TRUE
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
@@ -139,6 +139,7 @@ #define STM32_I2C_USE_I2C1 FALSE
#define STM32_I2C_USE_I2C2 FALSE
#define STM32_I2C_USE_I2C3 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
@@ -151,9 +152,7 @@ #define STM32_I2C_I2C1_DMA_PRIORITY 3
#define STM32_I2C_I2C2_DMA_PRIORITY 3
#define STM32_I2C_I2C3_DMA_PRIORITY 3
-#define STM32_I2C_I2C1_DMA_ERROR_HOOK() chSysHalt()
-#define STM32_I2C_I2C2_DMA_ERROR_HOOK() chSysHalt()
-#define STM32_I2C_I2C3_DMA_ERROR_HOOK() chSysHalt()
+#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
/*
* ICU driver system settings.
@@ -204,14 +203,25 @@ #define STM32_PWM_TIM9_IRQ_PRIORITY 7
/*
+ * SDC driver system settings.
+ */
+#define STM32_SDC_SDIO_DMA_PRIORITY 3
+#define STM32_SDC_SDIO_IRQ_PRIORITY 9
+#define STM32_SDC_WRITE_TIMEOUT_MS 250
+#define STM32_SDC_READ_TIMEOUT_MS 25
+#define STM32_SDC_CLOCK_ACTIVATION_DELAY 10
+#define STM32_SDC_SDIO_UNALIGNED_SUPPORT TRUE
+#define STM32_SDC_SDIO_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
+
+/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
-#define STM32_SERIAL_USE_USART2 TRUE
+#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
-#define STM32_SERIAL_USE_USART6 FALSE
+#define STM32_SERIAL_USE_USART6 TRUE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12
@@ -237,7 +247,13 @@ #define STM32_SPI_SPI1_IRQ_PRIORITY 10
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
#define STM32_SPI_SPI3_IRQ_PRIORITY 10
-#define STM32_SPI_DMA_ERROR_HOOK(spip) chSysHalt()
+#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
+
+/*
+ * ST driver system settings.
+ */
+#define STM32_ST_IRQ_PRIORITY 8
+#define STM32_ST_USE_TIMER 2
/*
* UART driver system settings.
@@ -272,7 +288,7 @@ #define STM32_UART_UART4_DMA_PRIORITY 0
#define STM32_UART_UART5_DMA_PRIORITY 0
#define STM32_UART_USART6_DMA_PRIORITY 0
-#define STM32_UART_DMA_ERROR_HOOK(uartp) chSysHalt()
+#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
/*
* USB driver system settings.
diff --git a/testhal/STM32F4xx/SDC/readme.txt b/testhal/STM32F4xx/SDC/readme.txt index b897676af..1daeb6c94 100644 --- a/testhal/STM32F4xx/SDC/readme.txt +++ b/testhal/STM32F4xx/SDC/readme.txt @@ -4,7 +4,7 @@ ** TARGET **
-The demo runs on an Olimex ST_STM3210E_EVAL board.
+The demo runs on an Olimex STM32-E407 board.
** The Demo **
|