11/*
22*****************************************************************************
3- @file Deneyap_KizilOtesiAliciVerici .cpp
3+ @file Deneyap_KizilotesiAliciVerici .cpp
44@mainpage Deneyap Infrarad Receiver Transmitter Arduino library source file
55@maintainer RFtek Electronics <[email protected] > 6- @version v1.0.0
7- @date June 29 , 2022
6+ @version v1.0.2
7+ @date November 07 , 2022
88@brief Includes functions to controlDeneyap Infrarad Receiver Transmitter
99 Arduino library
1010
@@ -26,8 +26,12 @@ Library includes:
2626 */
2727bool Transceiver::begin (uint8_t address, TwoWire &port) {
2828 Wire.begin ();
29+ #if defined(ARDUINO_DYM)
30+ Wire.setClock (100000 );
31+ #else
2932 Wire.setClock (50000 );
30- _i2cAddress = address;
33+ #endif
34+ _i2cAddress = address;
3135 _i2cPort = &port;
3236 _dataPacket = {0 };
3337
@@ -55,7 +59,7 @@ bool Transceiver::isConnected() {
5559uint16_t Transceiver::getFwVersion () {
5660 _dataPacket.command = TRANSCEIVER_REQUEST_FW_VERSION;
5761 _dataPacket.dataSize = 0 ;
58- return I2C_ReadData16bit (&_dataPacket);
62+ return I2C_ReadFirmwareData16bit (&_dataPacket);
5963}
6064
6165/* *
@@ -164,6 +168,11 @@ uint8_t Transceiver::I2C_ReadData(Transceiver_DataPacket_TypeDef *dataPacket) {
164168 return 1 ;
165169}
166170
171+ /* *
172+ * @brief Reads 8bit data from I2C interface
173+ * @param dataPacket: includes protocol to request data
174+ * @retval I2C 8bit data
175+ */
167176uint8_t Transceiver::I2C_ReadData8bit (Transceiver_DataPacket_TypeDef *dataPacket) {
168177 _i2cPort->beginTransmission (_i2cAddress);
169178 _i2cPort->write (dataPacket->command );
@@ -179,8 +188,7 @@ uint8_t Transceiver::I2C_ReadData8bit(Transceiver_DataPacket_TypeDef *dataPacket
179188 * @param dataPacket: includes protocol to request data
180189 * @retval I2C 16bit data
181190 */
182- uint16_t Transceiver::I2C_ReadData16bit (Transceiver_DataPacket_TypeDef *dataPacket)
183- {
191+ uint16_t Transceiver::I2C_ReadData16bit (Transceiver_DataPacket_TypeDef *dataPacket) {
184192 _i2cPort->beginTransmission (_i2cAddress);
185193 _i2cPort->write (dataPacket->command );
186194 _i2cPort->endTransmission ();
@@ -193,6 +201,24 @@ uint16_t Transceiver::I2C_ReadData16bit(Transceiver_DataPacket_TypeDef *dataPack
193201 return 0 ;
194202}
195203
204+ /* *
205+ * @brief Reads 16bit data from I2C interface
206+ * @param dataPacket: includes protocol to request data
207+ * @retval I2C 16bit data
208+ */
209+ uint16_t Transceiver::I2C_ReadFirmwareData16bit (Transceiver_DataPacket_TypeDef *dataPacket) {
210+ _i2cPort->beginTransmission (_i2cAddress);
211+ _i2cPort->write (dataPacket->command );
212+ _i2cPort->endTransmission ();
213+
214+ if (_i2cPort->requestFrom (_i2cAddress, static_cast <uint8_t >(2 )) != 0 ) {
215+ i2cData2 = _i2cPort->read ();
216+ i2cData1 = _i2cPort->read ();
217+ Serial.print (" v" ); Serial.print (i2cData1); Serial.print (" ." ); Serial.println (i2cData2);
218+ }
219+ return 0 ;
220+ }
221+
196222/* *
197223 * @brief Sends data packet based on a custom defined protocol
198224 * @param dataPacket: includes all related data
@@ -209,4 +235,4 @@ bool Transceiver::I2C_SendDataPacket(Transceiver_DataPacket_TypeDef *dataPacket)
209235 if (_i2cPort->endTransmission () == 0 )
210236 return true ;
211237 return false ;
212- }
238+ }
0 commit comments