forked from amaranth-lang/amaranth-boards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[breaking-change] Factor out "led", "button" and "switch" resources.
These resources were renamed as: * user_led → led * user_btn → button * user_sw → switch Fixes amaranth-lang#13.
- Loading branch information
1 parent
cb0c2cd
commit dd87f47
Showing
17 changed files
with
158 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .user import LEDResources, RGBLEDResource, ButtonResources, SwitchResources | ||
from .uart import UARTResource | ||
from .flash import SPIFlashResources | ||
from .spi import SPIResource | ||
from .flash import SPIFlashResources | ||
from .sram import SRAMResource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from nmigen.build import * | ||
|
||
|
||
__all__ = ["UserLEDResource"] | ||
|
||
|
||
def _SplitResources(*args, pins, invert=False, attrs=None, default_name, dir): | ||
assert isinstance(pins, (str, list, dict)) | ||
|
||
if isinstance(pins, str): | ||
pins = pins.split() | ||
if isinstance(pins, list): | ||
pins = dict(enumerate(pins)) | ||
|
||
resources = [] | ||
for number, pin in pins.items(): | ||
ios = [PinsN(pin, dir=dir) if invert else Pins(pin, dir=dir)] | ||
if attrs is not None: | ||
ios.append(attrs) | ||
resources.append(Resource.family(*args, number, default_name=default_name, ios=ios)) | ||
return resources | ||
|
||
|
||
def LEDResources(*args, **kwargs): | ||
return _SplitResources(*args, **kwargs, default_name="led", dir="o") | ||
|
||
|
||
def RGBLEDResource(*args, r, g, b, invert=False, attrs=None): | ||
ios = [] | ||
ios.append(Subsignal("r", Pins(r, dir="o", assert_width=1))) | ||
ios.append(Subsignal("g", Pins(g, dir="o", assert_width=1))) | ||
ios.append(Subsignal("b", Pins(b, dir="o", assert_width=1))) | ||
if attrs is not None: | ||
ios.append(attrs) | ||
return Resource.family(*args, default_name="rgb_led", ios=ios) | ||
|
||
|
||
def ButtonResources(*args, **kwargs): | ||
return _SplitResources(*args, **kwargs, default_name="button", dir="i") | ||
|
||
|
||
def SwitchResources(*args, **kwargs): | ||
return _SplitResources(*args, **kwargs, default_name="switch", dir="i") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.