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