Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ git clone --recurse-submodules https://github.com/modm-io/modm.git
## Targets

modm can generate code for <!--avrcount-->506<!--/avrcount-->
AVR, <!--samcount-->163<!--/samcount--> SAM and <!--stmcount-->2010<!--/stmcount-->
AVR, <!--samcount-->163<!--/samcount--> SAM and <!--stmcount-->2110<!--/stmcount-->
STM32 devices, however, there are different levels of support and testing.

<center>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/how-modm-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def prepare(module, options):

def build(env):
device = env[":target"]
env.substitutions = device.properties
env.substitutions = device.get_driver("uart")
env.outbasepath = "src/modm/platform/uart"
for instance in device.get_driver("uart:stm32*")["instance"]:
env.template("uart.hpp.in", "uart_{}.hpp".format(instance))
Expand Down
7 changes: 4 additions & 3 deletions examples/nucleo_f767zi/ethernet/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ main()
Leds::setOutput();
MODM_LOG_INFO << "\n\nReboot: Ethernet Example" << modm::endl;

Ethernet::Port::connect<Ethernet::RMII_Ref_Clk::Refclk,
Ethernet::Port::connect<
Ethernet::RMII_Ref_Clk::RefClk,
Ethernet::RMII_Mdc::Mdc,
Ethernet::RMII_Mdio::Mdio,
Ethernet::RMII_Crs_Dv::Rcccrsdv,
Ethernet::RMII_Tx_En::Txen,
Ethernet::RMII_Crs_Dv::RccCrsDv,
Ethernet::RMII_Tx_En::TxEn,
Ethernet::RMII_Tx_D0::Txd0,
Ethernet::RMII_Tx_D1::Txd1,
Ethernet::RMII_Rx_D0::Rxd0,
Expand Down
2 changes: 1 addition & 1 deletion ext/modm-devices
Submodule modm-devices updated 148 files
2 changes: 1 addition & 1 deletion ext/st/stm32
Submodule stm32 updated 72 files
+7 −7 README.md
+6 −0 patches/g0-3.patch
+2 −2 stm32f0xx/Include/stm32f030xc.h
+15 −5 stm32f0xx/Include/stm32f0xx.h
+66 −27 stm32f0xx/Release_Notes.html
+8 −11 stm32f1xx/Include/stm32f100xb.h
+8 −11 stm32f1xx/Include/stm32f100xe.h
+0 −4 stm32f1xx/Include/stm32f101x6.h
+0 −4 stm32f1xx/Include/stm32f101xb.h
+52 −3 stm32f1xx/Include/stm32f101xe.h
+58 −9 stm32f1xx/Include/stm32f101xg.h
+0 −4 stm32f1xx/Include/stm32f102x6.h
+4 −8 stm32f1xx/Include/stm32f102xb.h
+10 −14 stm32f1xx/Include/stm32f103x6.h
+12 −16 stm32f1xx/Include/stm32f103xb.h
+12 −15 stm32f1xx/Include/stm32f103xe.h
+8 −11 stm32f1xx/Include/stm32f103xg.h
+11 −19 stm32f1xx/Include/stm32f105xc.h
+15 −23 stm32f1xx/Include/stm32f107xc.h
+2 −2 stm32f1xx/Include/stm32f1xx.h
+401 −852 stm32f1xx/Release_Notes.html
+0 −3 stm32f2xx/Include/stm32f205xx.h
+0 −3 stm32f2xx/Include/stm32f207xx.h
+0 −3 stm32f2xx/Include/stm32f215xx.h
+0 −3 stm32f2xx/Include/stm32f217xx.h
+2 −2 stm32f2xx/Include/stm32f2xx.h
+35 −10 stm32f2xx/Release_Notes.html
+2 −2 stm32f3xx/Include/stm32f3xx.h
+32 −14 stm32f3xx/Release_Notes.html
+61 −85 stm32g0xx/Include/stm32g030xx.h
+86 −107 stm32g0xx/Include/stm32g031xx.h
+86 −107 stm32g0xx/Include/stm32g041xx.h
+7,453 −0 stm32g0xx/Include/stm32g050xx.h
+8,405 −0 stm32g0xx/Include/stm32g051xx.h
+8,713 −0 stm32g0xx/Include/stm32g061xx.h
+60 −79 stm32g0xx/Include/stm32g070xx.h
+92 −101 stm32g0xx/Include/stm32g071xx.h
+92 −101 stm32g0xx/Include/stm32g081xx.h
+648 −541 stm32g0xx/Include/stm32g0b0xx.h
+821 −407 stm32g0xx/Include/stm32g0b1xx.h
+814 −409 stm32g0xx/Include/stm32g0c1xx.h
+26 −5 stm32g0xx/Include/stm32g0xx.h
+2 −2 stm32g0xx/Include/system_stm32g0xx.h
+120 −35 stm32g0xx/Release_Notes.html
+5 −11 stm32l0xx/Include/stm32l010x4.h
+4 −11 stm32l0xx/Include/stm32l010x6.h
+4 −11 stm32l0xx/Include/stm32l010x8.h
+4 −11 stm32l0xx/Include/stm32l010xb.h
+4 −10 stm32l0xx/Include/stm32l011xx.h
+4 −10 stm32l0xx/Include/stm32l021xx.h
+5 −10 stm32l0xx/Include/stm32l031xx.h
+5 −10 stm32l0xx/Include/stm32l041xx.h
+5 −10 stm32l0xx/Include/stm32l051xx.h
+3 −10 stm32l0xx/Include/stm32l052xx.h
+5 −10 stm32l0xx/Include/stm32l053xx.h
+0 −6,405 stm32l0xx/Include/stm32l061xx.h
+3 −10 stm32l0xx/Include/stm32l062xx.h
+3 −10 stm32l0xx/Include/stm32l063xx.h
+5 −9 stm32l0xx/Include/stm32l071xx.h
+5 −9 stm32l0xx/Include/stm32l072xx.h
+5 −9 stm32l0xx/Include/stm32l073xx.h
+5 −9 stm32l0xx/Include/stm32l081xx.h
+5 −9 stm32l0xx/Include/stm32l082xx.h
+5 −9 stm32l0xx/Include/stm32l083xx.h
+2 −5 stm32l0xx/Include/stm32l0xx.h
+369 −441 stm32l0xx/Release_Notes.html
+0 −6 stm32wbxx/Include/stm32wb35xx.h
+0 −3 stm32wbxx/Include/stm32wb50xx.h
+0 −3 stm32wbxx/Include/stm32wb55xx.h
+0 −3 stm32wbxx/Include/stm32wb5mxx.h
+1 −1 stm32wbxx/Include/stm32wbxx.h
+54 −15 stm32wbxx/Release_Notes.html
8 changes: 8 additions & 0 deletions repo.lb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ def init(repo):
repo.add_filter("modm.ord", lambda letter: ord(letter[0].lower()) - ord("a"))
repo.add_filter("modm.chr", lambda num: chr(num + ord("A")))

# Global filters for naming things
def fmt_str(s):
return "".join(p.capitalize() for p in str(s).split("_"))
def fmt_driver(d):
return fmt_str(d.get("driver", "")) + fmt_str(d.get("instance", ""))
repo.add_filter("modm.fmt", fmt_str)
repo.add_filter("modm.fmt.driver", fmt_driver)

# Compute the available data from modm-devices
devices = DevicesCache()
try:
Expand Down
12 changes: 6 additions & 6 deletions src/modm/board/disco_f746ng/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ initializeUsbHs()
{
usb_hs::Device::initialize<SystemClock>();
usb_hs::Device::connect<
usb_hs::Ck::Ulpick, usb_hs::Stp::Ulpistp,
usb_hs::Dir::Ulpidir, usb_hs::Nxt::Ulpinxt,
usb_hs::D0::Ulpid0, usb_hs::D1::Ulpid1,
usb_hs::D2::Ulpid2, usb_hs::D3::Ulpid3,
usb_hs::D4::Ulpid4, usb_hs::D5::Ulpid5,
usb_hs::D6::Ulpid6, usb_hs::D7::Ulpid7>();
usb_hs::Ck::UlpiCk, usb_hs::Stp::UlpiStp,
usb_hs::Dir::UlpiDir, usb_hs::Nxt::UlpiNxt,
usb_hs::D0::UlpiD0, usb_hs::D1::UlpiD1,
usb_hs::D2::UlpiD2, usb_hs::D3::UlpiD3,
usb_hs::D4::UlpiD4, usb_hs::D5::UlpiD5,
usb_hs::D6::UlpiD6, usb_hs::D7::UlpiD7>();
usb_hs::Overcurrent::setInput();

// Deactivate VBUS Sensing B
Expand Down
22 changes: 4 additions & 18 deletions src/modm/driver/gpio/gpio_sampler.lb
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,22 @@ def prepare(module, options):
if options[":target"].identifier["platform"] != "stm32":
return False

core = options[":target"].get_driver("core:cortex-m*")
core = options[":target"].driver("core").type
# Cortex-M0 doesn't have the DWT->CYCCNT and Cortex-M7 support is broken
if not core or "m0" in core["type"] or "m7" in core["type"]:
if "m0" in core or "m7" in core:
return False

module.depends(
":platform:gpio",
":platform:core",
":architecture:interrupt")

return True


def build(env):
exti_vectors = [v["name"] for v in env[":target"].get_driver("core")["vector"] if "EXTI" in v["name"]]
# These are all exti possible vectors: 0, 0_1, 1, 15_10, 2, 2_3, 2_TSC, 3, 4, 4_15, 9_5
extimap = {
"0": [0], "1": [1], "2": [2], "3": [3], "4": [4],
"0_1": [0,1],
"2_TSC": [2],
"2_3": [2,3],
"4_15": [4,5,6,7,8,9,10,11,12,13,14,15],
"9_5": [5,6,7,8,9],
"15_10": [10,11,12,13,14,15],
}
extis = OrderedDict()
for v in sorted(exti_vectors):
extis[v] = extimap[v[4:]]

env.substitutions = {
"extis": extis,
"extis": env[":target"].core.shared_irqs("EXTI"),
"vectors_location": env.get(":platform:core:vector_table_location", "rom")
}
env.outbasepath = "modm/src/modm/driver"
Expand Down
47 changes: 20 additions & 27 deletions src/modm/platform/adc/stm32/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,6 @@ def prepare(module, options):
device = options[":target"]
if not device.has_driver("adc:stm32"):
return False
global props
props = {}
driver = device.get_driver("adc")
props["target"] = target = device.identifier
props["driver"] = driver
props["instances"] = []

if target["family"] in ["f2", "f4", "f7"]:
props["shared_irqs"] = {"ADC": listify(device.get_driver("adc")["instance"])}
props["shared_irq_ids"] = props["shared_irqs"]["ADC"]
else:
shared_irqs = [v["name"] for v in device.get_driver("core")["vector"]]
shared_irqs = [v for v in shared_irqs if v.startswith("ADC") and "_" in v]
props["shared_irqs"] = {}
props["shared_irq_ids"] = []
for irq in shared_irqs:
parts = irq[3:].split("_")
shared_irqs_ids = (int(parts[0]), int(parts[1]) )
props["shared_irqs"][irq] = shared_irqs_ids
props["shared_irq_ids"].extend(shared_irqs_ids)


module.depends(
":architecture:adc",
Expand All @@ -99,21 +78,35 @@ def prepare(module, options):
":math:algorithm",
":utils")

for instance in listify(device.get_driver("adc").get("instance", [])):
module.add_submodule(Instance(int(instance)))
for instance in device.driver("adc").instances():
module.add_submodule(Instance(instance.number))

return True

def build(env):
def validate(env):
device = env[":target"]
driver = device.get_driver("adc")

global props
props = {}
props["target"] = target = device.identifier
props["instances"] = []

shared_irqs = device.core.shared_irqs("ADC")
if shared_irqs.values():
props["shared_irqs"] = shared_irqs
props["shared_irq_ids"] = list(shared_irqs.values())[0]
else:
irq_name = next(device.core.vectors(lambda v: v.startswith("ADC")), "ADC")
instances = [i.number for i in device.driver("adc").instances()]
props["shared_irqs"] = {irq_name: instances}
props["shared_irq_ids"] = instances

def build(env):
device = env[":target"]
global props
env.substitutions = props
env.outbasepath = "modm/src/modm/platform/adc"

if device.get_driver("adc").get("instance", None) is None:
if not device.driver("adc").instances():
Instance(None).build(env)

if any(i in props["shared_irq_ids"] for i in props["instances"]):
Expand Down
11 changes: 3 additions & 8 deletions src/modm/platform/adc/stm32f0/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def init(module):

def prepare(module, options):
device = options[":target"]
if not (device.has_driver("adc:stm32-f0") or
device.has_driver("adc:stm32-g0")):
if not device.has_driver("adc:stm32-[fg]0"):
return False
module.depends(
":architecture:delay",
Expand All @@ -33,11 +32,10 @@ def prepare(module, options):

def build(env):
device = env[":target"]
driver = device.get_driver("adc")

properties = {}
properties["target"] = target = device.identifier
properties["id"] = driver.get("instance", [""])[0]
properties["id"] = device.driver("adc").instances([""])[0]

channels = {i:"In{}".format(i) for i in reversed(range(0,19))}
if target.family in ["g0"]:
Expand All @@ -52,10 +50,7 @@ def build(env):
else:
channels[18] = "Battery"
properties["channels"] = channels

irq = next(v["name"] for v in device.get_driver("core")["vector"]
if v["name"].startswith("ADC1"))
properties["irq"] = irq
properties["irq"] = next(device.core.vectors(lambda v: v.startswith("ADC1")))

env.substitutions = properties
env.outbasepath = "modm/src/modm/platform/adc"
Expand Down
16 changes: 4 additions & 12 deletions src/modm/platform/adc/stm32f3/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Instance(Module):
device = env[":target"]
driver = device.get_driver("adc")

properties = device.properties
properties = {}
properties["target"] = target = device.identifier
instance_id = int(self.instance)
properties["id"] = instance_id
Expand Down Expand Up @@ -145,18 +145,10 @@ def prepare(module, options):
":platform:gpio",
":platform:rcc")

for instance in listify(device.get_driver("adc")["instance"]):
module.add_submodule(Instance(int(instance)))
for instance in device.driver("adc").instances():
module.add_submodule(Instance(instance.number))

return True

def build(env):
device = env[":target"]
driver = device.get_driver("adc")

properties = device.properties
properties["target"] = device.identifier
properties["driver"] = driver

env.substitutions = properties
env.outbasepath = "modm/src/modm/platform/adc"
pass
11 changes: 4 additions & 7 deletions src/modm/platform/can/lpc/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ def prepare(module, options):

def build(env):
device = env[":target"]
driver = device.get_driver("can")

properties = device.properties
properties["target"] = target = device.identifier
properties["driver"] = driver

env.substitutions = properties
env.substitutions = {
"target": device.identifier,
"driver": device.get_driver("can"),
}
env.outbasepath = "modm/src/modm/platform/can"

env.template("c_can.cpp.in")
Expand Down
43 changes: 15 additions & 28 deletions src/modm/platform/can/stm32/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ can_map = {
},
}

def get_substitutions(instance, device, env):
def get_substitutions(env, instance):
device = env[":target"]
target = device.identifier

driver = device.get_driver("can")
instances = map(lambda i: int(i), driver["instance"]) if "instance" in driver else (0,)
instances = (i.number for i in device.driver("can").instances())
instances = instances if instances else [0]

cm = can_map[target["family"]]
cm = can_map[target.family]
is_single = (cm[instance].type == CanType.Single) or (cm[instance].associated_instance not in instances)
other = cm[instance].associated_instance

subs = {
"target": target,
"id": "" if instance == 0 else str(instance),
"own_instance": cm[instance].register,
"other_instance": cm[other].register if other in cm else None,
Expand All @@ -109,15 +113,7 @@ class Instance(Module):
return True

def build(self, env):
device = env[":target"]
driver = device.get_driver("can")

properties = device.properties
properties["target"] = target = device.identifier
properties["driver"] = driver
properties.update(get_substitutions(self.instance, device, env))

env.substitutions = properties
env.substitutions = get_substitutions(env, self.instance)
env.outbasepath = "modm/src/modm/platform/can"

env.template("can.hpp.in", "can_{}.hpp".format(self.instance))
Expand Down Expand Up @@ -147,34 +143,25 @@ def prepare(module, options):
":platform:rcc",
":utils")

driver = device.get_driver("can")
instances = device.driver("can").instances()
# If there is only one instance of the peripheral it is not numbered and
# merged into the generic can module.
if "instance" in driver:
for instance in listify(driver["instance"]):
module.add_submodule(Instance(int(instance)))
if instances:
for instance in instances:
module.add_submodule(Instance(instance.number))
else:
load_options(module)

return True

def build(env):
device = env[":target"]
driver = device.get_driver("can")

properties = device.properties
properties["target"] = device.identifier
properties["driver"] = driver

if "instance" not in driver:
properties.update(get_substitutions(0, device, env))

env.substitutions = properties
env.substitutions = {"target": env[":target"].identifier}
env.outbasepath = "modm/src/modm/platform/can"

env.template("can_filter.hpp.in")
env.template("can_filter.cpp.in")

if "instance" not in driver:
if not env[":target"].driver("can").instances():
env.substitutions = get_substitutions(env, 0)
env.template("can.hpp.in")
env.template("can.cpp.in")
2 changes: 1 addition & 1 deletion src/modm/platform/clock/lpc/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build(env):
device = env[":target"]
driver = device.get_driver("clock")

properties = device.properties
properties = {}
properties["target"] = target = device.identifier
properties["driver"] = driver

Expand Down
Loading