Coder Social home page Coder Social logo

QUESTION on using SoftSPI about digitalio HOT 4 CLOSED

greiman avatar greiman commented on June 26, 2024
QUESTION on using SoftSPI

from digitalio.

Comments (4)

greiman avatar greiman commented on June 26, 2024

You must handle CS just like hardware SPI. You can have multiple devices with different CS pins. They must all use the same SPI mode.

You only need transfer(). It works like hardware transfer().

  spi.send(data);
  // same as this transfer call but maybe a bit faster.
  spi.transfer(data);
  data = spi.receive();
  // same as this transfer call but maybe a bit faster.
  data = spi.transfer(0xff);

from digitalio.

mjs513 avatar mjs513 commented on June 26, 2024

Hi. Thanks for getting back to me. Did what you said this morning with the transfers just like normal SPI and it worked. Got confused when looking at the example (and working late at night). Now I am trying to get it work from within a 9250 library.

I declared the SoftSPI as spi in the main sketch but now getting spi not defined errors from within the library. How do I get it work? Any ideas. Here's the exact error


`C:\Users\CyberPalin\Documents\Arduino\libraries\MPU9250SPI\mpu9250_spi.cpp: In member function 'unsigned int mpu9250_spi::WriteReg(uint8_t, uint8_t)':

C:\Users\CyberPalin\Documents\Arduino\libraries\MPU9250SPI\mpu9250_spi.cpp:24:3: error: 'spi' was not declared in this scope

   spi.transfer(WriteAddr);`

Thanks
Mike

from digitalio.

greiman avatar greiman commented on June 26, 2024

Modifying a library to work with SoftSPI may not be easy. I can't guess about the structure of your 9250 library.

I really don't have time to help you convert a library from hardware SPI to SoftSPI.

A first step is to add an extern statement to the library.

If spi is define in your sketch like this:

#include "DigitalIO.h"
SoftSPI<7, 8, 9, 0> spi;

You will need something like this to define spi in the library.

#include "DigitalIO.h"
extern SoftSPI<7, 8, 9, 0> spi;

Good luck, sorry I don't have time to help more.

from digitalio.

mjs513 avatar mjs513 commented on June 26, 2024

Bill appreciate any help. Really wasn't looking for you to convert the library, I got that one. Just didn't know how to do the referencing. Think I can go from there.

Thanks again
Mike

UPDATE: Just to let you know I added the extern statement to the library (already did the other part of the conversion :) ) and it work perfectly.
Thanks again.

from digitalio.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.