From ffa23491f71e6c7b9a4a355e547e485648e48c8b Mon Sep 17 00:00:00 2001 From: gkostka Date: Sun, 12 Jan 2014 17:20:19 +0000 Subject: [PATCH] Comments and some minor fixes. --- demos/stm32f429_disco/config.h | 44 ++++++++++++++++-------- demos/stm32f429_disco/hw_init.c | 47 +++++++++++++++++++------- demos/stm32f429_disco/hw_init.h | 40 +++++++++++++++------- demos/stm32f429_disco/main.c | 47 ++++++++++++++++---------- demos/stm32f429_disco/pll.c | 45 +++++++++++++----------- demos/stm32f429_disco/pll.h | 44 ++++++++++++++---------- demos/stm32f429_disco/syscalls.c | 27 +++++++++++++++ demos/stm32f429_disco/usb_msc_lwext4.c | 36 +++++++++++++++++--- toolchain/cortex-m4.cmake | 4 +-- 9 files changed, 233 insertions(+), 101 deletions(-) diff --git a/demos/stm32f429_disco/config.h b/demos/stm32f429_disco/config.h index f6141c9..4ad3f19 100644 --- a/demos/stm32f429_disco/config.h +++ b/demos/stm32f429_disco/config.h @@ -1,26 +1,42 @@ -/** - * @file main.c - * @version 0.01 - * @date Jan 2, 2014 - * @author Grzegorz Kostka, kostka.grzegorz@gmail.com - * @brief ... +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. * - * @note + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * @addtogroup group - * @{ - * @addtogroup subgroup - * @{ - **********************************************************/ + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #ifndef CONFIG_H_ #define CONFIG_H_ + /**@brief Main clock frequency.*/ #define CFG_CCLK_FREQ 168000000ul +/**@brief EXT partition block size (only when static cache on)*/ +#define EXT_LOGICAL_BLOCK_SIZE (1024 * 4) + + #endif /* CONFIG_H_ */ -/** @} (end addtogroup subgroup) */ -/** @} (end addtogroup group) */ diff --git a/demos/stm32f429_disco/hw_init.c b/demos/stm32f429_disco/hw_init.c index 9f0ff97..e42cd1b 100644 --- a/demos/stm32f429_disco/hw_init.c +++ b/demos/stm32f429_disco/hw_init.c @@ -1,17 +1,30 @@ -/** - * @file hw_init.c - * @version 0.01 - * @date Oct 2, 2012 - * @author Grzegorz Kostka, kostka.grzegorz@gmail.com - * @brief ... +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. * - * @note + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * @addtogroup group - * @{ - * @addtogroup subgroup - * @{ - **********************************************************/ + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include #include @@ -62,7 +75,7 @@ void hw_init(void) LCD_SetLayer(LCD_FOREGROUND_LAYER); LCD_LOG_Init(); - LCD_LOG_SetHeader((uint8_t *)"LWEXT4 DEMO"); + LCD_LOG_SetHeader((uint8_t *)"STM32 LWEXT4 DEMO"); } void hw_usb_process(void) @@ -94,3 +107,11 @@ uint32_t hw_get_ms(void) { return _systick_; } + +void hw_wait_ms(uint32_t ms) +{ + volatile uint32_t t = _systick_; + + while((t + ms) > _systick_) + ; +} diff --git a/demos/stm32f429_disco/hw_init.h b/demos/stm32f429_disco/hw_init.h index 6b7890c..11e5d91 100644 --- a/demos/stm32f429_disco/hw_init.h +++ b/demos/stm32f429_disco/hw_init.h @@ -1,17 +1,31 @@ -/** - * @file hw_init.h - * @version 0.01 - * @date Oct 2, 2012 - * @author Grzegorz Kostka, kostka.grzegorz@gmail.com - * @brief ... +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. * - * @note + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * @addtogroup group - * @{ - * @addtogroup subgroup - * @{ - **********************************************************/ + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef HW_INIT_H_ #define HW_INIT_H_ @@ -27,6 +41,8 @@ bool hw_usb_enum_done(void); void hw_led_red(bool on); void hw_led_green(bool on); + uint32_t hw_get_ms(void); +void hw_wait_ms(uint32_t ms); #endif /* HW_INIT_H_ */ diff --git a/demos/stm32f429_disco/main.c b/demos/stm32f429_disco/main.c index d2f1b07..f72ef04 100644 --- a/demos/stm32f429_disco/main.c +++ b/demos/stm32f429_disco/main.c @@ -41,17 +41,20 @@ #include #include -/**@brief Input stream name.*/ -char input_name[128] = "ext2"; - /**@brief Read-write size*/ #define READ_WRITE_SZIZE 1024 * 8 +/**@brief Delay test (slower LCD scroll)*/ +#define TEST_DELAY_MS 2000 + +/**@brief Input stream name.*/ +char input_name[128] = "ext2"; + /**@brief Read-write size*/ static int rw_szie = READ_WRITE_SZIZE; /**@brief Read-write size*/ -static int rw_count = 1000; +static int rw_count = 100; /**@brief Directory test count*/ static int dir_cnt = 10; @@ -346,7 +349,7 @@ static void cleanup(void) printf("cleanup: remove /mp/dir1\n"); - start =get_ms(); + start = get_ms(); ext4_dir_rm("/mp/dir1"); stop = get_ms(); diff = stop - start; @@ -423,48 +426,56 @@ int main(void) printf("RW count: %d\n", rw_count); printf("Cache mode: %s\n", cache_mode ? "dynamic" : "static"); + + hw_wait_ms(TEST_DELAY_MS); if(!mount()) return EXIT_FAILURE; - cleanup(); - if(sbstat) + if(sbstat){ + hw_wait_ms(TEST_DELAY_MS); mp_stats(); + } + hw_wait_ms(TEST_DELAY_MS); dir_ls("/mp/"); if(!dir_test(dir_cnt)) return EXIT_FAILURE; + hw_wait_ms(TEST_DELAY_MS); if(!file_test()) return EXIT_FAILURE; dir_ls("/mp/"); - if(sbstat) + if(sbstat){ + hw_wait_ms(TEST_DELAY_MS); mp_stats(); + } - if(cleanup_flag) + if(cleanup_flag){ + hw_wait_ms(TEST_DELAY_MS); cleanup(); + } - if(bstat) + if(bstat){ + hw_wait_ms(TEST_DELAY_MS); block_stats(); + } if(!umount()) return EXIT_FAILURE; - printf("Test finish: OK\n"); + printf("\nTest finished: OK\n"); printf("Press RESET to restart\n"); - while (1) - { - volatile int count; - for (count = 0; count < 1000000; count++); + + while (1) { + hw_wait_ms(500); hw_led_green(1); - for (count = 0; count < 1000000; count++); + hw_wait_ms(500); hw_led_green(0); } } -/** @} (end addtogroup subgroup) */ -/** @} (end addtogroup group) */ diff --git a/demos/stm32f429_disco/pll.c b/demos/stm32f429_disco/pll.c index 9f15632..ec67ffa 100644 --- a/demos/stm32f429_disco/pll.c +++ b/demos/stm32f429_disco/pll.c @@ -1,17 +1,31 @@ -/** - * @file pll.c - * @version 0.01 - * @date Oct 2, 2012 - * @author Grzegorz Kostka, kostka.grzegorz@gmail.com - * @brief ... +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. * - * @note + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * @addtogroup group - * @{ - * @addtogroup subgroup - * @{ - **********************************************************/ + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include #include @@ -112,10 +126,3 @@ void pll_init(void) while (((RCC->CFGR) & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL) ; } - - -/** @} (end addtogroup subgroup) */ -/** @} (end addtogroup group) */ - - - diff --git a/demos/stm32f429_disco/pll.h b/demos/stm32f429_disco/pll.h index d8c7bb0..d77f580 100644 --- a/demos/stm32f429_disco/pll.h +++ b/demos/stm32f429_disco/pll.h @@ -1,31 +1,39 @@ -/** - * @file pll.h - * @version 0.01 - * @date Oct 2, 2012 - * @author Grzegorz Kostka, kostka.grzegorz@gmail.com - * @brief ... +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. * - * @note + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * @addtogroup group - * @{ - * @addtogroup subgroup - * @{ - **********************************************************/ + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef PLL_H_ #define PLL_H_ #include - /**@brief Clock initialization.*/ void pll_init(void); - - - #endif /* PLL_H_ */ -/** @} (end addtogroup subgroup) */ -/** @} (end addtogroup group) */ diff --git a/demos/stm32f429_disco/syscalls.c b/demos/stm32f429_disco/syscalls.c index 38c684f..40aee0c 100644 --- a/demos/stm32f429_disco/syscalls.c +++ b/demos/stm32f429_disco/syscalls.c @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include #include diff --git a/demos/stm32f429_disco/usb_msc_lwext4.c b/demos/stm32f429_disco/usb_msc_lwext4.c index 181ff63..a897a18 100644 --- a/demos/stm32f429_disco/usb_msc_lwext4.c +++ b/demos/stm32f429_disco/usb_msc_lwext4.c @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include #include @@ -11,17 +38,16 @@ #include #include - /**@brief Block size.*/ #define USB_MSC_BLOCK_SIZE 512 -extern USB_OTG_CORE_HANDLE USB_OTG_Core; -extern USBH_HOST USB_Host; - /**@brief MBR_block ID*/ #define MBR_BLOCK_ID 0 #define MBR_PART_TABLE_OFF 446 +extern USB_OTG_CORE_HANDLE USB_OTG_Core; +extern USBH_HOST USB_Host; + struct part_tab_entry { uint8_t status; uint8_t chs1[3]; @@ -55,7 +81,7 @@ EXT4_BLOCKDEV_STATIC_INSTANCE( ); /******************************************************************************/ -EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024); +EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, EXT_LOGICAL_BLOCK_SIZE); /******************************************************************************/ diff --git a/toolchain/cortex-m4.cmake b/toolchain/cortex-m4.cmake index d4c8d7f..c4b097a 100644 --- a/toolchain/cortex-m4.cmake +++ b/toolchain/cortex-m4.cmake @@ -18,8 +18,8 @@ set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags") +SET(CMAKE_C_FLAGS_DEBUG "-O2 -g -ggdb3" CACHE INTERNAL "c debug compiler flags") +SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags") SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags") SET(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c release compiler flags") -- 2.30.2