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

Add menu options for EEPROM size selection #261

Closed
wants to merge 1 commit 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
Add menu options for EEPROM size selection
  • Loading branch information
dbuezas committed Mar 30, 2023
commit f72beac49dbecf17fef3c6b690b76b41203f9989
71 changes: 71 additions & 0 deletions lgt8f/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ menu.clock=Clock
menu.variant=Variant
menu.arduino_isp=Arduino as ISP
menu.upload_speed=Upload speed
menu.eeprom=EEPROM Emulation

#############################
#### LGT8F328 P/E/S ####
Expand Down Expand Up @@ -95,6 +96,22 @@ menu.upload_speed=Upload speed
#328.menu.upload_speed.115200=115200
#328.menu.upload_speed.115200.upload.speed=115200

# EEPROM
328.menu.eeprom.0kb=0 KB
328.menu.eeprom.0kb.upload.maximum_size=31744
328.menu.eeprom.0kb.build.eeprom_size=0
328.menu.eeprom.1kb=1 KB
328.menu.eeprom.1kb.upload.maximum_size=29696
328.menu.eeprom.1kb.build.eeprom_size=1
328.menu.eeprom.2kb=2 KB
328.menu.eeprom.2kb.upload.maximum_size=27648
328.menu.eeprom.2kb.build.eeprom_size=2
328.menu.eeprom.4kb=4 KB
328.menu.eeprom.4kb.upload.maximum_size=23552
328.menu.eeprom.4kb.build.eeprom_size=4
328.menu.eeprom.8kb=8 KB
328.menu.eeprom.8kb.upload.maximum_size=15360
328.menu.eeprom.8kb.build.eeprom_size=8

###################################
#### LGT8F328 + 16 MHz crystal ####
Expand Down Expand Up @@ -216,6 +233,24 @@ menu.upload_speed=Upload speed
328_16.menu.upload_speed.19200=19200
328_16.menu.upload_speed.19200.upload.speed=19200


# EEPROM
328_16.menu.eeprom.0kb=0 KB
328_16.menu.eeprom.0kb.upload.maximum_size=31744
328_16.menu.eeprom.0kb.build.eeprom_size=0
328_16.menu.eeprom.1kb=1 KB
328_16.menu.eeprom.1kb.upload.maximum_size=29696
328_16.menu.eeprom.1kb.build.eeprom_size=1
328_16.menu.eeprom.2kb=2 KB
328_16.menu.eeprom.2kb.upload.maximum_size=27648
328_16.menu.eeprom.2kb.build.eeprom_size=2
328_16.menu.eeprom.4kb=4 KB
328_16.menu.eeprom.4kb.upload.maximum_size=23552
328_16.menu.eeprom.4kb.build.eeprom_size=4
328_16.menu.eeprom.8kb=8 KB
328_16.menu.eeprom.8kb.upload.maximum_size=15360
328_16.menu.eeprom.8kb.build.eeprom_size=8

###################################
#### LGT8F328 + 12 MHz crystal ####
###################################
Expand Down Expand Up @@ -321,6 +356,24 @@ menu.upload_speed=Upload speed
328_12.menu.upload_speed.19200=19200
328_12.menu.upload_speed.19200.upload.speed=19200


# EEPROM
328_12.menu.eeprom.0kb=0 KB
328_12.menu.eeprom.0kb.upload.maximum_size=31744
328_12.menu.eeprom.0kb.build.eeprom_size=0
328_12.menu.eeprom.1kb=1 KB
328_12.menu.eeprom.1kb.upload.maximum_size=29696
328_12.menu.eeprom.1kb.build.eeprom_size=1
328_12.menu.eeprom.2kb=2 KB
328_12.menu.eeprom.2kb.upload.maximum_size=27648
328_12.menu.eeprom.2kb.build.eeprom_size=2
328_12.menu.eeprom.4kb=4 KB
328_12.menu.eeprom.4kb.upload.maximum_size=23552
328_12.menu.eeprom.4kb.build.eeprom_size=4
328_12.menu.eeprom.8kb=8 KB
328_12.menu.eeprom.8kb.upload.maximum_size=15360
328_12.menu.eeprom.8kb.build.eeprom_size=8

############################
#### LGT8F88 ####
############################
Expand Down Expand Up @@ -412,3 +465,21 @@ lardu_328e.menu.arduino_isp.disable=Default (64)
lardu_328e.menu.arduino_isp.disable.build.SERIAL_RX_BUFFER_SIZE=64
lardu_328e.menu.arduino_isp.enable=[To burn an ISP] SERIAL_RX_BUFFER_SIZE to 250
lardu_328e.menu.arduino_isp.enable.build.SERIAL_RX_BUFFER_SIZE=250


# EEPROM
lardu_328e.menu.eeprom.0kb=0 KB
lardu_328e.menu.eeprom.0kb.upload.maximum_size=31744
lardu_328e.menu.eeprom.0kb.build.eeprom_size=0
lardu_328e.menu.eeprom.1kb=1 KB
lardu_328e.menu.eeprom.1kb.upload.maximum_size=29696
lardu_328e.menu.eeprom.1kb.build.eeprom_size=1
lardu_328e.menu.eeprom.2kb=2 KB
lardu_328e.menu.eeprom.2kb.upload.maximum_size=27648
lardu_328e.menu.eeprom.2kb.build.eeprom_size=2
lardu_328e.menu.eeprom.4kb=4 KB
lardu_328e.menu.eeprom.4kb.upload.maximum_size=23552
lardu_328e.menu.eeprom.4kb.build.eeprom_size=4
lardu_328e.menu.eeprom.8kb=8 KB
lardu_328e.menu.eeprom.8kb.upload.maximum_size=15360
lardu_328e.menu.eeprom.8kb.build.eeprom_size=8
4 changes: 0 additions & 4 deletions lgt8f/cores/lgt8f/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ void lgt8fx8x_init()
// store ivref calibration value (According to the LGT8F328D databook, if VCAL is rewritten, the value of VCAL1 can be lost.)
_VCAL_1_ = VCAL1;

// enable 1KB E2PROM
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LaZsolt The EEPROM.h library will set this to 1 by default when imported anyway.

If the lib is not imported, the ECCR register will stay at zero, which means "I won't use the EEPROM"

Copy link
Collaborator

@LaZsolt LaZsolt Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incompatible idea. #261 (comment)

ECCR = 0x80;
ECCR = 0x40;

// clock source settings
#if !defined(CLOCK_SOURCE)
if((VDTCR & 0x0C) == 0x0C) {
Expand Down
2 changes: 2 additions & 0 deletions lgt8f/libraries/E2PROM/examples/eeprom_read/eeprom_read.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ byte value;

void setup()
{
// initialize EEPROM simulation to the size selected in the menu
lgt_eeprom_init(EEPROM_SIZE);
// initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
Expand Down
2 changes: 2 additions & 0 deletions lgt8f/libraries/E2PROM/examples/eeprom_write/eeprom_write.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ int addr = 0;

void setup()
{
// initialize EEPROM simulation to the size selected in the menu
lgt_eeprom_init(EEPROM_SIZE);
}

void loop()
Expand Down
3 changes: 3 additions & 0 deletions lgt8f/libraries/E2PROM/examples/test/test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ byte *buff;

void setup()
{
// initialize EEPROM simulation to the size selected in the menu
lgt_eeprom_init(EEPROM_SIZE);

Serial.begin(9600);

while(!Serial);
Expand Down
10 changes: 5 additions & 5 deletions lgt8f/platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ compiler.elf2hex.extra_flags=
# --------------------

## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DEEPROM_SIZE={build.eeprom_size} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DEEPROM_SIZE={build.eeprom_size} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DEEPROM_SIZE={build.eeprom_size} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
Expand All @@ -83,10 +83,10 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*

## Preprocessor
preproc.includes.flags=-w -x c++ -M -MG -MP
recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DEEPROM_SIZE={build.eeprom_size} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"

preproc.macros.flags=-w -x c++ -E -CC
recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DSERIAL_RX_BUFFER_SIZE={build.SERIAL_RX_BUFFER_SIZE} -DEEPROM_SIZE={build.eeprom_size} -DCLOCK_SOURCE={build.clock_source} -DF_CPU=({build.f_osc}/{build.f_div}) -DF_OSC={build.f_osc} -DF_DIV={build.f_div} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"

# AVR Uploader/Programmers tools
# ------------------------------
Expand Down