Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
atomic_usage.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017 ARM Limited 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00020 * SOFTWARE. 00021 */ 00022 #ifndef MBED_ATOMIC_USAGE_H 00023 #define MBED_ATOMIC_USAGE_H 00024 00025 #include "BlockDevice.h" 00026 00027 /** 00028 * Setup the given block device to test littlefs atomic operations 00029 * 00030 * Format the blockdevice with a littlefs filesystem and create 00031 * the files and directories required to test atomic operations. 00032 * 00033 * @param bd Block device format and setup 00034 * @param force_rebuild Force a reformat even if the device is already setup 00035 * @return true if the block device was formatted, false otherwise 00036 * @note utest asserts are used to detect fatal errors so utest must be 00037 * initialized before calling this function. 00038 */ 00039 bool setup_atomic_operations(BlockDevice *bd, bool force_rebuild); 00040 00041 /** 00042 * Perform a set of atomic littlefs operations on the block device 00043 * 00044 * Mount the block device as a littlefs filesystem and a series of 00045 * atomic operations on it. Since the operations performed are atomic 00046 * the file system will always be in a well defined state. The block 00047 * device must have been setup by calling setup_atomic_operations. 00048 * 00049 * @param bd Block device to perform the operations on 00050 * @return -1 if flash is exhausted, otherwise the cycle count on the fs 00051 * @note utest asserts are used to detect fatal errors so utest must be 00052 * initialized before calling this function. 00053 */ 00054 int64_t perform_atomic_operations(BlockDevice *bd); 00055 00056 /** 00057 * Check that the littlefs image on the block device is in a good state 00058 * 00059 * Mount the block device as a littlefs filesystem and check the files 00060 * and directories to ensure they are valid. Since all the operations 00061 * performed are atomic the filesystem should always be in a good 00062 * state. 00063 * 00064 * @param bd Block device to check 00065 * @note This function does not change the contents of the block device 00066 * @note utest asserts are used to detect fatal errors so utest must be 00067 * initialized before calling this function. 00068 */ 00069 void check_atomic_operations(BlockDevice *bd); 00070 00071 #endif
Generated on Fri Jul 22 2022 04:53:45 by
 1.7.2
 1.7.2 
    