Skip to content

Conversation

@deadprogram
Copy link
Member

Adds support for the si5351 I2C programmable clock generator using code from @chiefMarlin which used code from @conotto which somehow never got merged.

Thank you everyone!

si5351/si5351.go Outdated
"math"

"tinygo.org/x/drivers"
"tinygo.org/x/drivers/internal/legacy"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is known to cause heap allocations, shall we try and avoid this from start?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point @ysoldak I just added another commit to use the regmap package instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated again with the latest code from #801

Adds support for the si5351 I2C programmable clock generator using code
from @chiefMarlin which used code from @conotto which somehow never got merged.

Thank you everyone!

Signed-off-by: deadprogram <[email protected]>
Copy link
Contributor

@soypat soypat left a comment

Choose a reason for hiding this comment

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

Very nice! Love to see regmap in use! FYI got a couple suggestions on how to avoid most if not all allocations

@deadprogram
Copy link
Member Author

Appears that there are no further heap allocations now. Should be ready to go.


// Power down all output drivers
buf := []byte{CLK0_CONTROL, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}
d.bus.Tx(uint16(d.Address), buf, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

First real use of regmap in the wild!

I was trying to wrap my head around it and how could I use it in cases like #800 (as suggested).

I basically hit this same problem -- can't just use regmap functions everywhere, consistently, have to fall back to raw d.bus.Tx here and there => have to keep both rw and bus. And that sort of defies the purpose, to me at least...

We may be better off implementing helper methods for reading and writing variable size slices, like this, but in internal package somewhere to be reusable?
https://github.com/tinygo-org/drivers/blob/dev/lsm9ds1/lsm9ds1.go#L216

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that @soypat is working on something like that. In the meantime, we can add in the future if we find it is needed.

@deadprogram
Copy link
Member Author

Any other feedback or can this get merged now?

Copy link
Contributor

@ysoldak ysoldak left a comment

Choose a reason for hiding this comment

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

LGTM

@soypat soypat merged commit 408851a into dev Nov 10, 2025
1 check passed
@soypat soypat deleted the si5351-redux branch November 10, 2025 11:04
@soypat
Copy link
Contributor

soypat commented Nov 10, 2025

Good stuff! Curious how the compiler is managing to not escape an array that is being passed into an interface. Very curious indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants