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