Skip to content

Spi slave improvments #6580

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

Merged
merged 11 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from 8 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
9 changes: 8 additions & 1 deletion libraries/SPISlave/src/SPISlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void SPISlaveClass::_s_status_tx(void *arg)
{
reinterpret_cast<SPISlaveClass*>(arg)->_status_tx();
}

void SPISlaveClass::begin()
{
hspi_slave_onData(&_s_data_rx);
Expand All @@ -72,6 +71,14 @@ void SPISlaveClass::begin()
hspi_slave_onStatusSent(&_s_status_tx);
hspi_slave_begin(4, this);
}
void SPISlaveClass::begin(uint8_t statusLength)
{
hspi_slave_onData(&_s_data_rx);
hspi_slave_onDataSent(&_s_data_tx);
hspi_slave_onStatus(&_s_status_rx);
hspi_slave_onStatusSent(&_s_status_tx);
hspi_slave_begin(statusLength, this);
}
void SPISlaveClass::end()
{
hspi_slave_onData(nullptr);
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 begin(uint8_t statusLength);
void end();
void setData(uint8_t * data, size_t len);
void setData(const char * data)
Expand Down
3 changes: 1 addition & 2 deletions libraries/SPISlave/src/hspi_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ void ICACHE_RAM_ATTR _hspi_slave_isr_handler(void *arg)

void hspi_slave_begin(uint8_t status_len, void * arg)
{
status_len &= 7;
if(status_len > 4) {
status_len = 4; //max 32 bits
}
Expand All @@ -85,7 +84,7 @@ void hspi_slave_begin(uint8_t status_len, void * arg)
pinMode(MISO, SPECIAL);
pinMode(MOSI, SPECIAL);

SPI1S = SPISE | SPISBE | 0x3E0; // SPI_SLAVE_REG
SPI1S = SPISE | SPISBE | SPISRBIE | SPISWBIE | SPISRSIE | SPISWSIE | SPISTRIE; // 0x3E0 // SPI_SLAVE_REG
SPI1U = SPIUMISOH | SPIUCOMMAND | SPIUSSE; // SPI_USER_REG
SPI1CLK = 0;
SPI1U2 = (7 << SPILCOMMAND); // SPI_USER2_REG
Expand Down