Last active
December 20, 2015 19:29
-
-
Save taylortrimble/6183237 to your computer and use it in GitHub Desktop.
I just want it to spit out SSPADD for my current use case. There is only one "formula", but I'll make it extensible. I tried to make this a full Ruby repo at one point, but it's more of a Gist. 😄
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
# I just want it to spit out SSPADD for my current use case. There is only one "formula", but I'll make it extensible. | |
def get_bits(number_of_bits_you_have, fosc, target_speed, formula) # returns SSPADD | |
case formula | |
when :master | |
result = (fosc / (4 * target_speed)) - 1 | |
else | |
# bad news bears | |
end | |
if result >= 2 ** number_of_bits_you_have | |
# bad news bears | |
end | |
result | |
end | |
result = get_bits(7, 40e6, 10e3, :master) | |
puts result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment