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

Merge from Dev #49

Merged
merged 92 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
49d5ed2
Add files via upload
Phonog Oct 31, 2016
ee3a305
Add files via upload
Phonog Oct 31, 2016
9765b9b
Add files via upload
Phonog Oct 31, 2016
9e5911b
Add files via upload
Phonog Oct 31, 2016
380b863
Merge branch 'Phonog-patch-1' of https://github.com/Phonog/Arduino_ST…
rogerclarkmelbourne Dec 18, 2016
f4e3c29
Increment size of emulated EEPROM
svmac Sep 14, 2019
6e1b2e6
Create TestCompile.yml
ArminJo Nov 14, 2020
79ec492
Update TestCompile.yml
ArminJo Nov 14, 2020
47a7122
Changed Ethernet.h to Ethernet_STM.h
ArminJo Nov 14, 2020
ae0eac8
Adding Adafruit Gfx library, excluding errorneous examples
ArminJo Nov 14, 2020
3b2b77d
included libs excluded examples, removed debug
ArminJo Nov 14, 2020
05d8bee
more exludes
ArminJo Nov 14, 2020
cb66e94
excluded OLED_I2C examples
ArminJo Nov 14, 2020
d9adc52
Compatibility with current HEAD versions of Adafruit GFX and Adafruit…
kiki-lamb Nov 25, 2020
70f99b7
Adafruit_GFX_AS: Use a macro to achieve s/textsize/textsize_x/.
kiki-lamb Nov 25, 2020
ad73d1c
Fix mistaken cast of wrong argument.
kiki-lamb Nov 25, 2020
e07d0a5
STM32F4 backup domain registers and backup domain sram
Mar 10, 2021
48817fa
STM32F4: RTClock - prevent clobbering if run on LSE and VBAT
Mar 11, 2021
46609bc
STM32F4 RTClock minor fix
Mar 11, 2021
bab4fda
F1: fix for #852: added function definition into pgmsapce.h
stevstrong Mar 17, 2021
4c2d5e1
USBComposite library updates: MIDI sysex support; bug fixes
arpruss Apr 10, 2021
edb69cc
fix maple_upload dfu_address set to {runtime.ide.path} instead of {up…
tomaskovacik May 7, 2021
098a98c
F1: Wire: add wire(const uint8*, int) to WireBase.h
stevstrong May 21, 2021
ec7a93e
Tools: Linux: Merge pull request #855 from tomaskovacik/master
stevstrong May 30, 2021
8f0490c
Merge branch 'rogerclarkmelbourne:master' into master
arpruss Feb 3, 2022
606e291
USB Composite 1.06 merge
arpruss Feb 3, 2022
dc35dd5
Delete unneeded file
arpruss Feb 3, 2022
0ddc946
Update WireBase.h
stevstrong Feb 24, 2022
52cceec
Added blackpill_f411 variant
board707 Mar 17, 2022
b59ea46
added build options for the abilirty to select HSI clock source witho…
purewack Apr 21, 2022
f5188ce
Fix incorrect upload method for F411
board707 Jun 24, 2022
2f43c05
fixes #883
ArminJo Sep 17, 2022
341cd89
Merge branch 'Arduino-IRremote-master'
rogerclarkmelbourne Sep 26, 2022
3f57bae
update USBComposite to 1.0.7
arpruss Jan 4, 2023
cd1d2a0
Merge pull request #850 from ag88/stm32f4bkp
stevstrong Sep 25, 2023
7c357b4
Merge branch 'rogerclarkmelbourne:master' into master
ArminJo Oct 27, 2023
29ffd9b
Added workflow_dispatch for manual build check
ArminJo Oct 27, 2023
bc91b52
Using ln -s instead of cp
ArminJo Oct 27, 2023
980dfe1
Using ln -s instead of cp
ArminJo Oct 27, 2023
dae6e85
Merge pull request #827 from ArminJo/master
stevstrong Oct 28, 2023
9f32103
Merge pull request #874 from board707/blackpill_F411
stevstrong Nov 3, 2023
819ed8e
Merge pull request #868 from arpruss/master
stevstrong Nov 3, 2023
de3b2c6
Fixing error: 'utoa' was not declared in this scope - see #884
ArminJo Nov 3, 2023
73cb0a6
Merge pull request #829 from kiki-lamb/adafruit-gfx-compat
stevstrong Nov 3, 2023
cca05ed
Merge pull request #912 from ArminJo/patch-1
stevstrong Nov 3, 2023
20d38f8
Merge pull request #878 from purewack/master
stevstrong Nov 3, 2023
33f4ee2
Merge pull request #674 from svmac/master
stevstrong Nov 3, 2023
317348a
Merge pull request #632 from rogerclarkmelbourne/Phonog-Phonog-patch-1
stevstrong Nov 3, 2023
916e416
Update README.md
stevstrong Nov 3, 2023
1b65c84
fix HardwareCANexample.ino
stevstrong Nov 3, 2023
7cf5070
Update wirish_digital.cpp - fix #859
stevstrong Nov 6, 2023
c5a8e9d
fix boardPWMpins table for generic gdf103c variant
stevstrong Nov 6, 2023
689f478
fix boardPWMpins for generic F103c variant
stevstrong Nov 6, 2023
da6b55d
fix boardPWMpins table for generic F103C variant
stevstrong Nov 6, 2023
4bc749d
fix BOARD_NR_PWM_PIN for generic F103C variant
stevstrong Nov 6, 2023
76b578e
Update SPI.cpp
stevstrong Nov 25, 2023
c8b2572
F1: DMA transfer setup function - changed parameter definition
stevstrong Nov 25, 2023
9935465
F1: SPI rework
stevstrong Nov 25, 2023
4b7266f
Update Print.cpp
stevstrong Nov 25, 2023
47dd80f
F1: fixed generic F103 board PWM pins
stevstrong Nov 25, 2023
3881eff
F1: added function to check if spi is in master mode
stevstrong Nov 28, 2023
e45327f
Update SPI.cpp
stevstrong Nov 28, 2023
7c67ed3
F1: SPI dmaTransferRepeat() got 2 optional parmaeters
stevstrong Dec 8, 2023
338020b
Rename hid-flash to hid_flash
stevstrong Jan 1, 2024
de2c714
systick allows up to 4 callbacks
stevstrong Feb 28, 2024
497771e
F4: added PRINTF
stevstrong Feb 28, 2024
83243b1
F4: added soft-reset nvic_sys_reset()
stevstrong Feb 28, 2024
9d8cc09
F4: optimized ring_buffer
stevstrong Feb 28, 2024
5ea8ea3
renamed tools/macosx/hid_flash
stevstrong Feb 28, 2024
df8a416
F4: fix heap start address for F411 boards
stevstrong Feb 28, 2024
ffac07f
F4: Wire support of alternative pins
stevstrong Feb 28, 2024
d4dde32
F4: added I2S library
stevstrong Feb 28, 2024
e683b64
Update SPI.h
stevstrong Feb 28, 2024
e9f9c3f
F4: removed arduino_uip library (not used)
stevstrong Feb 28, 2024
691cd7d
F4: added Adafruit_ILI9341_STM library
stevstrong Feb 28, 2024
2e17a3b
Delete AdvancedChatServer.ino
stevstrong Feb 28, 2024
1b54bf6
F4: allow output pin speed selection
stevstrong Feb 28, 2024
d0318b5
F4: small changes
stevstrong Feb 28, 2024
a722381
F1: small changes in Adafruit_ILI9341_STM
stevstrong Feb 28, 2024
34b28e7
F1: small changes in Serasidis_VS1003B lib
stevstrong Feb 28, 2024
c391d1e
F1: removed timer setup from board init
stevstrong Feb 28, 2024
492cc52
F1: SPI settings get initialized when creating the instance
stevstrong Feb 28, 2024
51c3391
Update wirish.h
stevstrong Feb 28, 2024
f308c1a
Delete c_cpp_properties.json
stevstrong Feb 28, 2024
0ee341b
Update .gitignore
stevstrong Feb 28, 2024
19cb95a
Merge remote-tracking branch 'upstream/master' into dev
stevstrong Feb 28, 2024
caee306
Update rcc_private.h
stevstrong Feb 28, 2024
04fd971
small fixes after previous merge
stevstrong Feb 28, 2024
c456624
Merge branch 'master' into dev
stevstrong Feb 28, 2024
a0bcc04
Update SPI.h
stevstrong Feb 28, 2024
3bcd71e
Merge branch 'dev' of https://github.com/stevstrong/Arduino_STM32 int…
stevstrong Feb 28, 2024
8b65f19
remove some not needed files
stevstrong Feb 28, 2024
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
84 changes: 84 additions & 0 deletions .github/workflows/TestCompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# TestCompile.yml
# Github workflow script to test compile all examples of an Arduino core repository.
#
# Copyright (C) 2020 Armin Joachimsmeyer
# https://github.com/ArminJo/Github-Actions
#

# This is the name of the workflow, visible on GitHub UI.
name: TestCompile
on:
workflow_dispatch: # To run it manually
description: 'manual build check'
push: # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
paths:
- '**.ino'
- '**.cpp'
- '**.h'
- '**TestCompile.yml'
pull_request:
jobs:
build:
name: Test compiling examples for Arduino_STM32
runs-on: ubuntu-latest
env:
# PLATFORM_DEFAULT_URL: http://dan.drown.org/stm32duino/package_STM32duino_index.json
# Comma separated list without double quotes around the list.
REQUIRED_LIBRARIES: SdFat,Streaming,Adafruit GFX Library,Adafruit SSD1306,Adafruit STMPE610,Adafruit TouchScreen,SD

strategy:
matrix:
# The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn`
# In the Arduino IDE, the fqbn is printed in the first line of the verbose output for compilation as parameter -fqbn=... for the "arduino-builder -dump-prefs" command
#
# Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native"
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro
# STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
#############################################################################################################
arduino-boards-fqbn:
- stm32duino:STM32F1:genericSTM32F103C
#- stm32duino:STM32F1:nucleo_f103rb
#- stm32duino:STM32F1:mapleMini

# Specify parameters for each board.
# With sketches-exclude you may exclude specific examples for a board. Use a comma separated list.
#############################################################################################################
include:
- arduino-boards-fqbn: stm32duino:STM32F1:genericSTM32F103C
# errors: BOARD_BUTTON_PIN not defined, 'textsize' was not declared in this scope, 'A0' was not declared in this scope, 'BOARD_LED_PIN' was not declared in this scope, no matching function for call to 'SPIClass::transfer(uint8_t*&, size_t&)
sketches-exclude: Debounce,StateChangeDetection,Button,QASlave,InteractiveTest,WhileStatementConditional,HardwareTimerOnePulseMode,HardwareTimerPWMInput,StringEx_Parsing,hello_STM,MIDI_Classic_Mode,JeeUdp,multipacketSD,udpListener,etherNode,SingleChannelContinuousConversion,OLED_I2C_NumberFonts,OLED_I2C_TinyFont_View,OLED_I2C_Scrolling_Text,OLED_I2C_Bitmap,OLED_I2C_3D_Cube,OLED_I2C_ViewFont,OLED_I2C_Graph_Demo,OLED_I2C_Brightness,OLED_I2C_NumberFonts,OLED_I2C_TinyFont_View,coos_display_blink,rtos_blink,rtos_display_blink,Twitter_Serial_GW,XivelyClientString,XivelyClient,ssd1306_128x64_i2c_STM32,breakouttouchpaint,graphicstest,stm32_graphicstest,TFT_Rainbow_ILI9341,TFT_Clock_ILI9341,TFT_Clock_Digital_ILI9341,TFT_Show_Font_ILI9341,graphicstest,stm32_graphicstest,onoffbutton_breakout,onoffbutton_breakout,onoffbutton,spitftbitmap,ssd1306_128x64_spi,ssd1306_128x32_i2c,ssd1306_128x32_spi,sdreader

#- arduino-boards-fqbn: stm32duino:STM32F1:nucleo_f103rb
# Examples to exclude because of ...
#sketches-exclude: WiiClassicJoystick,BasicUsage,DigisparkOLED,SoftPwm13Pins,TinySoftPwmDemo,DigiUSB2LCD,DigisparkUSBDemo,ArduinoNunchukDemo,DigisparkJoystickDemo

# Do not cancel all jobs / architectures if one job fails
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@master

- name: Use this repo as Arduino core
run: |
mkdir --parents $HOME/.arduino15/packages/stm32duino/hardware/STM32F1/0.0.7 # dummy release number
# cannot move, since we want to compile the examples in the library subfolder :-)
ln -s $GITHUB_WORKSPACE/STM32F1/* $HOME/.arduino15/packages/stm32duino/hardware/STM32F1/0.0.7
#cp --recursive $GITHUB_WORKSPACE/STM32F1/* $HOME/.arduino15/packages/stm32duino/hardware/STM32F1/0.0.7/
#ls -l --dereference --recursive --all $HOME/.arduino15/packages/stm32duino/hardware/STM32F1/0.0.7/

- name: Compile all examples
uses: ArminJo/arduino-test-compile@master
with:
required-libraries: ${{ env.REQUIRED_LIBRARIES }}
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }}
arduino-platform: stm32duino:STM32F1,arduino:sam # we require the C compiler from it. See dependencies of package_STM32duino_index.json
#platform-default-url: ${{ env.PLATFORM_DEFAULT_URL }}
#platform-url: ${{ matrix.platform-url }}
sketches-exclude: ${{ matrix.sketches-exclude }}
build-properties: ${{ toJson(matrix.build-properties) }}
sketch-names: "*.ino"
sketch-names-find-start: STM32F1/libraries/*/examples/
#debug-install: true
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
## Summary:
This repo contains the "Hardware" files to support STM32 based boards on Arduino version 1.8.x (some older versions may also work) including [LeafLabs Maple, and Maple mini](http://www.leaflabs.com/about-maple/), and other generic STM32F103 boards.


***We are also on Gitter https://gitter.im/stm32duino/Lobby/***
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stm32duino/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Background & Support:
* Based on https://github.com/bobc/maple-asp, which is in turn based on LibMaple by Leaflabs
* **Please read the wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki) for full details**
Expand Down
11 changes: 10 additions & 1 deletion STM32F1/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,16 @@ genericSTM32F103C.menu.upload_method.HIDUploadMethod.build.vect=VECT_TAB_ADDR=0x
genericSTM32F103C.menu.upload_method.HIDUploadMethod.build.ldscript=ld/hid_bootloader.ld

#-- CPU Clock frequency
genericSTM32F103C.menu.cpu_speed.speed_72mhz=72MHz (Normal)

genericSTM32F103C.menu.cpu_speed.speed_hsi_64mhz=64Mhz (HSI)
genericSTM32F103C.menu.cpu_speed.speed_hsi_64mhz.build.f_cpu=64000000L
genericSTM32F103C.menu.cpu_speed.speed_hsi_64mhz.build.hs_flag=-DUSE_HSI_CLOCK

genericSTM32F103C.menu.cpu_speed.speed_hsi_48mhz=48Mhz (HSI- USB)
genericSTM32F103C.menu.cpu_speed.speed_hsi_48mhz.build.f_cpu=48000000L
genericSTM32F103C.menu.cpu_speed.speed_hsi_48mhz.build.hs_flag=-DUSE_HSI_CLOCK -DHSI_USB_SPEED

genericSTM32F103C.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
genericSTM32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L

genericSTM32F103C.menu.cpu_speed.speed_48mhz=48MHz (Slow - with USB)
Expand Down
1 change: 1 addition & 0 deletions STM32F1/cores/maple/avr/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ typedef uint32_t prog_uint32_t;

#define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strncpy_P(dest, src, size) strncpy((dest), (src), (size))
#define strcat_P(dest, src) strcat((dest), (src))
#define strchr_P(s, c) strchr((s), (c))
#define strcmp_P(a, b) strcmp((a), (b))
Expand Down
1 change: 1 addition & 0 deletions STM32F1/cores/maple/libmaple/rcc_f1.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const struct rcc_dev_info rcc_dev_table[] = {
[RCC_TIMER13] = { .clk_domain = APB1, .line_num = 7 },
[RCC_TIMER14] = { .clk_domain = APB1, .line_num = 8 },
#endif
[RCC_CAN] = { .clk_domain = APB1, .line_num = 25 }, //! JMD after X893
};

__deprecated
Expand Down
8 changes: 4 additions & 4 deletions STM32F1/cores/maple/libmaple/rcc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

struct rcc_dev_info {
const rcc_clk_domain clk_domain;
const uint8 line_num;
const uint8_t line_num;
};

extern const struct rcc_dev_info rcc_dev_table[];
Expand All @@ -51,14 +51,14 @@ static inline rcc_clk_domain rcc_dev_clk(rcc_clk_id id) {
static inline void rcc_do_clk_enable(__IO uint32** enable_regs,
rcc_clk_id id) {
__IO uint32 *enable_reg = enable_regs[rcc_dev_clk(id)];
uint8 line_num = rcc_dev_table[id].line_num;
uint8_t line_num = rcc_dev_table[id].line_num;
bb_peri_set_bit(enable_reg, line_num, 1);
}

static inline void rcc_do_reset_dev(__IO uint32** reset_regs,
rcc_clk_id id) {
__IO uint32 *reset_reg = reset_regs[rcc_dev_clk(id)];
uint8 line_num = rcc_dev_table[id].line_num;
uint8_t line_num = rcc_dev_table[id].line_num;
bb_peri_set_bit(reset_reg, line_num, 1);
bb_peri_set_bit(reset_reg, line_num, 0);
}
Expand All @@ -75,7 +75,7 @@ static inline void rcc_do_set_prescaler(const uint32 *masks,
static inline void rcc_do_clk_disable(__IO uint32** enable_regs,
rcc_clk_id id) {
__IO uint32 *enable_reg = enable_regs[rcc_dev_clk(id)];
uint8 line_num = rcc_dev_table[id].line_num;
uint8_t line_num = rcc_dev_table[id].line_num;
bb_peri_set_bit(enable_reg, line_num, 0);
}

Expand Down
1 change: 1 addition & 0 deletions STM32F1/cores/maple/libmaple/series/rcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ typedef enum rcc_clk_id {
RCC_TIMER12,
RCC_TIMER13,
RCC_TIMER14,
RCC_CAN,
} rcc_clk_id;

/**
Expand Down
1 change: 1 addition & 0 deletions STM32F1/cores/maple/wirish.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <avr/dtostrf.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "itoa.h"

#include <libmaple/stm32.h>

Expand Down
2 changes: 1 addition & 1 deletion STM32F1/cores/maple/wirish_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void randomSeed(unsigned int seed);
* @return A pseudo-random number in the range [0,max).
* @see randomSeed()
*/
long random(long max);
long random(long max = __LONG_MAX__);

/**
* @brief Generate a pseudo-random number with lower and upper bounds.
Expand Down
4 changes: 4 additions & 0 deletions STM32F1/libraries/Adafruit_GFX_AS/Adafruit_GFX_AS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif

#define textsize textsize_x

Adafruit_GFX_AS::Adafruit_GFX_AS(int16_t w, int16_t h): Adafruit_GFX(w, h)
{
}
Expand Down Expand Up @@ -378,3 +380,5 @@ int16_t Adafruit_GFX_AS::drawFloat(float floatNumber, int16_t decimal, int16_t p
}
return sumX;
}

#undef textsize
31 changes: 23 additions & 8 deletions STM32F1/libraries/EEPROM/EEPROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
uint16 EEPROMClass::EE_CheckPage(uint32 pageBase, uint16 status)
{
uint32 pageEnd = pageBase + (uint32)PageSize;
uint32 pageEnd = pageBase + (uint32)PageSize * Pages;

// Page Status not EEPROM_ERASED and not a "state"
if ((*(__IO uint16*)pageBase) != EEPROM_ERASED && (*(__IO uint16*)pageBase) != status)
Expand Down Expand Up @@ -40,6 +40,10 @@ FLASH_Status EEPROMClass::EE_ErasePage(uint32 pageBase)
FlashStatus = FLASH_ErasePage(pageBase);
if (FlashStatus == FLASH_COMPLETE)
FlashStatus = FLASH_ProgramHalfWord(pageBase + 2, data);
for (size_t i = 1; i < Pages; i++)
{
FLASH_ErasePage(pageBase + PageSize * i);
}

return FlashStatus;
}
Expand Down Expand Up @@ -95,7 +99,7 @@ uint16 EEPROMClass::EE_GetVariablesCount(uint32 pageBase, uint16 skipAddress)
{
uint16 varAddress, nextAddress;
uint32 idx;
uint32 pageEnd = pageBase + (uint32)PageSize;
uint32 pageEnd = pageBase + (uint32)PageSize * Pages;
uint16 count = 0;

for (pageBase += 6; pageBase < pageEnd; pageBase += 4)
Expand Down Expand Up @@ -136,7 +140,7 @@ uint16 EEPROMClass::EE_PageTransfer(uint32 newPage, uint32 oldPage, uint16 SkipA
FLASH_Status FlashStatus;

// Transfer process: transfer variables from old to the new active page
newEnd = newPage + ((uint32)PageSize);
newEnd = newPage + ((uint32)PageSize * Pages);

// Find first free element in new page
for (newIdx = newPage + 4; newIdx < newEnd; newIdx += 4)
Expand All @@ -146,7 +150,7 @@ uint16 EEPROMClass::EE_PageTransfer(uint32 newPage, uint32 oldPage, uint16 SkipA
return EEPROM_OUT_SIZE;

oldEnd = oldPage + 4;
oldIdx = oldPage + (uint32)(PageSize - 2);
oldIdx = oldPage + (uint32)(PageSize * Pages - 2);

for (; oldIdx > oldEnd; oldIdx -= 4)
{
Expand Down Expand Up @@ -219,7 +223,7 @@ uint16 EEPROMClass::EE_VerifyPageFullWriteVariable(uint16 Address, uint16 Data)
return EEPROM_NO_VALID_PAGE;

// Get the valid Page end Address
pageEnd = pageBase + PageSize; // Set end of page
pageEnd = pageBase + PageSize * Pages; // Set end of page

for (idx = pageEnd - 2; idx > pageBase; idx -= 4)
{
Expand Down Expand Up @@ -254,7 +258,7 @@ uint16 EEPROMClass::EE_VerifyPageFullWriteVariable(uint16 Address, uint16 Data)
// Empty slot not found, need page transfer
// Calculate unique variables in page
count = EE_GetVariablesCount(pageBase, Address) + 1;
if (count >= (PageSize / 4 - 1))
if (count >= (PageSize * Pages / 4 - 1))
return EEPROM_OUT_SIZE;

if (pageBase == PageBase1)
Expand Down Expand Up @@ -284,6 +288,7 @@ EEPROMClass::EEPROMClass(void)
PageBase0 = EEPROM_PAGE0_BASE;
PageBase1 = EEPROM_PAGE1_BASE;
PageSize = EEPROM_PAGE_SIZE;
Pages = 1;
Status = EEPROM_NOT_INIT;
}

Expand All @@ -292,6 +297,16 @@ uint16 EEPROMClass::init(uint32 pageBase0, uint32 pageBase1, uint32 pageSize)
PageBase0 = pageBase0;
PageBase1 = pageBase1;
PageSize = pageSize;
Pages = 1;
return init();
}

uint16 EEPROMClass::init(uint32 pageBase0, uint32 pageBase1, uint32 pageSize, uint16 pages)
{
PageBase0 = pageBase0;
PageBase1 = pageBase1;
PageSize = pageSize;
Pages = pages;
return init();
}

Expand Down Expand Up @@ -481,7 +496,7 @@ uint16 EEPROMClass::read(uint16 Address, uint16 *Data)
return EEPROM_NO_VALID_PAGE;

// Get the valid Page end Address
pageEnd = pageBase + ((uint32)(PageSize - 2));
pageEnd = pageBase + ((uint32)(PageSize * Pages - 2));

// Check each active page address starting from end
for (pageBase += 6; pageEnd >= pageBase; pageEnd -= 4)
Expand Down Expand Up @@ -564,7 +579,7 @@ uint16 EEPROMClass::count(uint16 *Count)

uint16 EEPROMClass::maxcount(void)
{
return ((PageSize / 4)-1);
return ((PageSize * Pages / 4)-1);
}

EEPROMClass EEPROM;
2 changes: 2 additions & 0 deletions STM32F1/libraries/EEPROM/EEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class EEPROMClass

uint16 init(void);
uint16 init(uint32, uint32, uint32);
uint16 init(uint32, uint32, uint32, uint16);

uint16 format(void);

Expand All @@ -75,6 +76,7 @@ class EEPROMClass
uint32 PageBase0;
uint32 PageBase1;
uint32 PageSize;
uint16 Pages;
uint16 Status;
private:
FLASH_Status EE_ErasePage(uint32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
int ledPin = 13; // LED connected to digital pin 13
const char HELP_MSG[] = "Press :\r\n" \
" 0 display configuration\r\n" \
" 1 set configuration to 0x801F000 / 0x801F800 / 0x400 (RB MCU)\r\n" \
" 2 set configuration to 0x801F000 / 0x801F800 / 0x800 (ZE/RE MCU)\r\n" \
" 1 set configuration to 0x801F000 / 0x801F800 / 0x400 / 2 (RB MCU)\r\n" \
" 2 set configuration to 0x801F000 / 0x801F800 / 0x800 / 1 (ZE/RE MCU)\r\n" \
" 3 write/read variable\r\n" \
" 4 increment address\r\n" \
" 5 display pages top/bottom\r\n" \
Expand Down Expand Up @@ -40,13 +40,15 @@ void loop()
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x400;
EEPROM.Pages = 2;
DisplayConfig();
}
else if (cmd == '2')
{
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x800;
EEPROM.Pages = 1;
DisplayConfig();
}
else if (cmd == '3')
Expand Down Expand Up @@ -111,6 +113,8 @@ void DisplayConfig(void)
Serial.print (" (");
Serial.print (EEPROM.PageSize, DEC);
Serial.println(")");
Serial.print ("EEPROM.Pages : ");
Serial.println(EEPROM.Pages, DEC);
}

void DisplayHex(uint16 value)
Expand Down Expand Up @@ -149,7 +153,7 @@ void DisplayPagesEnd(uint32 endIndex)
{
Serial.println("Page 0 Bottom Page 1");

for (uint32 idx = EEPROM.PageSize - endIndex; idx < EEPROM.PageSize; idx += 4)
for (uint32 idx = EEPROM.PageSize * EEPROM.Pages - endIndex; idx < EEPROM.PageSize * EEPROM.Pages; idx += 4)
{
Serial.print (EEPROM.PageBase0 + idx, HEX);
Serial.print (" : ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/

#include <SPI.h>
#include <Ethernet.h>
#include <Ethernet_STM.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
Expand Down
Loading
Loading