source: ctrl/firmware/Main/CubeMX/FATFS/Target/eeprom_diskio.c @ 89

Last change on this file since 89 was 89, checked in by Zed, 3 months ago

Added basic I2C EEPROM support.

File size: 4.9 KB
Line 
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4  * @file    user_diskio.c
5  * @brief   This file includes a diskio driver skeleton to be completed by the user.
6  ******************************************************************************
7  * @attention
8  *
9  * Copyright (c) 2025 STMicroelectronics.
10  * All rights reserved.
11  *
12  * This software is licensed under terms that can be found in the LICENSE file
13  * in the root directory of this software component.
14  * If no LICENSE file comes with this software, it is provided AS-IS.
15  *
16  ******************************************************************************
17  */
18 /* USER CODE END Header */
19
20#ifdef USE_OBSOLETE_USER_CODE_SECTION_0
21/*
22 * Warning: the user section 0 is no more in use (starting from CubeMx version 4.16.0)
23 * To be suppressed in the future.
24 * Kept to ensure backward compatibility with previous CubeMx versions when
25 * migrating projects.
26 * User code previously added there should be copied in the new user sections before
27 * the section contents can be deleted.
28 */
29/* USER CODE BEGIN 0 */
30/* USER CODE END 0 */
31#endif
32
33/* USER CODE BEGIN DECL */
34
35/* Includes ------------------------------------------------------------------*/
36#include <string.h>
37#include "ff_gen_drv.h"
38
39/* Private typedef -----------------------------------------------------------*/
40/* Private define ------------------------------------------------------------*/
41
42/* Private variables ---------------------------------------------------------*/
43/* Disk status */
44static volatile DSTATUS Stat = STA_NOINIT;
45
46/* USER CODE END DECL */
47
48/* Private function prototypes -----------------------------------------------*/
49DSTATUS EEPROM_initialize (BYTE pdrv);
50DSTATUS EEPROM_status (BYTE pdrv);
51DRESULT EEPROM_read (BYTE pdrv, BYTE *buff, DWORD sector, UINT count);
52#if _USE_WRITE == 1
53  DRESULT EEPROM_write (BYTE pdrv, const BYTE *buff, DWORD sector, UINT count);
54#endif /* _USE_WRITE == 1 */
55#if _USE_IOCTL == 1
56  DRESULT EEPROM_ioctl (BYTE pdrv, BYTE cmd, void *buff);
57#endif /* _USE_IOCTL == 1 */
58
59Diskio_drvTypeDef  EEPROM_Driver =
60{
61  EEPROM_initialize,
62  EEPROM_status,
63  EEPROM_read,
64#if  _USE_WRITE
65  EEPROM_write,
66#endif  /* _USE_WRITE == 1 */
67#if  _USE_IOCTL == 1
68  EEPROM_ioctl,
69#endif /* _USE_IOCTL == 1 */
70};
71
72/* Private functions ---------------------------------------------------------*/
73
74/**
75  * @brief  Initializes a Drive
76  * @param  pdrv: Physical drive number (0..)
77  * @retval DSTATUS: Operation status
78  */
79DSTATUS EEPROM_initialize (
80        BYTE pdrv           /* Physical drive nmuber to identify the drive */
81)
82{
83  /* USER CODE BEGIN INIT */
84    Stat = STA_NOINIT;
85    return Stat;
86  /* USER CODE END INIT */
87}
88
89/**
90  * @brief  Gets Disk Status
91  * @param  pdrv: Physical drive number (0..)
92  * @retval DSTATUS: Operation status
93  */
94DSTATUS EEPROM_status (
95        BYTE pdrv       /* Physical drive number to identify the drive */
96)
97{
98  /* USER CODE BEGIN STATUS */
99    Stat = STA_NOINIT;
100    return Stat;
101  /* USER CODE END STATUS */
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  */
112DRESULT EEPROM_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  /* USER CODE BEGIN READ */
120    return RES_OK;
121  /* USER CODE END READ */
122}
123
124/**
125  * @brief  Writes Sector(s)
126  * @param  pdrv: Physical drive number (0..)
127  * @param  *buff: Data to be written
128  * @param  sector: Sector address (LBA)
129  * @param  count: Number of sectors to write (1..128)
130  * @retval DRESULT: Operation result
131  */
132#if _USE_WRITE == 1
133DRESULT EEPROM_write (
134        BYTE pdrv,          /* Physical drive nmuber to identify the drive */
135        const BYTE *buff,   /* Data to be written */
136        DWORD sector,       /* Sector address in LBA */
137        UINT count          /* Number of sectors to write */
138)
139{
140  /* USER CODE BEGIN WRITE */
141  /* USER CODE HERE */
142    return RES_OK;
143  /* USER CODE END WRITE */
144}
145#endif /* _USE_WRITE == 1 */
146
147/**
148  * @brief  I/O control operation
149  * @param  pdrv: Physical drive number (0..)
150  * @param  cmd: Control code
151  * @param  *buff: Buffer to send/receive control data
152  * @retval DRESULT: Operation result
153  */
154#if _USE_IOCTL == 1
155DRESULT EEPROM_ioctl (
156        BYTE pdrv,      /* Physical drive nmuber (0..) */
157        BYTE cmd,       /* Control code */
158        void *buff      /* Buffer to send/receive control data */
159)
160{
161  /* USER CODE BEGIN IOCTL */
162    DRESULT res = RES_ERROR;
163    return res;
164  /* USER CODE END IOCTL */
165}
166#endif /* _USE_IOCTL == 1 */
167
Note: See TracBrowser for help on using the repository browser.