Skip to content

Instantly share code, notes, and snippets.

@martinandrovich
Created March 9, 2019 02:04
Show Gist options
  • Save martinandrovich/8de7fabb1edd2e25e35a4d3569013317 to your computer and use it in GitHub Desktop.
Save martinandrovich/8de7fabb1edd2e25e35a4d3569013317 to your computer and use it in GitHub Desktop.
Demo of SPI module
// init SPI instance @ 8MHz (
// bps = SYSCLK / (CPSDVSR * (1 + SCR))
SPI* spi_test = spi.new(2);
// send value '110' to PWM1
spi.send(spi_test, PWM1, 110);
// send value '110' to PWM1 and validate
if(!spi.send(spi_test, PWM1, 110))
{
puts("Error!");
}
// request data from ENC1
uint16_t enc1_dat;
enc1_dat = spi.request(spi_test, ENC1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment