Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPISlave.end() added #4248

Merged
merged 16 commits into from
Mar 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libraries/SPISlave/src/SPISlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ void SPISlaveClass::begin()
hspi_slave_onStatusSent(&_s_status_tx);
hspi_slave_begin(4, this);
}
void SPISlaveClass::end()
{
hspi_slave_onData(nullptr);
hspi_slave_onDataSent(nullptr);
hspi_slave_onStatus(nullptr);
hspi_slave_onStatusSent(nullptr);
hspi_slave_end();
}
void SPISlaveClass::setData(uint8_t * data, size_t len)
{
if(len > 32) {
Expand Down
1 change: 1 addition & 0 deletions libraries/SPISlave/src/SPISlave.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class SPISlaveClass
{}
~SPISlaveClass() {}
void begin();
void end();
void setData(uint8_t * data, size_t len);
void setData(const char * data)
{
Expand Down
17 changes: 17 additions & 0 deletions libraries/SPISlave/src/hspi_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ void hspi_slave_begin(uint8_t status_len, void * arg)
ETS_SPI_INTR_ENABLE();
}

void hspi_slave_end()
{
ETS_SPI_INTR_DISABLE();
ETS_SPI_INTR_ATTACH(NULL, NULL);

pinMode(SS, INPUT);
pinMode(SCK, INPUT);
pinMode(MISO, INPUT);
pinMode(MOSI, INPUT);

// defaults
SPI1S = 0;
SPI1U = SPIUSSE | SPIUCOMMAND;
SPI1S1 = 0;
SPI1P = B110;
}

void hspi_slave_setStatus(uint32_t status)
{
SPI1WS = status;
Expand Down
3 changes: 3 additions & 0 deletions libraries/SPISlave/src/hspi_slave.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
//Start SPI SLave
void hspi_slave_begin(uint8_t status_len, void * arg);

//End SPI SLave
void hspi_slave_end();

//set the status register so the master can read it
void hspi_slave_setStatus(uint32_t status);

Expand Down