-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo: proof-of-concept for sharing values between host and device code
- Loading branch information
Showing
11 changed files
with
214 additions
and
58 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
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,31 @@ | ||
# | ||
# This file is part of Cynthion. | ||
# | ||
|
||
""" | ||
The values in this module are generated at runtime from the | ||
corresponding TOML files located in the `cynthion.git/host/cynthion/shared/` | ||
directory. | ||
""" | ||
|
||
import tomllib | ||
|
||
from collections import namedtuple | ||
from importlib.resources import files | ||
from os import path | ||
|
||
SHARED_TOML_DIR = files("cynthion").joinpath("shared") | ||
|
||
def _dict_to_namedtuple(data, typename="_"): | ||
return namedtuple(typename, data.keys())( | ||
*(_dict_to_namedtuple(v, typename + '_' + k) if isinstance(v, dict) else v for k, v in data.items()) | ||
) | ||
|
||
with open(path.join(SHARED_TOML_DIR, "libgreat.toml"), "rb") as f: | ||
libgreat = _dict_to_namedtuple(tomllib.load(f)) | ||
|
||
with open(path.join(SHARED_TOML_DIR, "registers.toml"), "rb") as f: | ||
registers = _dict_to_namedtuple(tomllib.load(f)) | ||
|
||
with open(path.join(SHARED_TOML_DIR, "usb.toml"), "rb") as f: | ||
usb = _dict_to_namedtuple(tomllib.load(f)) |
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,14 @@ | ||
### libgreat | ||
### | ||
### This configuration file defines constants that are shared between | ||
### the host and device implementations of the libgreat protocol. | ||
### | ||
|
||
# endpoint configurations | ||
[endpoints] | ||
bulk_in_address = 0x81 | ||
bulk_out_address = 0x02 | ||
|
||
# Vendor request constants | ||
[vendor] | ||
command_request = 0x65 |
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,4 @@ | ||
### registers | ||
### | ||
### TODO | ||
### |
Oops, something went wrong.