ff_format.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * FreeRTOS+FAT V2.3.3
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * https://www.FreeRTOS.org
  23. * https://github.com/FreeRTOS
  24. *
  25. */
  26. /**
  27. * @file ff_format.c
  28. * @ingroup FORMAT
  29. *
  30. **/
  31. #ifndef _FF_FORMAT_H_
  32. #define _FF_FORMAT_H_
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #ifndef PLUS_FAT_H
  37. #error this header will be included from "ff_headers.h"
  38. #endif
  39. /*---------- PROTOTYPES */
  40. /* PUBLIC (Interfaces): */
  41. typedef enum _FF_SizeType
  42. {
  43. eSizeIsQuota, /* Assign a quotum (sum of xSizes is free, all disk space will be allocated) */
  44. eSizeIsPercent, /* Assign a percentage of the available space (sum of xSizes must be <= 100) */
  45. eSizeIsSectors, /* Assign fixed number of sectors (sum of xSizes must be < ulSectorCount) */
  46. } eSizeType_t;
  47. typedef struct _FF_PartitionParameters
  48. {
  49. uint32_t ulSectorCount; /* Total number of sectors on the disk, including hidden/reserved */
  50. /* Must be obtained from the block driver */
  51. uint32_t ulHiddenSectors; /* Keep at least these initial sectors free */
  52. uint32_t ulInterSpace; /* Number of sectors to keep free between partitions (when 0 -> 2048) */
  53. BaseType_t xSizes[ ffconfigMAX_PARTITIONS ]; /* E.g. 80, 20, 0, 0 (see eSizeType) */
  54. BaseType_t xPrimaryCount; /* The number of partitions that must be "primary" */
  55. eSizeType_t eSizeType;
  56. } FF_PartitionParameters_t;
  57. FF_Error_t FF_Partition( FF_Disk_t * pxDisk,
  58. FF_PartitionParameters_t * pParams );
  59. FF_Error_t FF_Format( FF_Disk_t * pxDisk,
  60. BaseType_t xPartitionNumber,
  61. BaseType_t xPreferFAT16,
  62. BaseType_t xSmallClusters );
  63. FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk,
  64. BaseType_t xPartitionNumber,
  65. BaseType_t xPreferFAT16,
  66. BaseType_t xSmallClusters,
  67. const char * pcVolumeName );
  68. /* Private : */
  69. #ifdef __cplusplus
  70. } /* extern "C" */
  71. #endif
  72. #endif /* ifndef _FF_FORMAT_H_ */