void SPI0_Handler(void) { uint16_t us_data; uint32_t us_tx_data; uint8_t p_pcs; uint32_t status = spi_read_status(_spi_base); if (status & SPI_SR_RDRF) { if ( spi_read( _spi_base, &us_data, &p_pcs ) == SPI_OK ) { // store received byte fifo_push_uint8(_this->_spi_rx_fifo_desc, us_data); // If handler defined - call it with instance and received byte. if (_this->_call_back) { _this->_call_back(_this, (uint8_t)us_data); } } } if (status & SPI_SR_TDRE) { // more bytes to send? if ( fifo_pull_uint32(_this->_spi_tx_fifo_desc, &us_tx_data) == FIFO_OK ) { _spi_base->SPI_TDR = us_tx_data; } else { // No // Disable SPI TX interrupt spi_disable_interrupt(_spi_base, SPI_IDR_TDRE); _spi_active = 0; } } }
__interrupt #endif static void int_handler_usart(void) { if( USART->csr & AVR32_USART_RXRDY_MASK ) { U8 i, status; i = (USART->rhr & AVR32_USART_RHR_RXCHR_MASK) >> AVR32_USART_RHR_RXCHR_OFFSET; status = fifo_push_uint8(&fifo_desc_usart, i); if( status==FIFO_ERROR_OVERFLOW ) { // error gpio_clr_gpio_pin(RX_LED); gpio_clr_gpio_pin(TX_LED); } }