Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "k_storage.h"
Private variables
mSDDISK_FatFs
mSDDISK_Drive
StorageEvent
dir
StorageStatus
Private function prototypes
k_StorageInit()
StorageThread(const void *)
HAL_GPIO_EXTI_Callback(uint16_t)
k_StorageGetStatus(uint8_t)
Files
loading...
SourceVuSTM32 Libraries and SamplesSTemWinCore/Src/k_storage.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file k_storage.c * @author MCD Application Team * @brief This file provides the kernel storage functions ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "k_storage.h" /** @addtogroup CORE * @{ *//* ... */ /** @defgroup KERNEL_STORAGE * @brief Kernel storage routines * @{ *//* ... */ Includes /* External variables --------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ FATFS mSDDISK_FatFs; /* File system object for MSD disk logical drive */ char mSDDISK_Drive[4]; /* MSD Host logical drive number */ osMessageQId StorageEvent; DIR dir; extern uint32_t UserButton_press; extern uint32_t calibration_data[3*2]; static uint32_t StorageStatus[NUM_DISK_UNITS];Private variables /* Private function prototypes -----------------------------------------------*/ static void StorageThread(void const * argument); Private function prototypes /* Private functions ---------------------------------------------------------*/ /** * @brief Storage drives initialization * @param None * @retval None *//* ... */ void k_StorageInit(void) { /* Link the micro SD disk I/O driver */ FATFS_LinkDriver(&SD_Driver, mSDDISK_Drive); /* Create USB background task */ osThreadDef(STORAGE_Thread, StorageThread, osPriorityLow, 0, 512); osThreadCreate (osThread(STORAGE_Thread), NULL); /* Create Storage Message Queue */ osMessageQDef(osqueue, 10, uint16_t); StorageEvent = osMessageCreate (osMessageQ(osqueue), NULL); /* Enable SD Interrupt mode */ BSP_SD_Init(); BSP_SD_ITConfig(); if(BSP_SD_IsDetected()) { osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0); }if (BSP_SD_IsDetected()) { ... } }{ ... } /** * @brief Storage Thread * @param argument: pointer that is passed to the thread function as start argument. * @retval None *//* ... */ static void StorageThread(void const * argument) { osEvent event; for( ;; ) { event = osMessageGet( StorageEvent, osWaitForever ); if( event.status == osEventMessage ) { switch(event.value.v) { case MSDDISK_CONNECTION_EVENT: f_mount(&mSDDISK_FatFs, mSDDISK_Drive, 0); StorageStatus[MSD_DISK_UNIT] = 1; break; case MSDDISK_CONNECTION_EVENT: case MSDDISK_DISCONNECTION_EVENT: f_mount(0, mSDDISK_Drive, 0); StorageStatus[MSD_DISK_UNIT] = 0; break; case MSDDISK_DISCONNECTION_EVENT: }switch (event.value.v) { ... } }if (event.status == osEventMessage) { ... } }for (;;) { ... } }{ ... } /** * @brief SD detect callback * @param None * @retval None *//* ... */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if(GPIO_Pin == TS_INT_PIN) { k_TouchUpdate(); }if (GPIO_Pin == TS_INT_PIN) { ... } else if(GPIO_Pin == SD_DETECT_PIN) { if((BSP_SD_IsDetected())) { /* After sd disconnection, a SD Init is required */ BSP_SD_Init(); osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0); }if ((BSP_SD_IsDetected())) { ... } else { osMessagePut ( StorageEvent, MSDDISK_DISCONNECTION_EVENT, 0); }else { ... } }else if (GPIO_Pin == SD_DETECT_PIN) { ... } }{ ... } /** * @brief Storage get status * @param unit: logical storage unit index. * @retval int *//* ... */ uint8_t k_StorageGetStatus (uint8_t unit) { return StorageStatus[unit]; }{ ... } /** * @} *//* ... */ /** * @} *//* ... */
Details