change spi pins for atmega164a

This commit is contained in:
Stefan Rupp 2014-03-01 18:11:34 +01:00
parent e200301122
commit bb36d903d0

20
spi.c
View File

@ -41,8 +41,8 @@ static struct spi_comm_t spi_comm;
static inline void set_ack_miso(uint8_t ack) static inline void set_ack_miso(uint8_t ack)
{ {
if (ack) PORTC |= (1<<PC7); if (ack) PORTC |= (1<<PC3);
else PORTC &= ~(1<<PC7); else PORTC &= ~(1<<PC3);
} }
@ -96,7 +96,7 @@ ISR(PCINT1_vect)
{ {
uint8_t tx_obj, rx_obj; uint8_t tx_obj, rx_obj;
if (PINC & (1<<PC1)) { if (PINB & (1<<PB4)) {
// rising edge // rising edge
if ( spi_comm.rxin_buf[0] != SPI_COMM_PADDING ) { if ( spi_comm.rxin_buf[0] != SPI_COMM_PADDING ) {
uint8_t len = spi_comm.rxin_buf[0]; uint8_t len = spi_comm.rxin_buf[0];
@ -150,20 +150,20 @@ int8_t spi_slave_init()
ringbuf_put_nb(rbuff_unused, i); ringbuf_put_nb(rbuff_unused, i);
} }
PCMSK1 |= (1<<PCINT9); PCMSK1 |= (1<<PCINT12);
PCICR |= (1<<PCIE1); PCICR |= (1<<PCIE1);
/* Set MISO output, all others input */ /* Set MISO output, all others input */
DDRD |= (1<<PD2); DDRB |= (1<<PB6);
DDRD &= ~((1<<PD3)|(1<<PD4)); DDRB &= ~((1<<PB7)|(1<<PB5)|(1<<PB4));
/* Enable SPI */ /* Enable SPI */
SPCR = (1<<SPE) | (1<<SPIE); // enable SPI SPCR = (1<<SPE) | (1<<SPIE); // enable SPI
DDRB &= ~(1<<PB5); // ACK_MOSI DDRC &= ~(1<<PC4); // ACK_MOSI
PORTB &= ~(1<<PB5); PORTC &= ~(1<<PC4);
DDRC |= (1<<PC7); // ACK_MISO DDRC |= (1<<PC3); // ACK_MISO
set_ack_miso(0); set_ack_miso(0);
return 1; return 1;
@ -186,7 +186,6 @@ int8_t spi_prepare_to_send(void *data)
} }
else { else {
return -tx_object; return -tx_object;
//PORTB ^= (1<<PB3);
} }
} }
else { else {
@ -206,7 +205,6 @@ int8_t spi_receive(void *data)
} }
else { else {
return (-rx_object); return (-rx_object);
//PORTB ^= (1<<PB3);
} }
} }
else { else {