Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: i2c_slave_block_example i2c_lora_slave
smbus.h@5:493e5cc9c052, 2019-02-04 (annotated)
- Committer:
- Wayne Roberts
- Date:
- Mon Feb 04 13:42:05 2019 -0800
- Revision:
- 5:493e5cc9c052
- Parent:
- 4:7ab789db70da
update HAL state for STM32L4
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Wayne Roberts |
0:20421a857bd5 | 1 | #include <stdint.h> |
| Wayne Roberts |
0:20421a857bd5 | 2 | #include <stdbool.h> |
| Wayne Roberts |
3:c012313ebc13 | 3 | #include "device.h" |
| Wayne Roberts |
3:c012313ebc13 | 4 | //#define DEBUG_SMBUS |
| Wayne Roberts |
3:c012313ebc13 | 5 | #include "cmds.h" |
| Wayne Roberts |
0:20421a857bd5 | 6 | |
| Wayne Roberts |
0:20421a857bd5 | 7 | #ifdef __cplusplus |
| Wayne Roberts |
0:20421a857bd5 | 8 | extern "C" { |
| Wayne Roberts |
0:20421a857bd5 | 9 | #endif |
| Wayne Roberts |
0:20421a857bd5 | 10 | |
| Wayne Roberts |
3:c012313ebc13 | 11 | int smbus_init( PinName sda, PinName scl, uint8_t slaveAddress); |
| Wayne Roberts |
0:20421a857bd5 | 12 | |
| Wayne Roberts |
3:c012313ebc13 | 13 | #define CBUF_SIZE 512 |
| Wayne Roberts |
0:20421a857bd5 | 14 | typedef struct { |
| Wayne Roberts |
3:c012313ebc13 | 15 | uint8_t cbuf[CBUF_SIZE]; |
| Wayne Roberts |
0:20421a857bd5 | 16 | unsigned cbuf_in, cbuf_out; |
| Wayne Roberts |
3:c012313ebc13 | 17 | bool c_overrun; |
| Wayne Roberts |
0:20421a857bd5 | 18 | |
| Wayne Roberts |
0:20421a857bd5 | 19 | uint8_t tx_buf[32]; |
| Wayne Roberts |
0:20421a857bd5 | 20 | } i2c_slave_t; |
| Wayne Roberts |
0:20421a857bd5 | 21 | |
| Wayne Roberts |
0:20421a857bd5 | 22 | extern i2c_slave_t i2c; |
| Wayne Roberts |
0:20421a857bd5 | 23 | |
| Wayne Roberts |
1:914409dc83b1 | 24 | bool cmd_allowed(uint8_t); // return false if slave cannot take this cmd now |
| Wayne Roberts |
0:20421a857bd5 | 25 | |
| Wayne Roberts |
0:20421a857bd5 | 26 | void service_i2c(void); |
| Wayne Roberts |
0:20421a857bd5 | 27 | void service_i2c_write(uint8_t cmd, uint8_t len, const uint8_t* req); // provided by application |
| Wayne Roberts |
3:c012313ebc13 | 28 | void fill_tx_buf(uint8_t); //provided by application |
| Wayne Roberts |
0:20421a857bd5 | 29 | |
| Wayne Roberts |
0:20421a857bd5 | 30 | #ifdef __cplusplus |
| Wayne Roberts |
0:20421a857bd5 | 31 | } |
| Wayne Roberts |
0:20421a857bd5 | 32 | #endif |