i2c_common.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef _NODEMCU_I2C_COMMON_H_
  2. #define _NODEMCU_I2C_COMMON_H_
  3. #include "lauxlib.h"
  4. typedef enum {
  5. I2C_ID_SW = 0,
  6. I2C_ID_HW0,
  7. I2C_ID_HW1,
  8. I2C_ID_MAX
  9. } i2c_id_type;
  10. // ***************************************************************************
  11. // Hardware master prototypes
  12. //
  13. void li2c_hw_master_init( lua_State *L );
  14. void li2c_hw_master_setup( lua_State *L, unsigned id, unsigned sda, unsigned scl, uint32_t speed );
  15. void li2c_hw_master_start( lua_State *L, unsigned id );
  16. void li2c_hw_master_stop( lua_State *L, unsigned id );
  17. int li2c_hw_master_address( lua_State *L, unsigned id, uint16_t address, uint8_t direction, bool ack_check_en );
  18. void li2c_hw_master_write( lua_State *L, unsigned id, uint8_t data, bool ack_check_en );
  19. void li2c_hw_master_read( lua_State *L, unsigned id, uint32_t len );
  20. int li2c_hw_master_transfer( lua_State *L );
  21. // ***************************************************************************
  22. // Hardware slave prototypes
  23. //
  24. extern const LUA_REG_TYPE li2c_slave_map[];
  25. void li2c_hw_slave_init( lua_State *L );
  26. #endif /*_NODEMCU_I2C_COMMON_H_*/