tonton81 / tspislave Goto Github PK
View Code? Open in Web Editor NEWSPI Slave Library for Teensy LC/3.x
License: MIT License
SPI Slave Library for Teensy LC/3.x
License: MIT License
Hi did you test it with LC?
I am just testing your sketch from the example file.
When I select Teensy 3.6 in IDE 1.8.8 it compiles OK, but for 3.2 and LC I get an error
`C:\Users\Andrej\Documents\teensylc-tspislave-fastled\teensylc-tspislave-fastled.ino:11:29: error: 'SPI2' was not declared in this scope
TSPISlave mySPI = TSPISlave(SPI2, miso, mosi, sck, cs, spimode);
^
Error compiling for board Teensy LC.`
Tried to change the pins and SPI[x] to different values, but no effect.
Andrej
First off thank you very much for your work getting the teensy to act as an SPI slave. I'm having a strange issue though and was hoping you would recognize it and have a simple solution.
I have a master Teensy LC sending a few transfers and a Teensy 3.2 slave just sending back a matching response. I believe I understand SPI thoroughly and know responses are expected on the next transfer, but I'm actually getting the responses after 2 transfers. My slave code just responds with the received data and my master code is using the standard SPI library that works with everything else so I'm at a loss.
All I'm doing on the master is:
Serial.Println(SPI.transfer(0xFF), HEX);
Serial.Println(SPI.transfer(0x01), HEX);
Serial.Println(SPI.transfer(0x02), HEX);
Serial.Println(SPI.transfer(0x03), HEX);
Serial.Println(SPI.transfer(0x04), HEX);
but the returned result is:
0x03 // I know the first result will be junk left over from the last sequence, so this is ignored
0x04 // This is where I would expect the 0xFF back from the slave
0xFF // response arrives 1 byte late as well as subsequent bytes
0x01
0x02
My slave code doesn't differ much from the example, the onReceive function looks like this:
void myFunc()
{
while (mySPI.active())
{
if (mySPI.available())
{
uint16_t rx = mySPI.popr();
mySPI.pushr(rx);
}
}
}
From my understanding this code should just reflect any received data back as a response on the next transfer.
The SPImode argument is set to 8 on my slave, setting it to 16 actually makes the response delayed by another 2 bytes so that's not the issue. Thanks in advance for any help you can offer
Teensy 4.0 is here -- looks like the library will need some updating to support it. Right now there are compile errors like the following:
TSPISlave.cpp:54:15: error: 'IRQ_SPI0' was not declared in this scope
spi_irq = IRQ_SPI0;
TSPISlave.cpp: In member function 'bool TSPISlave::setSlaveMISO(uint8_t)':
TSPISlave.cpp:115:38: error: 'PORT_PCR_MUX' was not declared in this scope
CORE_PIN1_CONFIG = PORT_PCR_MUX(2);
TSPISlave.cpp: In member function 'bool TSPISlave::setSlaveMOSI(uint8_t)':
TSPISlave.cpp:141:24: error: 'PORT_PCR_DSE' was not declared in this scope
CORE_PIN0_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2);
I assume more #ifdef
s are required to setup SPI that are specific to the Teensy 4.0 hardware. Not sure how to fix this myself as I don't know the intricacies of configuring this, unfortunately.
Any plans for supporting Teensy 4.0 in the near future?
Hi I was wondering if its possible to change the ss polarity and phase using this library. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.