Skip to content

Commit

Permalink
added external eeprom
Browse files Browse the repository at this point in the history
  • Loading branch information
1brahimmohamed committed Nov 19, 2022
1 parent 34000ea commit 077cf75
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 0 deletions.
115 changes: 115 additions & 0 deletions External EEPROM/.cproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="de.innot.avreclipse.configuration.app.debug.830188540">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="de.innot.avreclipse.configuration.app.debug.830188540" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="de.innot.avreclipse.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=de.innot.avreclipse.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" id="de.innot.avreclipse.configuration.app.debug.830188540" name="Debug" parent="de.innot.avreclipse.configuration.app.debug">
<folderInfo id="de.innot.avreclipse.configuration.app.debug.830188540." name="/" resourcePath="">
<toolChain id="de.innot.avreclipse.toolchain.winavr.app.debug.932938876" name="AVR-GCC Toolchain" superClass="de.innot.avreclipse.toolchain.winavr.app.debug">
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.debug.579440854" name="Generate HEX file for Flash memory" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.debug"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.debug.215070955" name="Generate HEX file for EEPROM" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.debug"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.debug.1154609873" name="Generate Extended Listing (Source + generated Assembler)" superClass="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.debug"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.size.app.debug.911389098" name="Print Size" superClass="de.innot.avreclipse.toolchain.options.toolchain.size.app.debug"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.debug.1847880419" name="AVRDude" superClass="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.debug"/>
<targetPlatform id="de.innot.avreclipse.targetplatform.winavr.app.debug.2116254006" name="AVR Cross-Target" superClass="de.innot.avreclipse.targetplatform.winavr.app.debug"/>
<builder buildPath="${workspace_loc:/External EEPROM}/Debug" id="de.innot.avreclipse.target.builder.winavr.app.debug.1308753724" managedBuildOn="true" name="AVR GNU Make Builder.Debug" superClass="de.innot.avreclipse.target.builder.winavr.app.debug"/>
<tool id="de.innot.avreclipse.tool.assembler.winavr.app.debug.1493639735" name="AVR Assembler" superClass="de.innot.avreclipse.tool.assembler.winavr.app.debug">
<option id="de.innot.avreclipse.assembler.option.debug.level.1873855412" superClass="de.innot.avreclipse.assembler.option.debug.level"/>
</tool>
<tool id="de.innot.avreclipse.tool.compiler.winavr.app.debug.249124744" name="AVR Compiler" superClass="de.innot.avreclipse.tool.compiler.winavr.app.debug">
<option id="de.innot.avreclipse.compiler.option.debug.level.412596656" superClass="de.innot.avreclipse.compiler.option.debug.level"/>
<option id="de.innot.avreclipse.compiler.option.optimize.25655628" superClass="de.innot.avreclipse.compiler.option.optimize"/>
</tool>
<tool id="de.innot.avreclipse.tool.cppcompiler.app.debug.492439893" name="AVR C++ Compiler" superClass="de.innot.avreclipse.tool.cppcompiler.app.debug">
<option id="de.innot.avreclipse.cppcompiler.option.debug.level.717660395" superClass="de.innot.avreclipse.cppcompiler.option.debug.level"/>
<option id="de.innot.avreclipse.cppcompiler.option.optimize.1939681203" superClass="de.innot.avreclipse.cppcompiler.option.optimize"/>
</tool>
<tool id="de.innot.avreclipse.tool.linker.winavr.app.debug.1769215337" name="AVR C Linker" superClass="de.innot.avreclipse.tool.linker.winavr.app.debug"/>
<tool id="de.innot.avreclipse.tool.cpplinker.app.debug.1574983422" name="AVR C++ Linker" superClass="de.innot.avreclipse.tool.cpplinker.app.debug"/>
<tool id="de.innot.avreclipse.tool.archiver.winavr.base.1104667600" name="AVR Archiver" superClass="de.innot.avreclipse.tool.archiver.winavr.base"/>
<tool id="de.innot.avreclipse.tool.objdump.winavr.app.debug.876155767" name="AVR Create Extended Listing" superClass="de.innot.avreclipse.tool.objdump.winavr.app.debug"/>
<tool id="de.innot.avreclipse.tool.objcopy.flash.winavr.app.debug.1721891459" name="AVR Create Flash image" superClass="de.innot.avreclipse.tool.objcopy.flash.winavr.app.debug"/>
<tool id="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.debug.1933594973" name="AVR Create EEPROM image" superClass="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.debug"/>
<tool id="de.innot.avreclipse.tool.size.winavr.app.debug.1115513948" name="Print Size" superClass="de.innot.avreclipse.tool.size.winavr.app.debug"/>
<tool id="de.innot.avreclipse.tool.avrdude.app.debug.974299529" name="AVRDude" superClass="de.innot.avreclipse.tool.avrdude.app.debug"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="de.innot.avreclipse.configuration.app.release.1963393489">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="de.innot.avreclipse.configuration.app.release.1963393489" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="de.innot.avreclipse.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=de.innot.avreclipse.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" id="de.innot.avreclipse.configuration.app.release.1963393489" name="Release" parent="de.innot.avreclipse.configuration.app.release">
<folderInfo id="de.innot.avreclipse.configuration.app.release.1963393489." name="/" resourcePath="">
<toolChain id="de.innot.avreclipse.toolchain.winavr.app.release.1242899078" name="AVR-GCC Toolchain" superClass="de.innot.avreclipse.toolchain.winavr.app.release">
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.release.1391385514" name="Generate HEX file for Flash memory" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.release"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.release.819280566" name="Generate HEX file for EEPROM" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.release"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.release.487484558" name="Generate Extended Listing (Source + generated Assembler)" superClass="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.release"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.size.app.release.1724322543" name="Print Size" superClass="de.innot.avreclipse.toolchain.options.toolchain.size.app.release"/>
<option id="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.release.173284956" name="AVRDude" superClass="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.release"/>
<targetPlatform id="de.innot.avreclipse.targetplatform.winavr.app.release.409440643" name="AVR Cross-Target" superClass="de.innot.avreclipse.targetplatform.winavr.app.release"/>
<builder buildPath="${workspace_loc:/External EEPROM}/Release" id="de.innot.avreclipse.target.builder.winavr.app.release.374779986" managedBuildOn="true" name="AVR GNU Make Builder.Release" superClass="de.innot.avreclipse.target.builder.winavr.app.release"/>
<tool id="de.innot.avreclipse.tool.assembler.winavr.app.release.746378053" name="AVR Assembler" superClass="de.innot.avreclipse.tool.assembler.winavr.app.release">
<option id="de.innot.avreclipse.assembler.option.debug.level.867875465" superClass="de.innot.avreclipse.assembler.option.debug.level" value="de.innot.avreclipse.assembler.option.debug.level.none" valueType="enumerated"/>
<inputType id="de.innot.avreclipse.tool.assembler.input.363080624" superClass="de.innot.avreclipse.tool.assembler.input"/>
</tool>
<tool id="de.innot.avreclipse.tool.compiler.winavr.app.release.2032424787" name="AVR Compiler" superClass="de.innot.avreclipse.tool.compiler.winavr.app.release">
<option id="de.innot.avreclipse.compiler.option.debug.level.1630938019" superClass="de.innot.avreclipse.compiler.option.debug.level" value="de.innot.avreclipse.compiler.option.debug.level.none" valueType="enumerated"/>
<option id="de.innot.avreclipse.compiler.option.optimize.901805812" superClass="de.innot.avreclipse.compiler.option.optimize" value="de.innot.avreclipse.compiler.optimize.size" valueType="enumerated"/>
<inputType id="de.innot.avreclipse.compiler.winavr.input.900768003" name="C Source Files" superClass="de.innot.avreclipse.compiler.winavr.input"/>
</tool>
<tool id="de.innot.avreclipse.tool.cppcompiler.app.release.630909180" name="AVR C++ Compiler" superClass="de.innot.avreclipse.tool.cppcompiler.app.release">
<option id="de.innot.avreclipse.cppcompiler.option.debug.level.144134077" superClass="de.innot.avreclipse.cppcompiler.option.debug.level" value="de.innot.avreclipse.cppcompiler.option.debug.level.none" valueType="enumerated"/>
<option id="de.innot.avreclipse.cppcompiler.option.optimize.40523766" superClass="de.innot.avreclipse.cppcompiler.option.optimize" value="de.innot.avreclipse.cppcompiler.optimize.size" valueType="enumerated"/>
</tool>
<tool id="de.innot.avreclipse.tool.linker.winavr.app.release.1930614345" name="AVR C Linker" superClass="de.innot.avreclipse.tool.linker.winavr.app.release">
<inputType id="de.innot.avreclipse.tool.linker.input.861535777" name="OBJ Files" superClass="de.innot.avreclipse.tool.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="de.innot.avreclipse.tool.cpplinker.app.release.2005167351" name="AVR C++ Linker" superClass="de.innot.avreclipse.tool.cpplinker.app.release"/>
<tool id="de.innot.avreclipse.tool.archiver.winavr.base.1420666535" name="AVR Archiver" superClass="de.innot.avreclipse.tool.archiver.winavr.base"/>
<tool id="de.innot.avreclipse.tool.objdump.winavr.app.release.512339178" name="AVR Create Extended Listing" superClass="de.innot.avreclipse.tool.objdump.winavr.app.release"/>
<tool id="de.innot.avreclipse.tool.objcopy.flash.winavr.app.release.1904817565" name="AVR Create Flash image" superClass="de.innot.avreclipse.tool.objcopy.flash.winavr.app.release"/>
<tool id="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.release.779090291" name="AVR Create EEPROM image" superClass="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.release"/>
<tool id="de.innot.avreclipse.tool.size.winavr.app.release.1911315740" name="Print Size" superClass="de.innot.avreclipse.tool.size.winavr.app.release"/>
<tool id="de.innot.avreclipse.tool.avrdude.app.release.239074350" name="AVRDude" superClass="de.innot.avreclipse.tool.avrdude.app.release"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="External EEPROM.de.innot.avreclipse.project.winavr.elf_2.1.0.1494318287" name="AVR Cross Target Application" projectType="de.innot.avreclipse.project.winavr.elf_2.1.0"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="de.innot.avreclipse.configuration.app.release.1963393489;de.innot.avreclipse.configuration.app.release.1963393489.;de.innot.avreclipse.tool.compiler.winavr.app.release.2032424787;de.innot.avreclipse.compiler.winavr.input.900768003">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="de.innot.avreclipse.core.AVRGCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
27 changes: 27 additions & 0 deletions External EEPROM/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>External EEPROM</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>de.innot.avreclipse.core.avrnature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions External EEPROM/.settings/de.innot.avreclipse.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
avrtarget/ClockFrequency=1000000
avrtarget/ExtRAMSize=0
avrtarget/ExtendedRAM=false
avrtarget/MCUType=atmega32
avrtarget/UseEEPROM=false
avrtarget/UseExtendedRAMforHeap=true
eclipse.preferences.version=1
2 changes: 2 additions & 0 deletions External EEPROM/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
86 changes: 86 additions & 0 deletions External EEPROM/src/external_eeprom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/******************************************************************************
*
* Module: External EEPROM
* File Name: external_eeprom.c
* Description: Source file for the External EEPROM Memory
* Author: Ibrahim Mohamed
*
*******************************************************************************/

#include "external_eeprom.h"
#include "twi.h"

/*******************************************************************************
* Functions DEFINITIONS *
*******************************************************************************/

uint8 EEPROM_writeByte(uint16 u16addr,uint8 u8data)
{
/* Send the Start Bit */
TWI_start();
if (TWI_getStatus() != TWI_START)
return ERROR;

/* Send the device address, we need to get A8 A9 A10 address bits from the
* memory location address and R/W=0 (write) */
TWI_writeByte((uint8)(0xA0 | ((u16addr & 0x0700)>>7)));
if (TWI_getStatus() != TWI_MT_SLA_W_ACK)
return ERROR;

/* Send the required memory location address */
TWI_writeByte((uint8)(u16addr));
if (TWI_getStatus() != TWI_MT_DATA_ACK)
return ERROR;

/* write byte to eeprom */
TWI_writeByte(u8data);
if (TWI_getStatus() != TWI_MT_DATA_ACK)
return ERROR;

/* Send the Stop Bit */
TWI_stop();

return SUCCESS;

}

uint8 EEPROM_readByte(uint16 u16addr,uint8 *u8data)
{
/* Send the Start Bit */
TWI_start();
if (TWI_getStatus() != TWI_START)
return ERROR;

/* Send the device address, we need to get A8 A9 A10 address bits from the
* memory location address and R/W=0 (write) */
TWI_writeByte((uint8)((0xA0) | ((u16addr & 0x0700)>>7)));
if (TWI_getStatus() != TWI_MT_SLA_W_ACK)
return ERROR;

/* Send the required memory location address */
TWI_writeByte((uint8)(u16addr));
if (TWI_getStatus() != TWI_MT_DATA_ACK)
return ERROR;

/* Send the Repeated Start Bit */
TWI_start();
if (TWI_getStatus() != TWI_REP_START)
return ERROR;

/* Send the device address, we need to get A8 A9 A10 address bits from the
* memory location address and R/W=1 (Read) */
TWI_writeByte((uint8)((0xA0) | ((u16addr & 0x0700)>>7) | 1));
if (TWI_getStatus() != TWI_MT_SLA_R_ACK)
return ERROR;

/* Read Byte from Memory without send ACK */
*u8data = TWI_readByteWithNACK();
if (TWI_getStatus() != TWI_MR_DATA_NACK)
return ERROR;

/* Send the Stop Bit */
TWI_stop();

return SUCCESS;
}

31 changes: 31 additions & 0 deletions External EEPROM/src/external_eeprom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/******************************************************************************
*
* Module: External EEPROM
* File Name: external_eeprom.h
* Description: Header file for the External EEPROM Memory
* Author: Ibrahim Mohamed
*
*******************************************************************************/

#ifndef EXTERNAL_EEPROM_H_
#define EXTERNAL_EEPROM_H_

#include "std_types.h"

/*******************************************************************************
* Preprocessor Macros *
*******************************************************************************/
#define ERROR 0
#define SUCCESS 1

/*******************************************************************************
* Functions Prototypes *
*******************************************************************************/

uint8 EEPROM_writeByte(uint16 u16addr,uint8 u8data);
uint8 EEPROM_readByte(uint16 u16addr,uint8 *u8data);




#endif /* EXTERNAL_EEPROM_H_ */
Loading

0 comments on commit 077cf75

Please sign in to comment.