2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
5 * @addtogroup PIOS_SDCARD SDCard Functions
9 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
10 * Parts by Thorsten Klose (tk@midibox.org)
11 * @brief System and hardware Init functions header.
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 /* Public Functions */
36 uint8_t CSDStruct
; /* CSD structure */
37 uint8_t SysSpecVersion
; /* System specification version */
38 uint8_t Reserved1
; /* Reserved */
39 uint8_t TAAC
; /* Data read access-time 1 */
40 uint8_t NSAC
; /* Data read access-time 2 in CLK cycles */
41 uint8_t MaxBusClkFrec
; /* Max. bus clock frequency */
42 uint16_t CardComdClasses
; /* Card command classes */
43 uint8_t RdBlockLen
; /* Max. read data block length */
44 uint8_t PartBlockRead
; /* Partial blocks for read allowed */
45 uint8_t WrBlockMisalign
; /* Write block misalignment */
46 uint8_t RdBlockMisalign
; /* Read block misalignment */
47 uint8_t DSRImpl
; /* DSR implemented */
48 uint8_t Reserved2
; /* Reserved */
49 uint16_t DeviceSize
; /* Device Size */
50 uint8_t MaxRdCurrentVDDMin
; /* Max. read current @ VDD min */
51 uint8_t MaxRdCurrentVDDMax
; /* Max. read current @ VDD max */
52 uint8_t MaxWrCurrentVDDMin
; /* Max. write current @ VDD min */
53 uint8_t MaxWrCurrentVDDMax
; /* Max. write current @ VDD max */
54 uint8_t DeviceSizeMul
; /* Device size multiplier */
55 uint8_t EraseGrSize
; /* Erase group size */
56 uint8_t EraseGrMul
; /* Erase group size multiplier */
57 uint8_t WrProtectGrSize
; /* Write protect group size */
58 uint8_t WrProtectGrEnable
; /* Write protect group enable */
59 uint8_t ManDeflECC
; /* Manufacturer default ECC */
60 uint8_t WrSpeedFact
; /* Write speed factor */
61 uint8_t MaxWrBlockLen
; /* Max. write data block length */
62 uint8_t WriteBlockPaPartial
; /* Partial blocks for write allowed */
63 uint8_t Reserved3
; /* Reserved */
64 uint8_t ContentProtectAppli
; /* Content protection application */
65 uint8_t FileFormatGrouop
; /* File format group */
66 uint8_t CopyFlag
; /* Copy flag (OTP) */
67 uint8_t PermWrProtect
; /* Permanent write protection */
68 uint8_t TempWrProtect
; /* Temporary write protection */
69 uint8_t FileFormat
; /* File Format */
70 uint8_t ECC
; /* ECC code */
71 uint8_t msd_CRC
; /* CRC */
72 uint8_t Reserved4
; /* always 1 */
75 /* Structure taken from Mass Storage Driver example provided by STM */
77 uint8_t ManufacturerID
; /* ManufacturerID */
78 uint16_t OEM_AppliID
; /* OEM/Application ID */
79 char ProdName
[6]; /* Product Name */
80 uint8_t ProdRev
; /* Product Revision */
81 uint32_t ProdSN
; /* Product Serial Number */
82 uint8_t Reserved1
; /* Reserved1 */
83 uint16_t ManufactDate
; /* Manufacturing Date */
84 uint8_t msd_CRC
; /* CRC */
85 uint8_t Reserved2
; /* always 1 */
88 /* Global Variables */
89 extern VOLINFO PIOS_SDCARD_VolInfo
;
90 extern uint8_t PIOS_SDCARD_Sector
[SECTOR_SIZE
];
93 extern int32_t PIOS_SDCARD_Init(uint32_t spi_id
);
94 extern int32_t PIOS_SDCARD_PowerOn(void);
95 extern int32_t PIOS_SDCARD_PowerOff(void);
96 extern int32_t PIOS_SDCARD_CheckAvailable(uint8_t was_available
);
97 extern int32_t PIOS_SDCARD_SendSDCCmd(uint8_t cmd
, uint32_t addr
, uint8_t crc
);
98 extern int32_t PIOS_SDCARD_SectorRead(uint32_t sector
, uint8_t *buffer
);
99 extern int32_t PIOS_SDCARD_SectorWrite(uint32_t sector
, uint8_t *buffer
);
100 extern int32_t PIOS_SDCARD_CIDRead(SDCARDCidTypeDef
*cid
);
101 extern int32_t PIOS_SDCARD_CSDRead(SDCARDCsdTypeDef
*csd
);
103 extern int32_t PIOS_SDCARD_StartupLog(void);
104 extern int32_t PIOS_SDCARD_IsMounted();
105 extern int32_t PIOS_SDCARD_MountFS(uint32_t StartupLog
);
106 extern int32_t PIOS_SDCARD_GetFree(void);
107 #ifndef USE_SIM_POSIX
108 extern int32_t PIOS_SDCARD_ReadBuffer(PFILEINFO fileinfo
, uint8_t *buffer
, uint32_t len
);
109 extern int32_t PIOS_SDCARD_ReadLine(PFILEINFO fileinfo
, uint8_t *buffer
, uint32_t max_len
);
111 extern int32_t PIOS_SDCARD_FileCopy(char *Source
, char *Destination
);
112 extern int32_t PIOS_SDCARD_FileDelete(char *Filename
);
114 #endif /* PIOS_SDCARD_H */