// -------------------------------------------------------------------------------------------------------------------- /// \file i2c.h /// \brief File description // -------------------------------------------------------------------------------------------------------------------- // // vbchaos software design // // -------------------------------------------------------------------------------------------------------------------- /// $Revision: $ /// $Author: $ /// $Date: $ // (c) 2023 vbchaos // -------------------------------------------------------------------------------------------------------------------- #ifndef MAIN_HAL_INC_I2C_H_ #define MAIN_HAL_INC_I2C_H_ /** * i2c implementation * \defgroup i2c * \brief {group_description} * \addtogroup {Layer} * * Detailed description * @{ */ // -------------------------------------------------------------------------------------------------------------------- // Include files // -------------------------------------------------------------------------------------------------------------------- // CompilerIncludes // All include files that are provided by the compiler directly // ProjectIncludes // All include files that are provided by the project #include "ISerialBus.h" #include "driver/i2c.h" // -------------------------------------------------------------------------------------------------------------------- // Constant and macro definitions // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // Type definitions. // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // Function declarations // -------------------------------------------------------------------------------------------------------------------- class i2c : public ISerialBus { // ----------------------------------------------------------------------------------------------------------------- // Public Section // ----------------------------------------------------------------------------------------------------------------- public: // Class Constructor i2c(i2c_port_t* port); ~i2c(); FunctionStatus read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength); FunctionStatus write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length); // ----------------------------------------------------------------------------------------------------------------- // Protected Section // ----------------------------------------------------------------------------------------------------------------- protected: // ----------------------------------------------------------------------------------------------------------------- // Private Section // ----------------------------------------------------------------------------------------------------------------- private: void intWrite(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length); void intRead(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length); i2c_port_t* port; }; /** @} */ #endif /* MAIN_HAL_INC_I2C_H_ */