#include "MyI2C.h" #include "Time.h" #define NULL 0 MyI2C_RecSendData_Typedef Receive; MyI2C_RecSendData_Typedef * RData = &Receive; char* Get_Time(){ time varTime; char input[7]; RData->SlaveAdress7bits = 0x68; RData->Ptr_Data = input; RData->Nb_Data = 7; MyI2C_GetString(I2C1, 0x0, RData); // mask w/ 0x0F ==> lower 4 bits varTime.second = (input[0] & 0x0F) + 10*((input[0]>>4)&0x07); // shift >>4 + mask w/ 0x7 ==> upper 3 bits but one varTime.minute = (input[1] & 0x0F) + 10*(input[1]>>4); varTime.hour = (input[2] & 0x0F) + 10*((input[2]>>4)&0x3); // shift >>4 + mask w/ 0x7 ==> upper 2 bits but two varTime.weekday = input[3]; varTime.day = (input[4] & 0x0F) + 10*(input[4]>>4); varTime.month = (input[5] & 0x0F) + 10*(input[5]>>4); varTime.year = (input[6] & 0x0F) + 10*(input[6]>>4); return(varTime); }