Permalink
Browse files

Found the reverse data order flag and set it

  • Loading branch information...
kcuzner committed Aug 4, 2013
1 parent 4d09663 commit 023e6b78edc25c215b9ef025fbc60befbddc391e
Showing with 8 additions and 3 deletions.
  1. +1 −1 src/main.c
  2. +7 −2 src/psx.c
View
@@ -43,7 +43,7 @@ void psx_on_att(void)
void psx_on_recv(uint8_t received)
{
- if (received == 0x80)
+ if (received == 0x01)
{
PORTD ^= (1 << PD0);
}
View
@@ -33,7 +33,8 @@ void psx_setup(void)
//set up spi for slave mode
DDRB |= (1 < PB2); //miso is output
- SPCR = (1 << SPIE) | (1 << SPE) | (1 << CPOL) | (1 << CPHA); //enable spi interrupt, enable spi, read on rising edge, clock polarity inverted
+ //enable spi interrupt, enable spi, data order reversed, read on rising edge, clock polarity inverted
+ SPCR = (1 << SPIE) | (1 << SPE) | (1 << DORD) | (1 << CPOL) | (1 << CPHA);
}
void psx_main(void)
@@ -48,7 +49,11 @@ void psx_main(void)
void psx_ack(void)
{
- ackCounter = 2; //this is arbitrary...wait for two clock cycles before releasing ack
+ //we want it to go low for 10uS
+ //source of this number:
+ // 2uS is clock period for 500Khz and 10uS is clock period for 100Khz
+ // Since 2uS * 8 == 16 > 10, we can use 10uS and avoid bleeding into the
+ // next byte.
}
char psx_send(uint8_t data)

0 comments on commit 023e6b7

Please sign in to comment.