Created
March 15, 2017 17:34
-
-
Save rafacouto/2b6b7da10813ddb6483898d2135e7f58 to your computer and use it in GitHub Desktop.
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
-- clock_div: SPI clock divider, f(SPI) = 80 MHz / clock_div | |
function spi_test(clock_div) | |
spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_HIGH, 8, clock_div, spi.FULLDUPLEX) | |
for n=0,256 do | |
r = { spi.send(1, n) } | |
--print(n, r[2]) | |
if n > 0 and ((n-1)*2) % 256 ~= r[2] then print("ERROR!") ; return end | |
end | |
print("Test OK! :)") | |
end | |
-- test with ATtiny 2313: | |
-- > spi_test(19) | |
-- ERROR! | |
-- > spi_test(20) | |
-- Test OK! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment