-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patch-for-STM-files.patch
186 lines (164 loc) · 4.83 KB
/
Patch-for-STM-files.patch
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
From 37756f5ebbd729fd5a46d38b3afa5533bb121795 Mon Sep 17 00:00:00 2001
From: Lrakulka <Olecsandr32@gmail.com>
Date: Thu, 24 Aug 2017 19:16:10 +0300
Subject: [PATCH] Patch for STM files
---
Inc/fatfs.h | 2 +-
Inc/usbd_conf.h | 2 +-
Src/main.c | 15 +++++++++++----
Src/usbd_storage_if.c | 31 +++++++++++++++----------------
4 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/Inc/fatfs.h b/Inc/fatfs.h
index 2dc2221..a2ae0bc 100644
--- a/Inc/fatfs.h
+++ b/Inc/fatfs.h
@@ -50,7 +50,7 @@
#include "ff.h"
#include "ff_gen_drv.h"
-#include "sd_diskio.h" /* defines SD_Driver as external */
+#include "sd_io_controller.h" /* defines SD_Driver as external */
/* USER CODE BEGIN Includes */
diff --git a/Inc/usbd_conf.h b/Inc/usbd_conf.h
index 0d2af49..4696726 100644
--- a/Inc/usbd_conf.h
+++ b/Inc/usbd_conf.h
@@ -82,7 +82,7 @@
/*---------- -----------*/
#define USBD_SELF_POWERED 1
/*---------- -----------*/
-#define MSC_MEDIA_PACKET 512
+#define MSC_MEDIA_PACKET 4096
/****************************************/
/* #define for FS and HS identification */
diff --git a/Src/main.c b/Src/main.c
index d999b91..e11e6f4 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -47,7 +47,7 @@
#include "usb_device.h"
/* USER CODE BEGIN Includes */
-
+#include "user_interface.h"
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
@@ -100,11 +100,12 @@ int main(void)
MX_DMA_Init();
MX_SDIO_SD_Init();
MX_FATFS_Init();
- MX_USB_DEVICE_Init();
MX_TIM14_Init();
/* USER CODE BEGIN 2 */
-
+ initSDCard();
+ HAL_TIM_Base_Start_IT(&htim14);
+ MX_USB_DEVICE_Init();
/* USER CODE END 2 */
/* Infinite loop */
@@ -281,7 +282,13 @@ static void MX_GPIO_Init(void)
}
/* USER CODE BEGIN 4 */
-
+void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
+{
+ if (htim->Instance == TIM14)
+ {
+ checkConfFiles();
+ }
+}
/* USER CODE END 4 */
/**
diff --git a/Src/usbd_storage_if.c b/Src/usbd_storage_if.c
index e1c1a04..360beee 100644
--- a/Src/usbd_storage_if.c
+++ b/Src/usbd_storage_if.c
@@ -44,6 +44,7 @@
/* Includes ------------------------------------------------------------------*/
#include "usbd_storage_if.h"
/* USER CODE BEGIN INCLUDE */
+#include "sd_io_controller.h"
/* USER CODE END INCLUDE */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
@@ -96,17 +97,17 @@
const int8_t STORAGE_Inquirydata_FS[] = {/* 36 */
/* LUN 0 */
- 0x00,
- 0x80,
- 0x02,
+ 0x00,
+ 0x80,
+ 0x02,
0x02,
(STANDARD_INQUIRY_DATA_LEN - 5),
0x00,
- 0x00,
0x00,
- 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
- 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ 0x00,
+ 'D', 'o', 'u', 'b', 'l', 'e', ' ', ' ', /* Manufacturer : 8 bytes */
+ 'B', 'o', 't', 't', 'o', 'm', ' ', ' ', /* Product : 16 Bytes */
+ 'S', 't', 'i', 'c', 'k', ' ', ' ', ' ',
'0', '.', '0' ,'1', /* Version : 4 Bytes */
};
/* USER CODE END INQUIRY_DATA_FS */
@@ -178,7 +179,7 @@ USBD_StorageTypeDef USBD_Storage_Interface_fops_FS =
int8_t STORAGE_Init_FS (uint8_t lun)
{
/* USER CODE BEGIN 2 */
- return (USBD_OK);
+ return currentPartitionInit();
/* USER CODE END 2 */
}
@@ -192,9 +193,7 @@ int8_t STORAGE_Init_FS (uint8_t lun)
int8_t STORAGE_GetCapacity_FS (uint8_t lun, uint32_t *block_num, uint16_t *block_size)
{
/* USER CODE BEGIN 3 */
- *block_num = STORAGE_BLK_NBR;
- *block_size = STORAGE_BLK_SIZ;
- return (USBD_OK);
+ return currentPartitionCapacity(block_num, block_size);
/* USER CODE END 3 */
}
@@ -208,7 +207,7 @@ int8_t STORAGE_GetCapacity_FS (uint8_t lun, uint32_t *block_num, uint16_t *block
int8_t STORAGE_IsReady_FS (uint8_t lun)
{
/* USER CODE BEGIN 4 */
- return (USBD_OK);
+ return currentPartitionisReady();
/* USER CODE END 4 */
}
@@ -222,7 +221,7 @@ int8_t STORAGE_IsReady_FS (uint8_t lun)
int8_t STORAGE_IsWriteProtected_FS (uint8_t lun)
{
/* USER CODE BEGIN 5 */
- return (USBD_OK);
+ return currentPartitionIsWriteProtected();
/* USER CODE END 5 */
}
@@ -239,7 +238,7 @@ int8_t STORAGE_Read_FS (uint8_t lun,
uint16_t blk_len)
{
/* USER CODE BEGIN 6 */
- return (USBD_OK);
+ return currentPartitionRead(buf, blk_addr, blk_len);
/* USER CODE END 6 */
}
@@ -256,7 +255,7 @@ int8_t STORAGE_Write_FS (uint8_t lun,
uint16_t blk_len)
{
/* USER CODE BEGIN 7 */
- return (USBD_OK);
+ return currentPartitionWrite(buf, blk_addr, blk_len);
/* USER CODE END 7 */
}
@@ -270,7 +269,7 @@ int8_t STORAGE_Write_FS (uint8_t lun,
int8_t STORAGE_GetMaxLun_FS (void)
{
/* USER CODE BEGIN 8 */
- return (STORAGE_LUN_NBR - 1);
+ return currentPartitionMaxLun();
/* USER CODE END 8 */
}
--
2.13.2.windows.1