From 9ef529779f0cefa6dfe900a50b53e159c19a87a5 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Fri, 15 Sep 2017 15:36:16 +0200 Subject: [PATCH] Added deinit function --- spi.cpp | 11 +++++++++++ spi.h | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spi.cpp b/spi.cpp index ebe0d9d..652435a 100644 --- a/spi.cpp +++ b/spi.cpp @@ -65,6 +65,17 @@ void SPI::init( ClockDiv enmClockDiv /* = ClockDiv::CLKDIV_128 */, Mode enmMode SPCR |= ( 1 << SPE ); } +////////////////////////////////////////////////////////////////////////// +void SPI::deinit() +{ + SPCR = 0; + + sm_cSCK.setDirection( InOut::Dir::D_IN, false ); + sm_cMISO.setDirection( InOut::Dir::D_IN, false ); + sm_cMOSI.setDirection( InOut::Dir::D_IN, false ); + sm_cSS.setDirection( InOut::Dir::D_IN, false ); +} + ////////////////////////////////////////////////////////////////////////// void SPI::setClockDiv( ClockDiv enmClockDiv ) { diff --git a/spi.h b/spi.h index 7e902af..77c866b 100644 --- a/spi.h +++ b/spi.h @@ -1,7 +1,7 @@ /* * Copyright (c) by BlackMark 2016-2017 -* Date 14/09/2017 -* Version 1.2 +* Date 15/09/2017 +* Version 1.3 */ #ifndef SPI_H @@ -50,6 +50,7 @@ private: public: static void init( ClockDiv enmClockDiv = ClockDiv::CLKDIV_128, Mode enmMode = Mode::MODE_0, bool bMaster = true, bool bLSBFirst = false ); + static void deinit(); static void setClockDiv( ClockDiv enmClockDiv ); static void setMode( Mode enmMode ); static void setMaster( bool bMaster );