Browse Source

stm32f429 demo code format

pull/6/head
gkostka 9 years ago
parent
commit
0a123dfadb
  1. 80
      demos/stm32f429_disco/config.h
  2. 362
      demos/stm32f429_disco/hw_init.c
  3. 97
      demos/stm32f429_disco/hw_init.h
  4. 341
      demos/stm32f429_disco/main.c
  5. 295
      demos/stm32f429_disco/syscalls.c
  6. 572
      demos/stm32f429_disco/system_stm32f4xx.c
  7. 424
      demos/stm32f429_disco/usb_msc_lwext4.c
  8. 86
      demos/stm32f429_disco/usb_msc_lwext4.h
  9. 1050
      demos/stm32f429_disco/vectors.c

80
demos/stm32f429_disco/config.h

@ -1,42 +1,38 @@
/*
* 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.
*/
#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_ */
/*
* 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.
*/
#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_ */

362
demos/stm32f429_disco/hw_init.c

@ -1,191 +1,171 @@
/*
* 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 <config.h>
#include <stm32f4xx.h>
#include <stm32f429i_discovery_lcd.h>
#include <lcd_log.h>
#include <stdint.h>
#include <usbh_core.h>
#include <usbh_msc.h>
#include <hw_init.h>
#include <stdbool.h>
USBH_HandleTypeDef hUSB_Host;
static bool msc_connected = false;
static bool enum_done = false;
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
{
switch(id)
{
case HOST_USER_SELECT_CONFIGURATION:
break;
case HOST_USER_DISCONNECTION:
msc_connected = false;
enum_done = false;
break;
case HOST_USER_CLASS_ACTIVE:
enum_done = true;
break;
case HOST_USER_CONNECTION:
msc_connected = true;
break;
default:
break;
}
}
#define LCD_FRAME_BUFFER_LAYER0 (LCD_FRAME_BUFFER+0x130000)
#define LCD_FRAME_BUFFER_LAYER1 LCD_FRAME_BUFFER
#define CONVERTED_FRAME_BUFFER (LCD_FRAME_BUFFER+0x260000)
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/* Enable Power Control clock */
__PWR_CLK_ENABLE();
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig (&RCC_OscInitStruct);
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
}
void hw_init(void)
{
SystemInit();
HAL_Init();
SystemClock_Config();
/* Initialize the LEDs */
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
SysTick_Config(CFG_CCLK_FREQ / 1000);
USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
USBH_Start(&hUSB_Host);
BSP_LCD_Init();
/* Layer2 Init */
BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER_LAYER1);
BSP_LCD_SelectLayer(1);
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetColorKeying(1, LCD_COLOR_WHITE);
BSP_LCD_SetLayerVisible(1, DISABLE);
/* Layer1 Init */
BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER_LAYER0);
BSP_LCD_SelectLayer(0);
BSP_LCD_DisplayOn();
BSP_LCD_Clear(LCD_COLOR_BLACK);
LCD_LOG_Init();
LCD_LOG_SetHeader((uint8_t *)"STM32 LWEXT4 DEMO ");
}
void hw_usb_process(void)
{
USBH_Process(&hUSB_Host);
}
bool hw_usb_connected(void)
{
return msc_connected;
}
bool hw_usb_enum_done(void)
{
return enum_done;
}
void hw_led_red(bool on)
{
on ? BSP_LED_On(LED4) : BSP_LED_Off(LED4);
}
void hw_led_green(bool on)
{
on ? BSP_LED_On(LED3) : BSP_LED_Off(LED3);
}
uint32_t tim_get_ms(void)
{
return HAL_GetTick();
}
uint64_t tim_get_us(void)
{
return (uint64_t)HAL_GetTick() * 1000 +
((SysTick->LOAD - SysTick->VAL) * 1000) / SysTick->LOAD;
}
void tim_wait_ms(uint32_t ms)
{
volatile uint32_t t = HAL_GetTick();
while((t + ms) > HAL_GetTick())
;
}
/*
* 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 <config.h>
#include <stm32f4xx.h>
#include <stm32f429i_discovery_lcd.h>
#include <lcd_log.h>
#include <stdint.h>
#include <usbh_core.h>
#include <usbh_msc.h>
#include <hw_init.h>
#include <stdbool.h>
USBH_HandleTypeDef hUSB_Host;
static bool msc_connected = false;
static bool enum_done = false;
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
{
switch (id) {
case HOST_USER_SELECT_CONFIGURATION:
break;
case HOST_USER_DISCONNECTION:
msc_connected = false;
enum_done = false;
break;
case HOST_USER_CLASS_ACTIVE:
enum_done = true;
break;
case HOST_USER_CONNECTION:
msc_connected = true;
break;
default:
break;
}
}
#define LCD_FRAME_BUFFER_LAYER0 (LCD_FRAME_BUFFER + 0x130000)
#define LCD_FRAME_BUFFER_LAYER1 LCD_FRAME_BUFFER
#define CONVERTED_FRAME_BUFFER (LCD_FRAME_BUFFER + 0x260000)
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/* Enable Power Control clock */
__PWR_CLK_ENABLE();
/* The voltage scaling allows optimizing the power consumption when the
device is
clocked below the maximum system frequency, to update the voltage
scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
/* Select PLL as system clock source and configure the HCLK, PCLK1 and
PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType =
(RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 |
RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
}
void hw_init(void)
{
SystemInit();
HAL_Init();
SystemClock_Config();
/* Initialize the LEDs */
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
SysTick_Config(CFG_CCLK_FREQ / 1000);
USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
USBH_Start(&hUSB_Host);
BSP_LCD_Init();
/* Layer2 Init */
BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER_LAYER1);
BSP_LCD_SelectLayer(1);
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetColorKeying(1, LCD_COLOR_WHITE);
BSP_LCD_SetLayerVisible(1, DISABLE);
/* Layer1 Init */
BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER_LAYER0);
BSP_LCD_SelectLayer(0);
BSP_LCD_DisplayOn();
BSP_LCD_Clear(LCD_COLOR_BLACK);
LCD_LOG_Init();
LCD_LOG_SetHeader((uint8_t *)"STM32 LWEXT4 DEMO ");
}
void hw_usb_process(void) { USBH_Process(&hUSB_Host); }
bool hw_usb_connected(void) { return msc_connected; }
bool hw_usb_enum_done(void) { return enum_done; }
void hw_led_red(bool on) { on ? BSP_LED_On(LED4) : BSP_LED_Off(LED4); }
void hw_led_green(bool on) { on ? BSP_LED_On(LED3) : BSP_LED_Off(LED3); }
uint32_t tim_get_ms(void) { return HAL_GetTick(); }
uint64_t tim_get_us(void)
{
return (uint64_t)HAL_GetTick() * 1000 +
((SysTick->LOAD - SysTick->VAL) * 1000) / SysTick->LOAD;
}
void tim_wait_ms(uint32_t ms)
{
volatile uint32_t t = HAL_GetTick();
while ((t + ms) > HAL_GetTick())
;
}

97
demos/stm32f429_disco/hw_init.h

@ -1,49 +1,48 @@
/*
* 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.
*/
#ifndef HW_INIT_H_
#define HW_INIT_H_
#include <config.h>
#include <stdbool.h>
#include <stdint.h>
void hw_init(void);
void hw_usb_process(void);
bool hw_usb_connected(void);
bool hw_usb_enum_done(void);
void hw_led_red(bool on);
void hw_led_green(bool on);
uint32_t tim_get_ms(void);
uint64_t tim_get_us(void);
void tim_wait_ms(uint32_t ms);
#endif /* HW_INIT_H_ */
/*
* 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.
*/
#ifndef HW_INIT_H_
#define HW_INIT_H_
#include <config.h>
#include <stdbool.h>
#include <stdint.h>
void hw_init(void);
void hw_usb_process(void);
bool hw_usb_connected(void);
bool hw_usb_enum_done(void);
void hw_led_red(bool on);
void hw_led_green(bool on);
uint32_t tim_get_ms(void);
uint64_t tim_get_us(void);
void tim_wait_ms(uint32_t ms);
#endif /* HW_INIT_H_ */

341
demos/stm32f429_disco/main.c

@ -1,172 +1,169 @@
/*
* 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 <config.h>
#include <hw_init.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#include <time.h>
#include <usb_msc_lwext4.h>
#include <ext4.h>
#include "../../blockdev/test_lwext4.h"
/**@brief Read-write size*/
#define READ_WRITE_SZIZE 1024 * 16
/**@brief Delay test (slower LCD scroll)*/
#define TEST_DELAY_MS 1000
/**@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 = 100;
/**@brief Directory test count*/
static int dir_cnt = 100;
/**@brief Static or dynamic cache mode*/
static bool cache_mode = false;
/**@brief Cleanup after test.*/
static bool cleanup_flag = false;
/**@brief Block device stats.*/
static bool bstat = false;
/**@brief Superblock stats.*/
static bool sbstat = false;
/**@brief Block device handle.*/
static struct ext4_blockdev *bd;
/**@brief Block cache handle.*/
static struct ext4_bcache *bc;
static bool open_filedev(void)
{
bd = ext4_usb_msc_get();
bc = ext4_usb_msc_cache_get();
if(!bd || !bc){
printf("open_filedev: fail\n");
return false;
}
return true;
}
int main(void)
{
hw_init();
setbuf(stdout, 0);
printf("connect usb drive...\n");
while(!hw_usb_connected())
hw_usb_process();
printf("usb drive connected\n");
while(!hw_usb_enum_done())
hw_usb_process();
printf("usb drive enum done\n");
hw_led_red(1);
printf("test conditions:\n");
printf(" rw size: %d\n", rw_szie);
printf(" rw count: %d\n", rw_count);
printf(" cache mode: %s\n", cache_mode ? "dynamic" : "static");
if (!open_filedev())
goto Finish;
tim_wait_ms(TEST_DELAY_MS);
if(!test_lwext4_mount(bd, bc))
return EXIT_FAILURE;
tim_wait_ms(TEST_DELAY_MS);
ext4_cache_write_back("/mp/", 1);
test_lwext4_cleanup();
if(sbstat){
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_mp_stats();
}
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_dir_ls("/mp/");
if(!test_lwext4_dir_test(dir_cnt))
return EXIT_FAILURE;
tim_wait_ms(TEST_DELAY_MS);
if(!test_lwext4_file_test(rw_szie, rw_count))
return EXIT_FAILURE;
if(sbstat){
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_mp_stats();
}
if(cleanup_flag){
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_cleanup();
}
if(bstat){
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_block_stats();
}
ext4_cache_write_back("/mp/", 0);
if(!test_lwext4_umount())
return EXIT_FAILURE;
printf("press RESET button to restart\n");
Finish:
while (1) {
tim_wait_ms(500);
hw_led_green(1);
tim_wait_ms(500);
hw_led_green(0);
}
}
/*
* 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 <config.h>
#include <hw_init.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#include <time.h>
#include <usb_msc_lwext4.h>
#include <ext4.h>
#include "../../blockdev/test_lwext4.h"
/**@brief Read-write size*/
#define READ_WRITE_SZIZE 1024 * 16
/**@brief Delay test (slower LCD scroll)*/
#define TEST_DELAY_MS 1000
/**@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 = 100;
/**@brief Directory test count*/
static int dir_cnt = 100;
/**@brief Static or dynamic cache mode*/
static bool cache_mode = false;
/**@brief Cleanup after test.*/
static bool cleanup_flag = false;
/**@brief Block device stats.*/
static bool bstat = false;
/**@brief Superblock stats.*/
static bool sbstat = false;
/**@brief Block device handle.*/
static struct ext4_blockdev *bd;
/**@brief Block cache handle.*/
static struct ext4_bcache *bc;
static bool open_filedev(void)
{
bd = ext4_usb_msc_get();
bc = ext4_usb_msc_cache_get();
if (!bd || !bc) {
printf("open_filedev: fail\n");
return false;
}
return true;
}
int main(void)
{
hw_init();
setbuf(stdout, 0);
printf("connect usb drive...\n");
while (!hw_usb_connected())
hw_usb_process();
printf("usb drive connected\n");
while (!hw_usb_enum_done())
hw_usb_process();
printf("usb drive enum done\n");
hw_led_red(1);
printf("test conditions:\n");
printf(" rw size: %d\n", rw_szie);
printf(" rw count: %d\n", rw_count);
printf(" cache mode: %s\n", cache_mode ? "dynamic" : "static");
if (!open_filedev())
goto Finish;
tim_wait_ms(TEST_DELAY_MS);
if (!test_lwext4_mount(bd, bc))
return EXIT_FAILURE;
tim_wait_ms(TEST_DELAY_MS);
ext4_cache_write_back("/mp/", 1);
test_lwext4_cleanup();
if (sbstat) {
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_mp_stats();
}
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_dir_ls("/mp/");
if (!test_lwext4_dir_test(dir_cnt))
return EXIT_FAILURE;
tim_wait_ms(TEST_DELAY_MS);
if (!test_lwext4_file_test(rw_szie, rw_count))
return EXIT_FAILURE;
if (sbstat) {
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_mp_stats();
}
if (cleanup_flag) {
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_cleanup();
}
if (bstat) {
tim_wait_ms(TEST_DELAY_MS);
test_lwext4_block_stats();
}
ext4_cache_write_back("/mp/", 0);
if (!test_lwext4_umount())
return EXIT_FAILURE;
printf("press RESET button to restart\n");
Finish:
while (1) {
tim_wait_ms(500);
hw_led_green(1);
tim_wait_ms(500);
hw_led_green(0);
}
}

295
demos/stm32f429_disco/syscalls.c

@ -1,156 +1,139 @@
/*
* 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 <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <lcd_log.h>
int _getpid(void)
{
return 1;
}
int _kill(int pid, int sig)
{
errno = EINVAL;
return -1;
}
void _exit (int status)
{
_kill(status, -1);
while (1) {} /* Make sure we hang here */
}
int _write(int file, char *ptr, int len)
{
int todo;
for (todo = 0; todo < len; todo++)
{
__io_putchar( *ptr++ );
}
/* Implement your write code here, this is used by puts and printf for example */
return len;
}
caddr_t _sbrk(int incr)
{
extern char __heap_start;
extern char __heap_end;
static char *current_heap_end = &__heap_start;
char *previous_heap_end;
previous_heap_end = current_heap_end;
if (current_heap_end + incr > &__heap_end)
{
errno = ENOMEM;
return (caddr_t) -1;
}
current_heap_end += incr;
return (caddr_t)previous_heap_end;
}
int _close(int file)
{
return -1;
}
int _fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _isatty(int file)
{
return 1;
}
int _lseek(int file, int ptr, int dir)
{
return 0;
}
int _read(int file, char *ptr, int len)
{
return 0;
}
int _open(char *path, int flags, ...)
{
/* Pretend like we always fail */
return -1;
}
int _wait(int *status)
{
errno = ECHILD;
return -1;
}
int _unlink(char *name)
{
errno = ENOENT;
return -1;
}
int _stat(char *file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _link(char *old, char *new)
{
errno = EMLINK;
return -1;
}
int _fork(void)
{
errno = EAGAIN;
return -1;
}
int _execve(char *name, char **argv, char **env)
{
errno = ENOMEM;
return -1;
}
/*
* 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 <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <lcd_log.h>
int _getpid(void) { return 1; }
int _kill(int pid, int sig)
{
errno = EINVAL;
return -1;
}
void _exit(int status)
{
_kill(status, -1);
while (1) {
} /* Make sure we hang here */
}
int _write(int file, char *ptr, int len)
{
int todo;
for (todo = 0; todo < len; todo++) {
__io_putchar(*ptr++);
}
/* Implement your write code here, this is used by puts and printf for
* example */
return len;
}
caddr_t _sbrk(int incr)
{
extern char __heap_start;
extern char __heap_end;
static char *current_heap_end = &__heap_start;
char *previous_heap_end;
previous_heap_end = current_heap_end;
if (current_heap_end + incr > &__heap_end) {
errno = ENOMEM;
return (caddr_t)-1;
}
current_heap_end += incr;
return (caddr_t)previous_heap_end;
}
int _close(int file) { return -1; }
int _fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _isatty(int file) { return 1; }
int _lseek(int file, int ptr, int dir) { return 0; }
int _read(int file, char *ptr, int len) { return 0; }
int _open(char *path, int flags, ...)
{
/* Pretend like we always fail */
return -1;
}
int _wait(int *status)
{
errno = ECHILD;
return -1;
}
int _unlink(char *name)
{
errno = ENOENT;
return -1;
}
int _stat(char *file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _link(char *old, char *new)
{
errno = EMLINK;
return -1;
}
int _fork(void)
{
errno = EAGAIN;
return -1;
}
int _execve(char *name, char **argv, char **env)
{
errno = ENOMEM;
return -1;
}

572
demos/stm32f429_disco/system_stm32f4xx.c

@ -1,270 +1,302 @@
/**
******************************************************************************
* @file system_stm32f4xx.c
* @author MCD Application Team
* @version V1.0.1
* @date 26-February-2014
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
*
* This file provides two functions and one global variable to be called from
* user application:
* - SystemInit(): This function is called at startup just after reset and
* before branch to main program. This call is made inside
* the "startup_stm32f4xx.s" file.
*
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
* by the user application to setup the SysTick
* timer or configure other parameters.
*
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
* be called whenever the core clock is changed
* during program execution.
*
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/
/** @addtogroup stm32f4xx_system
* @{
*/
/** @addtogroup STM32F4xx_System_Private_Includes
* @{
*/
#include "stm32f4xx_hal.h"
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Defines
* @{
*/
/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
/******************************************************************************/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Macros
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Variables
* @{
*/
/* This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
Note: If you use this function to configure the system clock; then there
is no need to call the 2 first functions listed above, since SystemCoreClock
variable is updated automatically.
*/
uint32_t SystemCoreClock = 16000000;
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Functions
* @{
*/
/**
* @brief Setup the microcontroller system
* Initialize the FPU setting, vector table location and External memory
* configuration.
* @param None
* @retval None
*/
void SystemInit(void)
{
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
#endif
/* Reset the RCC clock configuration to the default reset state ------------*/
/* Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
/* Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xFEF6FFFF;
/* Reset PLLCFGR register */
RCC->PLLCFGR = 0x24003010;
/* Reset HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/* Disable all interrupts */
RCC->CIR = 0x00000000;
/* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}
/**
* @brief Update SystemCoreClock variable according to Clock Register Values.
* The SystemCoreClock variable contains the core clock (HCLK), it can
* be used by the user application to setup the SysTick timer or configure
* other parameters.
*
* @note Each time the core clock (HCLK) changes, this function must be called
* to update SystemCoreClock variable value. Otherwise, any configuration
* based on this variable will be incorrect.
*
* @note - The system frequency computed by this function is not the real
* frequency in the chip. It is calculated based on the predefined
* constant and the selected clock source:
*
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
*
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
*
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
* or HSI_VALUE(*) multiplied/divided by the PLL factors.
*
* (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
* 16 MHz) but the real value may vary depending on the variations
* in voltage and temperature.
*
* (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
* depends on the application requirements), user has to ensure that HSE_VALUE
* is same as the real frequency of the crystal used. Otherwise, this function
* may have wrong result.
*
* - The result of this function could be not correct when using fractional
* value for HSE crystal.
*
* @param None
* @retval None
*/
void SystemCoreClockUpdate(void)
{
uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
/* Get SYSCLK source -------------------------------------------------------*/
tmp = RCC->CFGR & RCC_CFGR_SWS;
switch (tmp)
{
case 0x00: /* HSI used as system clock source */
SystemCoreClock = HSI_VALUE;
break;
case 0x04: /* HSE used as system clock source */
SystemCoreClock = HSE_VALUE;
break;
case 0x08: /* PLL used as system clock source */
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
SYSCLK = PLL_VCO / PLL_P
*/
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
if (pllsource != 0)
{
/* HSE used as PLL clock source */
pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
}
else
{
/* HSI used as PLL clock source */
pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
}
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
SystemCoreClock = pllvco/pllp;
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
/* Compute HCLK frequency --------------------------------------------------*/
/* Get HCLK prescaler */
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
/* HCLK frequency */
SystemCoreClock >>= tmp;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file system_stm32f4xx.c
* @author MCD Application Team
* @version V1.0.1
* @date 26-February-2014
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
*
* This file provides two functions and one global variable to be called from
* user application:
* - SystemInit(): This function is called at startup just after reset and
* before branch to main program. This call is made inside
* the "startup_stm32f4xx.s" file.
*
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be
*used
* by the user application to setup the
*SysTick
* timer or configure other parameters.
*
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and
*must
* be called whenever the core clock is changed
* during program execution.
*
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without
*modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*notice,
* this list of conditions and the following disclaimer in the
*documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its
*contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
*ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
*LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
*USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/
/** @addtogroup stm32f4xx_system
* @{
*/
/** @addtogroup STM32F4xx_System_Private_Includes
* @{
*/
#include "stm32f4xx_hal.h"
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Defines
* @{
*/
/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET \
0x00 /*!< Vector Table base offset field. \
This value must be a multiple of 0x200. */
/******************************************************************************/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Macros
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Variables
* @{
*/
/* This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock
frequency
Note: If you use this function to configure the system clock; then there
is no need to call the 2 first functions listed above, since
SystemCoreClock
variable is updated automatically.
*/
uint32_t SystemCoreClock = 16000000;
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0,
1, 2, 3, 4, 6, 7, 8, 9};
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Functions
* @{
*/
/**
* @brief Setup the microcontroller system
* Initialize the FPU setting, vector table location and External
* memory
* configuration.
* @param None
* @retval None
*/
void SystemInit(void)
{
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10 * 2) |
(3UL << 11 * 2)); /* set CP10 and CP11 Full Access */
#endif
/* Reset the RCC clock configuration to the default reset state
* ------------*/
/* Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
/* Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xFEF6FFFF;
/* Reset PLLCFGR register */
RCC->PLLCFGR = 0x24003010;
/* Reset HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/* Disable all interrupts */
RCC->CIR = 0x00000000;
/* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
SCB->VTOR =
SRAM_BASE |
VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR =
FLASH_BASE |
VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}
/**
* @brief Update SystemCoreClock variable according to Clock Register Values.
* The SystemCoreClock variable contains the core clock (HCLK), it can
* be used by the user application to setup the SysTick timer or
* configure
* other parameters.
*
* @note Each time the core clock (HCLK) changes, this function must be
* called
* to update SystemCoreClock variable value. Otherwise, any
* configuration
* based on this variable will be incorrect.
*
* @note - The system frequency computed by this function is not the real
* frequency in the chip. It is calculated based on the predefined
* constant and the selected clock source:
*
* - If SYSCLK source is HSI, SystemCoreClock will contain the
* HSI_VALUE(*)
*
* - If SYSCLK source is HSE, SystemCoreClock will contain the
* HSE_VALUE(**)
*
* - If SYSCLK source is PLL, SystemCoreClock will contain the
* HSE_VALUE(**)
* or HSI_VALUE(*) multiplied/divided by the PLL factors.
*
* (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file
* (default value
* 16 MHz) but the real value may vary depending on the variations
* in voltage and temperature.
*
* (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file
* (its value
* depends on the application requirements), user has to ensure
* that HSE_VALUE
* is same as the real frequency of the crystal used. Otherwise,
* this function
* may have wrong result.
*
* - The result of this function could be not correct when using
* fractional
* value for HSE crystal.
*
* @param None
* @retval None
*/
void SystemCoreClockUpdate(void)
{
uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
/* Get SYSCLK source
* -------------------------------------------------------*/
tmp = RCC->CFGR & RCC_CFGR_SWS;
switch (tmp) {
case 0x00: /* HSI used as system clock source */
SystemCoreClock = HSI_VALUE;
break;
case 0x04: /* HSE used as system clock source */
SystemCoreClock = HSE_VALUE;
break;
case 0x08: /* PLL used as system clock source */
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
SYSCLK = PLL_VCO / PLL_P
*/
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
if (pllsource != 0) {
/* HSE used as PLL clock source */
pllvco = (HSE_VALUE / pllm) *
((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
} else {
/* HSI used as PLL clock source */
pllvco = (HSI_VALUE / pllm) *
((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
}
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >> 16) + 1) * 2;
SystemCoreClock = pllvco / pllp;
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
/* Compute HCLK frequency
* --------------------------------------------------*/
/* Get HCLK prescaler */
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
/* HCLK frequency */
SystemCoreClock >>= tmp;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

424
demos/stm32f429_disco/usb_msc_lwext4.c

@ -1,221 +1,203 @@
/*
* 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 <ext4_config.h>
#include <ext4_blockdev.h>
#include <ext4_errno.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <hw_init.h>
#include <usbh_core.h>
#include <usbh_msc.h>
#include <usb_msc_lwext4.h>
#include "../../blockdev/test_lwext4.h"
extern USBH_HandleTypeDef hUSB_Host;
/**@brief Block size.*/
#define USB_MSC_BLOCK_SIZE 512
/**@brief MBR_block ID*/
#define MBR_BLOCK_ID 0
#define MBR_PART_TABLE_OFF 446
struct part_tab_entry {
uint8_t status;
uint8_t chs1[3];
uint8_t type;
uint8_t chs2[3];
uint32_t first_lba;
uint32_t sectors;
}__attribute__((packed));
/**@brief Partition block offset*/
static uint32_t part_offset;
/**@brief IO timings*/
struct usb_msc_io_timings {
uint64_t acc_bread;
uint64_t acc_bwrite;
uint32_t cnt_bread;
uint32_t cnt_bwrite;
uint32_t av_bread;
uint32_t av_bwrite;
};
static struct usb_msc_io_timings io_timings;
void io_timings_clear(void)
{
memset(&io_timings, 0, sizeof(struct usb_msc_io_timings));
}
const struct ext4_io_stats * io_timings_get(uint32_t time_sum_ms)
{
static struct ext4_io_stats s;
s.io_read = (((float)io_timings.acc_bread * 100.0) / time_sum_ms);
s.io_read /= 1000.0;
s.io_write= (((float)io_timings.acc_bwrite * 100.0) / time_sum_ms);
s.io_write /= 1000.0;
s.cpu = 100.0 - s.io_read - s.io_write;
return &s;
}
/**********************BLOCKDEV INTERFACE**************************************/
static int usb_msc_open(struct ext4_blockdev *bdev);
static int usb_msc_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
uint32_t blk_cnt);
static int usb_msc_bwrite(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt);
static int usb_msc_close(struct ext4_blockdev *bdev);
/******************************************************************************/
EXT4_BLOCKDEV_STATIC_INSTANCE(
_usb_msc,
USB_MSC_BLOCK_SIZE,
0,
usb_msc_open,
usb_msc_bread,
usb_msc_bwrite,
usb_msc_close
);
/******************************************************************************/
EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, EXT_LOGICAL_BLOCK_SIZE);
/******************************************************************************/
static int usb_msc_open(struct ext4_blockdev *bdev)
{
(void)bdev;
static uint8_t mbr[512];
struct part_tab_entry *part0;
uint8_t status;
if(!hw_usb_connected())
return EIO;
status = USBH_MSC_Read(&hUSB_Host, 0, 0, mbr, 1);
if(status != USBH_OK)
return EIO;
part0 = (struct part_tab_entry *)(mbr + MBR_PART_TABLE_OFF);
MSC_LUNTypeDef lun;
USBH_MSC_GetLUNInfo(&hUSB_Host, 0, &lun);
part_offset = part0->first_lba;
_usb_msc.ph_bcnt = lun.capacity.block_nbr;
return hw_usb_connected() ? EOK : EIO;
}
static int usb_msc_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
uint32_t blk_cnt)
{
uint8_t status;
uint64_t v = tim_get_us();
if(!hw_usb_connected())
return EIO;
while(!USBH_MSC_UnitIsReady(&hUSB_Host, 0))
;
status = USBH_MSC_Read(&hUSB_Host, 0, blk_id + part_offset, buf, blk_cnt);
if(status != USBH_OK)
return EIO;
io_timings.acc_bread += tim_get_us() - v;
io_timings.cnt_bread++;
io_timings.av_bread = io_timings.acc_bread / io_timings.cnt_bread;
return EOK;
}
static int usb_msc_bwrite(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt)
{
uint8_t status;
uint64_t v = tim_get_us();
if(!hw_usb_connected())
return EIO;
while(!USBH_MSC_UnitIsReady(&hUSB_Host, 0))
;
status = USBH_MSC_Write(&hUSB_Host, 0, blk_id + part_offset, (void *)buf, blk_cnt);
if(status != USBH_OK)
return EIO;
io_timings.acc_bwrite += tim_get_us() - v;
io_timings.cnt_bwrite++;
io_timings.av_bwrite = io_timings.acc_bwrite / io_timings.cnt_bwrite;
return EOK;
}
static int usb_msc_close(struct ext4_blockdev *bdev)
{
(void)bdev;
return EOK;
}
/******************************************************************************/
struct ext4_bcache* ext4_usb_msc_cache_get(void)
{
return &_usb_msc_cache;
}
struct ext4_blockdev* ext4_usb_msc_get(void)
{
return &_usb_msc;
}
/*
* 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 <ext4_config.h>
#include <ext4_blockdev.h>
#include <ext4_errno.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <hw_init.h>
#include <usbh_core.h>
#include <usbh_msc.h>
#include <usb_msc_lwext4.h>
#include "../../blockdev/test_lwext4.h"
extern USBH_HandleTypeDef hUSB_Host;
/**@brief Block size.*/
#define USB_MSC_BLOCK_SIZE 512
/**@brief MBR_block ID*/
#define MBR_BLOCK_ID 0
#define MBR_PART_TABLE_OFF 446
struct part_tab_entry {
uint8_t status;
uint8_t chs1[3];
uint8_t type;
uint8_t chs2[3];
uint32_t first_lba;
uint32_t sectors;
} __attribute__((packed));
/**@brief Partition block offset*/
static uint32_t part_offset;
/**@brief IO timings*/
struct usb_msc_io_timings {
uint64_t acc_bread;
uint64_t acc_bwrite;
uint32_t cnt_bread;
uint32_t cnt_bwrite;
uint32_t av_bread;
uint32_t av_bwrite;
};
static struct usb_msc_io_timings io_timings;
void io_timings_clear(void)
{
memset(&io_timings, 0, sizeof(struct usb_msc_io_timings));
}
const struct ext4_io_stats *io_timings_get(uint32_t time_sum_ms)
{
static struct ext4_io_stats s;
s.io_read = (((float)io_timings.acc_bread * 100.0) / time_sum_ms);
s.io_read /= 1000.0;
s.io_write = (((float)io_timings.acc_bwrite * 100.0) / time_sum_ms);
s.io_write /= 1000.0;
s.cpu = 100.0 - s.io_read - s.io_write;
return &s;
}
/**********************BLOCKDEV INTERFACE**************************************/
static int usb_msc_open(struct ext4_blockdev *bdev);
static int usb_msc_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
uint32_t blk_cnt);
static int usb_msc_bwrite(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt);
static int usb_msc_close(struct ext4_blockdev *bdev);
/******************************************************************************/
EXT4_BLOCKDEV_STATIC_INSTANCE(_usb_msc, USB_MSC_BLOCK_SIZE, 0, usb_msc_open,
usb_msc_bread, usb_msc_bwrite, usb_msc_close);
/******************************************************************************/
EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE,
EXT_LOGICAL_BLOCK_SIZE);
/******************************************************************************/
static int usb_msc_open(struct ext4_blockdev *bdev)
{
(void)bdev;
static uint8_t mbr[512];
struct part_tab_entry *part0;
uint8_t status;
if (!hw_usb_connected())
return EIO;
status = USBH_MSC_Read(&hUSB_Host, 0, 0, mbr, 1);
if (status != USBH_OK)
return EIO;
part0 = (struct part_tab_entry *)(mbr + MBR_PART_TABLE_OFF);
MSC_LUNTypeDef lun;
USBH_MSC_GetLUNInfo(&hUSB_Host, 0, &lun);
part_offset = part0->first_lba;
_usb_msc.ph_bcnt = lun.capacity.block_nbr;
return hw_usb_connected() ? EOK : EIO;
}
static int usb_msc_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
uint32_t blk_cnt)
{
uint8_t status;
uint64_t v = tim_get_us();
if (!hw_usb_connected())
return EIO;
while (!USBH_MSC_UnitIsReady(&hUSB_Host, 0))
;
status =
USBH_MSC_Read(&hUSB_Host, 0, blk_id + part_offset, buf, blk_cnt);
if (status != USBH_OK)
return EIO;
io_timings.acc_bread += tim_get_us() - v;
io_timings.cnt_bread++;
io_timings.av_bread = io_timings.acc_bread / io_timings.cnt_bread;
return EOK;
}
static int usb_msc_bwrite(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt)
{
uint8_t status;
uint64_t v = tim_get_us();
if (!hw_usb_connected())
return EIO;
while (!USBH_MSC_UnitIsReady(&hUSB_Host, 0))
;
status = USBH_MSC_Write(&hUSB_Host, 0, blk_id + part_offset,
(void *)buf, blk_cnt);
if (status != USBH_OK)
return EIO;
io_timings.acc_bwrite += tim_get_us() - v;
io_timings.cnt_bwrite++;
io_timings.av_bwrite = io_timings.acc_bwrite / io_timings.cnt_bwrite;
return EOK;
}
static int usb_msc_close(struct ext4_blockdev *bdev)
{
(void)bdev;
return EOK;
}
/******************************************************************************/
struct ext4_bcache *ext4_usb_msc_cache_get(void) { return &_usb_msc_cache; }
struct ext4_blockdev *ext4_usb_msc_get(void) { return &_usb_msc; }

86
demos/stm32f429_disco/usb_msc_lwext4.h

@ -1,43 +1,43 @@
/*
* 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.
*/
#ifndef USB_MSC_LWEXT4_H_
#define USB_MSC_LWEXT4_H_
#include <ext4_config.h>
#include <ext4_blockdev.h>
#include <stdint.h>
#include <stdbool.h>
/**@brief USB MSC cache get.*/
struct ext4_bcache* ext4_usb_msc_cache_get(void);
/**@brief USB MSC blockdev get.*/
struct ext4_blockdev* ext4_usb_msc_get(void);
#endif /* USB_MSC_LWEXT4_H_ */
/*
* 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.
*/
#ifndef USB_MSC_LWEXT4_H_
#define USB_MSC_LWEXT4_H_
#include <ext4_config.h>
#include <ext4_blockdev.h>
#include <stdint.h>
#include <stdbool.h>
/**@brief USB MSC cache get.*/
struct ext4_bcache *ext4_usb_msc_cache_get(void);
/**@brief USB MSC blockdev get.*/
struct ext4_blockdev *ext4_usb_msc_get(void);
#endif /* USB_MSC_LWEXT4_H_ */

1050
demos/stm32f429_disco/vectors.c

File diff suppressed because it is too large
Loading…
Cancel
Save