cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] ST-LINK V3 Bridge API

svcguy
Associate III

Hello,

Wondering if anyone out there is knowledgeable in the ST-LINK V3 Bridge API? I'm working on a personal project developing a GUI application that uses the API to provide something like a Bus Pirate type development tool. If you want to look at bad C/C++ code the project is on GitHub. I've gotten the GPIO portion to work and am working on I2C. My specific question is this:

The I2C read/write methods take a parameter for returning the actual number of bytes written on the bus. Here's one of the methods signature:

Brg_StatusT WriteI2C(const uint8_t *pBuffer, uint16_t Addr, uint16_t SizeInBytes, uint16_t *pSizeWritten);

pSizeWritten is the parameter in question. It seems to always return zero even though the BrgStatusT return value is BRG_NO_ERR. I've looked at the bus on the scope and can see bytes written/read and they appear correct.

So is this a misuse/misunderstanding of the API on my part or a bug in the bridge sources or a bug in the DLL or cosmic interference??

EDIT: Forgot any kind of version info:

ST-LINK V3SET - fw ver V3J7M2B4S1

ST-LINK V3 Bridge API version - 1

ST-LINK USB Driver DLL version (from windows) - 5.1.3.0, this I think corresponds to 2.36.26 of STSW-LINK007

WIN 10 machine

Thanks for your time,

Andy

1 ACCEPTED SOLUTION

Accepted Solutions
svcguy
Associate III

So it appears I found my own answer. I read the sources several times but missed a little tidbit:

/**
 * @ingroup I2C
 * @brief This routine allows to transmit bytes on the I2C interface, in the mode initialized by Brg::InitI2C().\n
 * In master mode I2C the size bytes are transmitted in one I2C transaction ((re)start- addr- data -stop)
 * even if data may be split into several USB packets.
 * @param[in]  Addr  I2C slave address used in master mode (default 7bit): 
 *             use #I2C_10B_ADDR(Addr) if it is a 10bit address.
 * @param[in]  pBuffer Pointer on data buffer with data to be read.
 * @param[in]  SizeInBytes Data size to be read in bytes (min 1, max data buffer size).
 * @param[out] pSizeWritten If not NULL and in case of error, pSizeWritten returns the number of bytes
 *             transmitted before the error.
 *
 * @retval #BRG_NO_STLINK If Brg::OpenStlink() not called before
 * @retval #BRG_COM_INIT_NOT_DONE If I2C is not initialized
 * @retval #BRG_I2C_ERR In case of I2C error
 * @retval #BRG_COM_CMD_ORDER_ERR If low level I2C function call order is not consitent (Start, Cont, Stop)
 * @retval #BRG_NO_ERR If no error
 */

pSizeWritten is only filled with a value in the case of an error. So I suppose with no error its safe to assume SizeWritten == SizeInBytes.

View solution in original post

1 REPLY 1
svcguy
Associate III

So it appears I found my own answer. I read the sources several times but missed a little tidbit:

/**
 * @ingroup I2C
 * @brief This routine allows to transmit bytes on the I2C interface, in the mode initialized by Brg::InitI2C().\n
 * In master mode I2C the size bytes are transmitted in one I2C transaction ((re)start- addr- data -stop)
 * even if data may be split into several USB packets.
 * @param[in]  Addr  I2C slave address used in master mode (default 7bit): 
 *             use #I2C_10B_ADDR(Addr) if it is a 10bit address.
 * @param[in]  pBuffer Pointer on data buffer with data to be read.
 * @param[in]  SizeInBytes Data size to be read in bytes (min 1, max data buffer size).
 * @param[out] pSizeWritten If not NULL and in case of error, pSizeWritten returns the number of bytes
 *             transmitted before the error.
 *
 * @retval #BRG_NO_STLINK If Brg::OpenStlink() not called before
 * @retval #BRG_COM_INIT_NOT_DONE If I2C is not initialized
 * @retval #BRG_I2C_ERR In case of I2C error
 * @retval #BRG_COM_CMD_ORDER_ERR If low level I2C function call order is not consitent (Start, Cont, Stop)
 * @retval #BRG_NO_ERR If no error
 */

pSizeWritten is only filled with a value in the case of an error. So I suppose with no error its safe to assume SizeWritten == SizeInBytes.