2021-02-18 12:49:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2021-03-02 11:45:47 +00:00
|
|
|
#include <api-hal-resources.h>
|
2021-02-18 12:49:32 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void api_hal_i2c_init();
|
|
|
|
|
2021-03-02 11:45:47 +00:00
|
|
|
void api_hal_i2c_tx(I2C_TypeDef* instance, const uint8_t address, const uint8_t *data, const uint8_t size);
|
|
|
|
|
|
|
|
void api_hal_i2c_rx(I2C_TypeDef* instance, const uint8_t address, uint8_t *data, const uint8_t size);
|
|
|
|
|
|
|
|
void api_hal_i2c_trx(
|
|
|
|
I2C_TypeDef* instance, const uint8_t address,
|
|
|
|
const uint8_t *tx_data, const uint8_t tx_size,
|
|
|
|
uint8_t *rx_data, const uint8_t rx_size
|
|
|
|
);
|
|
|
|
|
2021-02-18 12:49:32 +00:00
|
|
|
void api_hal_i2c_lock();
|
|
|
|
|
|
|
|
void api_hal_i2c_unlock();
|
|
|
|
|
|
|
|
#define with_api_hal_i2c(type, pointer, function_body) \
|
|
|
|
{ \
|
|
|
|
api_hal_i2c_lock(); \
|
|
|
|
*pointer = ({ type __fn__ function_body __fn__; })(); \
|
|
|
|
api_hal_i2c_unlock(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|