cancel
Showing results for 
Search instead for 
Did you mean: 

SMBUS/ PMBUS Expansion Package

NAgar.1
Associate

I am trying to implement the PMBUS on STM32 processor using SMBUS/PMBUS exapnsion package. I am able to execute the read and write commands. But when I am trying to execute the READ_OR_WRITE command for read operation then I receive only FF FF in the output. Looking at the code, it says that if the command supports read then make the size = pStackContext->CurrentCommand->cmnd_master_Tx_Size, so even I just want to do a read operation for READ_OR_WRITE Command, it is expecting to receive the required data bytes specified in size.

Is there any work around to this problem?

Thanks

Nitish

1 REPLY 1
HNord.1
Associate II

Works for me like this in STACK_SMBUS_ExecuteCommand

   uint8_t *piobuf = STACK_SMBUS_GetBuffer( pStackContext );

   st_command_t *pCommand = pStackContext->CurrentCommand;

   if (!piobuf || !pCommand) {

      pStackContext->StateMachine |= SMBUS_SMS_ERROR;

      return STACK_ERROR;

   }

   const bool is_write = ((pStackContext->StateMachine & SMBUS_SMS_RECEIVE) != SMBUS_SMS_RECEIVE) && ( ( pCommand->cmnd_query & WRITE ) == WRITE );

   switch (pCommand->cmnd_code) {

case XXXX:

      if (is_write)

         set_XXXX(piobuf[0]);

      piobuf[0] = get_XXXX();

      return STACK_OK;

I am pretty sure there must be a better way to identify if it was a read or write operation than the above twisted condition.