i2c slave block transfer driver library

Dependents:   i2c_slave_block_example i2c_lora_slave

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers smbus.h Source File

smbus.h

00001 #include <stdint.h>
00002 #include <stdbool.h>
00003 #include "device.h"
00004 //#define DEBUG_SMBUS
00005 #include "cmds.h"
00006 
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010 
00011 int smbus_init( PinName sda, PinName scl, uint8_t slaveAddress);
00012 
00013 #define CBUF_SIZE        512
00014 typedef struct {
00015     uint8_t cbuf[CBUF_SIZE];
00016     unsigned cbuf_in, cbuf_out;
00017     bool c_overrun;
00018 
00019     uint8_t tx_buf[32];
00020 } i2c_slave_t;
00021 
00022 extern i2c_slave_t i2c;
00023 
00024 bool cmd_allowed(uint8_t);  // return false if slave cannot take this cmd now
00025 
00026 void service_i2c(void);
00027 void service_i2c_write(uint8_t cmd, uint8_t len, const uint8_t* req); // provided by application
00028 void fill_tx_buf(uint8_t);  //provided by application
00029 
00030 #ifdef __cplusplus
00031 }
00032 #endif