/*
 * rtc_chasi.c
 *
 *  Created on: 19 сент. 2020 г.
 *      Author: Ivan
 */

#include "rts_chasi.h"


unsigned char RTC_ConvertFromBinDec(unsigned char c)
{
	  unsigned char ch = ((c/10)<<4)|(c%10);
	  return ch;

}
unsigned char RTC_ConvertFromDec(unsigned char c)
{
	  unsigned char ch = ((c>>4)*10+(0b00001111&c));
	  return ch;

}
void I2C_SendByteByADDR1(I2C_TypeDef * i2c,uint8_t c,uint8_t addr)
{
  //Disable Pos
      LL_I2C_DisableBitPOS(i2c);
      LL_I2C_AcknowledgeNextData(i2c, LL_I2C_ACK);
      LL_I2C_GenerateStartCondition(i2c);
      while(!LL_I2C_IsActiveFlag_SB(i2c)){};
      (void) i2c->SR1;
      i2c->DR= addr|0;
     // LL_I2C_TransmitData8(ds1307WR);
      while(!LL_I2C_IsActiveFlag_ADDR(i2c)){};
      LL_I2C_ClearFlag_ADDR(i2c);
      I2C2->DR=c;
     // LL_I2C_TransmitData8(I2C, c);
      while(!LL_I2C_IsActiveFlag_TXE(i2c)){};
      LL_I2C_GenerateStopCondition(i2c);
}
