/trunk/libraries/eeprom/demo/SConscript |
---|
0,0 → 1,16 |
# Import environment set for target. |
Import('env_target') |
# Set target name. |
TARGET = 'eeprom__demo' |
# Set source file. |
sources = [ |
'eeprom__demo.c' |
] |
# Build project and libraries. |
env_target.BuildProject(sources, TARGET) |
# Compute memory usage. |
env_target.ComputeMemoryUsage(TARGET) |
/trunk/libraries/eeprom/demo/eeprom__demo.c |
---|
0,0 → 1,51 |
/**************************************************************************//** |
* \brief EEPROM library |
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
* \version 1.0 |
* \date 20111017 |
* |
* This file is part of the iDreamMicro library. |
* |
* This library is free software: you can redistribute it and/or modify it under |
* the terms of the GNU Lesser General Public License as published by the Free |
* Software Foundation, either version 3 of the License, or (at your option) any |
* later version. |
* |
* This library is distributed in the hope that it will be useful, but WITHOUT |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
* details. |
* |
* You should have received a copy of the GNU Lesser General Public License |
* along with this program. If not, see http://www.gnu.org/licenses/ |
******************************************************************************/ |
/**************************************************************************//** |
* \file eeprom__demo.c |
******************************************************************************/ |
/****************************************************************************** |
* Header file inclusions. |
******************************************************************************/ |
#include "../eeprom.h" |
#include <stdint.h> |
/**************************************************************************//** |
* \fn int main(void) |
* |
* \brief Main function. |
******************************************************************************/ |
int |
main |
( |
void |
){ |
eeprom__write_byte(0, 0x85); |
uint8_t read_byte = eeprom__read_byte(0); |
for (;;); |
return 0; |
} |
/trunk/libraries/eeprom/src/SConscript |
---|
0,0 → 1,13 |
# Import environment set for target. |
Import('env_target') |
# Define target name. |
TARGET = 'eeprom' |
# Define source files. |
sources = [ |
'eeprom.c' |
] |
# Build library. |
env_target.BuildLibrary(sources, TARGET) |
/trunk/libraries/eeprom/src/eeprom.c |
---|
0,0 → 1,159 |
/**************************************************************************//** |
* \brief EEPROM library |
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
* \version 1.0 |
* \date 20111017 |
* |
* This file is part of the iDreamMicro library. |
* |
* This library is free software: you can redistribute it and/or modify it under |
* the terms of the GNU Lesser General Public License as published by the Free |
* Software Foundation, either version 3 of the License, or (at your option) any |
* later version. |
* |
* This library is distributed in the hope that it will be useful, but WITHOUT |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
* details. |
* |
* You should have received a copy of the GNU Lesser General Public License |
* along with this program. If not, see http://www.gnu.org/licenses/ |
******************************************************************************/ |
/**************************************************************************//** |
* \file eeprom.c |
******************************************************************************/ |
/****************************************************************************** |
* Header file inclusions. |
******************************************************************************/ |
#include <eeprom/eeprom.h> |
#include <avr/io.h> |
#include <assert.h> |
#include <stdint.h> |
#include <stdlib.h> |
/****************************************************************************** |
* Public function definitions. |
******************************************************************************/ |
/**************************************************************************//** |
* \fn void eeprom__write_byte( |
* uint16_t address, |
* uint8_t data) |
* |
* \brief Write a byte in EEPROM. |
* |
* \param address Address. |
* \param data Data to write. |
******************************************************************************/ |
void |
eeprom__write_byte |
( |
uint16_t address, |
uint8_t data |
){ |
// Wait for completion of previous write. |
while (EECR & (1 << EEPE)); |
// Set up address. |
EEAR = address; |
// Set up data. |
EEDR = data; |
// Write logical one to EEMPE. |
EECR |= (1 << EEMPE); |
// Start EEPROM write. |
EECR |= (1 << EEPE); |
} |
/**************************************************************************//** |
* \fn void eeprom__write_bytes( |
* uint16_t address, |
* uint16_t size, |
* uint8_t* p_data) |
* |
* \brief Write bytes into EEPOM. |
* |
* \param address Address. |
* \param size Data size. |
* \param[in] p_data Data to write. |
******************************************************************************/ |
void |
eeprom__write_bytes |
( |
uint16_t address, |
uint16_t size, |
uint8_t* p_data |
){ |
// Check the preconditions. |
assert(NULL != p_data); |
for (uint16_t i = 0; i < size; i++) |
{ |
eeprom__write_byte(address + i, p_data[i]); |
} |
} |
/**************************************************************************//** |
* \fn uint8_t eeprom__read_byte( |
* uint16_t address) |
* |
* \brief Read data into EEPROM. |
* |
* \param address Address of data to read. |
* |
* \return Read data. |
******************************************************************************/ |
uint8_t |
eeprom__read_byte |
( |
uint16_t address |
){ |
// Wait for completion of previous write. |
while (EECR & (1 << EEPE)); |
// Set up address. |
EEAR = address; |
// Start EEPROM read. |
EECR |= (1 << EERE); |
// Read data register. |
uint8_t data = EEDR; |
return data; |
} |
/**************************************************************************//** |
* \fn void eeprom__read_bytes( |
* uint16_t address, |
* uint16_t size, |
* uint8_t* p_data) |
* |
* \brief Read bytes from EEPROM. |
* |
* \param address Address to read. |
* \param size Data size to read. |
* \param[in] p_data Data buffer. |
******************************************************************************/ |
void |
eeprom__read_bytes |
( |
uint16_t address, |
uint16_t size, |
uint8_t* p_data |
){ |
// Check the preconditions. |
assert(NULL != p_data); |
for (uint16_t i = 0; i < size; i++) |
{ |
p_data[i] = eeprom__read_byte(address + i); |
} |
} |
/trunk/libraries/eeprom/SConscript |
---|
0,0 → 1,16 |
# Import environment set for target. |
Import('env_target') |
# Define directories to process. |
directories = [ |
'src/' |
] |
# Process directories. |
for directory in directories: |
SConscript( |
directory + 'SConscript', |
variant_dir = '#build/' + '/libraries/eeprom/' + env_target['NAME'], |
exports = { 'env_target' : env_target }, |
duplicate = 0 |
) |
/trunk/libraries/eeprom/SConstruct |
---|
0,0 → 1,40 |
# Import build tools. |
SConscript('#min_env/build_tools.py') |
# Set environment for AVR-GCC. |
SConscript('#min_env/env_target.py') |
# Import environment set for AVR-GCC. |
Import('env_target') |
# Append CPPPATH. |
env_target.Append(CPPPATH = [ '#../' ]) |
# Build library. |
SConscript( |
'src/SConscript', |
variant_dir = '#build/lib/', |
exports = { 'env_target' : env_target }, |
duplicate = 0 |
) |
# Append LIBPATH and LIBS. |
env_target.Append(LIBPATH = [ '#build/lib/']) |
env_target.Append(LIBS = [ 'eeprom' ]) |
# Build demonstration program. |
SConscript( |
'demo/SConscript', |
variant_dir = '#build/demo/', |
exports = { 'env_target' : env_target }, |
duplicate = 0 |
) |
# Build test program. |
SConscript( |
'test/SConscript', |
variant_dir = '#build/test/', |
exports = { 'env_target' : env_target }, |
duplicate = 0 |
) |
/trunk/libraries/eeprom/min_env/env_target.py |
---|
0,0 → 1,28 |
# Create and initialize the environment. |
env_target = Environment() |
# Set environment for AVR-GCC. |
env_target['CC'] = 'avr-gcc' |
env_target['CPPPATH'] = '/usr/lib/avr/include' |
env_target['OBJCOPY'] = 'avr-objcopy' |
env_target['SIZE'] = 'avr-size' |
env_target['AR'] = 'avr-ar' |
env_target['RANLIB'] = 'avr-ranlib' |
env_target.Append(CCFLAGS = '-Os') |
env_target.Append(CCFLAGS = '-std=c99') |
# Define environment name. |
env_target.Append(NAME = 'env_target') |
# Microcontroller type. |
env_target.Append(MCU = 'atmega328p') |
# Microcontroller frequency in Hertz. |
env_target.Append(F_CPU = '16000000UL') |
# Set environment for an Atmel AVR ATmega328p microcontroller. |
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU']) |
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU']) |
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU']) |
# Export environment set for target. |
Export('env_target') |
/trunk/libraries/eeprom/min_env/build_tools.py |
---|
0,0 → 1,41 |
""" |
Build project. |
""" |
def BuildProject(env, sources, target_name): |
# Build program. |
env.Program(target = target_name + '.elf', source = sources) |
# Create hex binary file. |
env.Command( |
target_name + '.hex', |
target_name + '.elf', |
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET' |
) |
AddMethod(Environment, BuildProject) |
""" |
Build library. |
""" |
def BuildLibrary(env, sources, target_name): |
# Build static library. |
env.StaticLibrary(target = target_name, source = sources) |
# Append LIBPATH and LIBS. |
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ]) |
env.Append(LIBS = [ target_name ]) |
AddMethod(Environment, BuildLibrary) |
""" |
Compute memory usage. |
""" |
def ComputeMemoryUsage(env, target_name): |
# Compute memory usage. |
env.Command( |
None, |
target_name + '.elf', |
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE' |
) |
AddMethod(Environment, ComputeMemoryUsage) |
/trunk/libraries/eeprom/eeprom.h |
---|
0,0 → 1,121 |
/**************************************************************************//** |
* \brief EEPROM library |
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
* \version 1.0 |
* \date 20111017 |
* |
* This file is part of the iDreamMicro library. |
* |
* This library is free software: you can redistribute it and/or modify it under |
* the terms of the GNU Lesser General Public License as published by the Free |
* Software Foundation, either version 3 of the License, or (at your option) any |
* later version. |
* |
* This library is distributed in the hope that it will be useful, but WITHOUT |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
* details. |
* |
* You should have received a copy of the GNU Lesser General Public License |
* along with this program. If not, see http://www.gnu.org/licenses/ |
******************************************************************************/ |
/**************************************************************************//** |
* \headerfile eeprom.h |
******************************************************************************/ |
#ifndef H__IDREAMMICRO__EEPROM__H |
#define H__IDREAMMICRO__EEPROM__H |
#ifdef _cplusplus |
extern "C"{ |
#endif |
/****************************************************************************** |
* Header file inclusions. |
******************************************************************************/ |
#include <stdint.h> |
/****************************************************************************** |
* Public function definitions. |
******************************************************************************/ |
/**************************************************************************//** |
* \fn void eeprom__write_byte( |
* uint16_t address, |
* uint8_t data) |
* |
* \brief Write a byte in EEPROM. |
* |
* \param address Address. |
* \param data Data to write. |
******************************************************************************/ |
void |
eeprom__write_byte |
( |
uint16_t address, |
uint8_t data |
); |
/**************************************************************************//** |
* \fn void eeprom__write_bytes( |
* uint16_t address, |
* uint16_t size, |
* uint8_t* p_data) |
* |
* \brief Write bytes into EEPOM. |
* |
* \param address Address. |
* \param size Data size. |
* \param[in] p_data Data to write. |
******************************************************************************/ |
void |
eeprom__write_bytes |
( |
uint16_t address, |
uint16_t size, |
uint8_t* p_data |
); |
/**************************************************************************//** |
* \fn uint8_t eeprom__read_byte( |
* uint16_t address) |
* |
* \brief Read data into EEPROM. |
* |
* \param address Address of data to read. |
* |
* \return Read data. |
******************************************************************************/ |
uint8_t |
eeprom__read_byte |
( |
uint16_t address |
); |
/**************************************************************************//** |
* \fn void eeprom__read_bytes( |
* uint16_t address, |
* uint16_t size, |
* uint8_t* p_data) |
* |
* \brief Read bytes from EEPROM. |
* |
* \param address Address to read. |
* \param size Data size to read. |
* \param[in] p_data Data buffer. |
******************************************************************************/ |
void |
eeprom__read_bytes |
( |
uint16_t address, |
uint16_t size, |
uint8_t* p_data |
); |
#ifdef _cplusplus |
} |
#endif |
#endif /* H__IDREAMMICRO__EEPROM__H */ |
/trunk/libraries/eeprom |
---|
Modification de propriétés sur libraries/eeprom |
___________________________________________________________________ |
Added: svn:ignore |
## -0,0 +1 ## |
+build |