Bump to head
This commit is contained in:
@@ -54,10 +54,9 @@ jobs:
|
||||
generate_version ./Marlin/src/inc
|
||||
cat ./Marlin/src/inc/_Version.h
|
||||
#
|
||||
# Backup pins_RAMPS.h
|
||||
#
|
||||
cp Marlin/src/pins/pins_RAMPS.h Marlin/src/pins/pins_RAMPS.h.backup
|
||||
# Back up pins_RAMPS.h
|
||||
#
|
||||
backup_ramps
|
||||
|
||||
env_backup
|
||||
|
||||
|
||||
+148
-116
@@ -122,169 +122,201 @@ ifeq ($(HARDWARE_MOTHERBOARD),0)
|
||||
#
|
||||
|
||||
# MEGA/RAMPS up to 1.2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),3)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1000)
|
||||
|
||||
# RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),33)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1010)
|
||||
# RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),34)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1011)
|
||||
# RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),35)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1012)
|
||||
# RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),36)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1013)
|
||||
# RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),38)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1014)
|
||||
|
||||
# RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),43)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1020)
|
||||
# RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),44)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1021)
|
||||
# RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),45)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1022)
|
||||
# RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),46)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1023)
|
||||
# RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),48)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1024)
|
||||
|
||||
# RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),143)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1030)
|
||||
# RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),144)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1031)
|
||||
# RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),145)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1032)
|
||||
# RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),146)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1033)
|
||||
# RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),148)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1034)
|
||||
|
||||
#
|
||||
# RAMPS Derivatives - ATmega1280, ATmega2560
|
||||
#
|
||||
|
||||
# 3Drag Controller
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),77)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1100)
|
||||
# Velleman K8200 Controller (derived from 3Drag Controller)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),78)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
|
||||
# Velleman K8400 Controller (derived from 3Drag Controller)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),79)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
|
||||
# 2PrintBeta BAM&DICE with STK drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),401)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
|
||||
# 2PrintBeta BAM&DICE Due with STK drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),402)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
|
||||
# MKS BASE v1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),40)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1105)
|
||||
# MKS v1.4 with A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1106)
|
||||
# MKS v1.5 with Allegro A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),405)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1107)
|
||||
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),41)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
|
||||
# MKS GEN v1.3 or 1.4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),47)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
|
||||
# MKS GEN L
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),53)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1110)
|
||||
# zrib V2.0 control board (Chinese knock off RAMPS replica)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),504)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1111)
|
||||
# Bigtreetech or BIQU KFB2.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
|
||||
# Felix 2.0+ Electronics Board (RAMPS like)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),37)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
|
||||
# Invent-A-Part RigidBoard
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),42)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
|
||||
# Invent-A-Part RigidBoard V2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),52)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
|
||||
# Sainsmart 2-in-1 board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),49)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
|
||||
# Ultimaker
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),7)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
|
||||
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),71)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
|
||||
MCU ?= atmega1280
|
||||
|
||||
# Azteeg X3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),67)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
|
||||
# Azteeg X3 Pro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),68)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
|
||||
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),72)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
|
||||
# Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),80)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
|
||||
# Raise3D Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),333)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
|
||||
# Rapide Lite RL200 Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
|
||||
# Formbot T-Rex 2 Plus
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),95)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
|
||||
# Formbot T-Rex 3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),96)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
|
||||
# Formbot Raptor
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),97)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
|
||||
# Formbot Raptor 2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),98)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
|
||||
# bq ZUM Mega 3D
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),503)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
|
||||
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),431)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
|
||||
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),343)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
|
||||
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),443)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
|
||||
# TriGorilla Anycubic version 1.4 Rev 1.1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
|
||||
# Creality: Ender-4, CR-8
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),243)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
|
||||
# Creality: CR10S, CR20, CR-X
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),244)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
|
||||
# Dagoma F5
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
|
||||
# Fysetc F6
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),541)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
|
||||
# Duplicator i3 Plus
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),31)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
|
||||
# VORON
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),441)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
|
||||
# TRONXY V3 1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
|
||||
# Z-Bolt X Series
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
|
||||
|
||||
#
|
||||
# RAMBo and derivatives
|
||||
#
|
||||
|
||||
# Rambo
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1200)
|
||||
# Mini-Rambo
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1201)
|
||||
# Mini-Rambo 1.0a
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1202)
|
||||
# Einsy Rambo
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1203)
|
||||
# Einsy Retro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1204)
|
||||
# abee Scoovo X9H
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1205)
|
||||
|
||||
#
|
||||
# Other ATmega1280, ATmega2560
|
||||
#
|
||||
|
||||
# Cartesio CN Controls V11
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),111)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1300)
|
||||
# Cartesio CN Controls V12
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),112)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1301)
|
||||
# Cheaptronic v1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),2)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1302)
|
||||
# Cheaptronic v2.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),21)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1303)
|
||||
# Makerbot Mightyboard Revision E
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),200)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1304)
|
||||
# Megatronics
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),70)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1305)
|
||||
# Megatronics v2.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),701)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1306)
|
||||
# Megatronics v3.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),703)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1307)
|
||||
# Megatronics v3.1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),704)
|
||||
# Rambo
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),301)
|
||||
# Mini-Rambo
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),302)
|
||||
# Mini-Rambo 1.0a
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),303)
|
||||
# Einsy Rambo
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),304)
|
||||
# Einsy Retro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),305)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1308)
|
||||
# Megatronics v3.2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1309)
|
||||
# Elefu Ra Board (v3)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),21)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1310)
|
||||
# Leapfrog
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),999)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1311)
|
||||
# Mega controller
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),310)
|
||||
# abee Scoovo X9H
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),321)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1312)
|
||||
# Geeetech GT2560 Rev B for Mecreator2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1313)
|
||||
# Geeetech GT2560 Rev. A
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),74)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1314)
|
||||
# Geeetech GT2560 Rev. A+ (with auto level probe)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),75)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1315)
|
||||
# Geeetech GT2560 Rev B for A10(M/D)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1316)
|
||||
# Geeetech GT2560 Rev B for A20(M/D)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1317)
|
||||
# Einstart retrofit
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1318)
|
||||
# Wanhao 0ne+ i3 Mini
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1319)
|
||||
|
||||
#
|
||||
# ATmega1281, ATmega2561
|
||||
#
|
||||
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),702)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1400)
|
||||
MCU ?= atmega1281
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),25)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1410)
|
||||
MCU ?= atmega1281
|
||||
|
||||
#
|
||||
@@ -292,43 +324,43 @@ else ifeq ($(HARDWARE_MOTHERBOARD),25)
|
||||
#
|
||||
|
||||
# Sanguinololu < 1.2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),6)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1500)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
# Sanguinololu 1.2 and above
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),62)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1501)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
# Melzi
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),63)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1502)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
# Melzi with ATmega1284 (MaKr3d version)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),66)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1503)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
# Melzi Creality3D board (for CR-10 etc)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),89)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1504)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
# Melzi Malyan M150 board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),92)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1505)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
# Tronxy X5S
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),505)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1506)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
# STB V1.1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),64)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1507)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
# Azteeg X1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),65)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1508)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
# Anet 1.0 (Melzi clone)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),69)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1509)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
|
||||
@@ -337,51 +369,51 @@ else ifeq ($(HARDWARE_MOTHERBOARD),69)
|
||||
#
|
||||
|
||||
# Gen3 Monolithic Electronics
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),22)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1600)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
# Gen3+
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),9)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1601)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
# Gen6
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),5)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1602)
|
||||
HARDWARE_VARIANT ?= Gen6
|
||||
MCU ?= atmega644p
|
||||
# Gen6 deluxe
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),51)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1603)
|
||||
HARDWARE_VARIANT ?= Gen6
|
||||
MCU ?= atmega644p
|
||||
# Gen7 custom (Alfons3 Version)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),10)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1604)
|
||||
HARDWARE_VARIANT ?= Gen7
|
||||
MCU ?= atmega644
|
||||
F_CPU ?= 20000000
|
||||
# Gen7 v1.1, v1.2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),11)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1605)
|
||||
HARDWARE_VARIANT ?= Gen7
|
||||
MCU ?= atmega644p
|
||||
F_CPU ?= 20000000
|
||||
# Gen7 v1.3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),12)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1606)
|
||||
HARDWARE_VARIANT ?= Gen7
|
||||
MCU ?= atmega644p
|
||||
F_CPU ?= 20000000
|
||||
# Gen7 v1.4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),13)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1607)
|
||||
HARDWARE_VARIANT ?= Gen7
|
||||
MCU ?= atmega1284p
|
||||
F_CPU ?= 20000000
|
||||
# Alpha OMCA board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),90)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1608)
|
||||
HARDWARE_VARIANT ?= SanguinoA
|
||||
MCU ?= atmega644
|
||||
# Final OMCA board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),91)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1609)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
# Sethi 3D_1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),20)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1610)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega644p
|
||||
|
||||
@@ -390,46 +422,46 @@ else ifeq ($(HARDWARE_MOTHERBOARD),20)
|
||||
#
|
||||
|
||||
# Teensylu
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),8)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1700)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
# Printrboard (AT90USB1286)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),81)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1701)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
# Printrboard Revision F (AT90USB1286)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),811)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1702)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
# Brainwave (AT90USB646)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),82)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1703)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb646
|
||||
# Brainwave Pro (AT90USB1286)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),83)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1704)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
# SAV Mk-I (AT90USB1286)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),84)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1705)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
# Teensy++2.0 (AT90USB1286)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),85)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1706)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
# 5DPrint D8 Driver Board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),88)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1707)
|
||||
HARDWARE_VARIANT ?= Teensy
|
||||
MCU ?= at90usb1286
|
||||
|
||||
# UltiMachine Archim1 (with DRV8825 drivers)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1591)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),3023)
|
||||
HARDWARE_VARIANT ?= archim
|
||||
MCPU = cortex-m3
|
||||
F_CPU = 84000000L
|
||||
IS_MCU = 0
|
||||
# UltiMachine Archim2 (with TMC2130 drivers)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1592)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),3024)
|
||||
HARDWARE_VARIANT ?= archim
|
||||
MCPU = cortex-m3
|
||||
F_CPU = 84000000L
|
||||
@@ -576,7 +608,7 @@ ifeq ($(U8GLIB), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(TMC), 1)
|
||||
LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
|
||||
LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(RELOC_WORKAROUND), 1)
|
||||
@@ -647,8 +679,8 @@ LIBWARN = -w -Wno-packed-bitfield-compat
|
||||
CSTANDARD = -std=gnu99
|
||||
CXXSTANDARD = -std=gnu++11
|
||||
CDEBUG = -g$(DEBUG)
|
||||
CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas
|
||||
CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas
|
||||
CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
|
||||
CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
|
||||
CTUNING = -fsigned-char -funsigned-bitfields -fpack-struct -fno-exceptions \
|
||||
-fshort-enums -ffunction-sections -fdata-sections
|
||||
ifneq ($(HARDWARE_MOTHERBOARD),)
|
||||
@@ -663,7 +695,7 @@ ASFLAGS := $(CDEFS)
|
||||
ifeq ($(HARDWARE_VARIANT), archim)
|
||||
LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
|
||||
LD_SUFFIX = $(LDLIBS)
|
||||
LDFLAGS = -lm -gcc -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
|
||||
LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
|
||||
else
|
||||
LD_PREFIX = -Wl,--gc-sections,--relax
|
||||
LDFLAGS = -lm
|
||||
@@ -740,7 +772,7 @@ ifeq (${AVRDUDE_PROGRAMMER}, arduino)
|
||||
stty -hup < $(UPLOAD_PORT); true
|
||||
endif
|
||||
|
||||
# Display size of file.
|
||||
# Display size of file.
|
||||
HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
|
||||
ELFSIZE = $(SIZE) $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \
|
||||
$(SIZE) $(BUILD_DIR)/$(TARGET).elf
|
||||
@@ -790,7 +822,7 @@ extcoff: $(TARGET).elf
|
||||
.elf.sym:
|
||||
$(NM) -n $< > $@
|
||||
|
||||
# Link: create ELF output file from library.
|
||||
# Link: create ELF output file from library.
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
|
||||
$(Pecho) " CXX $@"
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom Bitmap for splashscreen
|
||||
*
|
||||
* You may use one of the following tools to generate the C++ bitmap array from
|
||||
* a black and white image:
|
||||
*
|
||||
* - http://www.marlinfw.org/tools/u8glib/converter.html
|
||||
* - http://www.digole.com/tools/PicturetoC_Hex_converter.php
|
||||
*/
|
||||
|
||||
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
|
||||
#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
|
||||
#define CUSTOM_BOOTSCREEN_INVERTED
|
||||
|
||||
const unsigned char custom_start_bmp[] PROGMEM = {
|
||||
B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,
|
||||
B11111110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,
|
||||
B11111100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
|
||||
B11111100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
|
||||
B11111110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
|
||||
B11111100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000000,B00000001,B11110000,B00111111,
|
||||
B11111110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000000,B00000010,B00001000,B00011111,
|
||||
B11111100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000000,B00000101,B00000100,B00111111,
|
||||
B11111110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000000,B00001010,B00000010,B00011111,
|
||||
B11111100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000000,B00010101,B00000001,B00111111,
|
||||
B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
|
||||
B11111100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000000,B00010100,B00000001,B00111111,
|
||||
B11111110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
|
||||
B11111100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B00010101,B00000001,B00111111,
|
||||
B11111110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101010,B00001010,B00000010,B00011111,
|
||||
B11111100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010001,B00000101,B00000100,B00111111,
|
||||
B11111110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100001,B00000010,B10001000,B00011111,
|
||||
B11111100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010001,B00000001,B11110000,B00111111,
|
||||
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101010,B00000000,B00000000,B00011111,
|
||||
B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00000000,B00000000,B00111111,
|
||||
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
|
||||
B11111100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
|
||||
B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
|
||||
B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
|
||||
B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
||||
B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
|
||||
B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
||||
B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
|
||||
B11100000,B00101110,B11111011,B01111101,B11111011,B11111011,B11001111,B11000001,B11011111,B10111011,B00111110,B11000000,B11100001,B11111110,B00111100,B00011111,
|
||||
B11111101,B11101110,B01111011,B00111001,B11111001,B11110011,B11001111,B10011110,B11011111,B10111011,B00111110,B11011111,B11011110,B11111100,B11011101,B11100111,
|
||||
B11111101,B11101110,B00111011,B10111011,B11111001,B11101011,B11010111,B10111111,B01011111,B10111011,B01011110,B11011111,B11011110,B11111101,B11101101,B11110111,
|
||||
B11111101,B11101110,B10111011,B11010011,B11111010,B11101011,B10110111,B00111111,B11011111,B10111011,B01001110,B11011111,B11011111,B11111111,B11001101,B11110011,
|
||||
B11111101,B11101110,B11011011,B11000111,B11111010,B11101011,B10111011,B01111111,B11000000,B00111011,B01101110,B11000000,B11100011,B11111111,B00011101,B11110011,
|
||||
B11111101,B11101110,B11001011,B11101111,B11111010,B11011011,B10111011,B01111111,B11011111,B10111011,B01100110,B11011111,B11111000,B11111111,B11001101,B11110011,
|
||||
B11111101,B11101110,B11101011,B11101111,B11111011,B01011011,B00000011,B00111111,B01011111,B10111011,B01110110,B11011111,B11111110,B01111111,B11101101,B11110011,
|
||||
B11111101,B11101110,B11110011,B11101111,B11111011,B01011011,B01111001,B10111110,B11011111,B10111011,B01111010,B11011111,B11011110,B01111101,B11101101,B11110111,
|
||||
B11111101,B11101110,B11110011,B11101111,B11111011,B10111010,B11111101,B10011110,B11011111,B10111011,B01111100,B11011111,B11011110,B11111101,B11001101,B11100111,
|
||||
B11111101,B11101110,B11111011,B11101111,B11111011,B10111010,B11111101,B11000001,B11011111,B10111011,B01111110,B11000000,B11100000,B11111110,B00011100,B00011111
|
||||
};
|
||||
@@ -33,10 +33,8 @@
|
||||
#define HAL_PLATFORM HAL_LPC1768
|
||||
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
|
||||
#define HAL_PLATFORM HAL_STM32F1
|
||||
#elif defined(STM32GENERIC) && defined(STM32F4)
|
||||
#define HAL_PLATFORM HAL_STM32F4
|
||||
#elif defined(STM32GENERIC) && defined(STM32F7)
|
||||
#define HAL_PLATFORM HAL_STM32F7
|
||||
#elif defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
#define HAL_PLATFORM HAL_STM32_F4_F7
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
#define HAL_PLATFORM HAL_STM32
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
@@ -50,3 +48,5 @@
|
||||
#define XSTR_(M) #M
|
||||
#define XSTR(M) XSTR_(M)
|
||||
#define HAL_PATH(PATH, NAME) XSTR(PATH/HAL_PLATFORM/NAME)
|
||||
|
||||
#include HAL_PATH(.,HAL.h)
|
||||
@@ -22,50 +22,18 @@
|
||||
|
||||
#ifdef __AVR__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//uint8_t MCUSR;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_init(void) {
|
||||
// Init Servo Pins
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include "fastio_AVR.h"
|
||||
@@ -33,18 +27,20 @@
|
||||
#ifdef USBCON
|
||||
#include "HardwareSerial.h"
|
||||
#else
|
||||
#define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
|
||||
#include "MarlinSerial.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//#define analogInputToDigitalPin(IO) IO
|
||||
|
||||
@@ -59,9 +55,9 @@
|
||||
// On AVR this is in math.h?
|
||||
//#define square(x) ((x)*(x))
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef uint16_t hal_timer_t;
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFF
|
||||
@@ -71,9 +67,9 @@ typedef int8_t pin_t;
|
||||
#define SHARED_SERVOS HAS_SERVOS
|
||||
#define HAL_SERVO_LIB Servo
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//extern uint8_t MCUSR;
|
||||
|
||||
@@ -105,9 +101,9 @@ typedef int8_t pin_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_init(void);
|
||||
|
||||
|
||||
@@ -31,10 +31,6 @@
|
||||
|
||||
#ifdef __AVR__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
void spiBegin(void) {
|
||||
|
||||
@@ -275,7 +275,6 @@
|
||||
|
||||
#endif // !USBCON
|
||||
|
||||
|
||||
#ifdef INTERNAL_SERIAL_PORT
|
||||
template <uint8_t serial>
|
||||
struct MarlinInternalSerialCfg {
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
|
||||
*/
|
||||
|
||||
#include "../../core/macros.h"
|
||||
#include "../../module/endstops.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM_plus_70[] = {
|
||||
// PORTLIST
|
||||
// -------------------------------------------
|
||||
// ------------------------
|
||||
PE , // PE 0 ** 0 ** USART0_RX
|
||||
PE , // PE 1 ** 1 ** USART0_TX
|
||||
PE , // PE 4 ** 2 ** PWM2
|
||||
@@ -140,7 +140,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM_plus_70[] = {
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM_plus_70[] = {
|
||||
// PIN IN PORT
|
||||
// -------------------------------------------
|
||||
// ------------------------
|
||||
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX
|
||||
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX
|
||||
_BV( 4 ) , // PE 4 ** 2 ** PWM2
|
||||
@@ -234,7 +234,7 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM_plus_70[] = {
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM_plus_70[] = {
|
||||
// TIMERS
|
||||
// -------------------------------------------
|
||||
// ------------------------
|
||||
NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
|
||||
NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
|
||||
TIMER3B , // PE 4 ** 2 ** PWM2
|
||||
|
||||
@@ -25,53 +25,21 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include <Wire.h>
|
||||
#include "usb/usb_task.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// HAL initialization task
|
||||
void HAL_init(void) {
|
||||
@@ -122,9 +90,9 @@ int freeMemory() {
|
||||
return (int)&free_memory - (heap_end ? heap_end : (int)&_ebss);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
HAL_adc_result = analogRead(adc_pin);
|
||||
|
||||
@@ -68,10 +68,6 @@
|
||||
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
||||
#endif
|
||||
|
||||
#ifndef vsnprintf_P
|
||||
#define vsnprintf_P vsnprintf
|
||||
#endif
|
||||
|
||||
// Fix bug in pgm_read_ptr
|
||||
#undef pgm_read_ptr
|
||||
#define pgm_read_ptr(addr) (*((void**)(addr)))
|
||||
|
||||
@@ -37,27 +37,18 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../shared/Delay.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#if EITHER(DUE_SOFTWARE_SPI, FORCE_SOFT_SPI)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Software SPI
|
||||
// ------------------------
|
||||
|
||||
// Make sure GCC optimizes this file.
|
||||
// Note that this line triggers a bug in GCC which is fixed by casting.
|
||||
@@ -551,9 +542,9 @@
|
||||
// slave selects controlled by SPI controller
|
||||
// doesn't support changing SPI speeds for SD card
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
static bool spiInitialized = false;
|
||||
|
||||
void spiInit(uint8_t spiRate) {
|
||||
|
||||
@@ -28,36 +28,23 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include "HAL_timers_Due.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 9
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
{ TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5]
|
||||
@@ -71,17 +58,9 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
{ TC2, 2, TC8_IRQn, 0}, // 8
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/*
|
||||
Timer_clock1: Prescaler 2 -> 42MHz
|
||||
|
||||
@@ -26,15 +26,11 @@
|
||||
* For ARDUINO_ARCH_SAM
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
@@ -69,9 +65,9 @@ typedef uint32_t hal_timer_t;
|
||||
#define HAL_TEMP_TIMER_ISR() void TC4_Handler()
|
||||
#define HAL_TONE_TIMER_ISR() void TC6_Handler()
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef struct {
|
||||
Tc *pTimerRegs;
|
||||
@@ -80,15 +76,15 @@ typedef struct {
|
||||
uint8_t priority;
|
||||
} tTimerConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
extern const tTimerConfig TimerConfig[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
#include <pins_arduino.h>
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
/**
|
||||
* Utility functions
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#if NONE(I2C_EEPROM, SPI_EEPROM)
|
||||
#if !defined(E2END) && NONE(I2C_EEPROM, SPI_EEPROM)
|
||||
#define E2END 0xFFF // Default to Flash emulated EEPROM size (EepromEmulation_Due.cpp)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
* \asf_license_stop
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
|
||||
*/
|
||||
@@ -1904,7 +1905,7 @@ static void udd_ep_in_sent(udd_ep_id_t ep)
|
||||
ptr_src = &ptr_job->buf[ptr_job->buf_cnt];
|
||||
nb_remain = ptr_job->buf_size - ptr_job->buf_cnt;
|
||||
// Fill a bank even if no data (ZLP)
|
||||
nb_data = MIN(nb_remain, pkt_size);
|
||||
nb_data = min(nb_remain, pkt_size);
|
||||
// Modify job information
|
||||
ptr_job->buf_cnt += nb_data;
|
||||
ptr_job->buf_load = nb_data;
|
||||
|
||||
@@ -291,7 +291,7 @@ extern "C" {
|
||||
//! available greater size, then applies register format of UOTGHS controller
|
||||
//! for endpoint size bit-field.
|
||||
#undef udd_format_endpoint_size
|
||||
#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)MIN(MAX(size, 8), 1024) << 1) - 1) - 1 - 3)
|
||||
#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)min(max(size, 8), 1024) << 1) - 1) - 1 - 3)
|
||||
//! Configures the selected endpoint size
|
||||
#define udd_configure_endpoint_size(ep, size) (Wr_bitfield(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPSIZE_Msk, udd_format_endpoint_size(size)))
|
||||
//! Gets the configured selected endpoint size
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include <rom/rtc.h>
|
||||
#include <driver/adc.h>
|
||||
@@ -48,49 +44,33 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define V_REF 1100
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
esp_adc_cal_characteristics_t characteristics;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_init(void) {
|
||||
i2s_init();
|
||||
@@ -128,9 +108,9 @@ void _delay_ms(int delay_ms) { delay(delay_ms); }
|
||||
// return free memory between end of heap (or end bss) and whatever is current
|
||||
int freeMemory() { return ESP.getFreeHeap(); }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
#define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL
|
||||
|
||||
adc1_channel_t get_channel(int pin) {
|
||||
|
||||
@@ -24,10 +24,6 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
@@ -43,9 +39,9 @@
|
||||
#include "WebSocketSerial.h"
|
||||
#include "FlushableHardwareSerial.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
extern portMUX_TYPE spinlock;
|
||||
|
||||
@@ -69,24 +65,24 @@ extern portMUX_TYPE spinlock;
|
||||
#undef pgm_read_ptr
|
||||
#define pgm_read_ptr(addr) (*(addr))
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef int16_t pin_t;
|
||||
|
||||
#define HAL_SERVO_LIB Servo
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/** result of last ADC conversion */
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// clear reset reason
|
||||
void HAL_clear_reset_source (void);
|
||||
|
||||
@@ -48,8 +48,8 @@ void Servo::detach() { ledcDetachPin(this->pin); }
|
||||
|
||||
int Servo::read() { return this->degrees; }
|
||||
|
||||
void Servo::write(int degrees) {
|
||||
this->degrees = constrain(degrees, MIN_ANGLE, MAX_ANGLE);
|
||||
void Servo::write(int inDegrees) {
|
||||
this->degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE);
|
||||
int us = map(this->degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
|
||||
int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE);
|
||||
ledcWrite(channel, duty);
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include <pins_arduino.h>
|
||||
@@ -34,28 +30,28 @@
|
||||
#include "../../core/macros.h"
|
||||
#include <SPI.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#if ENABLED(SOFTWARE_SPI)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
#error "Software SPI not supported for ESP32. Use Hardware SPI."
|
||||
|
||||
#else
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void spiBegin() {
|
||||
#if !PIN_EXISTS(SS)
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include "esp_types.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
@@ -36,28 +32,15 @@
|
||||
|
||||
#include "HAL_timers_ESP32.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 4
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1};
|
||||
|
||||
@@ -68,17 +51,9 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
{ TIMER_GROUP_1, TIMER_1, 1, nullptr }, // 3
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void IRAM_ATTR timer_group0_isr(void *para) {
|
||||
const int timer_idx = (int)para;
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
#include "driver/timer.h"
|
||||
|
||||
@@ -33,9 +29,9 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../pins/pins.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
//
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
@@ -81,9 +77,9 @@ extern "C" void tempTC_Handler(void);
|
||||
extern "C" void stepTC_Handler(void);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef struct {
|
||||
timer_group_t group;
|
||||
@@ -92,15 +88,15 @@ typedef struct {
|
||||
void (*fn)(void);
|
||||
} tTimerConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
extern const tTimerConfig TimerConfig[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start (const uint8_t timer_num, uint32_t frequency);
|
||||
void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t count);
|
||||
|
||||
@@ -47,9 +47,9 @@ int freeMemory() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init(void) {
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#define F_CPU 100000000
|
||||
#define SystemCoreClock F_CPU
|
||||
#include <iostream>
|
||||
|
||||
@@ -24,15 +24,11 @@
|
||||
* HAL timers for Linux X86_64
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#define FALLING 0x03
|
||||
#define RISING 0x04
|
||||
|
||||
#define E2END 0xFFF // EEPROM end address
|
||||
|
||||
typedef uint8_t byte;
|
||||
#define PROGMEM
|
||||
#define PSTR(v) (v)
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
#include "../shared/persistent_store_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
uint8_t buffer[E2END];
|
||||
#define LINUX_EEPROM_SIZE (E2END + 1)
|
||||
uint8_t buffer[LINUX_EEPROM_SIZE];
|
||||
char filename[] = "eeprom.dat";
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
@@ -40,8 +41,8 @@ bool PersistentStore::access_start() {
|
||||
fseek(eeprom_file, 0L, SEEK_END);
|
||||
std::size_t file_size = ftell(eeprom_file);
|
||||
|
||||
if (file_size < E2END) {
|
||||
memset(buffer + file_size, eeprom_erase_value, E2END - file_size);
|
||||
if (file_size < LINUX_EEPROM_SIZE) {
|
||||
memset(buffer + file_size, eeprom_erase_value, LINUX_EEPROM_SIZE - file_size);
|
||||
}
|
||||
else {
|
||||
fseek(eeprom_file, 0L, SEEK_SET);
|
||||
|
||||
@@ -34,7 +34,7 @@ void HAL_init(void);
|
||||
#include <stdarg.h>
|
||||
#include <algorithm>
|
||||
|
||||
extern "C" volatile millis_t _millis;
|
||||
extern "C" volatile uint32_t _millis;
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
|
||||
@@ -49,15 +49,11 @@
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
#if ENABLED(LPC_SOFTWARE_SPI)
|
||||
|
||||
#include "SoftwareSPI.h"
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
* HAL For LPC1768
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../../core/macros.h"
|
||||
@@ -51,9 +47,9 @@
|
||||
#define SBIT_MR3R 10
|
||||
#define SBIT_MR3S 11
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define _HAL_TIMER(T) _CAT(LPC_TIM, T)
|
||||
#define _HAL_TIMER_IRQ(T) TIMER##T##_IRQn
|
||||
@@ -95,9 +91,9 @@ typedef uint32_t hal_timer_t;
|
||||
#define STEP_TIMER _HAL_TIMER(STEP_TIMER_NUM)
|
||||
#define TEMP_TIMER _HAL_TIMER(TEMP_TIMER_NUM)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
void HAL_timer_init(void);
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
|
||||
|
||||
@@ -44,9 +44,7 @@ extern uint32_t MSC_SD_Init(uint8_t pdrv);
|
||||
extern "C" int isLPC1769();
|
||||
extern "C" void disk_timerproc(void);
|
||||
|
||||
void SysTick_Callback() {
|
||||
disk_timerproc();
|
||||
}
|
||||
void SysTick_Callback() { disk_timerproc(); }
|
||||
|
||||
void HAL_init(void) {
|
||||
|
||||
@@ -99,6 +97,26 @@ void HAL_init(void) {
|
||||
OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef LPC1768_ENABLE_CLKOUT_12M
|
||||
/**
|
||||
* CLKOUTCFG register
|
||||
* bit 8 (CLKOUT_EN) = enables CLKOUT signal. Disabled for now to prevent glitch when enabling GPIO.
|
||||
* bits 7:4 (CLKOUTDIV) = set to 0 for divider setting of /1
|
||||
* bits 3:0 (CLKOUTSEL) = set to 1 to select main crystal oscillator as CLKOUT source
|
||||
*/
|
||||
LPC_SC->CLKOUTCFG = (0<<8)|(0<<4)|(1<<0);
|
||||
// set P1.27 pin to function 01 (CLKOUT)
|
||||
PINSEL_CFG_Type PinCfg;
|
||||
PinCfg.Portnum = 1;
|
||||
PinCfg.Pinnum = 27;
|
||||
PinCfg.Funcnum = 1; // function 01 (CLKOUT)
|
||||
PinCfg.OpenDrain = 0; // not open drain
|
||||
PinCfg.Pinmode = 2; // no pull-up/pull-down
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
// now set CLKOUT_EN bit
|
||||
LPC_SC->CLKOUTCFG |= (1<<8);
|
||||
#endif
|
||||
|
||||
USB_Init(); // USB Initialization
|
||||
USB_Connect(FALSE); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
|
||||
@@ -28,54 +28,25 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../shared/Delay.h"
|
||||
|
||||
#if ENABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
#if ENABLED(SRAM_EEPROM_EMULATION)
|
||||
#if STM32F7xx
|
||||
#include "stm32f7xx_ll_pwr.h"
|
||||
#elif STM32F4xx
|
||||
#include "stm32f4xx_ll_pwr.h"
|
||||
#else
|
||||
#error "EEPROM_EMULATED_WITH_SRAM is currently only supported for STM32F4xx and STM32F7xx"
|
||||
#error "SRAM_EEPROM_EMULATION is currently only supported for STM32F4xx and STM32F7xx"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// ------------------------
|
||||
|
||||
// Needed for DELAY_NS() / DELAY_US() on CORTEX-M7
|
||||
#if (defined(__arm__) || defined(__thumb__)) && __CORTEX_M == 7
|
||||
@@ -100,7 +71,7 @@ void HAL_init(void) {
|
||||
OUT_WRITE(LED_PIN, LOW);
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
#if ENABLED(SRAM_EEPROM_EMULATION)
|
||||
// Enable access to backup SRAM
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
HAL_PWR_EnableBkUpAccess();
|
||||
@@ -129,9 +100,9 @@ extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
HAL_adc_result = analogRead(adc_pin);
|
||||
|
||||
@@ -24,10 +24,6 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../core/macros.h"
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
@@ -43,9 +39,9 @@
|
||||
#include <USBSerial.h>
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#if SERIAL_PORT == 0
|
||||
#error "Serial port 0 does not exist"
|
||||
@@ -128,24 +124,24 @@
|
||||
#undef pgm_read_ptr
|
||||
#define pgm_read_ptr(addr) (*(addr))
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef int16_t pin_t;
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/** result of last ADC conversion */
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
@@ -23,35 +23,31 @@
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#if ENABLED(SOFTWARE_SPI)
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
#error "Software SPI not supported for STM32. Use Hardware SPI."
|
||||
|
||||
#else
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* VGPV SPI speed start and PCLK2/2, by default 108/2 = 54Mhz
|
||||
|
||||
@@ -19,53 +19,30 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
#include "HAL_timers_STM32.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 2
|
||||
|
||||
//#define PRESCALER 1
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
stm32f4_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
|
||||
stm32_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
bool timers_initialized[NUM_HARDWARE_TIMERS] = { false };
|
||||
|
||||
|
||||
@@ -21,16 +21,12 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
@@ -128,21 +124,21 @@ extern void Temp_Handler(stimer_t *htim);
|
||||
#define HAL_STEP_TIMER_ISR() void Step_Handler(stimer_t *htim)
|
||||
#define HAL_TEMP_TIMER_ISR() void Temp_Handler(stimer_t *htim)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef stimer_t stm32f4_timer_t;
|
||||
typedef stimer_t stm32_timer_t;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
extern stm32f4_timer_t TimerHandle[];
|
||||
extern stm32_timer_t TimerHandle[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
|
||||
@@ -27,21 +27,21 @@
|
||||
* These use GPIO register access for fast port manipulation.
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
extern GPIO_TypeDef * FastIOPortMap[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void FastIO_init(); // Must be called before using fast io macros
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define _BV32(b) (1UL << (b))
|
||||
|
||||
|
||||
@@ -28,20 +28,20 @@
|
||||
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#if NONE(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
#if NONE(SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
|
||||
#include <EEPROM.h>
|
||||
static bool eeprom_data_written = false;
|
||||
#endif
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
#if NONE(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
#if NONE(SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
|
||||
eeprom_buffer_fill();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
#if NONE(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
#if NONE(SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
|
||||
if (eeprom_data_written) {
|
||||
eeprom_buffer_flush();
|
||||
eeprom_data_written = false;
|
||||
@@ -66,7 +66,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
#elif DISABLED(SRAM_EEPROM_EMULATION)
|
||||
eeprom_buffered_write_byte(pos, v);
|
||||
#else
|
||||
*(__IO uint8_t *)(BKPSRAM_BASE + (uint8_t * const)pos) = v;
|
||||
@@ -76,20 +76,20 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
pos++;
|
||||
value++;
|
||||
};
|
||||
#if NONE(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
#if NONE(SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
|
||||
eeprom_data_written = true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
do {
|
||||
// Read from either external EEPROM, program flash or Backup SRAM
|
||||
const uint8_t c = (
|
||||
#if EITHER(SPI_EEPROM, I2C_EEPROM)
|
||||
eeprom_read_byte((uint8_t*)pos)
|
||||
#elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
#elif DISABLED(SRAM_EEPROM_EMULATION)
|
||||
eeprom_buffered_read_byte(pos)
|
||||
#else
|
||||
(*(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos)))
|
||||
@@ -107,7 +107,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
size_t PersistentStore::capacity() {
|
||||
#if EITHER(SPI_EEPROM, I2C_EEPROM)
|
||||
return E2END + 1;
|
||||
#elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
#elif DISABLED(SRAM_EEPROM_EMULATION)
|
||||
return E2END + 1;
|
||||
#else
|
||||
return 4096; // 4kB
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -30,10 +30,8 @@
|
||||
|
||||
#ifdef __STM32F1__
|
||||
#include "../HAL_STM32F1/fastio_STM32F1.h"
|
||||
#elif defined(STM32F4)
|
||||
#include "../HAL_STM32F4/fastio_STM32F4.h"
|
||||
#elif defined(STM32F7)
|
||||
#include "../HAL_STM32F7/fastio_STM32F7.h"
|
||||
#elif defined(STM32F4) || defined(STM32F7)
|
||||
#include "../HAL_STM32_F4_F7/fastio_STM32_F4_F7.h"
|
||||
#endif
|
||||
|
||||
extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
|
||||
@@ -48,7 +46,7 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
|
||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
|
||||
#define PRINT_PORT(p) print_port(p)
|
||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||
#define MULTI_NAME_PAD 20 // space needed to be pretty if not first name assigned to a pin
|
||||
#define MULTI_NAME_PAD 21 // space needed to be pretty if not first name assigned to a pin
|
||||
|
||||
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
||||
#ifndef M43_NEVER_TOUCH
|
||||
@@ -97,7 +95,7 @@ static inline void pwm_details(const pin_t pin) {
|
||||
timer_dev * const tdev = PIN_MAP[pin].timer_device;
|
||||
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||
const char num = (
|
||||
#ifdef STM32_HIGH_DENSITY
|
||||
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
|
||||
tdev == &timer8 ? '8' :
|
||||
tdev == &timer5 ? '5' :
|
||||
#endif
|
||||
@@ -114,22 +112,8 @@ static inline void pwm_details(const pin_t pin) {
|
||||
|
||||
static inline void print_port(pin_t pin) {
|
||||
const char port = 'A' + char(pin >> 4); // pin div 16
|
||||
/* seems not to be required for our devices
|
||||
gpio_dev * const gp = PIN_MAP[pin].gpio_device;
|
||||
const char port = (
|
||||
#if STM32_NR_GPIO_PORTS > 4
|
||||
gp == &gpiog ? 'G' :
|
||||
gp == &gpiof ? 'F' :
|
||||
gp == &gpioe ? 'E' :
|
||||
#endif
|
||||
gp == &gpiod ? 'D' :
|
||||
gp == &gpioc ? 'C' :
|
||||
gp == &gpiob ? 'B' :
|
||||
gp == &gpioa ? 'A' : '?'
|
||||
);
|
||||
*/
|
||||
const int16_t gbit = PIN_MAP[pin].gpio_bit;
|
||||
char buffer[6];
|
||||
char buffer[8];
|
||||
sprintf_P(buffer, PSTR("P%c%hd "), port, gbit);
|
||||
if (gbit < 10) SERIAL_CHAR(' ');
|
||||
SERIAL_ECHO(buffer);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -22,10 +22,12 @@
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "watchdog_STM32.h"
|
||||
#include <IWatchdog.h>
|
||||
|
||||
@@ -33,7 +35,7 @@
|
||||
|
||||
void watchdog_reset() {
|
||||
IWatchdog.reload();
|
||||
#if PIN_EXISTS(LED)
|
||||
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
|
||||
TOGGLE(LED_PIN); // heartbeat indicator
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -27,22 +27,14 @@
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include <STM32ADC.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define __I
|
||||
#define __IO volatile
|
||||
@@ -70,13 +62,10 @@
|
||||
__IO uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */
|
||||
} SCB_Type;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||
|
||||
@@ -89,18 +78,19 @@
|
||||
#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
|
||||
#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#ifdef SERIAL_USB
|
||||
USBSerial SerialUSB;
|
||||
#endif
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
STM32ADC adc(ADC1);
|
||||
|
||||
uint8_t adc_pins[] = {
|
||||
@@ -166,13 +156,13 @@ enum TEMP_PINS : char {
|
||||
|
||||
uint16_t HAL_adc_results[ADC_PIN_COUNT];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
||||
uint32_t reg_value;
|
||||
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
|
||||
@@ -185,9 +175,9 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
||||
SCB->AIRCR = reg_value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//
|
||||
// Leave PA11/PA12 intact if USBSerial is not used
|
||||
@@ -263,9 +253,9 @@ extern "C" {
|
||||
}
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Init the AD in continuous capture mode
|
||||
void HAL_adc_init(void) {
|
||||
// configure the ADC
|
||||
|
||||
@@ -28,14 +28,6 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
#ifndef vsnprintf_P
|
||||
#define vsnprintf_P vsnprintf
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../core/macros.h"
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
@@ -51,9 +43,9 @@
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#ifdef SERIAL_USB
|
||||
#define UsbSerial Serial
|
||||
@@ -156,22 +148,22 @@ void HAL_init(void);
|
||||
#define RST_SOFTWARE 32
|
||||
#define RST_BACKUP 64
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/** result of last ADC conversion */
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// Disable interrupts
|
||||
#define cli() noInterrupts()
|
||||
|
||||
@@ -124,6 +124,8 @@ bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t millis();
|
||||
|
||||
bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) {
|
||||
if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
|
||||
if (blockAddress >= SdCard.LogBlockNbr) return false;
|
||||
@@ -165,9 +167,9 @@ bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) {
|
||||
|
||||
inline uint32_t SDIO_GetCardState(void) { return SDIO_CmdSendStatus(SdCard.RelCardAdd << 16U) ? (SDIO_GetResponse(SDIO_RESP1) >> 9U) & 0x0FU : SDIO_CARD_ERROR; }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// SD Commands and Responses
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void SDIO_SendCommand(uint16_t command, uint32_t argument) { SDIO->ARG = argument; SDIO->CMD = (uint32_t)(SDIO_CMD_CPSMEN | command); }
|
||||
uint8_t SDIO_GetCommandResponse(void) { return (uint8_t)(SDIO->RESPCMD); }
|
||||
|
||||
@@ -21,18 +21,14 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
|
||||
#include "libmaple/sdio.h"
|
||||
#include "libmaple/dma.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define SDMMC_CMD_GO_IDLE_STATE ((uint8_t)0) /* Resets the SD memory card. */
|
||||
#define SDMMC_CMD_ALL_SEND_CID ((uint8_t)2) /* Asks any card connected to the host to send the CID numbers on the CMD line. */
|
||||
@@ -106,9 +102,9 @@
|
||||
|
||||
#define SDIO_CLOCK 18000000 /* 18 MHz */
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef struct {
|
||||
uint32_t CardType; // Card Type
|
||||
@@ -121,9 +117,9 @@ typedef struct {
|
||||
uint32_t LogBlockSize; // Logical block size in bytes
|
||||
} SDIO_CardInfoTypeDef;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
inline uint32_t SDIO_GetCardState(void);
|
||||
|
||||
|
||||
@@ -32,34 +32,25 @@
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include <SPI.h>
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#if ENABLED(SOFTWARE_SPI)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
#error "Software SPI not supported for STM32F1. Use hardware SPI."
|
||||
|
||||
#else
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* VGPV SPI speed start and F_CPU/2, by default 72/2 = 36Mhz
|
||||
|
||||
@@ -26,45 +26,17 @@
|
||||
|
||||
#ifdef __STM32F1__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
#include "HAL_timers_STM32F1.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* Timer_clock1: Prescaler 2 -> 36 MHz
|
||||
|
||||
@@ -25,16 +25,12 @@
|
||||
* HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
#include <libmaple/timer.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* TODO: Check and confirm what timer we will use for each Temps and stepper driving.
|
||||
@@ -96,21 +92,16 @@ timer_dev* get_timer_dev(int number);
|
||||
extern "C" void tempTC_Handler(void);
|
||||
extern "C" void stepTC_Handler(void);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
/*
|
||||
static HardwareTimer StepperTimer(STEP_TIMER_NUM);
|
||||
static HardwareTimer TempTimer(TEMP_TIMER_NUM);
|
||||
*/
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//static HardwareTimer StepperTimer(STEP_TIMER_NUM);
|
||||
//static HardwareTimer TempTimer(TEMP_TIMER_NUM);
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
|
||||
@@ -49,10 +49,10 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool set/*=true*/) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
do {
|
||||
uint8_t c = eeprom_read_byte((uint8_t*)pos);
|
||||
if (set && value) *value = c;
|
||||
if (writing && value) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#ifndef E2END
|
||||
#define E2END 4095
|
||||
#define E2END 0xFFF // 4KB
|
||||
#endif
|
||||
#define HAL_STM32F1_EEPROM_SIZE (E2END + 1)
|
||||
|
||||
|
||||
@@ -56,5 +56,4 @@ void watchdog_init(void) {
|
||||
}
|
||||
|
||||
#endif // USE_WATCHDOG
|
||||
|
||||
#endif // __STM32F1__
|
||||
|
||||
@@ -1,569 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file EEPROM/EEPROM_Emulation/src/eeprom.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.2.6
|
||||
* @date 04-November-2016
|
||||
* @brief This file provides all the EEPROM emulation firmware functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/** @addtogroup EEPROM_Emulation
|
||||
* @{
|
||||
*/
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4))
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "eeprom_emul.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Global variable used to store variable value in read sequence */
|
||||
uint16_t DataVar = 0;
|
||||
|
||||
/* Virtual address defined by the user: 0xFFFF value is prohibited */
|
||||
uint16_t VirtAddVarTab[NB_OF_VAR];
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
static HAL_StatusTypeDef EE_Format(void);
|
||||
static uint16_t EE_FindValidPage(uint8_t Operation);
|
||||
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data);
|
||||
static uint16_t EE_VerifyPageFullyErased(uint32_t Address);
|
||||
|
||||
/**
|
||||
* @brief Restore the pages to a known good state in case of page's status
|
||||
* corruption after a power loss.
|
||||
* @param None.
|
||||
* @retval - Flash error code: on write Flash error
|
||||
* - FLASH_COMPLETE: on success
|
||||
*/
|
||||
uint16_t EE_Initialize(void) {
|
||||
uint16_t PageStatus0 = 6, PageStatus1 = 6;
|
||||
uint16_t VarIdx = 0;
|
||||
uint16_t EepromStatus = 0, ReadStatus = 0;
|
||||
int16_t x = -1;
|
||||
HAL_StatusTypeDef FlashStatus;
|
||||
uint32_t SectorError = 0;
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
|
||||
|
||||
/* Get Page0 status */
|
||||
PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
/* Get Page1 status */
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
pEraseInit.TypeErase = TYPEERASE_SECTORS;
|
||||
pEraseInit.Sector = PAGE0_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
|
||||
/* Check for invalid header states and repair if necessary */
|
||||
switch (PageStatus0) {
|
||||
case ERASED:
|
||||
if (PageStatus1 == VALID_PAGE) { /* Page0 erased, Page1 valid */
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == RECEIVE_DATA) { /* Page0 erased, Page1 receive */
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
else { /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
break;
|
||||
|
||||
case RECEIVE_DATA:
|
||||
if (PageStatus1 == VALID_PAGE) { /* Page0 receive, Page1 valid */
|
||||
/* Transfer data from Page1 to Page0 */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
|
||||
x = VarIdx;
|
||||
if (VarIdx != x) {
|
||||
/* Read the last variables' updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1) {
|
||||
/* Transfer the variable to the Page0 */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
pEraseInit.Sector = PAGE1_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == ERASED) { /* Page0 receive, Page1 erased */
|
||||
pEraseInit.Sector = PAGE1_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
else { /* Invalid state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
break;
|
||||
|
||||
case VALID_PAGE:
|
||||
if (PageStatus1 == VALID_PAGE) { /* Invalid state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
else if (PageStatus1 == ERASED) { /* Page0 valid, Page1 erased */
|
||||
pEraseInit.Sector = PAGE1_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
}
|
||||
else { /* Page0 valid, Page1 receive */
|
||||
/* Transfer data from Page0 to Page1 */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
|
||||
x = VarIdx;
|
||||
|
||||
if (VarIdx != x) {
|
||||
/* Read the last variables' updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1) {
|
||||
/* Transfer the variable to the Page1 */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
pEraseInit.Sector = PAGE0_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Any other state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
break;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify if specified page is fully erased.
|
||||
* @param Address: page address
|
||||
* This parameter can be one of the following values:
|
||||
* @arg PAGE0_BASE_ADDRESS: Page0 base address
|
||||
* @arg PAGE1_BASE_ADDRESS: Page1 base address
|
||||
* @retval page fully erased status:
|
||||
* - 0: if Page not erased
|
||||
* - 1: if Page erased
|
||||
*/
|
||||
uint16_t EE_VerifyPageFullyErased(uint32_t Address) {
|
||||
uint32_t ReadStatus = 1;
|
||||
uint16_t AddressValue = 0x5555;
|
||||
/* Check each active page address starting from end */
|
||||
while (Address <= PAGE0_END_ADDRESS) {
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
AddressValue = (*(__IO uint16_t*)Address);
|
||||
/* Compare the read address with the virtual address */
|
||||
if (AddressValue != ERASED) {
|
||||
/* In case variable value is read, reset ReadStatus flag */
|
||||
ReadStatus = 0;
|
||||
break;
|
||||
}
|
||||
/* Next address location */
|
||||
Address += 4;
|
||||
}
|
||||
/* Return ReadStatus value: (0: Page not erased, 1: Sector erased) */
|
||||
return ReadStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the last stored variable data, if found, which correspond to
|
||||
* the passed virtual address
|
||||
* @param VirtAddress: Variable virtual address
|
||||
* @param Data: Global variable contains the read variable value
|
||||
* @retval Success or error status:
|
||||
* - 0: if variable was found
|
||||
* - 1: if the variable was not found
|
||||
* - NO_VALID_PAGE: if no valid page was found.
|
||||
*/
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) {
|
||||
uint16_t ValidPage = PAGE0;
|
||||
uint16_t AddressValue = 0x5555, ReadStatus = 1;
|
||||
uint32_t Address = EEPROM_START_ADDRESS, PageStartAddress = EEPROM_START_ADDRESS;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (ValidPage == NO_VALID_PAGE) return NO_VALID_PAGE;
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
Address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
|
||||
|
||||
/* Check each active page address starting from end */
|
||||
while (Address > (PageStartAddress + 2)) {
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
AddressValue = (*(__IO uint16_t*)Address);
|
||||
|
||||
/* Compare the read address with the virtual address */
|
||||
if (AddressValue == VirtAddress) {
|
||||
/* Get content of Address-2 which is variable value */
|
||||
*Data = (*(__IO uint16_t*)(Address - 2));
|
||||
/* In case variable value is read, reset ReadStatus flag */
|
||||
ReadStatus = 0;
|
||||
break;
|
||||
}
|
||||
else /* Next address location */
|
||||
Address -= 4;
|
||||
}
|
||||
/* Return ReadStatus value: (0: variable exist, 1: variable doesn't exist) */
|
||||
return ReadStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes/upadtes variable data in EEPROM.
|
||||
* @param VirtAddress: Variable virtual address
|
||||
* @param Data: 16 bit data to be written
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data) {
|
||||
/* Write the variable virtual address and value in the EEPROM */
|
||||
uint16_t Status = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
|
||||
/* In case the EEPROM active page is full */
|
||||
if (Status == PAGE_FULL) /* Perform Page transfer */
|
||||
Status = EE_PageTransfer(VirtAddress, Data);
|
||||
|
||||
/* Return last operation status */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE
|
||||
* @param None
|
||||
* @retval Status of the last operation (Flash write or erase) done during
|
||||
* EEPROM formating
|
||||
*/
|
||||
static HAL_StatusTypeDef EE_Format(void) {
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint32_t SectorError = 0;
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
|
||||
pEraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
pEraseInit.Sector = PAGE0_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
/* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
pEraseInit.Sector = PAGE1_ID;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find valid Page for write or read operation
|
||||
* @param Operation: operation to achieve on the valid page.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg READ_FROM_VALID_PAGE: read operation from valid page
|
||||
* @arg WRITE_IN_VALID_PAGE: write operation from valid page
|
||||
* @retval Valid page number (PAGE or PAGE1) or NO_VALID_PAGE in case
|
||||
* of no valid page was found
|
||||
*/
|
||||
static uint16_t EE_FindValidPage(uint8_t Operation) {
|
||||
uint16_t PageStatus0 = 6, PageStatus1 = 6;
|
||||
|
||||
/* Get Page0 actual status */
|
||||
PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
|
||||
/* Get Page1 actual status */
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
/* Write or read operation */
|
||||
switch (Operation) {
|
||||
case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */
|
||||
if (PageStatus1 == VALID_PAGE) {
|
||||
/* Page0 receiving data */
|
||||
if (PageStatus0 == RECEIVE_DATA) return PAGE0; /* Page0 valid */
|
||||
else return PAGE1; /* Page1 valid */
|
||||
}
|
||||
else if (PageStatus0 == VALID_PAGE) {
|
||||
/* Page1 receiving data */
|
||||
if (PageStatus1 == RECEIVE_DATA) return PAGE1; /* Page1 valid */
|
||||
else return PAGE0; /* Page0 valid */
|
||||
}
|
||||
else
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
|
||||
case READ_FROM_VALID_PAGE: /* ---- Read operation ---- */
|
||||
if (PageStatus0 == VALID_PAGE)
|
||||
return PAGE0; /* Page0 valid */
|
||||
else if (PageStatus1 == VALID_PAGE)
|
||||
return PAGE1; /* Page1 valid */
|
||||
else
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
|
||||
default:
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify if active page is full and Writes variable in EEPROM.
|
||||
* @param VirtAddress: 16 bit virtual address of the variable
|
||||
* @param Data: 16 bit data to be written as variable value
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data) {
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint16_t ValidPage = PAGE0;
|
||||
uint32_t Address = EEPROM_START_ADDRESS, PageEndAddress = EEPROM_START_ADDRESS+PAGE_SIZE;
|
||||
|
||||
/* Get valid Page for write operation */
|
||||
ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (ValidPage == NO_VALID_PAGE) return NO_VALID_PAGE;
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((ValidPage + 1) * PAGE_SIZE));
|
||||
|
||||
/* Check each active page address starting from begining */
|
||||
while (Address < PageEndAddress) {
|
||||
/* Verify if Address and Address+2 contents are 0xFFFFFFFF */
|
||||
if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF) {
|
||||
/* Set variable data */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* Set variable virtual address */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address + 2, VirtAddress);
|
||||
/* Return program operation status */
|
||||
return FlashStatus;
|
||||
}
|
||||
else /* Next address location */
|
||||
Address += 4;
|
||||
}
|
||||
|
||||
/* Return PAGE_FULL in case the valid page is full */
|
||||
return PAGE_FULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transfers last updated variables data from the full Page to
|
||||
* an empty one.
|
||||
* @param VirtAddress: 16 bit virtual address of the variable
|
||||
* @param Data: 16 bit data to be written as variable value
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) {
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint32_t NewPageAddress = EEPROM_START_ADDRESS;
|
||||
uint16_t OldPageId=0;
|
||||
uint16_t ValidPage = PAGE0, VarIdx = 0;
|
||||
uint16_t EepromStatus = 0, ReadStatus = 0;
|
||||
uint32_t SectorError = 0;
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
if (ValidPage == PAGE1) { /* Page1 valid */
|
||||
/* New page address where variable will be moved to */
|
||||
NewPageAddress = PAGE0_BASE_ADDRESS;
|
||||
/* Old page ID where variable will be taken from */
|
||||
OldPageId = PAGE1_ID;
|
||||
}
|
||||
else if (ValidPage == PAGE0) { /* Page0 valid */
|
||||
/* New page address where variable will be moved to */
|
||||
NewPageAddress = PAGE1_BASE_ADDRESS;
|
||||
/* Old page ID where variable will be taken from */
|
||||
OldPageId = PAGE0_ID;
|
||||
}
|
||||
else
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
|
||||
/* Set the new Page status to RECEIVE_DATA status */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, RECEIVE_DATA);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
/* Write the variable passed as parameter in the new active page */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
|
||||
/* Transfer process: transfer variables from old to the new active page */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
if (VirtAddVarTab[VarIdx] != VirtAddress) { /* Check each variable except the one passed as parameter */
|
||||
/* Read the other last variable updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1) {
|
||||
/* Transfer the variable to the new active page */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pEraseInit.TypeErase = TYPEERASE_SECTORS;
|
||||
pEraseInit.Sector = OldPageId;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
|
||||
/* Erase the old Page: Set old Page status to ERASED status */
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
/* Set new Page status to VALID_PAGE status */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
/* Return last operation flash status */
|
||||
return FlashStatus;
|
||||
}
|
||||
|
||||
#endif // STM32F4 || STM32F4xx
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
@@ -1,142 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4))
|
||||
|
||||
/**
|
||||
* Description: functions for I2C connected external EEPROM.
|
||||
* Not platform dependent.
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include "EEPROM_Emul/eeprom_emul.h"
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
static bool eeprom_initialized = false;
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
|
||||
// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F4
|
||||
// #define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// EEPROM
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
void eeprom_init() {
|
||||
if (!eeprom_initialized) {
|
||||
HAL_FLASH_Unlock();
|
||||
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
/* EEPROM Init */
|
||||
if (EE_Initialize() != EE_OK)
|
||||
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
eeprom_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write_byte(uint8_t *pos, unsigned char value) {
|
||||
uint16_t eeprom_address = (unsigned) pos;
|
||||
|
||||
eeprom_init();
|
||||
|
||||
HAL_FLASH_Unlock();
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
if (EE_WriteVariable(eeprom_address, (uint16_t) value) != EE_OK)
|
||||
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
}
|
||||
|
||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
uint16_t data = 0xFF;
|
||||
uint16_t eeprom_address = (unsigned)pos;
|
||||
|
||||
eeprom_init();
|
||||
|
||||
if (EE_ReadVariable(eeprom_address, &data) != EE_OK) {
|
||||
return (unsigned char)data;
|
||||
}
|
||||
return (unsigned char)data;
|
||||
}
|
||||
|
||||
void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
|
||||
uint16_t data = 0xFF;
|
||||
uint16_t eeprom_address = (unsigned) __src;
|
||||
|
||||
eeprom_init();
|
||||
|
||||
for (uint8_t c = 0; c < __n; c++) {
|
||||
EE_ReadVariable(eeprom_address+c, &data);
|
||||
*((uint8_t*)__dst + c) = data;
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
|
||||
|
||||
}
|
||||
|
||||
#endif // EEPROM_SETTINGS && (!I2C_EEPROM && !SPI_EEPROM)
|
||||
#endif // STM32GENERIC && STM32F4
|
||||
@@ -1,133 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
*
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && defined(STM32F4)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
//#include <Wire.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/* VGPV Done with defines
|
||||
// disable interrupts
|
||||
void cli(void) { noInterrupts(); }
|
||||
|
||||
// enable interrupts
|
||||
void sei(void) { interrupts(); }
|
||||
*/
|
||||
|
||||
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
|
||||
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
}
|
||||
|
||||
// return free memory between end of heap (or end bss) and whatever is current
|
||||
|
||||
/*
|
||||
#include "wirish/syscalls.c"
|
||||
//extern caddr_t _sbrk(int incr);
|
||||
#ifndef CONFIG_HEAP_END
|
||||
extern char _lm_heap_end;
|
||||
#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
static int freeMemory() {
|
||||
char top = 't';
|
||||
return &top - reinterpret_cast<char*>(sbrk(0));
|
||||
}
|
||||
int freeMemory() {
|
||||
int free_memory;
|
||||
int heap_end = (int)_sbrk(0);
|
||||
free_memory = ((int)&free_memory) - ((int)heap_end);
|
||||
return free_memory;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
HAL_adc_result = analogRead(adc_pin);
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result(void) {
|
||||
return HAL_adc_result;
|
||||
}
|
||||
|
||||
#endif // // STM32GENERIC && STM32F4
|
||||
@@ -1,236 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
*
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
#ifndef vsnprintf_P
|
||||
#define vsnprintf_P vsnprintf
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include "fastio_STM32F4.h"
|
||||
#include "watchdog_STM32F4.h"
|
||||
#include "HAL_timers_STM32F4.h"
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef USBCON
|
||||
#include <USBSerial.h>
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//Serial override
|
||||
//extern HalSerial usb_serial;
|
||||
|
||||
#if SERIAL_PORT == 0
|
||||
#error "Serial port 0 does not exist"
|
||||
#endif
|
||||
|
||||
#if !WITHIN(SERIAL_PORT, -1, 6)
|
||||
#error "SERIAL_PORT must be from -1 to 6"
|
||||
#endif
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL0 SerialUSB
|
||||
#elif SERIAL_PORT == 1
|
||||
#define MYSERIAL0 SerialUART1
|
||||
#elif SERIAL_PORT == 2
|
||||
#define MYSERIAL0 SerialUART2
|
||||
#elif SERIAL_PORT == 3
|
||||
#define MYSERIAL0 SerialUART3
|
||||
#elif SERIAL_PORT == 4
|
||||
#define MYSERIAL0 SerialUART4
|
||||
#elif SERIAL_PORT == 5
|
||||
#define MYSERIAL0 SerialUART5
|
||||
#elif SERIAL_PORT == 6
|
||||
#define MYSERIAL0 SerialUART6
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == 0
|
||||
#error "Serial port 0 does not exist"
|
||||
#endif
|
||||
|
||||
#if !WITHIN(SERIAL_PORT_2, -1, 6)
|
||||
#error "SERIAL_PORT_2 must be from -1 to 6"
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL1 SerialUSB
|
||||
#elif SERIAL_PORT_2 == 1
|
||||
#define MYSERIAL1 SerialUART1
|
||||
#elif SERIAL_PORT_2 == 2
|
||||
#define MYSERIAL1 SerialUART2
|
||||
#elif SERIAL_PORT_2 == 3
|
||||
#define MYSERIAL1 SerialUART3
|
||||
#elif SERIAL_PORT_2 == 4
|
||||
#define MYSERIAL1 SerialUART4
|
||||
#elif SERIAL_PORT_2 == 5
|
||||
#define MYSERIAL1 SerialUART5
|
||||
#elif SERIAL_PORT_2 == 6
|
||||
#define MYSERIAL1 SerialUART6
|
||||
#endif
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
|
||||
#undef _BV
|
||||
#define _BV(b) (1 << (b))
|
||||
|
||||
/**
|
||||
* TODO: review this to return 1 for pins that are not analog input
|
||||
*/
|
||||
#ifndef analogInputToDigitalPin
|
||||
#define analogInputToDigitalPin(p) (p)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
#define cli() __disable_irq()
|
||||
#define sei() __enable_irq()
|
||||
|
||||
// On AVR this is in math.h?
|
||||
#define square(x) ((x)*(x))
|
||||
|
||||
#ifndef strncpy_P
|
||||
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
||||
#endif
|
||||
|
||||
// Fix bug in pgm_read_ptr
|
||||
#undef pgm_read_ptr
|
||||
#define pgm_read_ptr(addr) (*(addr))
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/** result of last ADC conversion */
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
inline void HAL_init(void) { }
|
||||
|
||||
/** clear reset reason */
|
||||
void HAL_clear_reset_source (void);
|
||||
|
||||
/** reset reason */
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
/*
|
||||
extern "C" {
|
||||
int freeMemory(void);
|
||||
}
|
||||
*/
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
|
||||
/*
|
||||
static int freeMemory() {
|
||||
volatile int top;
|
||||
top = (int)((char*)&top - reinterpret_cast<char*>(_sbrk(0)));
|
||||
return top;
|
||||
}
|
||||
*/
|
||||
|
||||
static int freeMemory() {
|
||||
volatile char top;
|
||||
return &top - reinterpret_cast<char*>(_sbrk(0));
|
||||
}
|
||||
|
||||
//
|
||||
// SPI: Extended functions which take a channel number (hardware SPI only)
|
||||
//
|
||||
|
||||
/** Write single byte to specified SPI channel */
|
||||
void spiSend(uint32_t chan, byte b);
|
||||
/** Write buffer to specified SPI channel */
|
||||
void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
|
||||
/** Read single byte from specified SPI channel */
|
||||
uint8_t spiRec(uint32_t chan);
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
|
||||
/**
|
||||
* TODO: Write all this EEPROM stuff. Can emulate EEPROM in flash as last resort.
|
||||
* Wire library should work for i2c EEPROMs.
|
||||
*/
|
||||
void eeprom_write_byte(uint8_t *pos, unsigned char value);
|
||||
uint8_t eeprom_read_byte(uint8_t *pos);
|
||||
void eeprom_read_block (void *__dst, const void *__src, size_t __n);
|
||||
void eeprom_update_block (const void *__src, void *__dst, size_t __n);
|
||||
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
|
||||
|
||||
inline void HAL_adc_init(void) {}
|
||||
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result(void);
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY)
|
||||
#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE)
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && defined(STM32F4)
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SERVOS
|
||||
|
||||
#include "HAL_Servo_STM32F4.h"
|
||||
|
||||
int8_t libServo::attach(const int pin) {
|
||||
return Servo::attach(pin);
|
||||
}
|
||||
|
||||
int8_t libServo::attach(const int pin, const int min, const int max) {
|
||||
return Servo::attach(pin, min, max);
|
||||
}
|
||||
|
||||
void libServo::move(const int value) {
|
||||
constexpr uint16_t servo_delay[] = SERVO_DELAY;
|
||||
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
||||
if (this->attach(0) >= 0) {
|
||||
this->write(value);
|
||||
safe_delay(servo_delay[this->servoIndex]);
|
||||
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
|
||||
this->detach();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // HAS_SERVOS
|
||||
|
||||
#endif // STM32GENERIC && STM32F4
|
||||
@@ -1,153 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Fast I/O interfaces for STM32F4
|
||||
* These use GPIO functions instead of Direct Port Manipulation, as on AVR.
|
||||
*/
|
||||
|
||||
#undef _BV
|
||||
#define _BV(b) (1 << (b))
|
||||
|
||||
#define READ(IO) digitalRead(IO)
|
||||
#define WRITE(IO,V) digitalWrite(IO,V)
|
||||
|
||||
#define _GET_MODE(IO)
|
||||
#define _SET_MODE(IO,M) pinMode(IO, M)
|
||||
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) /*!< Output Push Pull Mode & GPIO_NOPULL */
|
||||
|
||||
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
#define SET_INPUT(IO) _SET_MODE(IO, INPUT) /*!< Input Floating Mode */
|
||||
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) /*!< Input with Pull-up activation */
|
||||
#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) /*!< Input with Pull-down activation */
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||
#define SET_PWM(IO) pinMode(IO, PWM)
|
||||
|
||||
#define TOGGLE(IO) OUT_WRITE(IO, !READ(IO))
|
||||
|
||||
#define IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO)
|
||||
|
||||
#define PWM_PIN(P) true
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
#define extDigitalRead(IO) digitalRead(IO)
|
||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||
|
||||
//
|
||||
// Pins Definitions
|
||||
//
|
||||
#define PORTA 0
|
||||
#define PORTB 1
|
||||
#define PORTC 2
|
||||
#define PORTD 3
|
||||
#define PORTE 4
|
||||
|
||||
#define _STM32_PIN(P,PN) ((PORT##P * 16) + PN)
|
||||
|
||||
#define PA0 _STM32_PIN(A, 0)
|
||||
#define PA1 _STM32_PIN(A, 1)
|
||||
#define PA2 _STM32_PIN(A, 2)
|
||||
#define PA3 _STM32_PIN(A, 3)
|
||||
#define PA4 _STM32_PIN(A, 4)
|
||||
#define PA5 _STM32_PIN(A, 5)
|
||||
#define PA6 _STM32_PIN(A, 6)
|
||||
#define PA7 _STM32_PIN(A, 7)
|
||||
#define PA8 _STM32_PIN(A, 8)
|
||||
#define PA9 _STM32_PIN(A, 9)
|
||||
#define PA10 _STM32_PIN(A, 10)
|
||||
#define PA11 _STM32_PIN(A, 11)
|
||||
#define PA12 _STM32_PIN(A, 12)
|
||||
#define PA13 _STM32_PIN(A, 13)
|
||||
#define PA14 _STM32_PIN(A, 14)
|
||||
#define PA15 _STM32_PIN(A, 15)
|
||||
|
||||
#define PB0 _STM32_PIN(B, 0)
|
||||
#define PB1 _STM32_PIN(B, 1)
|
||||
#define PB2 _STM32_PIN(B, 2)
|
||||
#define PB3 _STM32_PIN(B, 3)
|
||||
#define PB4 _STM32_PIN(B, 4)
|
||||
#define PB5 _STM32_PIN(B, 5)
|
||||
#define PB6 _STM32_PIN(B, 6)
|
||||
#define PB7 _STM32_PIN(B, 7)
|
||||
#define PB8 _STM32_PIN(B, 8)
|
||||
#define PB9 _STM32_PIN(B, 9)
|
||||
#define PB10 _STM32_PIN(B, 10)
|
||||
#define PB11 _STM32_PIN(B, 11)
|
||||
#define PB12 _STM32_PIN(B, 12)
|
||||
#define PB13 _STM32_PIN(B, 13)
|
||||
#define PB14 _STM32_PIN(B, 14)
|
||||
#define PB15 _STM32_PIN(B, 15)
|
||||
|
||||
#define PC0 _STM32_PIN(C, 0)
|
||||
#define PC1 _STM32_PIN(C, 1)
|
||||
#define PC2 _STM32_PIN(C, 2)
|
||||
#define PC3 _STM32_PIN(C, 3)
|
||||
#define PC4 _STM32_PIN(C, 4)
|
||||
#define PC5 _STM32_PIN(C, 5)
|
||||
#define PC6 _STM32_PIN(C, 6)
|
||||
#define PC7 _STM32_PIN(C, 7)
|
||||
#define PC8 _STM32_PIN(C, 8)
|
||||
#define PC9 _STM32_PIN(C, 9)
|
||||
#define PC10 _STM32_PIN(C, 10)
|
||||
#define PC11 _STM32_PIN(C, 11)
|
||||
#define PC12 _STM32_PIN(C, 12)
|
||||
#define PC13 _STM32_PIN(C, 13)
|
||||
#define PC14 _STM32_PIN(C, 14)
|
||||
#define PC15 _STM32_PIN(C, 15)
|
||||
|
||||
#define PD0 _STM32_PIN(D, 0)
|
||||
#define PD1 _STM32_PIN(D, 1)
|
||||
#define PD2 _STM32_PIN(D, 2)
|
||||
#define PD3 _STM32_PIN(D, 3)
|
||||
#define PD4 _STM32_PIN(D, 4)
|
||||
#define PD5 _STM32_PIN(D, 5)
|
||||
#define PD6 _STM32_PIN(D, 6)
|
||||
#define PD7 _STM32_PIN(D, 7)
|
||||
#define PD8 _STM32_PIN(D, 8)
|
||||
#define PD9 _STM32_PIN(D, 9)
|
||||
#define PD10 _STM32_PIN(D, 10)
|
||||
#define PD11 _STM32_PIN(D, 11)
|
||||
#define PD12 _STM32_PIN(D, 12)
|
||||
#define PD13 _STM32_PIN(D, 13)
|
||||
#define PD14 _STM32_PIN(D, 14)
|
||||
#define PD15 _STM32_PIN(D, 15)
|
||||
|
||||
#define PE0 _STM32_PIN(E, 0)
|
||||
#define PE1 _STM32_PIN(E, 1)
|
||||
#define PE2 _STM32_PIN(E, 2)
|
||||
#define PE3 _STM32_PIN(E, 3)
|
||||
#define PE4 _STM32_PIN(E, 4)
|
||||
#define PE5 _STM32_PIN(E, 5)
|
||||
#define PE6 _STM32_PIN(E, 6)
|
||||
#define PE7 _STM32_PIN(E, 7)
|
||||
#define PE8 _STM32_PIN(E, 8)
|
||||
#define PE9 _STM32_PIN(E, 9)
|
||||
#define PE10 _STM32_PIN(E, 10)
|
||||
#define PE11 _STM32_PIN(E, 11)
|
||||
#define PE12 _STM32_PIN(E, 12)
|
||||
#define PE13 _STM32_PIN(E, 13)
|
||||
#define PE14 _STM32_PIN(E, 14)
|
||||
#define PE15 _STM32_PIN(E, 15)
|
||||
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
*
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||
* Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && defined(STM32F4)
|
||||
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
|
||||
bool PersistentStore::access_start() { return true; }
|
||||
bool PersistentStore::access_finish() { return true; }
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
while (size--) {
|
||||
uint8_t * const p = (uint8_t * const)pos;
|
||||
uint8_t v = *value;
|
||||
// EEPROM has only ~100,000 write cycles,
|
||||
// so only write bytes that have changed!
|
||||
if (v != eeprom_read_byte(p)) {
|
||||
eeprom_write_byte(p, v);
|
||||
if (eeprom_read_byte(p) != v) {
|
||||
SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
crc16(crc, &v, 1);
|
||||
pos++;
|
||||
value++;
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing) {
|
||||
do {
|
||||
uint8_t c = eeprom_read_byte((uint8_t*)pos);
|
||||
if (writing) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
} while (--size);
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t PersistentStore::capacity() { return E2END + 1; }
|
||||
|
||||
#endif // EEPROM_SETTINGS
|
||||
#endif // STM32GENERIC && STM32F4
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef NUM_DIGITAL_PINS // Only in ST's Arduino core (STM32duino, STM32Core)
|
||||
#include "../HAL_STM32/pinsDebug_STM32duino.h"
|
||||
#elif defined(BOARD_NR_GPIO_PINS) // Only in STM32GENERIC (Maple)
|
||||
#include "../HAL_STM32/pinsDebug_STM32GENERIC.h"
|
||||
#else
|
||||
#error "M43 not supported for this board"
|
||||
#endif
|
||||
@@ -1,111 +0,0 @@
|
||||
/******************************************************************************
|
||||
* @file eeprom_emul.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.2.6
|
||||
* @date 04-November-2016
|
||||
* @brief This file contains all the functions prototypes for the EEPROM
|
||||
* emulation firmware library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../HAL.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* EEPROM emulation firmware error codes */
|
||||
#define EE_OK (uint32_t)HAL_OK
|
||||
#define EE_ERROR (uint32_t)HAL_ERROR
|
||||
#define EE_BUSY (uint32_t)HAL_BUSY
|
||||
#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
|
||||
|
||||
/* Define the size of the sectors to be used */
|
||||
#define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */
|
||||
|
||||
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
|
||||
be done by word */
|
||||
#define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3
|
||||
|
||||
/* EEPROM start address in Flash */
|
||||
#define EEPROM_START_ADDRESS ((uint32_t)0x08100000) /* EEPROM emulation start address:
|
||||
from sector2 : after 16KByte of used
|
||||
Flash memory */
|
||||
|
||||
/* Pages 0 and 1 base and end addresses */
|
||||
#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
|
||||
#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
|
||||
#define PAGE0_ID FLASH_SECTOR_1
|
||||
|
||||
#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
|
||||
#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
|
||||
#define PAGE1_ID FLASH_SECTOR_2
|
||||
|
||||
/* Used Flash pages for EEPROM emulation */
|
||||
#define PAGE0 ((uint16_t)0x0000)
|
||||
#define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
|
||||
|
||||
/* No valid page define */
|
||||
#define NO_VALID_PAGE ((uint16_t)0x00AB)
|
||||
|
||||
/* Page status definitions */
|
||||
#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
|
||||
#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
|
||||
#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
|
||||
|
||||
/* Valid pages in read and write defines */
|
||||
#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
|
||||
#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
|
||||
|
||||
/* Page full define */
|
||||
#define PAGE_FULL ((uint8_t)0x80)
|
||||
|
||||
/* Variables' number */
|
||||
#define NB_OF_VAR ((uint16_t)4096)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
uint16_t EE_Initialize(void);
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
|
||||
uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -1,139 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
|
||||
/**
|
||||
* Description: functions for I2C connected external EEPROM.
|
||||
* Not platform dependent.
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include "EEPROM_Emul/eeprom_emul.h"
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
static bool eeprom_initialized = false;
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
|
||||
// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F7
|
||||
#define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// EEPROM
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
void eeprom_init() {
|
||||
if (!eeprom_initialized) {
|
||||
HAL_FLASH_Unlock();
|
||||
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
/* EEPROM Init */
|
||||
if (EE_Initialize() != EE_OK)
|
||||
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
eeprom_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write_byte(uint8_t *pos, unsigned char value) {
|
||||
uint16_t eeprom_address = (unsigned) pos;
|
||||
|
||||
eeprom_init();
|
||||
|
||||
HAL_FLASH_Unlock();
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
if (EE_WriteVariable(eeprom_address, (uint16_t) value) != EE_OK)
|
||||
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
}
|
||||
|
||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
uint16_t data = 0xFF;
|
||||
uint16_t eeprom_address = (unsigned)pos;
|
||||
|
||||
eeprom_init();
|
||||
|
||||
if (EE_ReadVariable(eeprom_address, &data) != EE_OK) {
|
||||
return (unsigned char)data;
|
||||
}
|
||||
return (unsigned char)data;
|
||||
}
|
||||
|
||||
void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
|
||||
uint16_t data = 0xFF;
|
||||
uint16_t eeprom_address = (unsigned) __src;
|
||||
|
||||
eeprom_init();
|
||||
|
||||
for (uint8_t c = 0; c < __n; c++) {
|
||||
EE_ReadVariable(eeprom_address+c, &data);
|
||||
*((uint8_t*)__dst + c) = data;
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
|
||||
|
||||
}
|
||||
|
||||
#endif // STM32F7
|
||||
@@ -1,139 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
*
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
//#include <Wire.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/* VGPV Done with defines
|
||||
// disable interrupts
|
||||
void cli(void) { noInterrupts(); }
|
||||
|
||||
// enable interrupts
|
||||
void sei(void) { interrupts(); }
|
||||
*/
|
||||
|
||||
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET)
|
||||
return RST_WATCHDOG;
|
||||
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET)
|
||||
return RST_SOFTWARE;
|
||||
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
|
||||
return RST_EXTERNAL;
|
||||
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
|
||||
return RST_POWER_ON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
}
|
||||
|
||||
// return free memory between end of heap (or end bss) and whatever is current
|
||||
|
||||
/*
|
||||
#include "wirish/syscalls.c"
|
||||
//extern caddr_t _sbrk(int incr);
|
||||
#ifndef CONFIG_HEAP_END
|
||||
extern char _lm_heap_end;
|
||||
#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
static int freeMemory() {
|
||||
char top = 't';
|
||||
return &top - reinterpret_cast<char*>(sbrk(0));
|
||||
}
|
||||
int freeMemory() {
|
||||
int free_memory;
|
||||
int heap_end = (int)_sbrk(0);
|
||||
free_memory = ((int)&free_memory) - ((int)heap_end);
|
||||
return free_memory;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
HAL_adc_result = analogRead(adc_pin);
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result(void) {
|
||||
return HAL_adc_result;
|
||||
}
|
||||
|
||||
#endif // STM32F7
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <../../libraries/Servo/src/Servo.h>
|
||||
|
||||
// Inherit and expand on the official library
|
||||
class libServo : public Servo {
|
||||
public:
|
||||
int8_t attach(const int pin);
|
||||
int8_t attach(const int pin, const int min, const int max);
|
||||
void move(const int value);
|
||||
private:
|
||||
uint16_t min_ticks;
|
||||
uint16_t max_ticks;
|
||||
uint8_t servoIndex; // index into the channel data for this servo
|
||||
};
|
||||
@@ -1,164 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Software SPI functions originally from Arduino Sd2Card Library
|
||||
* Copyright (c) 2009 by William Greiman
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adapted to the STM32F7 HAL
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include <pins_arduino.h>
|
||||
#include "spi_pins.h"
|
||||
#include "../../core/macros.h"
|
||||
#include <SPI.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#if ENABLED(SOFTWARE_SPI)
|
||||
// --------------------------------------------------------------------------
|
||||
// Software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
#error "Software SPI not supported for STM32F7. Use hardware SPI."
|
||||
|
||||
#else
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* VGPV SPI speed start and F_CPU/2, by default 72/2 = 36Mhz
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Begin SPI port setup
|
||||
*
|
||||
* @return Nothing
|
||||
*
|
||||
* @details Only configures SS pin since libmaple creates and initialize the SPI object
|
||||
*/
|
||||
void spiBegin(void) {
|
||||
#if !PIN_EXISTS(SS)
|
||||
#error SS_PIN not defined!
|
||||
#endif
|
||||
|
||||
OUT_WRITE(SS_PIN, HIGH);
|
||||
}
|
||||
|
||||
/** Configure SPI for specified SPI speed */
|
||||
void spiInit(uint8_t spiRate) {
|
||||
// Use datarates Marlin uses
|
||||
uint32_t clock;
|
||||
switch (spiRate) {
|
||||
case SPI_FULL_SPEED: clock = 20000000; break; // 13.9mhz=20000000 6.75mhz=10000000 3.38mhz=5000000 .833mhz=1000000
|
||||
case SPI_HALF_SPEED: clock = 5000000; break;
|
||||
case SPI_QUARTER_SPEED: clock = 2500000; break;
|
||||
case SPI_EIGHTH_SPEED: clock = 1250000; break;
|
||||
case SPI_SPEED_5: clock = 625000; break;
|
||||
case SPI_SPEED_6: clock = 300000; break;
|
||||
default:
|
||||
clock = 4000000; // Default from the SPI libarary
|
||||
}
|
||||
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
|
||||
SPI.begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receives a single byte from the SPI port.
|
||||
*
|
||||
* @return Byte received
|
||||
*
|
||||
* @details
|
||||
*/
|
||||
uint8_t spiRec(void) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
uint8_t returnByte = SPI.transfer(0xFF);
|
||||
SPI.endTransaction();
|
||||
return returnByte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receives a number of bytes from the SPI port to a buffer
|
||||
*
|
||||
* @param buf Pointer to starting address of buffer to write to.
|
||||
* @param nbyte Number of bytes to receive.
|
||||
* @return Nothing
|
||||
*
|
||||
* @details Uses DMA
|
||||
*/
|
||||
void spiRead(uint8_t* buf, uint16_t nbyte) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.dmaTransfer(0, const_cast<uint8_t*>(buf), nbyte);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sends a single byte on SPI port
|
||||
*
|
||||
* @param b Byte to send
|
||||
*
|
||||
* @details
|
||||
*/
|
||||
void spiSend(uint8_t b) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(b);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write token and then write from 512 byte buffer to SPI (for SD card)
|
||||
*
|
||||
* @param buf Pointer with buffer start address
|
||||
* @return Nothing
|
||||
*
|
||||
* @details Use DMA
|
||||
*/
|
||||
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(token);
|
||||
SPI.dmaSend(const_cast<uint8_t*>(buf), 512);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
#endif // SOFTWARE_SPI
|
||||
|
||||
#endif // STM32F7
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Test STM32F7-specific configuration values for errors at compile-time.
|
||||
*/
|
||||
//#if ENABLED(SPINDLE_LASER_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
|
||||
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
|
||||
//#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F7. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../module/endstops.h"
|
||||
|
||||
// One ISR for all EXT-Interrupts
|
||||
void endstop_ISR(void) { endstops.update(); }
|
||||
|
||||
void setup_endstop_interrupts(void) {
|
||||
#if HAS_X_MAX
|
||||
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_X_MIN
|
||||
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z3_MAX
|
||||
attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z3_MIN
|
||||
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Define SPI Pins: SCK, MISO, MOSI, SS
|
||||
*/
|
||||
#define SCK_PIN PA5
|
||||
#define MISO_PIN PA6
|
||||
#define MOSI_PIN PA7
|
||||
#define SS_PIN PA8
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
|
||||
#include "watchdog_STM32F7.h"
|
||||
|
||||
IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
void watchdog_init() {
|
||||
hiwdg.Instance = IWDG;
|
||||
hiwdg.Init.Prescaler = IWDG_PRESCALER_32; //32kHz LSI clock and 32x prescalar = 1024Hz IWDG clock
|
||||
hiwdg.Init.Reload = 4095; //4095 counts = 4 seconds at 1024Hz
|
||||
if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
|
||||
//Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void watchdog_reset() {
|
||||
/* Refresh IWDG: reload counter */
|
||||
if (HAL_IWDG_Refresh(&hiwdg) != HAL_OK) {
|
||||
/* Refresh Error */
|
||||
//Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_WATCHDOG
|
||||
|
||||
#endif // STM32F7
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
/**
|
||||
* Description: Functions for a Flash emulated EEPROM
|
||||
* Not platform dependent.
|
||||
*/
|
||||
|
||||
// Include configs and pins to get all EEPROM flags
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#ifdef STM32F7
|
||||
#define HAS_EMULATED_EEPROM 1
|
||||
#else
|
||||
#define HAS_EMULATED_EEPROM NONE(I2C_EEPROM, SPI_EEPROM)
|
||||
#endif
|
||||
|
||||
#if HAS_EMULATED_EEPROM && ENABLED(EEPROM_SETTINGS)
|
||||
|
||||
// ------------------------
|
||||
// Includes
|
||||
// ------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#include "eeprom_emul.h"
|
||||
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// ------------------------
|
||||
|
||||
// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
|
||||
// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F4/7
|
||||
|
||||
#ifdef STM32F7
|
||||
#define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
|
||||
#else
|
||||
//#define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// ------------------------
|
||||
|
||||
static bool eeprom_initialized = false;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
void eeprom_init() {
|
||||
if (!eeprom_initialized) {
|
||||
HAL_FLASH_Unlock();
|
||||
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
/* EEPROM Init */
|
||||
if (EE_Initialize() != EE_OK)
|
||||
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
eeprom_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write_byte(uint8_t *pos, unsigned char value) {
|
||||
eeprom_init();
|
||||
|
||||
HAL_FLASH_Unlock();
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
uint16_t eeprom_address = unsigned(pos);
|
||||
if (EE_WriteVariable(eeprom_address, uint16_t(value)) != EE_OK)
|
||||
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
}
|
||||
|
||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
eeprom_init();
|
||||
|
||||
uint16_t data = 0xFF;
|
||||
uint16_t eeprom_address = unsigned(pos);
|
||||
(void)EE_ReadVariable(eeprom_address, &data); // Data unchanged on error
|
||||
|
||||
return uint8_t(data);
|
||||
}
|
||||
|
||||
void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
|
||||
eeprom_init();
|
||||
|
||||
uint16_t data = 0xFF;
|
||||
uint16_t eeprom_address = unsigned(__src);
|
||||
for (uint8_t c = 0; c < __n; c++) {
|
||||
EE_ReadVariable(eeprom_address+c, &data);
|
||||
*((uint8_t*)__dst + c) = data;
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
|
||||
|
||||
}
|
||||
|
||||
#endif // EEPROM_SETTINGS
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
*
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
//#include <Wire.h>
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
/* VGPV Done with defines
|
||||
// disable interrupts
|
||||
void cli(void) { noInterrupts(); }
|
||||
|
||||
// enable interrupts
|
||||
void sei(void) { interrupts(); }
|
||||
*/
|
||||
|
||||
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
}
|
||||
|
||||
// return free memory between end of heap (or end bss) and whatever is current
|
||||
|
||||
/*
|
||||
#include "wirish/syscalls.c"
|
||||
//extern caddr_t _sbrk(int incr);
|
||||
#ifndef CONFIG_HEAP_END
|
||||
extern char _lm_heap_end;
|
||||
#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
static int freeMemory() {
|
||||
char top = 't';
|
||||
return &top - reinterpret_cast<char*>(sbrk(0));
|
||||
}
|
||||
int freeMemory() {
|
||||
int free_memory;
|
||||
int heap_end = (int)_sbrk(0);
|
||||
free_memory = ((int)&free_memory) - ((int)heap_end);
|
||||
return free_memory;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
|
||||
|
||||
uint16_t HAL_adc_get_result(void) { return HAL_adc_result; }
|
||||
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
@@ -24,34 +24,34 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
#ifndef vsnprintf_P
|
||||
#define vsnprintf_P vsnprintf
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
|
||||
#include "fastio_STM32F7.h"
|
||||
#include "watchdog_STM32F7.h"
|
||||
#include "fastio_STM32_F4_F7.h"
|
||||
#include "watchdog_STM32_F4_F7.h"
|
||||
|
||||
#include "HAL_timers_STM32F7.h"
|
||||
#include "HAL_timers_STM32_F4_F7.h"
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef defined(STM32F4) && USBCON
|
||||
#include <USBSerial.h>
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//Serial override
|
||||
//extern HalSerial usb_serial;
|
||||
|
||||
#if defined(STM32F4) && SERIAL_PORT == 0
|
||||
#error "Serial port 0 does not exist"
|
||||
#endif
|
||||
|
||||
#if !WITHIN(SERIAL_PORT, -1, 6)
|
||||
#error "SERIAL_PORT must be from -1 to 6"
|
||||
#endif
|
||||
@@ -72,6 +72,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if defined(STM32F4) && SERIAL_PORT_2 == 0
|
||||
#error "Serial port 0 does not exist"
|
||||
#endif
|
||||
#if !WITHIN(SERIAL_PORT_2, -1, 6)
|
||||
#error "SERIAL_PORT_2 must be from -1 to 6"
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
@@ -125,22 +128,26 @@
|
||||
#undef pgm_read_ptr
|
||||
#define pgm_read_ptr(addr) (*(addr))
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
#ifdef STM32F4
|
||||
#define HAL_SERVO_LIB libServo
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/** result of last ADC conversion */
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
@@ -162,6 +169,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
|
||||
/*
|
||||
static int freeMemory() {
|
||||
volatile int top;
|
||||
@@ -169,12 +177,16 @@ static int freeMemory() {
|
||||
return top;
|
||||
}
|
||||
*/
|
||||
|
||||
static int freeMemory() {
|
||||
volatile char top;
|
||||
return &top - reinterpret_cast<char*>(_sbrk(0));
|
||||
}
|
||||
|
||||
//
|
||||
// SPI: Extended functions which take a channel number (hardware SPI only)
|
||||
//
|
||||
|
||||
/** Write single byte to specified SPI channel */
|
||||
void spiSend(uint32_t chan, byte b);
|
||||
/** Write buffer to specified SPI channel */
|
||||
@@ -182,19 +194,22 @@ void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
|
||||
/** Read single byte from specified SPI channel */
|
||||
uint8_t spiRec(uint32_t chan);
|
||||
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
|
||||
/**
|
||||
* TODO: Write all this eeprom stuff. Can emulate eeprom in flash as last resort.
|
||||
* Wire library should work for i2c eeproms.
|
||||
* TODO: Write all this EEPROM stuff. Can emulate EEPROM in flash as last resort.
|
||||
* Wire library should work for i2c EEPROMs.
|
||||
*/
|
||||
void eeprom_write_byte(uint8_t *pos, unsigned char value);
|
||||
uint8_t eeprom_read_byte(uint8_t *pos);
|
||||
void eeprom_read_block (void *__dst, const void *__src, size_t __n);
|
||||
void eeprom_update_block (const void *__src, void *__dst, size_t __n);
|
||||
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
|
||||
|
||||
@@ -210,3 +225,8 @@ uint16_t HAL_adc_get_result(void);
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
#ifdef STM32F4
|
||||
#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY)
|
||||
#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE)
|
||||
#endif
|
||||
+4
-4
@@ -21,13 +21,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SERVOS
|
||||
|
||||
#include "HAL_Servo_STM32F7.h"
|
||||
#include "HAL_Servo_STM32_F4_F7.h"
|
||||
|
||||
int8_t libServo::attach(const int pin) {
|
||||
if (this->servoIndex >= MAX_SERVOS) return -1;
|
||||
@@ -49,6 +49,6 @@ void libServo::move(const int value) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // HAS_SERVOS
|
||||
|
||||
#endif // STM32F7
|
||||
#endif // HAS_SERVOS
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
+6
-3
@@ -22,7 +22,11 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Servo.h>
|
||||
//#ifdef STM32F7
|
||||
// #include <../../libraries/Servo/src/Servo.h>
|
||||
//#else
|
||||
#include <Servo.h>
|
||||
//#endif
|
||||
|
||||
// Inherit and expand on the official library
|
||||
class libServo : public Servo {
|
||||
@@ -31,7 +35,6 @@ class libServo : public Servo {
|
||||
int8_t attach(const int pin, const int min, const int max);
|
||||
void move(const int value);
|
||||
private:
|
||||
uint16_t min_ticks;
|
||||
uint16_t max_ticks;
|
||||
uint16_t min_ticks, max_ticks;
|
||||
uint8_t servoIndex; // index into the channel data for this servo
|
||||
};
|
||||
+12
-23
@@ -27,14 +27,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adapted to the STM32F4 HAL
|
||||
* Adapted to the Marlin STM32F4/7 HAL
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && defined(STM32F4)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
#include "HAL.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
@@ -43,28 +39,26 @@
|
||||
#include "../../core/macros.h"
|
||||
#include <SPI.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#if ENABLED(SOFTWARE_SPI)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
#error "Software SPI not supported for STM32F4. Use hardware SPI."
|
||||
|
||||
// ------------------------
|
||||
#error "Software SPI not supported for STM32F4/7. Use Hardware SPI."
|
||||
#else
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* VGPV SPI speed start and F_CPU/2, by default 72/2 = 36Mhz
|
||||
@@ -127,13 +121,11 @@ uint8_t spiRec(void) {
|
||||
*/
|
||||
void spiRead(uint8_t* buf, uint16_t nbyte) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
|
||||
#ifdef STM32GENERIC
|
||||
SPI.dmaTransfer(0, const_cast<uint8_t*>(buf), nbyte);
|
||||
#else
|
||||
SPI.transfer((uint8_t*)buf, nbyte);
|
||||
#endif
|
||||
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
@@ -161,16 +153,13 @@ void spiSend(uint8_t b) {
|
||||
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(token);
|
||||
|
||||
#ifdef STM32GENERIC
|
||||
SPI.dmaSend(const_cast<uint8_t*>(buf), 512);
|
||||
#else
|
||||
SPI.transfer((uint8_t*)buf, nullptr, 512);
|
||||
#endif
|
||||
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
#endif // SOFTWARE_SPI
|
||||
|
||||
#endif // STM32GENERIC && STM32F4
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
+8
-7
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (c) 2017 Victor Perez
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +21,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
extern IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
void watchdog_init();
|
||||
void watchdog_reset();
|
||||
#ifdef STM32F4
|
||||
#include "STM32F4/HAL_timers_STM32F4.h"
|
||||
#else
|
||||
#include "STM32F7/HAL_timers_STM32F7.h"
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
# This HAL is for...
|
||||
|
||||
- STM32F407 MCU with STM32Generic Arduino core by danieleff.
|
||||
- STM32F765 board "The Borg" with STM32Generic.
|
||||
|
||||
See the `README.md` files in HAL_STM32F4 and HAL_STM32F7 for the specifics of those hals.
|
||||
+8
-32
@@ -22,52 +22,28 @@
|
||||
|
||||
#if defined(STM32GENERIC) && defined(STM32F4)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
#include "../HAL.h"
|
||||
#include "HAL_timers_STM32F4.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 2
|
||||
#define STEP_TIMER_IRQ_ID TIM5_IRQn
|
||||
#define TEMP_TIMER_IRQ_ID TIM7_IRQn
|
||||
|
||||
//#define PRESCALER 1
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
stm32f4_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
|
||||
stm32_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
bool timers_initialized[NUM_HARDWARE_TIMERS] = {false};
|
||||
|
||||
+11
-15
@@ -21,15 +21,11 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
@@ -75,29 +71,29 @@
|
||||
#endif
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#ifdef STM32GENERIC
|
||||
typedef struct {
|
||||
TIM_HandleTypeDef handle;
|
||||
uint32_t callback;
|
||||
} tTimerConfig;
|
||||
typedef tTimerConfig stm32f4_timer_t;
|
||||
typedef tTimerConfig stm32_timer_t;
|
||||
#else
|
||||
typedef stimer_t stm32f4_timer_t;
|
||||
typedef stimer_t stm32_timer_t;
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
extern stm32f4_timer_t TimerHandle[];
|
||||
extern stm32_timer_t TimerHandle[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
+10
-36
@@ -20,56 +20,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "HAL.h"
|
||||
#if defined(STM32GENERIC) && defined(STM32F7)
|
||||
|
||||
#include "../HAL.h"
|
||||
#include "HAL_timers_STM32F7.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Externals
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 2
|
||||
|
||||
//#define PRESCALER 1
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
tTimerConfig timerConfig[NUM_HARDWARE_TIMERS];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
|
||||
bool timers_initialized[NUM_HARDWARE_TIMERS] = {false};
|
||||
bool timers_initialized[NUM_HARDWARE_TIMERS] = { false };
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
|
||||
@@ -153,4 +127,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
return NVIC->ISER[IRQ_Id >> 5] & _BV32(IRQ_Id & 0x1F);
|
||||
}
|
||||
|
||||
#endif // STM32F7
|
||||
#endif // STM32GENERIC && STM32F7
|
||||
+9
-13
@@ -21,15 +21,11 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
@@ -61,17 +57,17 @@
|
||||
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define TEMP_ISR_ENABLED() HAL_timer_interrupt_enabled(TEMP_TIMER_NUM)
|
||||
// TODO change this
|
||||
|
||||
// TODO change this
|
||||
|
||||
extern void TC5_Handler();
|
||||
extern void TC7_Handler();
|
||||
#define HAL_STEP_TIMER_ISR() void TC5_Handler()
|
||||
#define HAL_TEMP_TIMER_ISR() void TC7_Handler()
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
typedef struct {
|
||||
TIM_HandleTypeDef timerdef;
|
||||
@@ -79,15 +75,15 @@ typedef struct {
|
||||
uint32_t callback;
|
||||
} tTimerConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
//extern const tTimerConfig timerConfig[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
+3
-4
@@ -4,7 +4,7 @@
|
||||
|
||||
https://github.com/danieleff/STM32GENERIC
|
||||
|
||||
but i have not committed the changes needed for the Borg there yet, so please use:
|
||||
but I haven't committed the changes needed for the Borg there yet, so please use:
|
||||
|
||||
https://github.com/Spawn32/STM32GENERIC
|
||||
|
||||
@@ -15,9 +15,9 @@ Download the latest GNU ARM Embedded Toolchain:
|
||||
|
||||
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
|
||||
|
||||
(The one in Arduino dosen't support STM32F7).
|
||||
(The one in Arduino doesn't support STM32F7).
|
||||
|
||||
Change compiler.path in platform.txt to point to that you downloaded.
|
||||
Change compiler.path in platform.txt to point to the one you downloaded.
|
||||
|
||||
# This HAL is in development.
|
||||
# Currently only tested on "The Borg".
|
||||
@@ -25,4 +25,3 @@ Change compiler.path in platform.txt to point to that you downloaded.
|
||||
You will also need the latest Arduino 1.9.0-beta or newer.
|
||||
|
||||
This HAL is a modified version of Chris Barr's Picoprint STM32F4 HAL, so shouldn't be to hard to get it to work on a F4.
|
||||
|
||||
+17
-15
@@ -25,22 +25,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//#include <Arduino.h>
|
||||
#if defined(STM32GENERIC) && defined(STM32F7)
|
||||
|
||||
#ifdef STM32F7
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_DRIVER(TMC2660)
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <SPI.h>
|
||||
#include "TMC2660.h"
|
||||
|
||||
#include "HAL.h"
|
||||
#include "../../core/serial.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../Marlin.h"
|
||||
#include "../../module/stepper_indirection.h"
|
||||
#include "../../module/printcounter.h"
|
||||
#include "../../libs/duration_t.h"
|
||||
#include "../../libs/hex_print_routines.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../../../Marlin.h"
|
||||
#include "../../../module/stepper_indirection.h"
|
||||
#include "../../../module/printcounter.h"
|
||||
#include "../../../libs/duration_t.h"
|
||||
#include "../../../libs/hex_print_routines.h"
|
||||
|
||||
//some default values used in initialization
|
||||
#define DEFAULT_MICROSTEPPING_VALUE 32
|
||||
@@ -630,19 +630,19 @@ uint16_t TMC26XStepper::getCoolStepLowerSgThreshold() {
|
||||
}
|
||||
|
||||
uint16_t TMC26XStepper::getCoolStepUpperSgThreshold() {
|
||||
return (uint8_t)((cool_step_register_value & SE_MAX_PATTERN) >> 8) << 5;
|
||||
return uint8_t((cool_step_register_value & SE_MAX_PATTERN) >> 8) << 5;
|
||||
}
|
||||
|
||||
uint8_t TMC26XStepper::getCoolStepCurrentIncrementSize() {
|
||||
return (uint8_t)((cool_step_register_value & CURRENT_DOWN_STEP_SPEED_PATTERN) >> 13);
|
||||
return uint8_t((cool_step_register_value & CURRENT_DOWN_STEP_SPEED_PATTERN) >> 13);
|
||||
}
|
||||
|
||||
uint8_t TMC26XStepper::getCoolStepNumberOfSGReadings() {
|
||||
return (uint8_t)((cool_step_register_value & SE_CURRENT_STEP_WIDTH_PATTERN) >> 5);
|
||||
return uint8_t((cool_step_register_value & SE_CURRENT_STEP_WIDTH_PATTERN) >> 5);
|
||||
}
|
||||
|
||||
uint8_t TMC26XStepper::getCoolStepLowerCurrentLimit() {
|
||||
return (uint8_t)((cool_step_register_value & MINIMUM_CURRENT_FOURTH) >> 15);
|
||||
return uint8_t((cool_step_register_value & MINIMUM_CURRENT_FOURTH) >> 15);
|
||||
}
|
||||
|
||||
void TMC26XStepper::setEnabled(boolean enabled) {
|
||||
@@ -895,4 +895,6 @@ inline void TMC26XStepper::send262(uint32_t datagram) {
|
||||
driver_status_result = i_datagram;
|
||||
}
|
||||
|
||||
#endif // STM32F7
|
||||
#endif // HAS_DRIVER(TMC2660)
|
||||
|
||||
#endif // STM32GENERIC && STM32F7
|
||||
-1
@@ -140,7 +140,6 @@ class TMC26XStepper {
|
||||
*/
|
||||
void un_start();
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Set the rotation speed in RPM.
|
||||
* \param whatSpeed the desired speed in RPM.
|
||||
+2
-2
@@ -22,14 +22,14 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Test STM32F4-specific configuration values for errors at compile-time.
|
||||
* Test STM32F4/7-specific configuration values for errors at compile-time.
|
||||
*/
|
||||
//#if ENABLED(SPINDLE_LASER_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
|
||||
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
|
||||
//#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F4. Disable EMERGENCY_PARSER to continue."
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F4/7. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
+77
-121
@@ -8,8 +8,8 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
@@ -47,14 +47,11 @@
|
||||
/** @addtogroup EEPROM_Emulation
|
||||
* @{
|
||||
*/
|
||||
#ifdef STM32F7
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "eeprom_emul.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Global variable used to store variable value in read sequence */
|
||||
@@ -79,76 +76,66 @@ static uint16_t EE_VerifyPageFullyErased(uint32_t Address);
|
||||
* - FLASH_COMPLETE: on success
|
||||
*/
|
||||
uint16_t EE_Initialize(void) {
|
||||
uint16_t PageStatus0 = 6, PageStatus1 = 6;
|
||||
uint16_t VarIdx = 0;
|
||||
uint16_t EepromStatus = 0, ReadStatus = 0;
|
||||
int16_t x = -1;
|
||||
HAL_StatusTypeDef FlashStatus;
|
||||
uint32_t SectorError = 0;
|
||||
/* Get Page0 and Page1 status */
|
||||
uint16_t PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS),
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
|
||||
|
||||
/* Get Page0 status */
|
||||
PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
/* Get Page1 status */
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
pEraseInit.TypeErase = TYPEERASE_SECTORS;
|
||||
pEraseInit.Sector = PAGE0_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
|
||||
/* Check for invalid header states and repair if necessary */
|
||||
uint32_t SectorError;
|
||||
switch (PageStatus0) {
|
||||
case ERASED:
|
||||
if (PageStatus1 == VALID_PAGE) { /* Page0 erased, Page1 valid */
|
||||
/* Erase Page0 */
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == RECEIVE_DATA) { /* Page0 erased, Page1 receive */
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
HAL_StatusTypeDef fStat = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
if (fStat != HAL_OK) return fStat;
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
}
|
||||
else { /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return EE_Format();
|
||||
}
|
||||
break;
|
||||
|
||||
case RECEIVE_DATA:
|
||||
if (PageStatus1 == VALID_PAGE) { /* Page0 receive, Page1 valid */
|
||||
/* Transfer data from Page1 to Page0 */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
int16_t x = -1;
|
||||
for (uint16_t VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
|
||||
x = VarIdx;
|
||||
if (VarIdx != x) {
|
||||
/* Read the last variables' updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
uint16_t ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1) {
|
||||
/* Transfer the variable to the Page0 */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
uint16_t EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
HAL_StatusTypeDef FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
pEraseInit.Sector = PAGE1_ID;
|
||||
@@ -156,9 +143,8 @@ uint16_t EE_Initialize(void) {
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == ERASED) { /* Page0 receive, Page1 erased */
|
||||
@@ -167,20 +153,18 @@ uint16_t EE_Initialize(void) {
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
HAL_StatusTypeDef fStat = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
if (fStat != HAL_OK) return fStat;
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
}
|
||||
else { /* Invalid state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return EE_Format();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -204,17 +188,18 @@ uint16_t EE_Initialize(void) {
|
||||
}
|
||||
else { /* Page0 valid, Page1 receive */
|
||||
/* Transfer data from Page0 to Page1 */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
int16_t x = -1;
|
||||
for (uint16_t VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
|
||||
x = VarIdx;
|
||||
|
||||
if (VarIdx != x) {
|
||||
/* Read the last variables' updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
uint16_t ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1) {
|
||||
/* Transfer the variable to the Page1 */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
uint16_t EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
}
|
||||
@@ -229,19 +214,16 @@ uint16_t EE_Initialize(void) {
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, simply return the result */
|
||||
return HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Any other state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
break;
|
||||
/* As the last operation, simply return the result */
|
||||
return EE_Format();
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
@@ -259,11 +241,10 @@ uint16_t EE_Initialize(void) {
|
||||
*/
|
||||
uint16_t EE_VerifyPageFullyErased(uint32_t Address) {
|
||||
uint32_t ReadStatus = 1;
|
||||
uint16_t AddressValue = 0x5555;
|
||||
/* Check each active page address starting from end */
|
||||
while (Address <= PAGE0_END_ADDRESS) {
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
AddressValue = (*(__IO uint16_t*)Address);
|
||||
uint16_t AddressValue = (*(__IO uint16_t*)Address);
|
||||
/* Compare the read address with the virtual address */
|
||||
if (AddressValue != ERASED) {
|
||||
/* In case variable value is read, reset ReadStatus flag */
|
||||
@@ -288,26 +269,22 @@ uint16_t EE_VerifyPageFullyErased(uint32_t Address) {
|
||||
* - NO_VALID_PAGE: if no valid page was found.
|
||||
*/
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) {
|
||||
uint16_t ValidPage = PAGE0;
|
||||
uint16_t AddressValue = 0x5555, ReadStatus = 1;
|
||||
uint32_t Address = EEPROM_START_ADDRESS, PageStartAddress = EEPROM_START_ADDRESS;
|
||||
uint16_t ReadStatus = 1;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
uint16_t ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (ValidPage == NO_VALID_PAGE) return NO_VALID_PAGE;
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
Address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
|
||||
/* Get the valid Page start and end Addresses */
|
||||
uint32_t PageStartAddress = uint32_t(EEPROM_START_ADDRESS) + uint32_t(ValidPage * (PAGE_SIZE)),
|
||||
Address = PageStartAddress + PAGE_SIZE - 2;
|
||||
|
||||
/* Check each active page address starting from end */
|
||||
while (Address > (PageStartAddress + 2)) {
|
||||
while (Address > PageStartAddress + 2) {
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
AddressValue = (*(__IO uint16_t*)Address);
|
||||
uint16_t AddressValue = (*(__IO uint16_t*)Address);
|
||||
|
||||
/* Compare the read address with the virtual address */
|
||||
if (AddressValue == VirtAddress) {
|
||||
@@ -353,16 +330,17 @@ uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data) {
|
||||
* EEPROM formating
|
||||
*/
|
||||
static HAL_StatusTypeDef EE_Format(void) {
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint32_t SectorError = 0;
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
|
||||
pEraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
pEraseInit.Sector = PAGE0_ID;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
|
||||
HAL_StatusTypeDef FlashStatus; // = HAL_OK
|
||||
|
||||
/* Erase Page0 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
|
||||
uint32_t SectorError;
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
@@ -375,9 +353,9 @@ static HAL_StatusTypeDef EE_Format(void) {
|
||||
pEraseInit.Sector = PAGE1_ID;
|
||||
/* Erase Page1 */
|
||||
if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* As the last operation, just return the result code */
|
||||
uint32_t SectorError;
|
||||
return HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
@@ -393,26 +371,20 @@ static HAL_StatusTypeDef EE_Format(void) {
|
||||
* of no valid page was found
|
||||
*/
|
||||
static uint16_t EE_FindValidPage(uint8_t Operation) {
|
||||
uint16_t PageStatus0 = 6, PageStatus1 = 6;
|
||||
|
||||
/* Get Page0 actual status */
|
||||
PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
|
||||
/* Get Page1 actual status */
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
/* Get Page0 and Page1 actual status */
|
||||
uint16_t PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS),
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
/* Write or read operation */
|
||||
switch (Operation) {
|
||||
case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */
|
||||
if (PageStatus1 == VALID_PAGE) {
|
||||
/* Page0 receiving data */
|
||||
if (PageStatus0 == RECEIVE_DATA) return PAGE0; /* Page0 valid */
|
||||
else return PAGE1; /* Page1 valid */
|
||||
return (PageStatus0 == RECEIVE_DATA) ? PAGE0 : PAGE1;
|
||||
}
|
||||
else if (PageStatus0 == VALID_PAGE) {
|
||||
/* Page1 receiving data */
|
||||
if (PageStatus1 == RECEIVE_DATA) return PAGE1; /* Page1 valid */
|
||||
else return PAGE0; /* Page0 valid */
|
||||
return (PageStatus1 == RECEIVE_DATA) ? PAGE1 : PAGE0;
|
||||
}
|
||||
else
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
@@ -441,34 +413,26 @@ static uint16_t EE_FindValidPage(uint8_t Operation) {
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data) {
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint16_t ValidPage = PAGE0;
|
||||
uint32_t Address = EEPROM_START_ADDRESS, PageEndAddress = EEPROM_START_ADDRESS+PAGE_SIZE;
|
||||
|
||||
/* Get valid Page for write operation */
|
||||
ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
|
||||
uint16_t ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (ValidPage == NO_VALID_PAGE) return NO_VALID_PAGE;
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((ValidPage + 1) * PAGE_SIZE));
|
||||
/* Get the valid Page start and end Addresses */
|
||||
uint32_t Address = uint32_t(EEPROM_START_ADDRESS) + uint32_t(ValidPage * (PAGE_SIZE)),
|
||||
PageEndAddress = Address + PAGE_SIZE - 1;
|
||||
|
||||
/* Check each active page address starting from begining */
|
||||
while (Address < PageEndAddress) {
|
||||
/* Verify if Address and Address+2 contents are 0xFFFFFFFF */
|
||||
if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF) {
|
||||
/* Set variable data */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address, Data);
|
||||
HAL_StatusTypeDef FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
/* Set variable virtual address */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address + 2, VirtAddress);
|
||||
/* Return program operation status */
|
||||
return FlashStatus;
|
||||
/* Set variable virtual address, return status */
|
||||
return HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address + 2, VirtAddress);
|
||||
}
|
||||
else /* Next address location */
|
||||
Address += 4;
|
||||
@@ -490,16 +454,10 @@ static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Da
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) {
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint32_t NewPageAddress = EEPROM_START_ADDRESS;
|
||||
uint16_t OldPageId=0;
|
||||
uint16_t ValidPage = PAGE0, VarIdx = 0;
|
||||
uint16_t EepromStatus = 0, ReadStatus = 0;
|
||||
uint32_t SectorError = 0;
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
uint16_t ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
uint32_t NewPageAddress = EEPROM_START_ADDRESS;
|
||||
uint16_t OldPageId = 0;
|
||||
|
||||
if (ValidPage == PAGE1) { /* Page1 valid */
|
||||
/* New page address where variable will be moved to */
|
||||
@@ -517,20 +475,20 @@ static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) {
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
|
||||
/* Set the new Page status to RECEIVE_DATA status */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, RECEIVE_DATA);
|
||||
HAL_StatusTypeDef FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, RECEIVE_DATA);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
/* Write the variable passed as parameter in the new active page */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
uint16_t EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK) return EepromStatus;
|
||||
|
||||
/* Transfer process: transfer variables from old to the new active page */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
for (uint16_t VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
|
||||
if (VirtAddVarTab[VarIdx] != VirtAddress) { /* Check each variable except the one passed as parameter */
|
||||
/* Read the other last variable updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
uint16_t ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1) {
|
||||
/* Transfer the variable to the new active page */
|
||||
@@ -541,26 +499,24 @@ static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) {
|
||||
}
|
||||
}
|
||||
|
||||
FLASH_EraseInitTypeDef pEraseInit;
|
||||
pEraseInit.TypeErase = TYPEERASE_SECTORS;
|
||||
pEraseInit.Sector = OldPageId;
|
||||
pEraseInit.NbSectors = 1;
|
||||
pEraseInit.VoltageRange = VOLTAGE_RANGE;
|
||||
|
||||
/* Erase the old Page: Set old Page status to ERASED status */
|
||||
uint32_t SectorError;
|
||||
FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
/* Set new Page status to VALID_PAGE status */
|
||||
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK) return FlashStatus;
|
||||
|
||||
/* Return last operation flash status */
|
||||
return FlashStatus;
|
||||
/* As the last operation, just return the result code */
|
||||
return HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, VALID_PAGE);
|
||||
}
|
||||
|
||||
#endif // STM32F7
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
|
||||
/**
|
||||
* @}
|
||||
+36
-31
@@ -8,7 +8,7 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright � 2016 STMicroelectronics International N.V.
|
||||
* Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,63 +45,68 @@
|
||||
******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../HAL.h"
|
||||
// ------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* EEPROM emulation firmware error codes */
|
||||
#define EE_OK (uint32_t)HAL_OK
|
||||
#define EE_ERROR (uint32_t)HAL_ERROR
|
||||
#define EE_BUSY (uint32_t)HAL_BUSY
|
||||
#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
|
||||
#define EE_OK uint32_t(HAL_OK)
|
||||
#define EE_ERROR uint32_t(HAL_ERROR)
|
||||
#define EE_BUSY uint32_t(HAL_BUSY)
|
||||
#define EE_TIMEOUT uint32_t(HAL_TIMEOUT)
|
||||
|
||||
/* Define the size of the sectors to be used */
|
||||
#define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */
|
||||
#define PAGE_SIZE uint32_t(0x4000) /* Page size = 16KByte */
|
||||
|
||||
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
|
||||
be done by word */
|
||||
#define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3
|
||||
#define VOLTAGE_RANGE uint8_t(VOLTAGE_RANGE_3)
|
||||
|
||||
/* EEPROM start address in Flash */
|
||||
#define EEPROM_START_ADDRESS ((uint32_t)0x08078000) /* EEPROM emulation start address:
|
||||
after 480KByte of used Flash memory */
|
||||
#ifdef STM32F7
|
||||
#define EEPROM_START_ADDRESS uint32_t(0x08100000) /* EEPROM emulation start address:
|
||||
from sector2 : after 16KByte of used
|
||||
Flash memory */
|
||||
#else
|
||||
#define EEPROM_START_ADDRESS uint32_t(0x08078000) /* EEPROM emulation start address:
|
||||
after 480KByte of used Flash memory */
|
||||
#endif
|
||||
|
||||
/* Pages 0 and 1 base and end addresses */
|
||||
#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
|
||||
#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
|
||||
#define PAGE0_ID FLASH_SECTOR_1
|
||||
#define PAGE0_BASE_ADDRESS uint32_t(EEPROM_START_ADDRESS + 0x0000)
|
||||
#define PAGE0_END_ADDRESS uint32_t(EEPROM_START_ADDRESS + PAGE_SIZE - 1)
|
||||
#define PAGE0_ID FLASH_SECTOR_1
|
||||
|
||||
#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
|
||||
#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
|
||||
#define PAGE1_ID FLASH_SECTOR_2
|
||||
#define PAGE1_BASE_ADDRESS uint32_t(EEPROM_START_ADDRESS + 0x4000)
|
||||
#define PAGE1_END_ADDRESS uint32_t(EEPROM_START_ADDRESS + 2 * (PAGE_SIZE) - 1)
|
||||
#define PAGE1_ID FLASH_SECTOR_2
|
||||
|
||||
/* Used Flash pages for EEPROM emulation */
|
||||
#define PAGE0 ((uint16_t)0x0000)
|
||||
#define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
|
||||
#define PAGE0 uint16_t(0x0000)
|
||||
#define PAGE1 uint16_t(0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
|
||||
|
||||
/* No valid page define */
|
||||
#define NO_VALID_PAGE ((uint16_t)0x00AB)
|
||||
#define NO_VALID_PAGE uint16_t(0x00AB)
|
||||
|
||||
/* Page status definitions */
|
||||
#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
|
||||
#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
|
||||
#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
|
||||
#define ERASED uint16_t(0xFFFF) /* Page is empty */
|
||||
#define RECEIVE_DATA uint16_t(0xEEEE) /* Page is marked to receive data */
|
||||
#define VALID_PAGE uint16_t(0x0000) /* Page containing valid data */
|
||||
|
||||
/* Valid pages in read and write defines */
|
||||
#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
|
||||
#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
|
||||
#define READ_FROM_VALID_PAGE uint8_t(0x00)
|
||||
#define WRITE_IN_VALID_PAGE uint8_t(0x01)
|
||||
|
||||
/* Page full define */
|
||||
#define PAGE_FULL ((uint8_t)0x80)
|
||||
#define PAGE_FULL uint8_t(0x80)
|
||||
|
||||
/* Variables' number */
|
||||
#define NB_OF_VAR ((uint16_t)4096)
|
||||
#define NB_OF_VAR uint16_t(4096)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
uint16_t EE_Initialize(void);
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
|
||||
+40
-36
@@ -23,7 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Fast I/O interfaces for STM32F7
|
||||
* Fast I/O interfaces for STM32F4/7
|
||||
* These use GPIO functions instead of Direct Port Manipulation, as on AVR.
|
||||
*/
|
||||
|
||||
@@ -63,10 +63,8 @@
|
||||
#define PORTC 2
|
||||
#define PORTD 3
|
||||
#define PORTE 4
|
||||
#define PORTF 5
|
||||
#define PORTG 6
|
||||
|
||||
#define _STM32_PIN(_PORT,_PIN) ((PORT##_PORT * 16) + _PIN)
|
||||
#define _STM32_PIN(P,PN) ((PORT##P * 16) + PN)
|
||||
|
||||
#define PA0 _STM32_PIN(A, 0)
|
||||
#define PA1 _STM32_PIN(A, 1)
|
||||
@@ -153,36 +151,42 @@
|
||||
#define PE14 _STM32_PIN(E, 14)
|
||||
#define PE15 _STM32_PIN(E, 15)
|
||||
|
||||
#define PF0 _STM32_PIN(F, 0)
|
||||
#define PF1 _STM32_PIN(F, 1)
|
||||
#define PF2 _STM32_PIN(F, 2)
|
||||
#define PF3 _STM32_PIN(F, 3)
|
||||
#define PF4 _STM32_PIN(F, 4)
|
||||
#define PF5 _STM32_PIN(F, 5)
|
||||
#define PF6 _STM32_PIN(F, 6)
|
||||
#define PF7 _STM32_PIN(F, 7)
|
||||
#define PF8 _STM32_PIN(F, 8)
|
||||
#define PF9 _STM32_PIN(F, 9)
|
||||
#define PF10 _STM32_PIN(F, 10)
|
||||
#define PF11 _STM32_PIN(F, 11)
|
||||
#define PF12 _STM32_PIN(F, 12)
|
||||
#define PF13 _STM32_PIN(F, 13)
|
||||
#define PF14 _STM32_PIN(F, 14)
|
||||
#define PF15 _STM32_PIN(F, 15)
|
||||
#ifdef STM32F7
|
||||
#define PORTF 5
|
||||
#define PORTG 6
|
||||
|
||||
#define PG0 _STM32_PIN(G, 0)
|
||||
#define PG1 _STM32_PIN(G, 1)
|
||||
#define PG2 _STM32_PIN(G, 2)
|
||||
#define PG3 _STM32_PIN(G, 3)
|
||||
#define PG4 _STM32_PIN(G, 4)
|
||||
#define PG5 _STM32_PIN(G, 5)
|
||||
#define PG6 _STM32_PIN(G, 6)
|
||||
#define PG7 _STM32_PIN(G, 7)
|
||||
#define PG8 _STM32_PIN(G, 8)
|
||||
#define PG9 _STM32_PIN(G, 9)
|
||||
#define PG10 _STM32_PIN(G, 10)
|
||||
#define PG11 _STM32_PIN(G, 11)
|
||||
#define PG12 _STM32_PIN(G, 12)
|
||||
#define PG13 _STM32_PIN(G, 13)
|
||||
#define PG14 _STM32_PIN(G, 14)
|
||||
#define PG15 _STM32_PIN(G, 15)
|
||||
#define PF0 _STM32_PIN(F, 0)
|
||||
#define PF1 _STM32_PIN(F, 1)
|
||||
#define PF2 _STM32_PIN(F, 2)
|
||||
#define PF3 _STM32_PIN(F, 3)
|
||||
#define PF4 _STM32_PIN(F, 4)
|
||||
#define PF5 _STM32_PIN(F, 5)
|
||||
#define PF6 _STM32_PIN(F, 6)
|
||||
#define PF7 _STM32_PIN(F, 7)
|
||||
#define PF8 _STM32_PIN(F, 8)
|
||||
#define PF9 _STM32_PIN(F, 9)
|
||||
#define PF10 _STM32_PIN(F, 10)
|
||||
#define PF11 _STM32_PIN(F, 11)
|
||||
#define PF12 _STM32_PIN(F, 12)
|
||||
#define PF13 _STM32_PIN(F, 13)
|
||||
#define PF14 _STM32_PIN(F, 14)
|
||||
#define PF15 _STM32_PIN(F, 15)
|
||||
|
||||
#define PG0 _STM32_PIN(G, 0)
|
||||
#define PG1 _STM32_PIN(G, 1)
|
||||
#define PG2 _STM32_PIN(G, 2)
|
||||
#define PG3 _STM32_PIN(G, 3)
|
||||
#define PG4 _STM32_PIN(G, 4)
|
||||
#define PG5 _STM32_PIN(G, 5)
|
||||
#define PG6 _STM32_PIN(G, 6)
|
||||
#define PG7 _STM32_PIN(G, 7)
|
||||
#define PG8 _STM32_PIN(G, 8)
|
||||
#define PG9 _STM32_PIN(G, 9)
|
||||
#define PG10 _STM32_PIN(G, 10)
|
||||
#define PG11 _STM32_PIN(G, 11)
|
||||
#define PG12 _STM32_PIN(G, 12)
|
||||
#define PG13 _STM32_PIN(G, 13)
|
||||
#define PG14 _STM32_PIN(G, 14)
|
||||
#define PG15 _STM32_PIN(G, 15)
|
||||
|
||||
#endif // STM32GENERIC && STM32F7
|
||||
+4
-4
@@ -21,7 +21,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef STM32F7
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
@@ -52,10 +52,10 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
do {
|
||||
uint8_t c = eeprom_read_byte((uint8_t*)pos);
|
||||
*value = c;
|
||||
if (writing) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
@@ -66,4 +66,4 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
size_t PersistentStore::capacity() { return E2END + 1; }
|
||||
|
||||
#endif // EEPROM_SETTINGS
|
||||
#endif // STM32F7
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
@@ -23,5 +23,5 @@
|
||||
#elif defined(BOARD_NR_GPIO_PINS) // Only in STM32GENERIC (Maple)
|
||||
#include "../HAL_STM32/pinsDebug_STM32GENERIC.h"
|
||||
#else
|
||||
#error "M43 not supported for this board"
|
||||
#error "M43 Pins Debugging not supported for this board."
|
||||
#endif
|
||||
+8
-9
@@ -20,13 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(STM32GENERIC) && defined(STM32F4)
|
||||
#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
|
||||
#include "watchdog_STM32F4.h"
|
||||
#include "watchdog_STM32_F4_F7.h"
|
||||
|
||||
IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
|
||||
//Error_Handler();
|
||||
}
|
||||
else {
|
||||
#if PIN_EXISTS(LED) && !ENABLED(PINS_DEBUGGING)
|
||||
TOGGLE(LED_PIN); // heartbeat indicator
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void watchdog_reset() {
|
||||
@@ -45,13 +50,7 @@
|
||||
/* Refresh Error */
|
||||
//Error_Handler();
|
||||
}
|
||||
else {
|
||||
#if PIN_EXISTS(LED)
|
||||
TOGGLE(LED_PIN); // heartbeat indicator
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_WATCHDOG
|
||||
|
||||
#endif // STM32GENERIC && STM32F4
|
||||
#endif // STM32GENERIC && (STM32F4 || STM32F7)
|
||||
@@ -28,15 +28,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
@@ -48,8 +44,8 @@ typedef uint32_t hal_timer_t;
|
||||
#define FTM0_TIMER_PRESCALE_BITS 0b011
|
||||
#define FTM1_TIMER_PRESCALE_BITS 0b010
|
||||
|
||||
#define FTM0_TIMER_RATE (F_BUS / FTM0_TIMER_PRESCALE) // 60MHz / 8 = 7500kHz
|
||||
#define FTM1_TIMER_RATE (F_BUS / FTM1_TIMER_PRESCALE) // 60MHz / 4 = 15MHz
|
||||
#define FTM0_TIMER_RATE (F_BUS / (FTM0_TIMER_PRESCALE)) // 60MHz / 8 = 7500kHz
|
||||
#define FTM1_TIMER_RATE (F_BUS / (FTM1_TIMER_PRESCALE)) // 60MHz / 4 = 15MHz
|
||||
|
||||
#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
|
||||
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifdef __MK20DX256__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
|
||||
#include "../persistent_store_api.h"
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
namespace HAL {
|
||||
namespace PersistentStore {
|
||||
|
||||
@@ -27,10 +27,6 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
@@ -47,9 +43,9 @@
|
||||
#define ST7920_DELAY_2 DELAY_NS(750)
|
||||
#define ST7920_DELAY_3 DELAY_NS(750)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
// ------------------------
|
||||
|
||||
#define IS_32BIT_TEENSY (defined(__MK64FX512__) || defined(__MK66FX1M0__))
|
||||
#define IS_TEENSY35 defined(__MK64FX512__)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user