Si5351
Si5351 copied to clipboard
Eliminate do_div, floating point and malloc()
Perhaps you'd like to try these changes, which probably reduce the AVR binary size quite a bit and perhaps improve performance. I admit I have not yet compiled or tested them on AVR; they're derived from a PSoC 5LP variation I'm working with.
Replace floating point with fixed-point. Eliminate use of do_div() macro. Use 64-bit long long types for above. Refactor frequency programming; eliminate malloc/free. Note also that I've tweaked the handling of PLLB and CLK1/CLK2; not sure that's exactly right yet but going to test it.
These changes are directly derived from code that's working on PSoC 5LP, modulo different I2C API.
Thanks much for all of your work on this. I'm going to leave it open for now, just because I'm working hard on the Arduino branch of the code, and want to get those commitments finished before I get back to this code. Once the Arduino library additions/fixes are done, I'll look at integrating this pull request, then pulling over the changes from the Arduino library.
Actually I tend to think the float vs fixed-point change makes little size difference, but I'll try build it for AVR at some point.
... and I might get my suggested code to actually compile on an AVR :-)
Ah, it was easy. I compared the total binary size on AVR for float vs fixed ref_freq adjustment - as suspected, it reduced the total binary a bit - around 330 bytes. I also suspect it performs better but haven't measured.
OK, I got my proposed changes to compile for AVR. Comparing before/after, the binary shrunk around 1000 bytes (optimization -O1). Now I'll have to connect an ATmega8 to an Si5351 and see if it works LOL