SPI not included in Ardunio language

What does this mean? which is on the specs of the Ardunio mini pro page

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

What does it mean by not sported in the ardunio language, there is a SPI.h libuary to import that supports SPI? Does it just mean SPI is not sported in the core ardunio code without includes?

Cheers

Oddly worded - It's not built-into the language, but is fully supported by the SPI library; just include SPI.h.

Some of the official documentation pages are out of date, and leave an impression that doesn't reflect current reality; this may be one of those cases.

Cool so its not just me it is what i thought you just need the spi.h library to run it.

I was asking because I am trying to get SPI working using as a base the “blink with out delay example” I was simply going to add some code to it so that a LED strip blinks in time using SPI.

the thing is that as soon as I add the line

SPI.begin();

the on-board LED stops flashing. Looking at the specs I can see on-board LED is pin 13 which over laps with SPI. So i get why it does not work as it is setting pin 13 so something other than output.

One thing I dont currently understand is the

SPI.transfer(buffer, size).

i want to send 32bit frames, on a PC I would simple save the value in to a variable and write it out to the SPI bus. But Ardunio is new to me so not sure how you go about this and what it means by buffer and size?

#include <SPI.h>



/* Blink without Delay

 Turns on and off a light emitting diode (LED) connected to a digital
 pin, without using the delay() function.  This means that other code
 can run at the same time without being interrupted by the LED code.

 The circuit:
 * Use the onboard LED.
 * Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino model, check
  the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products

 created 2005
 by David A. Mellis
 modified 8 Feb 2010
 by Paul Stoffregen
 modified 11 Nov 2013
 by Scott Fitzgerald
 modified 9 Jan 2017
 by Arturo Guadalupi


 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */

// constants won't change. Used here to set a pin number :
const int ledPin =  LED_BUILTIN;// the number of the LED pin

// Variables will change :
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change :
const long interval = 100;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

// start the SPI library:
//  SPI.begin();


}

void loop() {
  
      ledState = HIGH;
    
    digitalWrite(ledPin, ledState);
  

//SPI.transfer(0);

}

buffer is just the array of bytes you want to send and size is how many bytes are in that array.

Ahh

so a 32byte array called LED would be sent like

spi.transfer(LED, 4)

DevilWAH:
Ahh

so a 32byte array called LED would be sent like

spi.transfer(LED, 4)

It would look like that for a 32 bit array.

DevilWAH:

spi.transfer(LED, 4)

It would be safer to use

spi.transfer(LED, sizeof(LED))

And while the compiler would not care “LED” is not a very meaningful name for anything other than those little plastic things with two wires that light up.

…R

Delta_G:
It would look like that for a 32 bit array.

For some one who has worked with 32bit IP address for 15 year you would think I would be able to get my bits n bytes correct.

I meant bit but hands typed byte :slight_smile:

Robin2:
It would be safer to use

spi.transfer(LED, sizeof(LED))

That's a nice nugget of information to remember. I am learning that in my python/perl and other programming on PC's I have been very lazy and just let the interpreters / compilers to handle a lot of the "stuff". I am starting to see that to be successful with Ardunio you need to be more precise and tidy.

Robin2:
And while the compiler would not care "LED" is not a very meaningful name for anything other than those little plastic things with two wires that light up.

Its actually for running addressable LED strips, but at the moment all I am attempting is saving the brightness, Red code, blue code, green code (each a 8bit value) in to a single 32bit variable and then writing it out via SPI.

your right not the best of variable names but the entire code is only about 8 lines and I do have a nice two lines of comment describing it.

thanks for all your input it really has helped me on my way.