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
9fa58af7
Commit
9fa58af7
authored
6 years ago
by
Alexandre Abadie
Browse files
Options
Downloads
Patches
Plain Diff
drivers/periph: add API for internal MCU EEPROM
parent
01934de2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/include/periph/eeprom.h
+82
-0
82 additions, 0 deletions
drivers/include/periph/eeprom.h
drivers/periph_common/eeprom.c
+52
-0
52 additions, 0 deletions
drivers/periph_common/eeprom.c
with
134 additions
and
0 deletions
drivers/include/periph/eeprom.h
0 → 100644
+
82
−
0
View file @
9fa58af7
/*
* 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.
*/
/**
* @defgroup drivers_periph_eeprom EEPROM driver
* @ingroup drivers_periph
* @brief Low-level EEPROM interface
*
* @{
* @file
* @brief Low-level eeprom driver interface
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
*/
#ifndef PERIPH_EEPROM_H
#define PERIPH_EEPROM_H
#include
<stdint.h>
#include
"cpu.h"
#include
"periph_cpu.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#ifndef EEPROM_SIZE
#error "periph/eeprom: EEPROM_SIZE is not defined"
#endif
/**
* @brief Read a byte at the given position in eeprom
*
* @param[in] pos position to read
*
* @return the byte read
*/
uint8_t
eeprom_read_byte
(
uint32_t
pos
);
/**
* @brief Read @p len bytes from the given position
*
* @param[in] pos start position in eeprom
* @param[out] data output byte array to write to
* @param[in] len the number of bytes to read
*
* @return the number of bytes read
*/
size_t
eeprom_read
(
uint32_t
pos
,
uint8_t
*
data
,
size_t
len
);
/**
* @brief Write a byte at the given position
*
* @param[in] pos position to write
* @param[in] data byte address to write to
*/
void
eeprom_write_byte
(
uint32_t
pos
,
uint8_t
data
);
/**
* @brief Write @p len bytes at the given position
*
* @param[in] pos start position in eeprom
* @param[in] data input byte array to read into
* @param[in] len the number of bytes to read
*
* @return the number of bytes written
*/
size_t
eeprom_write
(
uint32_t
pos
,
const
uint8_t
*
data
,
size_t
len
);
#ifdef __cplusplus
}
#endif
#endif
/* PERIPH_EEPROM_H */
/** @} */
This diff is collapsed.
Click to expand it.
drivers/periph_common/eeprom.c
0 → 100644
+
52
−
0
View file @
9fa58af7
/*
* 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 drivers
* @{
*
* @file
* @brief Common eeprom functions implementation
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
* @}
*/
#include
<string.h>
#include
"cpu.h"
#include
"assert.h"
/* guard this file, must be done before including periph/eeprom.h */
#if defined(EEPROM_SIZE)
#include
"periph/eeprom.h"
size_t
eeprom_read
(
uint32_t
pos
,
uint8_t
*
data
,
size_t
len
)
{
assert
(
pos
+
len
<
EEPROM_SIZE
);
for
(
size_t
i
=
0
;
i
<
len
;
i
++
)
{
data
[
i
]
=
eeprom_read_byte
(
pos
++
);
}
return
len
;
}
size_t
eeprom_write
(
uint32_t
pos
,
const
uint8_t
*
data
,
size_t
len
)
{
assert
(
pos
+
len
<
EEPROM_SIZE
);
for
(
size_t
i
=
0
;
i
<
len
;
i
++
)
{
eeprom_write_byte
(
pos
++
,
data
[
i
]);
}
return
len
;
}
#endif
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