diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-06-14 09:26:16 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-06-14 09:26:16 +0000 |
commit | 2d4c475d1d9a67d03193366a6a402d00de7f414a (patch) | |
tree | 3255af82e3afacb3684ec86f61df4c71ff82f823 /os/hal/lib/peripherals/flash/hal_flash.c | |
parent | 75d0d3d59766c8834305dce0025e27a037b9408d (diff) | |
download | ChibiOS-2d4c475d1d9a67d03193366a6a402d00de7f414a.tar.gz ChibiOS-2d4c475d1d9a67d03193366a6a402d00de7f414a.tar.bz2 ChibiOS-2d4c475d1d9a67d03193366a6a402d00de7f414a.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9625 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/lib/peripherals/flash/hal_flash.c')
-rw-r--r-- | os/hal/lib/peripherals/flash/hal_flash.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/os/hal/lib/peripherals/flash/hal_flash.c b/os/hal/lib/peripherals/flash/hal_flash.c index b65ca3768..439a9c6aa 100644 --- a/os/hal/lib/peripherals/flash/hal_flash.c +++ b/os/hal/lib/peripherals/flash/hal_flash.c @@ -72,4 +72,44 @@ flash_error_t flashWaitErase(BaseFlash *devp) { }
}
+/**
+ * @brief Returns the offset of a sector.
+ */
+flash_offset_t flashGetSectorOffset(BaseFlash *devp,
+ flash_sector_t sector) {
+ flash_offset_t offset;
+ const flash_descriptor_t *descriptor = flashGetDescriptor(devp);
+
+ osalDbgAssert(sector < descriptor->sectors_count, "invalid sector");
+
+ if (descriptor->sectors != NULL) {
+ offset = descriptor->sectors[sector].offset;
+ }
+ else {
+ offset = (flash_offset_t)sector * (flash_offset_t)descriptor->sectors_size;
+ }
+
+ return offset;
+}
+
+/**
+ * @brief Returns the size of a sector.
+ */
+uint32_t flashGetSectorSize(BaseFlash *devp,
+ flash_sector_t sector) {
+ uint32_t size;
+ const flash_descriptor_t *descriptor = flashGetDescriptor(devp);
+
+ osalDbgAssert(sector < descriptor->sectors_count, "invalid sector");
+
+ if (descriptor->sectors != NULL) {
+ size = descriptor->sectors[sector].size;
+ }
+ else {
+ size = descriptor->sectors_size;
+ }
+
+ return size;
+}
+
/** @} */
|