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

SPI slave ISR not raised #296

Closed
aznoohwee opened this issue Jul 3, 2018 · 3 comments
Closed

SPI slave ISR not raised #296

aznoohwee opened this issue Jul 3, 2018 · 3 comments

Comments

@aznoohwee
Copy link

I found that IRQ is not raised when simulating firmware operating as a SPI slave.

PR is WIP to see if there is anything else that needs to be done but here is a quick fix.

static avr_cycle_count_t avr_spi_raise(struct avr_t * avr, avr_cycle_count_t when, void * param)
{
avr_spi_t * p = (avr_spi_t *)param;

if (avr_regbit_get(avr, p->spe)) {
	// in master mode, any byte is sent as it comes..
	if (avr_regbit_get(avr, p->mstr)) {
		avr_raise_interrupt(avr, &p->spi);
		avr_raise_irq(p->io.irq + SPI_IRQ_OUTPUT, avr->data[p->r_spdr]);
	}
    // in slave mode, bytes are sent but no interrupt is raised
    // TODO check for state of SS line??
    else {
		avr_raise_irq(p->io.irq + SPI_IRQ_OUTPUT, avr->data[p->r_spdr]);
    }
}
return 0;

}

@aznoohwee
Copy link
Author

Related to #222

@buserror
Copy link
Owner

buserror commented Jul 5, 2018

Good catch -- to be fair I've haven't had to use spi slave in a long time, so that probably had been left as 'an exercise to the reader' ;-)
Please PR, even if it's not all polished, as long as you are happy it works...

@aznoohwee
Copy link
Author

Closing this issue in favor of #300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants