Adds a const buffer listener (#742)

Replaces need for const_cast in SPI and I2C functions
This commit is contained in:
Thad House
2017-11-17 10:01:49 -08:00
committed by Peter Johnson
parent a20474bfc7
commit cd1dbb1e3a
10 changed files with 55 additions and 10 deletions

View File

@@ -30,7 +30,7 @@ int32_t HALSIM_RegisterI2CReadCallback(int32_t index,
void HALSIM_CancelI2CReadCallback(int32_t index, int32_t uid);
int32_t HALSIM_RegisterI2CWriteCallback(int32_t index,
HAL_BufferCallback callback,
HAL_ConstBufferCallback callback,
void* param);
void HALSIM_CancelI2CWriteCallback(int32_t index, int32_t uid);

View File

@@ -15,6 +15,10 @@ typedef void (*HAL_NotifyCallback)(const char* name, void* param,
typedef void (*HAL_BufferCallback)(const char* name, void* param,
unsigned char* buffer, unsigned int count);
typedef void (*HAL_ConstBufferCallback)(const char* name, void* param,
const unsigned char* buffer,
unsigned int count);
namespace hal {
template <typename CallbackFunction>

View File

@@ -132,5 +132,7 @@ void HalCallbackListenerVectorImpl<ListenerType>::erase_impl(unsigned int uid) {
typedef HalCallbackListenerVectorImpl<HAL_NotifyCallback> NotifyListenerVector;
typedef HalCallbackListenerVectorImpl<HAL_BufferCallback> BufferListenerVector;
typedef HalCallbackListenerVectorImpl<HAL_ConstBufferCallback>
ConstBufferListenerVector;
} // namespace hal

View File

@@ -30,7 +30,7 @@ int32_t HALSIM_RegisterSPIReadCallback(int32_t index,
void HALSIM_CancelSPIReadCallback(int32_t index, int32_t uid);
int32_t HALSIM_RegisterSPIWriteCallback(int32_t index,
HAL_BufferCallback callback,
HAL_ConstBufferCallback callback,
void* param);
void HALSIM_CancelSPIWriteCallback(int32_t index, int32_t uid);