2017-02-01 00:14:49 +01:00
|
|
|
|
|
|
|
#ifndef _NODEMCU_I2C_COMMON_H_
|
|
|
|
#define _NODEMCU_I2C_COMMON_H_
|
|
|
|
|
|
|
|
#include "lauxlib.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
I2C_ID_SW = 0,
|
|
|
|
I2C_ID_HW0,
|
|
|
|
I2C_ID_HW1,
|
|
|
|
I2C_ID_MAX
|
|
|
|
} i2c_id_type;
|
|
|
|
|
|
|
|
|
2017-02-05 21:23:19 +01:00
|
|
|
// ***************************************************************************
|
|
|
|
// Hardware master prototypes
|
|
|
|
//
|
2017-02-01 00:14:49 +01:00
|
|
|
void li2c_hw_master_init( lua_State *L );
|
|
|
|
void li2c_hw_master_setup( lua_State *L, unsigned id, unsigned sda, unsigned scl, uint32_t speed );
|
|
|
|
void li2c_hw_master_start( lua_State *L, unsigned id );
|
|
|
|
void li2c_hw_master_stop( lua_State *L, unsigned id );
|
|
|
|
int li2c_hw_master_address( lua_State *L, unsigned id, uint16_t address, uint8_t direction, bool ack_check_en );
|
|
|
|
void li2c_hw_master_write( lua_State *L, unsigned id, uint8_t data, bool ack_check_en );
|
|
|
|
void li2c_hw_master_read( lua_State *L, unsigned id, uint32_t len );
|
|
|
|
int li2c_hw_master_transfer( lua_State *L );
|
|
|
|
|
2017-02-05 21:23:19 +01:00
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// Hardware slave prototypes
|
|
|
|
//
|
|
|
|
extern const LUA_REG_TYPE li2c_slave_map[];
|
|
|
|
void li2c_hw_slave_init( lua_State *L );
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-01 00:14:49 +01:00
|
|
|
#endif /*_NODEMCU_I2C_COMMON_H_*/
|