-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunction_master_transmit.hpp
44 lines (32 loc) · 1.53 KB
/
function_master_transmit.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef HAL_EXTENSION_I2C_FUNCTION_MASTER_TRANSMIT_HPP
#define HAL_EXTENSION_I2C_FUNCTION_MASTER_TRANSMIT_HPP
#if __has_include("i2c.h")
#include "i2c.h"
namespace halex {
template <class T>
inline HAL_StatusTypeDef i2cMasterTransmit(I2C_HandleTypeDef *hi2c, uint8_t target, const T &data, uint32_t timeout) noexcept {
return HAL_I2C_Master_Transmit(hi2c, target << 1, (uint8_t *) &data, sizeof(T), timeout);
}
template <class T>
inline HAL_StatusTypeDef i2cMasterTransmit(I2C_HandleTypeDef &hi2c, uint8_t target, const T &data, uint32_t timeout) noexcept {
return i2cMasterTransmit(&hi2c, target, data, timeout);
}
template <class T>
inline HAL_StatusTypeDef i2cMasterTransmit_IT(I2C_HandleTypeDef *hi2c, uint8_t target, const T &data) noexcept {
return HAL_I2C_Master_Transmit_IT(hi2c, target << 1, (uint8_t *) &data, sizeof(T));
}
template <class T>
inline HAL_StatusTypeDef i2cMasterTransmit_IT(I2C_HandleTypeDef &hi2c, uint8_t target, const T &data) noexcept {
return i2cMasterTransmit_IT(&hi2c, target, data);
}
template <class T>
inline HAL_StatusTypeDef i2cMasterTransmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t target, const T &data) noexcept {
return HAL_I2C_Master_Transmit_DMA(hi2c, target << 1, (uint8_t *) &data, sizeof(T));
}
template <class T>
inline HAL_StatusTypeDef i2cMasterTransmit_DMA(I2C_HandleTypeDef &hi2c, uint8_t target, const T &data) noexcept {
return i2cMasterTransmit_DMA(&hi2c, target, data);
}
} // namespace halex
#endif // __has_include
#endif // HAL_EXTENSION_I2C_FUNCTION_MASTER_TRANSMIT_HPP