@@ -34,12 +34,6 @@ static const char *TAG = "sccb-ng";
3434
3535#define TIMEOUT_MS 1000 /*!< I2C timeout duration */
3636#define SCCB_FREQ CONFIG_SCCB_CLK_FREQ /*!< I2C master frequency */
37- #define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
38- #define READ_BIT I2C_MASTER_READ /*!< I2C master read */
39- #define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave */
40- #define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
41- #define ACK_VAL 0x0 /*!< I2C ack value */
42- #define NACK_VAL 0x1 /*!< I2C nack value */
4337#if CONFIG_SCCB_HARDWARE_I2C_PORT1
4438const int SCCB_I2C_PORT_DEFAULT = 1 ;
4539#else
@@ -299,11 +293,9 @@ int SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data)
299293{
300294 i2c_master_dev_handle_t dev_handle = * (get_handle_from_address (slv_addr ));
301295
302- uint16_t reg_htons = LITTLETOBIG (reg );
303-
304296 uint8_t tx_buffer [3 ];
305- tx_buffer [0 ] = reg_htons >> 8 ;
306- tx_buffer [1 ] = reg_htons & 0x00ff ;
297+ tx_buffer [0 ] = reg >> 8 ;
298+ tx_buffer [1 ] = reg & 0x00ff ;
307299 tx_buffer [2 ] = data ;
308300
309301 esp_err_t ret = i2c_master_transmit (dev_handle , tx_buffer , 3 , TIMEOUT_MS );
@@ -339,11 +331,9 @@ int SCCB_Write_Addr16_Val16(uint8_t slv_addr, uint16_t reg, uint16_t data)
339331{
340332 i2c_master_dev_handle_t dev_handle = * (get_handle_from_address (slv_addr ));
341333
342- uint16_t reg_htons = LITTLETOBIG (reg );
343-
344334 uint8_t tx_buffer [4 ];
345- tx_buffer [0 ] = reg_htons >> 8 ;
346- tx_buffer [1 ] = reg_htons & 0x00ff ;
335+ tx_buffer [0 ] = reg >> 8 ;
336+ tx_buffer [1 ] = reg & 0x00ff ;
347337 tx_buffer [2 ] = data >> 8 ;
348338 tx_buffer [3 ] = data & 0x00ff ;
349339
@@ -354,5 +344,4 @@ int SCCB_Write_Addr16_Val16(uint8_t slv_addr, uint16_t reg, uint16_t data)
354344 ESP_LOGE (TAG , "W [%04x]=%02x fail\n" , reg , data );
355345 }
356346 return ret == ESP_OK ? 0 : -1 ;
357- return 0 ;
358347}
0 commit comments