diff options
Diffstat (limited to 'ucs2-interface')
-rw-r--r-- | ucs2-interface/ucs_config.h | 12 | ||||
-rw-r--r-- | ucs2-interface/ucs_interface.h | 5 | ||||
-rw-r--r-- | ucs2-interface/ucs_lib_interf.c | 5 |
3 files changed, 20 insertions, 2 deletions
diff --git a/ucs2-interface/ucs_config.h b/ucs2-interface/ucs_config.h index 16210af..93bba34 100644 --- a/ucs2-interface/ucs_config.h +++ b/ucs2-interface/ucs_config.h @@ -65,6 +65,14 @@ typedef enum } UnicensCmdResult_t; /** + * \brief Asynchronous callback notifiying a command result + * \param result_ptr The asynchronous result of the command + * \param request_ptr User reference, typically points to the afb_req + * object. + */ +typedef void (*Ucsi_ResultCb_t)(void *result_ptr, void *request_ptr); + +/** * \brief Internal enum for Unicens Integration */ typedef enum @@ -135,6 +143,10 @@ typedef struct uint16_t timeout; uint8_t dataLen; uint8_t data[I2C_WRITE_MAX_LEN]; + + Ucsi_ResultCb_t result_fptr; + void *request_ptr; + } UnicensCmdI2CWrite_t; /** diff --git a/ucs2-interface/ucs_interface.h b/ucs2-interface/ucs_interface.h index c18d440..0ec603a 100644 --- a/ucs2-interface/ucs_interface.h +++ b/ucs2-interface/ucs_interface.h @@ -179,11 +179,14 @@ bool UCSI_SetRouteActive(UCSI_Data_t *pPriv, uint16_t routeId, bool isActive); * \param timeout - Timeout in milliseconds. * \param dataLen - Amount of bytes to send via I2C * \param pData - The payload to be send. + * \param result_fptr - Callback function notifying the asynchronous result. + * \param request_ptr - User reference which is provided for the asynchronous result. * * \return true, if route command was enqueued to Unicens. */ bool UCSI_I2CWrite(UCSI_Data_t *pPriv, uint16_t targetAddress, bool isBurst, uint8_t blockCount, - uint8_t slaveAddr, uint16_t timeout, uint8_t dataLen, uint8_t *pData); + uint8_t slaveAddr, uint16_t timeout, uint8_t dataLen, uint8_t *pData, + Ucsi_ResultCb_t result_fptr, void *request_ptr); /** * \brief Enables or disables a route by the given routeId diff --git a/ucs2-interface/ucs_lib_interf.c b/ucs2-interface/ucs_lib_interf.c index fd60496..508b723 100644 --- a/ucs2-interface/ucs_lib_interf.c +++ b/ucs2-interface/ucs_lib_interf.c @@ -308,7 +308,8 @@ bool UCSI_SetRouteActive(UCSI_Data_t *my, uint16_t routeId, bool isActive) } bool UCSI_I2CWrite(UCSI_Data_t *my, uint16_t targetAddress, bool isBurst, uint8_t blockCount, - uint8_t slaveAddr, uint16_t timeout, uint8_t dataLen, uint8_t *pData) + uint8_t slaveAddr, uint16_t timeout, uint8_t dataLen, uint8_t *pData, + Ucsi_ResultCb_t result_fptr, void *request_ptr) { UnicensCmdEntry_t entry; assert(MAGIC == my->magic); @@ -321,6 +322,8 @@ bool UCSI_I2CWrite(UCSI_Data_t *my, uint16_t targetAddress, bool isBurst, uint8_ entry.val.I2CWrite.slaveAddr = slaveAddr; entry.val.I2CWrite.timeout = timeout; entry.val.I2CWrite.dataLen = dataLen; + entry.val.I2CWrite.result_fptr = result_fptr; + entry.val.I2CWrite.request_ptr = request_ptr; memcpy(entry.val.I2CWrite.data, pData, dataLen); return EnqueueCommand(my, &entry); } |