Skip to content

Commit

Permalink
[processing] Do not require protothread module to use SPI with fibers
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand committed Oct 4, 2023
1 parent 3b2530f commit 13c1cd2
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/modm/platform/spi/at90_tiny_mega/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_properties(env):
device = env[":target"]
driver = device.get_driver("spi:avr")
properties = {}
properties["use_fiber"] = env.get(":processing:protothread:use_fiber", False)
properties["use_fiber"] = env.query(":processing:fiber:__enabled", False)
properties["target"] = device.identifier
properties["partname"] = device.partname
properties["driver"] = driver
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/spi/rp/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Instance(Module):
def build(self, env):
env.substitutions = {
"id": self.instance,
"use_fiber": env.get(":processing:protothread:use_fiber", False)
"use_fiber": env.query(":processing:fiber:__enabled", False)
}
env.outbasepath = "modm/src/modm/platform/spi"

Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/spi/sam/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_properties(env):
device = env[":target"]
driver = device.get_driver("spi")
properties = {}
properties["use_fiber"] = env.get(":processing:protothread:use_fiber", False)
properties["use_fiber"] = env.query(":processing:fiber:__enabled", False)
properties["target"] = device.identifier
properties["features"] = driver["feature"] if "feature" in driver else []
return properties
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/spi/sam_x7x/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def get_properties(env):
device = env[":target"]
properties = {}
properties["use_fiber"] = env.get(":processing:protothread:use_fiber", False)
properties["use_fiber"] = env.query(":processing:fiber:__enabled", False)
properties["target"] = device.identifier
return properties

Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/spi/stm32/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_properties(env):
device = env[":target"]
driver = device.get_driver("spi")
properties = {}
properties["use_fiber"] = env.get(":processing:protothread:use_fiber", False)
properties["use_fiber"] = env.query(":processing:fiber:__enabled", False)
properties["target"] = device.identifier
properties["features"] = driver["feature"] if "feature" in driver else []
return properties
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/spi/stm32_uart/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_properties(env):
"target": device.identifier,
"driver": driver,
"over8_sampling": ("feature" in driver) and ("over8" in driver["feature"]),
"use_fiber": env.get(":processing:protothread:use_fiber", False),
"use_fiber": env.query(":processing:fiber:__enabled", False)
}
return properties

Expand Down
9 changes: 8 additions & 1 deletion src/modm/processing/fiber/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, Erik Henriksson
# Copyright (c) 2021, Christopher Durand
# Copyright (c) 2021-2023, Christopher Durand
# Copyright (c) 2021, Niklas Hauser
#
# This file is part of the modm project.
Expand All @@ -16,9 +16,16 @@ def init(module):
module.name = ":processing:fiber"
module.description = FileReader("module.md")

def is_enabled(env):
return env.get(":processing:protothread:use_fiber", False) or \
not env.has_module(":processing:protothread")

def prepare(module, options):
module.depends(":processing:timer")

module.add_query(
EnvironmentQuery(name="__enabled", factory=is_enabled))

# No ARM64 support yet!
return "arm64" not in options[":target"].get_driver("core")["type"]

Expand Down
2 changes: 1 addition & 1 deletion src/modm/processing/resumable/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def prepare(module, options):

def build(env):
env.outbasepath = "modm/src/modm/processing/resumable"
if env.get(":processing:protothread:use_fiber", False):
if env.query(":processing:fiber:__enabled", False):
env.copy("macros_fiber.hpp", "macros.hpp")
env.copy("resumable_fiber.hpp", "resumable.hpp")
else:
Expand Down

0 comments on commit 13c1cd2

Please sign in to comment.