mirror of
https://github.com/PotentiaRobotics/engine-software.git
synced 2025-04-09 23:00:21 -04:00
36 lines
688 B
C++
36 lines
688 B
C++
#include <SPI.h>
|
|
|
|
void setup (void)
|
|
{
|
|
|
|
digitalWrite(SS, HIGH); // ensure SS stays high for now
|
|
|
|
// Put SCK, MOSI, SS pins into output mode
|
|
// also put SCK, MOSI into LOW state, and SS into HIGH state.
|
|
// Then put SPI hardware into Master mode and turn SPI on
|
|
SPI.begin ();
|
|
|
|
// Slow down the master a bit
|
|
SPI.setClockDivider(SPI_CLOCK_DIV8);
|
|
|
|
} // end of setup
|
|
|
|
|
|
void loop (void)
|
|
{
|
|
|
|
char c;
|
|
|
|
// enable Slave Select
|
|
digitalWrite(SS, LOW); // SS is pin 10
|
|
|
|
// send test string
|
|
for (const char * p = "Hello, world!\n" ; c = *p; p++)
|
|
SPI.transfer (c);
|
|
|
|
// disable Slave Select
|
|
digitalWrite(SS, HIGH);
|
|
|
|
delay (1000); // 1 seconds delay
|
|
} // end of loop
|