Skip to content
Open
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
9 changes: 6 additions & 3 deletions splashasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ What are valid params for each instruction are better defined in the binary docs
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Protocol four cc |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Size | Reserved |
| Size | Port | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
: Parameters :
Expand All @@ -119,7 +119,11 @@ What are valid params for each instruction are better defined in the binary docs
Protocol : A four cc code, currently either "SPI " or "I2C "
Size : length in bytes of the parameters block that follows.
This is unique to a four cc and file version
Reserved : three pad bytes (struct alignment after Size), always 0x00
Port : Sets the output block we will be writing to, this
needs to be in agreement with the pins to get an
output. Not relevant for Pis earlier than the Pi 5
Reserved : three pad bytes (struct alignment after Size), always

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two pad bytes

0x00

Defines are implicitly numbered: the index used later by
COMMAND's "Out idx" field is just the order in which DEFINE
Expand Down Expand Up @@ -211,7 +215,6 @@ What are valid params for each instruction are better defined in the binary docs

## Limitations

- This is currently incompatible with the Pi 5 family
- You can have a maximum of 4 SPI defines
- You can have a maximum of 10 I2C defines
- The delays are blocking and therefore a long splash description will slow down a boot
Expand Down
9 changes: 6 additions & 3 deletions splashasm/splash_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ class SPI_PARAMS(Enum):
CPHA: Param = Param(default=1, allowed_values=(1, 2))
CSPOL: Param = Param(default=1, allowed_values=(1, 2))
FREQ: Param = Param(default=25000000)
PORT: Param = Param(default=0)

class I2C_PARAMS(Enum):
SDA: Param = Param(default=2, allowed_values=(2,))
SCL: Param = Param(default=3, allowed_values=(3,))
ADDR: Param = Param(default=0xFF)
FREQ: Param = Param(default=100000)
PORT: Param = Param(default=1)

class State:
lines: str
Expand Down Expand Up @@ -316,7 +318,7 @@ def _do_emit_binary(self, state, arr_ptr):
print(f"Didn't specify nessercary param {p.name} in {self.__class__.__name__} on in file {self.file_name} on line {self.start_line}, defaulting to {p.value.default}")
values[p.name] = p.value.default
elif p.name in values.keys() and not p.value.check(values[p.name]):
raise ValueError(f"{p.name} cannot be set to {values[p.name]}, the only valid options are {", ".join(str(v) for v in p.value.allowed_values)}")
print(f"{p.name} set to {values[p.name]}, the options are {", ".join(str(v) for v in p.value.allowed_values)} are you sure?")
elif p.name not in values.keys() and p.value.default is None:
values[p.name] = 0xFF

Expand All @@ -331,7 +333,8 @@ def _do_emit_binary(self, state, arr_ptr):
packed += values["FREQ"].to_bytes(4, byteorder='little')

arr_ptr.append(len(packed))
arr_ptr.extend(b'\x00\x00\x00') # reserved (struct padding after param_len)
arr_ptr.append(values["PORT"] & 0xff)
arr_ptr.extend(b'\x00\x00') # reserved (struct padding after param_len)
arr_ptr.extend(packed)

class Delay(Instruction):
Expand Down Expand Up @@ -593,7 +596,7 @@ def pretty_print(data):
def make_file(input_file):
buf = bytearray()
buf.extend(MAGIC) # magic
buf.append(1) # version
buf.append(2) # version

buf.extend(compile_file(input_file))

Expand Down