Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev(Examples): Test clang-format-run workflow #745

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 41 additions & 43 deletions Examples/MAX32670/WearLeveling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Below is a list of the supported commands:
* help: Prints out the list of available commands and describes how each command is used.
* stop: Ends the example.
* read: Reads data from a file and prints it to the terminal.
* write: Writes data to a file and can optionally create the file to write to if it does not already exist.
* write: Writes a characterstring to a file
* swl: Stands for "show wear leveling". This command performs a specified number of writes (passed as an argument on the command line) to a test file and prints out the number of times each filesystem block was written to. Users should see the writes occur somewhat evenly across most filesystem blocks.

Enter "help" in the command line to see more details on the usage of each of the commands including what arguments/options need to be specified to successfully execute each command.
Expand Down Expand Up @@ -34,54 +34,50 @@ Universal instructions on building, flashing, and debugging this project can be
The Console UART of the device will output these messages:

```
********** Wear Leveling Example **********
Mounting the filesystem...
C:/MaximSDK/Libraries/littlefs/lfs.c:1224:error: Corrupted dir pair at {0x0, 0x1}
*************** Wear Leveling Example ***************
Mounting the file system...
littlefs/lfs.c:1224:error: Corrupted dir pair at {0x0, 0x1}
Filesystem is invalid, formatting...
Filesystem is mounted! Ready for commands.

cmd> help

The available commands are:
* help
Description: Prints out list of available commands.
Usage: help

* stop
Description: Ends the example.
Usage: stop

* read
Description: Reads data from a specific location within a file. If
the read is successful, the data read is printed to the
terminal.
Usage: read <filename> <number of bytes to read> <location>

* write
Description: Writes a character string to a specific location within
a file.
Usage: write (--create) <filename> <character string> <location>
Options:
--create: Creates file <filename> if it does not already exist.
* swl
DDescription: Stands for "show wear leveling". Writes to a file the
specified number of times. Once all writes have completed,
the number of times each flash page (filesystem block)
was written to is printed to the terminal. This command may
take a while to complete. LED0 is used as a heartbeat while
the command is executing.
Usage: swl <number of writes>


cmd> write --create demo_file thisisanexampledatastringtowritetodemofile 0
File system is mounted!

CLI Initialized! Enter 'help' to see a list of available commands.

$ help
help

stop:
Usage: stop
Description: Ends the example

read:
Usage: read <filename> <number of bytes> <location>
Description: Reads data from a specific location within a file.

write:
Usage: write <filename> <character string> <location>
Description: Writes a character string to a specific location within a file.

swl:
Usage: swl <number of writes>
Description: Stands for "show wear leveling." This command writes to a file
the specified number of times. Once all writes have completed, the number
of times each flash page (filesystem block) was written to is printed to
the terminal. (Writes should be distributed somewhat evenly across many
filesystem blocks.) This command may take a while to complete. LED0 is
used as a heartbeat while the command is executing.

$ write demo_file thisisanexampledatastringtowritetodemofile 0
write demo_file thisisanexampledatastringtowritetodemofile 0
42 bytes were written to demo_file in filesystem block 6.

cmd> read demo_file 42 0
$ read demo_file 42 0
read demo_file 42 0
42 bytes were read from demo_file in filesystem block 6.
The following string was read from file demo_file:
thisisanexampledatastringtowritetodemofile

cmd> swl 1000
$ swl 1000
swl 1000
All writes have completed. Here are the results:
Block 0 was written to 0 times.
Block 1 was written to 0 times.
Expand All @@ -101,8 +97,10 @@ Block 14 was written to 83 times.
Block 15 was written to 83 times.


cmd> stop
$ stop
stop

$
Filesystem resources released.
Example complete!
```
Expand Down
60 changes: 0 additions & 60 deletions Examples/MAX32670/WearLeveling/include/cli.h

This file was deleted.

54 changes: 54 additions & 0 deletions Examples/MAX32670/WearLeveling/include/cmd_table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/******************************************************************************
* Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
******************************************************************************/

#ifndef EXAMPLES_MAX32670_WEARLEVELING_INCLUDE_CMD_TABLE_H_
#define EXAMPLES_MAX32670_WEARLEVELING_INCLUDE_CMD_TABLE_H_

#define CMD_TABLE \
{ { "stop", "stop", "Ends the example", handle_stop }, \
{ "read", "read <filename> <number of bytes> <location>", \
"Reads data from a specific location within a file.", handle_read }, \
{ "write", "write <filename> <character string> <location>", \
"Writes a character string to a specific location within a file.\n If the create flag is included and the file does not exist, the file will\n be created.", \
handle_write }, \
{ "swl", "swl <number of writes>", \
"Stands for \"show wear leveling.\" This command writes to a file\n the specified number of times. Once all writes have completed, the number\n of times each flash page (filesystem block) was written to is printed to\n the terminal. (Writes should be distributed somewhat evenly across many\n filesystem blocks.) This command may take a while to complete. LED0 is\n used as a heartbeat while the command is executing.", \
handle_swl } };

#define FILENAME_POS 1
#define NUM_WRITES_POS 1
#define NUM_BYTES_POS 2
#define DATA_POS 2
#define LOCATION_POS 3

#endif /* EXAMPLES_MAX32670_WEARLEVELING_INCLUDE_CMD_TABLE_H_ */
42 changes: 0 additions & 42 deletions Examples/MAX32670/WearLeveling/include/main.h

This file was deleted.

Loading
Loading