Hi ho!
Looks like libmaple.h needs to be included to do SPI stuff -- perhaps either HardwareSPI.h should require it, or the documentation at http://leaflabs.com/docs/spi could use a comment?
Hi ho!
Looks like libmaple.h needs to be included to do SPI stuff -- perhaps either HardwareSPI.h should require it, or the documentation at http://leaflabs.com/docs/spi could use a comment?
yo star,
The documentation needs to get cleaned up, you shouldn't need to include anything. Can you try this sketch and see if the SPI works for you?
#define CS 10
byte buf[] = "Hello world!";
HardwareSPI spi1(1);
void setup() {
/* Set up chip select as output */
pinMode(CS, OUTPUT);
/* CS is usually active low, so initialize it high */
digitalWrite(CS, HIGH);
/* Initialize SPI */
spi1.begin(SPI_4_5MHZ, LSBFIRST, 0);
}
void loop() {
/* Send message */
digitalWrite(CS, LOW);
spi1.send(buf, sizeof buf);
digitalWrite(CS,HIGH);
delay(1000);
}
Let me know if this doesn't work for you.
BTW, we'll add this to the documentation, but there's also another form of the HardwareSPI constructor that sets up the SPI at the following default values:
speed: 1.125 MHZ
endianness: MSB
SPI Mode: 0
You can call it just by doing
spi1.begin()
Yep, this compiles & uploads fine.
I was getting some errors that said something about uint8 and uint32 being unrecognized types, that disappeared after I include libmaple. This does not seem to cause those errors.
shouldnt toggling chip select be part of the spi.send()?
also, star, could you give more info on the type errors? was that from the ide?
You must log in to post.