Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
3896b4aa
Commit
3896b4aa
authored
6 years ago
by
Alexandre Abadie
Browse files
Options
Downloads
Patches
Plain Diff
tests/periph_eeprom: add test application
parent
aa6cf073
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/periph_eeprom/Makefile
+9
-0
9 additions, 0 deletions
tests/periph_eeprom/Makefile
tests/periph_eeprom/README.md
+17
-0
17 additions, 0 deletions
tests/periph_eeprom/README.md
tests/periph_eeprom/main.c
+119
-0
119 additions, 0 deletions
tests/periph_eeprom/main.c
with
145 additions
and
0 deletions
tests/periph_eeprom/Makefile
0 → 100644
+
9
−
0
View file @
3896b4aa
BOARD
?=
b-l072z-lrwan1
include
../Makefile.tests_common
FEATURES_REQUIRED
+=
periph_eeprom
USEMODULE
+=
shell
USEMODULE
+=
shell_commands
# provides reboot command
include
$(RIOTBASE)/Makefile.include
This diff is collapsed.
Click to expand it.
tests/periph_eeprom/README.md
0 → 100644
+
17
−
0
View file @
3896b4aa
Expected result
===============
Use the provided shell commands to read and write bytes from/to the MCU's
internal EEPROM memory.
# Read 10 bytes from the beginning of the eeprom
> read 0 10
# Write HelloWorld starting from the 10th position in the eeprom
> write 10 HelloWorld
Background
==========
This test application provides shell commands to verify the implementations of
the
`eeprom`
peripheral driver interface.
This diff is collapsed.
Click to expand it.
tests/periph_eeprom/main.c
0 → 100644
+
119
−
0
View file @
3896b4aa
/*
* Copyright (C) 2018 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Manual test application for the EEPROM peripheral drivers
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
* @}
*/
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
#include
"shell.h"
#include
"periph/eeprom.h"
#ifndef BUFFER_SIZE
#define BUFFER_SIZE (42U)
#endif
static
char
buffer
[
BUFFER_SIZE
+
1
];
static
int
cmd_info
(
int
argc
,
char
**
argv
)
{
(
void
)
argc
;
(
void
)
argv
;
#ifdef EEPROM_START_ADDR
printf
(
"EEPROM start addr:
\t
0x%08x
\n
"
,
(
int
)
EEPROM_START_ADDR
);
#endif
printf
(
"EEPROM size:
\t\t
%i
\n
"
,
(
int
)
EEPROM_SIZE
);
return
0
;
}
static
int
cmd_read
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
{
printf
(
"usage: %s <pos> <count>
\n
"
,
argv
[
0
]);
return
1
;
}
uint32_t
pos
=
atoi
(
argv
[
1
]);
uint8_t
count
=
atoi
(
argv
[
2
]);
if
(
!
count
)
{
puts
(
"Count should be greater than 0"
);
return
1
;
}
if
(
count
>
BUFFER_SIZE
)
{
puts
(
"Count exceeds buffer size"
);
return
1
;
}
if
(
pos
+
count
>=
EEPROM_SIZE
)
{
puts
(
"Failed: cannot read out of eeprom bounds"
);
return
1
;
}
size_t
ret
=
eeprom_read
(
pos
,
(
uint8_t
*
)
buffer
,
count
);
buffer
[
count
]
=
'\0'
;
printf
(
"Data read from EEPROM (%d bytes): %s
\n
"
,
(
int
)
ret
,
buffer
);
return
0
;
}
static
int
cmd_write
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
{
printf
(
"usage: %s <pos> <data>
\n
"
,
argv
[
0
]);
return
1
;
}
uint32_t
pos
=
atoi
(
argv
[
1
]);
if
(
pos
+
strlen
(
argv
[
2
])
>=
EEPROM_SIZE
)
{
puts
(
"Failed: cannot write out of eeprom bounds"
);
return
1
;
}
size_t
ret
=
eeprom_write
(
pos
,
(
uint8_t
*
)
argv
[
2
],
strlen
(
argv
[
2
]));
printf
(
"%d bytes written to EEPROM
\n
"
,
(
int
)
ret
);
return
0
;
}
static
const
shell_command_t
shell_commands
[]
=
{
{
"info"
,
"Print information about eeprom"
,
cmd_info
},
{
"read"
,
"Read bytes from eeprom"
,
cmd_read
},
{
"write"
,
"Write bytes to eeprom"
,
cmd_write
},
{
NULL
,
NULL
,
NULL
}
};
int
main
(
void
)
{
puts
(
"EEPROM read write test
\n
"
);
puts
(
"Please refer to the README.md for more details
\n
"
);
cmd_info
(
0
,
NULL
);
/* run the shell */
char
line_buf
[
SHELL_DEFAULT_BUFSIZE
];
shell_run
(
shell_commands
,
line_buf
,
SHELL_DEFAULT_BUFSIZE
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment