ctr_mcu/snake_trunk/i2c_mcu.h

41 lines
967 B
C

#ifndef __ic2_mcu__
#define __ic2_mcu__
// ========================================================
typedef enum{
I2C_ERR_OK = 0,
I2C_ERR_NAK,
I2C_ERR_NOSLAVE,
I2C_ERR_TIMEOUT,
I2C_ERR_UNDEF = 0xFF
}i2c_err;
// ========================================================
extern volatile bit iic_mcu_busy;
extern bit iic_mcu_wo_dma;
extern i2c_err iic_mcu_result;
// ========================================================
i2c_err iic_mcu_read( u8 SLA, u8 adrs, u8 len, u8 * dest );
u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs );
i2c_err iic_mcu_write( u8 SLA, u8 adrs, u8 len, void * src );
i2c_err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat );
i2c_err iic_mcu_write_a_byte_codec( u8 adrs, u8 dat ); // codecバグ回避機能付き
// ↓その通信が完了したら解除されます。
#define iic_mcu_set_wo_dma() { while( iic_mcu_busy ){;} iic_mcu_wo_dma = true; }
void iic_mcu_start( );
void iic_mcu_stop( );
#endif