mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2025-04-21 12:27:27 +03:00
atusb/fw/: added "lazy enabling" of UART-SPI after ATUSB_GPIO
- spi.h (spi_off), spi.c: disable the UART - spi.c (spi_initialized, spi_begin, spi_init): initialize the UART if necessary - board_app.c (gpio): call spi_off to disable the UART instead of open-coding the operation - board_app.c (gpio): don't explicitly re-enable the UART but defer it to the next communication
This commit is contained in:
@@ -19,8 +19,13 @@
|
||||
#include "spi.h"
|
||||
|
||||
|
||||
static int spi_initialized = 0;
|
||||
|
||||
|
||||
void spi_begin(void)
|
||||
{
|
||||
if (!spi_initialized)
|
||||
spi_init();
|
||||
CLR(nSS);
|
||||
}
|
||||
|
||||
@@ -41,6 +46,13 @@ void spi_end(void)
|
||||
}
|
||||
|
||||
|
||||
void spi_off(void)
|
||||
{
|
||||
spi_initialized = 0;
|
||||
UCSR1B = 0;
|
||||
}
|
||||
|
||||
|
||||
void spi_init(void)
|
||||
{
|
||||
SET(nSS);
|
||||
@@ -55,4 +67,6 @@ void spi_init(void)
|
||||
UCSR1B = 1 << RXEN1 | 1 << TXEN1;
|
||||
/* enable receiver and transmitter */
|
||||
UBRR1 = 0; /* reconfirm the bit rate */
|
||||
|
||||
spi_initialized = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user