mtb-pmbus 1.2.0.1772
 
Loading...
Searching...
No Matches
Command Handler Functions

General Description

A variety of functions are provided to work with commands:

In this section, functions with the isr suffix are optimized for use during ISRs, typically in command callback functions. APIs without the isr suffix return the MTB_PMBUS_STATUS_CMD_IS_ACTIVE status if the selected command is participating in an active transfer. To access data for specific pages or phases of commands, use APIs with the ext suffix.

Functions

mtb_pmbus_status_t mtb_pmbus_cmd_update_data (mtb_pmbus_stc_t *inst, uint32_t code, uint8_t *data, uint32_t data_size)
 Update the data buffer for the selected command with new data.
 
void mtb_pmbus_cmd_update_data_isr (mtb_pmbus_stc_t *inst, uint32_t code, uint8_t *data, uint32_t data_size)
 Update the data buffer for the selected command with new data.
 
mtb_pmbus_status_t mtb_pmbus_cmd_update_data_ext (mtb_pmbus_stc_t *inst, uint32_t code, int32_t page, int32_t phase, uint8_t *data, uint32_t data_size)
 Update the data buffer for the selected command, page and phase with the new data.
 
void mtb_pmbus_cmd_update_data_ext_isr (mtb_pmbus_stc_t *inst, uint32_t code, int32_t page, int32_t phase, uint8_t *data, uint32_t data_size)
 Update the data buffer for the selected command, page and phase with the new data.
 
mtb_pmbus_status_t mtb_pmbus_cmd_read_data (mtb_pmbus_stc_t *inst, uint32_t code, uint8_t *data, uint32_t data_size)
 Read the data from the internal buffer for selected command.
 
void mtb_pmbus_cmd_read_data_isr (mtb_pmbus_stc_t *inst, uint32_t code, uint8_t *data, uint32_t data_size)
 Read the data from the internal buffer for selected command.
 
mtb_pmbus_status_t mtb_pmbus_cmd_read_data_ext (mtb_pmbus_stc_t *inst, uint32_t code, int32_t page, int32_t phase, uint8_t *data, uint32_t data_size)
 Read the data from the buffer for the selected command, page and phase.
 
void mtb_pmbus_cmd_read_data_ext_isr (mtb_pmbus_stc_t *inst, uint32_t code, int32_t page, int32_t phase, uint8_t *data, uint32_t data_size)
 Read the data from the buffer for the selected command, page and phase.
 
mtb_pmbus_status_t mtb_pmbus_cmd_get_transfer_size (mtb_pmbus_stc_t *inst, uint32_t code, uint8_t *size)
 Returns the number of bytes which is transferred during last transaction.
 
void mtb_pmbus_cmd_get_transfer_size_isr (mtb_pmbus_stc_t *inst, uint32_t code, uint8_t *size)
 Returns the number of bytes which is transferred during last transaction.
 
mtb_pmbus_status_t mtb_pmbus_cmd_get_transfer_size_ext (mtb_pmbus_stc_t *inst, uint32_t code, int32_t page, int32_t phase, uint8_t *size)
 Returns the number of bytes which is transferred during last transaction.
 
void mtb_pmbus_cmd_get_transfer_size_ext_isr (mtb_pmbus_stc_t *inst, uint32_t code, int32_t page, int32_t phase, uint8_t *size)
 Returns the number of bytes which is transferred during last transaction.
 
void mtb_pmbus_cmd_is_active_isr (mtb_pmbus_stc_t *inst, uint32_t code, bool *status)
 Returns true if command participate in current transfer, otherwise returns false.
 
mtb_pmbus_status_t mtb_pmbus_cmd_is_active (mtb_pmbus_stc_t *inst, uint32_t code, bool *status)
 Returns true if command participate in current transfer, otherwise returns false.
 
void mtb_pmbus_cmd_enable_disable_isr (mtb_pmbus_stc_t *inst, uint32_t code, bool status)
 Enable/Disable command.
 
mtb_pmbus_status_t mtb_pmbus_cmd_enable_disable (mtb_pmbus_stc_t *inst, uint32_t code, bool status)
 Enable/Disable command.
 
mtb_pmbus_status_t mtb_pmbus_cmd_ext_enable_disable (mtb_pmbus_stc_t *inst, bool status)
 Enable/Disable the extended command.
 
mtb_pmbus_status_t mtb_pmbus_cmd_all_enable_disable (mtb_pmbus_stc_t *inst, bool status)
 Enable/Disable all commands from both command tables: main ( mtb_pmbus_stc_config_t::cmd_table) and extended ( mtb_pmbus_stc_config_t::ext_cmd_table).
 
mtb_pmbus_status_t mtb_pmbus_cmd_get_status (mtb_pmbus_stc_t *inst, uint32_t code, bool *status)
 Returns true if a command is executed at least one time.
 
void mtb_pmbus_cmd_wr_protect_isr (mtb_pmbus_stc_t *inst, uint32_t code, bool status)
 Enable or disable write protection for a specific command.
 
mtb_pmbus_status_t mtb_pmbus_cmd_wr_protect (mtb_pmbus_stc_t *inst, uint32_t code, bool status)
 Enable or disable write protection for a specific command.
 
mtb_pmbus_status_t mtb_pmbus_cmd_all_wr_protect (mtb_pmbus_stc_t *inst, bool status)
 Enables or disables write protection for all PMBus commands.
 
mtb_pmbus_status_t mtb_pmbus_cmd_exit_isr (mtb_pmbus_stc_t *inst)
 Requests to pause the Process Call protocol execution and exit from the ISR handler.
 
mtb_pmbus_status_t mtb_pmbus_cmd_complete_transfer (mtb_pmbus_stc_t *inst, uint32_t code)
 Resumes a paused Process Call protocol transaction.
 
mtb_pmbus_status_t mtb_pmbus_cmd_process_call_wr_done (mtb_pmbus_stc_t *inst, bool *status)
 Determines if the current MTB_PMBUS_CMD_WRITE_DONE event is for a Process Call protocol.
 

Function Documentation

◆ mtb_pmbus_cmd_update_data()

mtb_pmbus_status_t mtb_pmbus_cmd_update_data ( mtb_pmbus_stc_t * inst,
uint32_t code,
uint8_t * data,
uint32_t data_size )

Update the data buffer for the selected command with new data.

For the Block Read and Block Write-Block Read Process Call protocols: If the updated data size is smaller than the command size in the command table, only updated bytes will be transferred.

This function always updates data from the 0 position.

The function validates the input parameters and returns the appropriate error status.

The function prevents updating the data content if the command is active, to avoid data corruption. Therefore, using this function within a PMBus callback (executed inside an ISR) will have no effect.

Use this function only for not paged/phased commands.

Warning
Updating the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is updated from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and update order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
dataThe pointer to the data array
data_sizeThe size of the data array
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_update_data_isr()

void mtb_pmbus_cmd_update_data_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
uint8_t * data,
uint32_t data_size )

Update the data buffer for the selected command with new data.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

For the Block Read and Block Write-Block Read Process Call protocols: If the updated data size is smaller than the command size in the command table, only the updated bytes will be transferred.

This function always updates data from position 0.

Use this function only for non-paged/non-phased commands.

Warning
The updating data for active command can lead to data corruption.
Updating the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is updated from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and update order.
Parameters
instPointer to the PMBus instance structure
codeCommand code
dataPointer to the data array
data_sizeSize of the data array

◆ mtb_pmbus_cmd_update_data_ext()

mtb_pmbus_status_t mtb_pmbus_cmd_update_data_ext ( mtb_pmbus_stc_t * inst,
uint32_t code,
int32_t page,
int32_t phase,
uint8_t * data,
uint32_t data_size )

Update the data buffer for the selected command, page and phase with the new data.

For the Block Read and Block Write-Block Read Process Call protocols: If the updated data size is smaller than the command size in the command table, only updated bytes will be transferred.

This function always updates data from the 0 position.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
Updating the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is updated from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and update order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
pageThe page number to update. If the command is not paged, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
phaseThe phase number to update. If the command is not phased, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
dataThe pointer to the data array
data_sizeThe size of the data array
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_update_data_ext_isr()

void mtb_pmbus_cmd_update_data_ext_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
int32_t page,
int32_t phase,
uint8_t * data,
uint32_t data_size )

Update the data buffer for the selected command, page and phase with the new data.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

For the Block Read and Block Write-Block Read Process Call protocols: If the updated data size is smaller than the command size in the command table, only updated bytes will be transferred.

This function always update data from the 0 position.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
The updating data for active command can lead to data corruption.
Updating the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is updated from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and update order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
pageThe page number to update. If the command is not paged, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
phaseThe phase number to update. If the command is not phased, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
dataThe pointer to the data array
data_sizeThe size of the data array

◆ mtb_pmbus_cmd_read_data()

mtb_pmbus_status_t mtb_pmbus_cmd_read_data ( mtb_pmbus_stc_t * inst,
uint32_t code,
uint8_t * data,
uint32_t data_size )

Read the data from the internal buffer for selected command.

The function validates the input parameters and returns the appropriate error status.

The function prevents reading the data content if the command is active, to avoid data corruption. Therefore, using this function within a PMBus callback (executed inside an ISR) will have no effect.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
Reading the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is accessed from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and access order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
dataThe pointer to the data array
data_sizeThe size of the data array
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_read_data_isr()

void mtb_pmbus_cmd_read_data_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
uint8_t * data,
uint32_t data_size )

Read the data from the internal buffer for selected command.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
The returned data for command which take part in active transfer can be invalid.
Reading the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is accessed from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and access order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
dataThe pointer to the data array
data_sizeThe size of the data array

◆ mtb_pmbus_cmd_read_data_ext()

mtb_pmbus_status_t mtb_pmbus_cmd_read_data_ext ( mtb_pmbus_stc_t * inst,
uint32_t code,
int32_t page,
int32_t phase,
uint8_t * data,
uint32_t data_size )

Read the data from the buffer for the selected command, page and phase.

The function validates the input parameters and returns the appropriate error status.

The function prevents reading the data content if the command is active, to avoid data corruption. Therefore, using this function within a PMBus callback (executed inside an ISR) will have no effect.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
Reading the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is accessed from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and access order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
pageThe page number to update. If the command is not paged, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
phaseThe phase number to update. If the command is not phased, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
dataThe pointer to the data array
data_sizeThe size of the data array
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_read_data_ext_isr()

void mtb_pmbus_cmd_read_data_ext_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
int32_t page,
int32_t phase,
uint8_t * data,
uint32_t data_size )

Read the data from the buffer for the selected command, page and phase.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
The returned data for command which take part in active transfer can be invalid.
Reading the command buffer is not an atomic operation and does not occur within a critical section. Therefore, in projects where the command buffer is accessed from multiple execution contexts, it is the user's responsibility to ensure the proper synchronization and access order.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
pageThe page number to update. If the command is not paged, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
phaseThe phase number to update. If the command is not phased, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
dataThe pointer to the data array
data_sizeThe size of the data array

◆ mtb_pmbus_cmd_get_transfer_size()

mtb_pmbus_status_t mtb_pmbus_cmd_get_transfer_size ( mtb_pmbus_stc_t * inst,
uint32_t code,
uint8_t * size )

Returns the number of bytes which is transferred during last transaction.

For majority of protocol the size of read/write data equal to command size, but for the Block Write-Block Read Process Call, Block Write, Block Read protocols, the size of transfer can be smaller than the maximum size of command in command table.

The function validates the input parameters and returns the appropriate error status.

The function prevents reading the transfer size if the command is active, to avoid data corruption. Therefore, using this function within a PMBus callback (executed inside an ISR) will have no effect.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code
sizeThe size of the last transaction
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_get_transfer_size_isr()

void mtb_pmbus_cmd_get_transfer_size_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
uint8_t * size )

Returns the number of bytes which is transferred during last transaction.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

For the majority of protocols, the size of read/write data is equal to the command size, but for the Block Write-Block Read Process Call, Block Write, Block Read protocols, the size of transfer can be smaller than the maximum size of a command in the command table.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
The returned transfer size for command which takes part in active transfer can be invalid.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
sizeThe size of the last transaction

◆ mtb_pmbus_cmd_get_transfer_size_ext()

mtb_pmbus_status_t mtb_pmbus_cmd_get_transfer_size_ext ( mtb_pmbus_stc_t * inst,
uint32_t code,
int32_t page,
int32_t phase,
uint8_t * size )

Returns the number of bytes which is transferred during last transaction.

For the majority of protocols, the size of read/write data is equal to the command size, but for the Block Write-Block Read Process Call, Block Write, Block Read protocols, the size of transfer can be smaller than the maximum size of command in command table.

The function validates the input parameters and returns the appropriate error status.

The function prevents reading the transfer size if the command is active, to avoid data corruption. Therefore, using this function within a PMBus callback (executed inside an ISR) will have no effect.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code
pageThe page number to update. If the command is not paged, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
phaseThe phase number to update. If the command is not phased, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
sizeThe pointer to transfer size
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_get_transfer_size_ext_isr()

void mtb_pmbus_cmd_get_transfer_size_ext_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
int32_t page,
int32_t phase,
uint8_t * size )

Returns the number of bytes which is transferred during last transaction.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

For the majority of protocols, the size of read/write data is equal to the command size, but for the Block Write-Block Read Process Call, Block Write, Block Read protocols, the size of transfer can be smaller than the maximum size of a command in the command table.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
The returned transfer size for command which takes part in active transfer can be invalid.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
pageThe page number to update. If the command is not paged, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
phaseThe phase number to update. If the command is not phased, then use MTB_PMBUS_NO_PAGE_PHASE as input parameters
sizeThe pointer to transfer size

◆ mtb_pmbus_cmd_is_active_isr()

void mtb_pmbus_cmd_is_active_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool * status )

Returns true if command participate in current transfer, otherwise returns false.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code
statusTrue if command is active, otherwise false

◆ mtb_pmbus_cmd_is_active()

mtb_pmbus_status_t mtb_pmbus_cmd_is_active ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool * status )

Returns true if command participate in current transfer, otherwise returns false.

The function validates the input parameters and returns the appropriate error status.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code
statusTrue if command is active, otherwise false
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_enable_disable_isr()

void mtb_pmbus_cmd_enable_disable_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool status )

Enable/Disable command.

If the command is enabled, the PMBus Middleware sends ACK bit after receiving the command code and transmits or receives data, otherwise the PMBus sends NACK after receiving the command code.

The function can be used to enable/disable commands from both command tables: main ( mtb_pmbus_stc_config_t::cmd_table) and extended ( mtb_pmbus_stc_config_t::ext_cmd_table).

To disable the extended command, use mtb_pmbus_cmd_ext_enable_disable.

This function is optimized for use during ISR and is recommended to be used in a command callback. The function skips validation of input parameters and does not check if the command is currently being updated or read by the controller.

Warning
Enabling/Disabling the command which take part in active transfer can lead to unexpected behavior.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code
statusSet to true to enable command, set to false to disable command

◆ mtb_pmbus_cmd_enable_disable()

mtb_pmbus_status_t mtb_pmbus_cmd_enable_disable ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool status )

Enable/Disable command.

If the command is enabled, the PMBus Middleware sends ACK bit after receiving the command code and transmits or receives data, otherwise the PMBus sends NACK after receiving the command code.

The function can be used to enable/disable commands from both command tables: main ( mtb_pmbus_stc_config_t::cmd_table) and extended ( mtb_pmbus_stc_config_t::ext_cmd_table).

To disable the extended command, use mtb_pmbus_cmd_ext_enable_disable.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code
statusSet to true to enable command, set to false to disable command
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_ext_enable_disable()

mtb_pmbus_status_t mtb_pmbus_cmd_ext_enable_disable ( mtb_pmbus_stc_t * inst,
bool status )

Enable/Disable the extended command.

If the command is enabled, the PMBus middleware sends ACK bit after receiving the command code and transmits or receives data, otherwise the PMBus sends NACK after receiving the command code.

When the extended command is disabled, none commands from the extended table will be transmitted.

Note
This function is only available when MTB_PMBUS_SUPPORT_EXT_CMD is enabled at compile time options.
Parameters
instThe pointer to the PMBus instance structure
statusSet to true to enable the command, set to false to disable the command
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_all_enable_disable()

mtb_pmbus_status_t mtb_pmbus_cmd_all_enable_disable ( mtb_pmbus_stc_t * inst,
bool status )

Enable/Disable all commands from both command tables: main ( mtb_pmbus_stc_config_t::cmd_table) and extended ( mtb_pmbus_stc_config_t::ext_cmd_table).

If the command is enabled, the PMBus middleware sends ACK bit after receiving the command code and transmits or receives data, otherwise the PMBus sends NACK after receiving the command code.

The function prevents enabling/disabling the commands if PMBus instance takes part in communication.

Parameters
instThe pointer to the PMBus instance structure
statusSet to true to enable all the commands, set to false to disable all the commands
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_get_status()

mtb_pmbus_status_t mtb_pmbus_cmd_get_status ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool * status )

Returns true if a command is executed at least one time.

Returns true if a command is executed at least one time (The controller executes transaction for this command and transaction is completed). Returns false if a command never executed after enabling of middleware or after the last calling of mtb_pmbus_cmd_get_status() for this command.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code
statusStatus of command execution
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_wr_protect_isr()

void mtb_pmbus_cmd_wr_protect_isr ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool status )

Enable or disable write protection for a specific command.

When write protection is enabled (status = true), the PMBus middleware will NACK any write attempts to the specified command code. When disabled (status = false), normal write access is allowed.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Warning
Enabling/Disabling write protection for the command which take part in active transfer can lead to unexpected behavior.
Parameters
instThe pointer to the PMBus instance structure
codeThe command code for target command
statusSet to true to enable write protection, false to disable

◆ mtb_pmbus_cmd_wr_protect()

mtb_pmbus_status_t mtb_pmbus_cmd_wr_protect ( mtb_pmbus_stc_t * inst,
uint32_t code,
bool status )

Enable or disable write protection for a specific command.

When write protection is enabled (status = true), the PMBus middleware will NACK any write attempts to the specified command code. When disabled (status = false), normal write access is allowed.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Parameters
instThe pointer to the PMBus instance structure
codeThe command code for target command
statusSet to true to enable write protection, false to disable
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_all_wr_protect()

mtb_pmbus_status_t mtb_pmbus_cmd_all_wr_protect ( mtb_pmbus_stc_t * inst,
bool status )

Enables or disables write protection for all PMBus commands.

This function sets the write protection status for all commands in the PMBus instance.

The function prevents enabling/disabling the commands protection if PMBus instance takes part in communication.

Parameters
instThe pointer to the PMBus instance structure.
statusSet to true to enable write protection, false to disable.
Returns
mtb_pmbus_status_t

◆ mtb_pmbus_cmd_exit_isr()

mtb_pmbus_status_t mtb_pmbus_cmd_exit_isr ( mtb_pmbus_stc_t * inst)

Requests to pause the Process Call protocol execution and exit from the ISR handler.

This function must be called from within the command callback during the MTB_PMBUS_CMD_WRITE_DONE event for Process Call protocols. It allows the application to defer the read response phase, enabling time-consuming processing outside the ISR context.

When called during the allowed window (MTB_PMBUS_CMD_WRITE_DONE event), the function pauses the I2C hardware transmission. The middleware will suspend the transaction after the write phase completes, allowing the application to process the received data and prepare the response outside of ISR context. After processing, the application must call mtb_pmbus_cmd_complete_transfer() to resume and complete the transaction.

Usage pattern:

  1. Controller initiates Process Call write phase
  2. In MTB_PMBUS_CMD_WRITE_DONE callback, call mtb_pmbus_cmd_exit_isr()
  3. Exit ISR and process received data in main application context
  4. Update response data buffer
  5. Call mtb_pmbus_cmd_complete_transfer() to resume and send response
Parameters
instThe pointer to the PMBus instance structure
Returns
mtb_pmbus_status_t Status of the operation:
  • MTB_PMBUS_STATUS_SUCCESS: Pause request was accepted and hardware transmission paused successfully
  • MTB_PMBUS_STATUS_BAD_PARAM: Function was called outside the allowed context (not during MTB_PMBUS_CMD_WRITE_DONE event for Process Call) or hardware pause operation failed
Note
This function should only be used with Process Call protocols
Must be called from within the MTB_PMBUS_CMD_WRITE_DONE event callback
If a command supports both write and process call capabilities (MTB_PMBUS_CMD_CAP_DIR_WR | MTB_PMBUS_CMD_CAP_DIR_PROCESS_CALL), the user can call mtb_pmbus_cmd_process_call_wr_done() function to determine whether the current MTB_PMBUS_CMD_WRITE_DONE event occurred for a Process Call transaction

◆ mtb_pmbus_cmd_complete_transfer()

mtb_pmbus_status_t mtb_pmbus_cmd_complete_transfer ( mtb_pmbus_stc_t * inst,
uint32_t code )

Resumes a paused Process Call protocol transaction.

This function must be called outside of ISR context after calling mtb_pmbus_cmd_exit_isr() to complete a Process Call protocol transaction. After the write phase completes and the application processes the received data, this function resumes the I2C transaction and sends the response data to the controller.

To apply this function to an extended command, put parameter code into macros MTB_PMBUS_CONV_CMD_EXT_CMD_FORMAT.

Usage pattern:

  1. In MTB_PMBUS_CMD_WRITE_DONE callback, call mtb_pmbus_cmd_exit_isr() to pause the transaction
  2. Exit ISR and process received data in the main application context
  3. Update the command buffer with response data
  4. Call mtb_pmbus_cmd_complete_transfer() to resume and complete the transaction
Parameters
instThe pointer to the PMBus instance structure
codeCommand code of the paused Process Call command
Returns
mtb_pmbus_status_t Status of the operation:
  • MTB_PMBUS_STATUS_SUCCESS: Transaction resumed and completed successfully
  • MTB_PMBUS_STATUS_BAD_PARAM: The specified command is not in paused state (either not a Process Call or mtb_pmbus_cmd_exit_isr() was not called)
Note
This function must be called outside of ISR/callback context
This function should only be used with Process Call protocols

◆ mtb_pmbus_cmd_process_call_wr_done()

mtb_pmbus_status_t mtb_pmbus_cmd_process_call_wr_done ( mtb_pmbus_stc_t * inst,
bool * status )

Determines if the current MTB_PMBUS_CMD_WRITE_DONE event is for a Process Call protocol.

This function checks whether the current MTB_PMBUS_CMD_WRITE_DONE event occurred for a Process Call transaction. It is useful when a command supports both standard write and Process Call capabilities (MTB_PMBUS_CMD_CAP_DIR_WR | MTB_PMBUS_CMD_CAP_DIR_PROCESS_CALL), allowing the application to distinguish between the two operation types.

When a command supports both capabilities, the WRITE_DONE callback will be triggered for both write and Process Call operations. This function returns true only when the event is for a Process Call, indicating that:

  • The pause mechanism is available (mtb_pmbus_cmd_exit_isr() can be called)
  • A read phase will follow to send response data back to the controller
Parameters
instThe pointer to the PMBus instance structure
statusPointer to a boolean variable that will be updated with the result:
  • true: Current WRITE_DONE event is for a Process Call protocol
  • false: Current WRITE_DONE event is for a standard write operation
Returns
mtb_pmbus_status_t Status of the operation:
  • MTB_PMBUS_STATUS_SUCCESS: Status retrieved successfully
  • MTB_PMBUS_STATUS_BAD_PARAM: Invalid parameter (status pointer is NULL)
Note
This function should be called from within the MTB_PMBUS_CMD_WRITE_DONE callback