Browse code

Add source code of the firmware for the IO Board

Pawel Jablonski authored on 05/06/2023 17:01:27
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,180 @@
1
+/*-----------------------------------------------------------------------*/
2
+/* Low level disk I/O module skeleton for FatFs     (C)ChaN, 2014        */
3
+/*                                                                       */
4
+/*   Portions COPYRIGHT 2017 STMicroelectronics                          */
5
+/*   Portions Copyright (C) 2014, ChaN, all right reserved               */
6
+/*-----------------------------------------------------------------------*/
7
+/* If a working storage control module is available, it should be        */
8
+/* attached to the FatFs via a glue function rather than modifying it.   */
9
+/* This is an example of glue functions to attach various exsisting      */
10
+/* storage control modules to the FatFs module with a defined API.       */
11
+/*-----------------------------------------------------------------------*/
12
+
13
+/**
14
+  ******************************************************************************
15
+  * @file    diskio.c 
16
+  * @author  MCD Application Team
17
+  * @version V1.4.1
18
+  * @date    14-February-2017
19
+  * @brief   FatFs low level disk I/O module.
20
+  ******************************************************************************
21
+  * @attention
22
+  *
23
+  *
24
+  * Redistribution and use in source and binary forms, with or without 
25
+  * modification, are permitted, provided that the following conditions are met:
26
+  *
27
+  * 1. Redistribution of source code must retain the above copyright notice, 
28
+  *    this list of conditions and the following disclaimer.
29
+  * 2. Redistributions in binary form must reproduce the above copyright notice,
30
+  *    this list of conditions and the following disclaimer in the documentation
31
+  *    and/or other materials provided with the distribution.
32
+  * 3. Neither the name of STMicroelectronics nor the names of other 
33
+  *    contributors to this software may be used to endorse or promote products 
34
+  *    derived from this software without specific written permission.
35
+  * 4. This software, including modifications and/or derivative works of this 
36
+  *    software, must execute solely and exclusively on microcontroller or
37
+  *    microprocessor devices manufactured by or for STMicroelectronics.
38
+  * 5. Redistribution and use of this software other than as permitted under 
39
+  *    this license is void and will automatically terminate your rights under 
40
+  *    this license. 
41
+  *
42
+  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
43
+  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
44
+  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
45
+  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
46
+  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
47
+  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
48
+  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49
+  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
50
+  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
51
+  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
52
+  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53
+  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
+  *
55
+  ******************************************************************************
56
+  */
57
+
58
+/* Includes ------------------------------------------------------------------*/
59
+#include "diskio.h"
60
+#include "ff_gen_drv.h"
61
+
62
+/* Private typedef -----------------------------------------------------------*/
63
+/* Private define ------------------------------------------------------------*/
64
+/* Private variables ---------------------------------------------------------*/
65
+extern Disk_drvTypeDef  disk;
66
+
67
+/* Private function prototypes -----------------------------------------------*/
68
+/* Private functions ---------------------------------------------------------*/
69
+
70
+/**
71
+  * @brief  Gets Disk Status 
72
+  * @param  pdrv: Physical drive number (0..)
73
+  * @retval DSTATUS: Operation status
74
+  */
75
+DSTATUS disk_status (
76
+	BYTE pdrv		/* Physical drive nmuber to identify the drive */
77
+)
78
+{
79
+  DSTATUS stat;
80
+  
81
+  stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
82
+  return stat;
83
+}
84
+
85
+/**
86
+  * @brief  Initializes a Drive
87
+  * @param  pdrv: Physical drive number (0..)
88
+  * @retval DSTATUS: Operation status
89
+  */
90
+DSTATUS disk_initialize (
91
+	BYTE pdrv				/* Physical drive nmuber to identify the drive */
92
+)
93
+{
94
+  DSTATUS stat = RES_OK;
95
+  
96
+  if(disk.is_initialized[pdrv] == 0)
97
+  { 
98
+    disk.is_initialized[pdrv] = 1;
99
+    stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
100
+  }
101
+  return stat;
102
+}
103
+
104
+/**
105
+  * @brief  Reads Sector(s) 
106
+  * @param  pdrv: Physical drive number (0..)
107
+  * @param  *buff: Data buffer to store read data
108
+  * @param  sector: Sector address (LBA)
109
+  * @param  count: Number of sectors to read (1..128)
110
+  * @retval DRESULT: Operation result
111
+  */
112
+DRESULT disk_read (
113
+	BYTE pdrv,		/* Physical drive nmuber to identify the drive */
114
+	BYTE *buff,		/* Data buffer to store read data */
115
+	DWORD sector,	        /* Sector address in LBA */
116
+	UINT count		/* Number of sectors to read */
117
+)
118
+{
119
+  DRESULT res;
120
+ 
121
+  res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
122
+  return res;
123
+}
124
+
125
+/**
126
+  * @brief  Writes Sector(s)  
127
+  * @param  pdrv: Physical drive number (0..)
128
+  * @param  *buff: Data to be written
129
+  * @param  sector: Sector address (LBA)
130
+  * @param  count: Number of sectors to write (1..128)
131
+  * @retval DRESULT: Operation result
132
+  */
133
+#if _USE_WRITE == 1
134
+DRESULT disk_write (
135
+	BYTE pdrv,		/* Physical drive nmuber to identify the drive */
136
+	const BYTE *buff,	/* Data to be written */
137
+	DWORD sector,		/* Sector address in LBA */
138
+	UINT count        	/* Number of sectors to write */
139
+)
140
+{
141
+  DRESULT res;
142
+  
143
+  res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
144
+  return res;
145
+}
146
+#endif /* _USE_WRITE == 1 */
147
+
148
+/**
149
+  * @brief  I/O control operation  
150
+  * @param  pdrv: Physical drive number (0..)
151
+  * @param  cmd: Control code
152
+  * @param  *buff: Buffer to send/receive control data
153
+  * @retval DRESULT: Operation result
154
+  */
155
+#if _USE_IOCTL == 1
156
+DRESULT disk_ioctl (
157
+	BYTE pdrv,		/* Physical drive nmuber (0..) */
158
+	BYTE cmd,		/* Control code */
159
+	void *buff		/* Buffer to send/receive control data */
160
+)
161
+{
162
+  DRESULT res;
163
+
164
+  res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
165
+  return res;
166
+}
167
+#endif /* _USE_IOCTL == 1 */
168
+
169
+/**
170
+  * @brief  Gets Time from RTC 
171
+  * @param  None
172
+  * @retval Time in DWORD
173
+  */
174
+__weak DWORD get_fattime (void)
175
+{
176
+  return 0;
177
+}
178
+
179
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
180
+