diff --git a/spi.cpp b/spi.cpp index 3797077..ddc0e47 100644 --- a/spi.cpp +++ b/spi.cpp @@ -29,13 +29,6 @@ void SPI::setCPHA( bool bCPHA ) ////////////////////////////////////////////////////////////////////////// void SPI::init( ClockDiv enmClockDiv /* = ClockDiv::CLKDIV_128 */, Mode enmMode /* = Mode::MODE_0 */, bool bMaster /* = true */, bool bLSBFirst /* = false */ ) { - setClockDiv( enmClockDiv ); - setMode( enmMode ); - setMaster( bMaster ); - setBitOrder( bLSBFirst ); - - SPCR |= ( 1 << SPE ); - if( bMaster ) { InOut::writePin( sm_enmSS, true ); @@ -52,6 +45,13 @@ void SPI::init( ClockDiv enmClockDiv /* = ClockDiv::CLKDIV_128 */, Mode enmMode InOut::setPinDirection( sm_enmMOSI, InOut::Dir::D_IN, false ); InOut::setPinDirection( sm_enmSS, InOut::Dir::D_IN, true ); } + + setClockDiv( enmClockDiv ); + setMode( enmMode ); + setMaster( bMaster ); + setBitOrder( bLSBFirst ); + + SPCR |= ( 1 << SPE ); } ////////////////////////////////////////////////////////////////////////// diff --git a/spi.h b/spi.h index 9f0336b..5bcff36 100644 --- a/spi.h +++ b/spi.h @@ -1,7 +1,7 @@ /* -* Copyright (c) by BlackMark 2016 -* Date 26/05/2016 -* Version 1.0 +* Copyright (c) by BlackMark 2016-2017 +* Date 14/09/2017 +* Version 1.1 */ #ifndef SPI_H