From 7a1761e054faf44d168557406873434fff47a5ac Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 17 Sep 2017 14:12:05 +0200 Subject: [PATCH] Added option for pullup on MISO pin --- spi.cpp | 4 ++-- spi.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spi.cpp b/spi.cpp index 652435a..16bf25f 100644 --- a/spi.cpp +++ b/spi.cpp @@ -33,7 +33,7 @@ void SPI::setCPHA( bool bCPHA ) } ////////////////////////////////////////////////////////////////////////// -void SPI::init( ClockDiv enmClockDiv /* = ClockDiv::CLKDIV_128 */, Mode enmMode /* = Mode::MODE_0 */, bool bMaster /* = true */, bool bLSBFirst /* = false */ ) +void SPI::init( ClockDiv enmClockDiv /* = ClockDiv::CLKDIV_128 */, Mode enmMode /* = Mode::MODE_0 */, bool bMaster /* = true */, bool bLSBFirst /* = false */, bool bMISOPullup /* = false */ ) { sm_cSCK.setPin( sm_enmSCK ); sm_cMISO.setPin( sm_enmMISO ); @@ -45,7 +45,7 @@ void SPI::init( ClockDiv enmClockDiv /* = ClockDiv::CLKDIV_128 */, Mode enmMode sm_cSS.write( true ); sm_cSCK.setDirection( InOut::Dir::D_OUT, false ); - sm_cMISO.setDirection( InOut::Dir::D_IN, false ); + sm_cMISO.setDirection( InOut::Dir::D_IN, bMISOPullup ); sm_cMOSI.setDirection( InOut::Dir::D_OUT, false ); sm_cSS.setDirection( InOut::Dir::D_OUT, false ); } diff --git a/spi.h b/spi.h index 77c866b..8bc9318 100644 --- a/spi.h +++ b/spi.h @@ -1,7 +1,7 @@ /* * Copyright (c) by BlackMark 2016-2017 -* Date 15/09/2017 -* Version 1.3 +* Date 17/09/2017 +* Version 1.4 */ #ifndef SPI_H @@ -49,7 +49,7 @@ private: static InOutPin sm_cSS; public: - static void init( ClockDiv enmClockDiv = ClockDiv::CLKDIV_128, Mode enmMode = Mode::MODE_0, bool bMaster = true, bool bLSBFirst = false ); + static void init( ClockDiv enmClockDiv = ClockDiv::CLKDIV_128, Mode enmMode = Mode::MODE_0, bool bMaster = true, bool bLSBFirst = false, bool bMISOPullup = false ); static void deinit(); static void setClockDiv( ClockDiv enmClockDiv ); static void setMode( Mode enmMode );