diff --git a/AT42QT1244.c b/AT42QT1244.c index 89b2fb405..7c8d43064 100755 --- a/AT42QT1244.c +++ b/AT42QT1244.c @@ -1,6 +1,6 @@ /*!\file AT42QT1244.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief AT42QT1244 Driver code @@ -24,17 +24,17 @@ I2C_slave AT42QT1244_hal = { { pNull, I2C_ADDR(AT42QT1244_BASE_ADDR), I2C_slave_ /*!\brief 16bits CRC calculation for AT42QT1244 -** \param[in] crc - current crc value -** \param[in] data - new data for crc -** \return New CRC value ** \details 16bits crc calculation. Initial crc entry must be 0. ** The message is not augmented with 'zero' bits. polynomial = X16 + X15 + X2 + 1 ** Repeat this function for each data block byte, folding the result back into the call parameter crc +** \param[in] crc - current crc value +** \param[in] data - new data for crc +** \return New CRC value **/ static uint16_t crc16(uint16_t crc, uint8_t data) { - crc ^= (uint16_t) (data) * 0x100; - for (int i = 7 ; i > 0 ; i--) + crc ^= (uint16_t) data * 0x100; + for (int i = 7 ; i >= 0 ; i--) { if (crc & 0x8000) { crc = (crc << 1) ^ 0x1021; } else { crc <<= 1; } @@ -112,7 +112,7 @@ FctERR AT42QT1244_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_AT42QT1244 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/BMP180.c b/BMP180.c index 7df780641..378ae0fa7 100755 --- a/BMP180.c +++ b/BMP180.c @@ -1,6 +1,6 @@ /*!\file BMP180.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief BMP180 Driver code @@ -81,7 +81,7 @@ FctERR BMP180_Read_Word(uint16_t * data, uint16_t addr) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_BMP180 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/DRV2605L.c b/DRV2605L.c index a8eacc0b3..08cc42647 100755 --- a/DRV2605L.c +++ b/DRV2605L.c @@ -1,6 +1,6 @@ /*!\file DRV2605L.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief DRV2605L Driver code @@ -62,7 +62,7 @@ FctERR DRV2605L_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_DRV2605L in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/DS_GPMS.c b/DS_GPMS.c index 58ce9b8f9..cb04574af 100755 --- a/DS_GPMS.c +++ b/DS_GPMS.c @@ -1,6 +1,6 @@ /*!\file DS_GPMS.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief DS-GPM.S Driver code @@ -62,7 +62,7 @@ FctERR GPMS_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_GPMS in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/FM24C.c b/FM24C.c index 2591588f5..b71b2865b 100755 --- a/FM24C.c +++ b/FM24C.c @@ -1,6 +1,6 @@ /*!\file FM24C.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief FM24C Driver code @@ -14,7 +14,7 @@ #if defined(HAL_I2C_MODULE_ENABLED) #if defined(I2C_FM24C) /****************************************************************/ -#if defined(I2C_MB85RC256V) +#if defined(I2C_MB85RC256V) && !defined(NO_WARN_I2C_DRIVERS) #warning "FM24CxxB -> Defined along with MB85RC256V: use with caution, might have same I2C addresses if on same I2C bus!!!" #endif /****************************************************************/ @@ -106,7 +106,7 @@ FctERR FM24C_ReadWrite(uint8_t * data, uint16_t addr, uint16_t nb, bool wr) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_FM24C in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/MB85RC256V.c b/MB85RC256V.c index 1f8b61291..1a00f87c6 100755 --- a/MB85RC256V.c +++ b/MB85RC256V.c @@ -1,6 +1,6 @@ /*!\file MB85RC256V.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief MB85RC256V Driver code @@ -13,7 +13,7 @@ #if defined(HAL_I2C_MODULE_ENABLED) #if defined(I2C_MB85RC256V) /****************************************************************/ -#if defined(I2C_FM24C) +#if defined(I2C_FM24C) && !defined(NO_WARN_I2C_DRIVERS) #warning "MB85RC256V -> Defined along with FM24CxxB: use with caution, might have same I2C addresses if on same I2C bus!!!" #endif /****************************************************************/ @@ -78,7 +78,7 @@ FctERR MB85RC256V_Read_ID(uint8_t * data) } /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_MB85RC256V in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/MCP4725.c b/MCP4725.c index dd9339cdc..736706ffa 100755 --- a/MCP4725.c +++ b/MCP4725.c @@ -1,6 +1,6 @@ /*!\file MCP4725.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief MCP4725 Driver code @@ -73,7 +73,7 @@ FctERR MCP4725_General_Call(uint8_t cmd) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_MCP4725 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/MCP9808.c b/MCP9808.c index 58cb6d0a2..0b7a1d797 100755 --- a/MCP9808.c +++ b/MCP9808.c @@ -1,6 +1,6 @@ /*!\file MCP9808.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief MCP9808 Driver code @@ -97,7 +97,7 @@ FctERR MCP9808_Read(uint16_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_MCP9808 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/MCP9808_proc.h b/MCP9808_proc.h index ae2b6e4bf..d38835607 100755 --- a/MCP9808_proc.h +++ b/MCP9808_proc.h @@ -35,8 +35,8 @@ // ***************************************************************************** typedef struct MCP9808_proc { float Temperature; - bool TLower; bool TUpper; + bool TLower; bool TCrit; bool NewData; uint32_t hLast; diff --git a/MTCH6102.c b/MTCH6102.c index 5e4de6609..387b0330b 100755 --- a/MTCH6102.c +++ b/MTCH6102.c @@ -1,6 +1,6 @@ /*!\file MTCH6102.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief MTCH6102 Driver code @@ -65,7 +65,7 @@ FctERR MTCH6102_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_MTCH6102 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/PCA9624.c b/PCA9624.c index ab1bf7597..fb23c271a 100755 --- a/PCA9624.c +++ b/PCA9624.c @@ -1,6 +1,6 @@ /*!\file PCA9624.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief PCA9624 Driver code @@ -13,7 +13,7 @@ #if defined(HAL_I2C_MODULE_ENABLED) #if defined(I2C_PCA9624) /****************************************************************/ -#if defined(I2C_PCA9685) +#if defined(I2C_PCA9685) && !defined(NO_WARN_I2C_DRIVERS) #warning "PCA9624 -> Multiple PCA96xx types: use with caution if using CALL addresses if on same I2C bus!!!" #endif /****************************************************************/ @@ -66,7 +66,7 @@ FctERR PCA9624_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_PCA9624 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/PCA9685.c b/PCA9685.c index a186c6a6c..dee0aa84b 100755 --- a/PCA9685.c +++ b/PCA9685.c @@ -1,6 +1,6 @@ /*!\file PCA9685.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief PCA9685 Driver code @@ -13,7 +13,7 @@ #if defined(HAL_I2C_MODULE_ENABLED) #if defined(I2C_PCA9685) /****************************************************************/ -#if defined(I2C_PCA9624) +#if defined(I2C_PCA9624) && !defined(NO_WARN_I2C_DRIVERS) #warning "PCA9685 -> Multiple PCA96xx types: use with caution if using CALL addresses if on same I2C bus!!!" #endif /****************************************************************/ @@ -65,7 +65,7 @@ FctERR PCA9685_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_PCA9685 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/PCF8523.c b/PCF8523.c index 294f264e3..26287e9b7 100755 --- a/PCF8523.c +++ b/PCF8523.c @@ -1,6 +1,6 @@ /*!\file PCF8523.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief PCF8523 Driver code @@ -62,7 +62,7 @@ FctERR PCF8523_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_PCF8523 in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/README.md b/README.md index 84a2528a7..361967280 100755 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ ARM I2C Drivers for various components - use $CPNT$_Init() once - start using $CPNT$_funcs() +- if you find warning messages annoying, you could define NO_WARN_I2C_DRIVERS (underscores between words) in compiler options to hide warning messages + ## Remarks diff --git a/template/CPNT.c.txt b/template/CPNT.c.txt index fb05b099e..b34fd96b1 100755 --- a/template/CPNT.c.txt +++ b/template/CPNT.c.txt @@ -1,6 +1,6 @@ /*!\file $CPNT$.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief $CPNT$ Driver code @@ -71,7 +71,7 @@ FctERR $CPNT$_Read(uint8_t * data, uint16_t addr, uint16_t nb) /****************************************************************/ -#else +#elif !defined(NO_WARN_I2C_DRIVERS) #warning "You have to define I2C_$CPNT$ in globals.h with an I2C instance for this to work!" #endif #endif diff --git a/template/CPNT.h.txt b/template/CPNT.h.txt index 17531dcbc..ec5babc12 100755 --- a/template/CPNT.h.txt +++ b/template/CPNT.h.txt @@ -1,6 +1,6 @@ /*!\file $CPNT$.h ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief $CPNT$ Driver declarations diff --git a/template/CPNT_ex.c.txt b/template/CPNT_ex.c.txt index ec6ec36ee..09e9e16a0 100755 --- a/template/CPNT_ex.c.txt +++ b/template/CPNT_ex.c.txt @@ -1,6 +1,6 @@ /*!\file $CPNT$_ex.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief $CPNT$ Driver extensions code diff --git a/template/CPNT_ex.h.txt b/template/CPNT_ex.h.txt index 91908fbf1..8db21c4bf 100755 --- a/template/CPNT_ex.h.txt +++ b/template/CPNT_ex.h.txt @@ -1,6 +1,6 @@ /*!\file $CPNT$_ex.h ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief $CPNT$ Driver extensions declarations diff --git a/template/CPNT_proc.c.txt b/template/CPNT_proc.c.txt index 09ff3d3d0..15c9a4c9c 100755 --- a/template/CPNT_proc.c.txt +++ b/template/CPNT_proc.c.txt @@ -1,6 +1,6 @@ /*!\file $CPNT$_proc.c ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief $CPNT$ Driver procedures code diff --git a/template/CPNT_proc.h.txt b/template/CPNT_proc.h.txt index 5151cef5d..37be9c965 100755 --- a/template/CPNT_proc.h.txt +++ b/template/CPNT_proc.h.txt @@ -1,6 +1,6 @@ /*!\file $CPNT$_proc.h ** \author SMFSW -** \version v0.2 +** \version v0.3 ** \date 2017 ** \copyright MIT (c) 2017, SMFSW ** \brief $CPNT$ Driver procedures declarations