Bus Master and PC Functions

group group_prot_functions_busmaster

Functions

cy_en_prot_status_t Cy_Prot_ConfigBusMaster(en_prot_master_t busMaster, bool privileged, bool secure, uint32_t pcMask)

Configures the allowed protection contexts, security (secure/non-secure) and privilege level of the bus transaction created by the specified master.

note

This function is applicable for both CPUSS ver_1 and ver_2.

note

The function accepts pcMask values from CY_PROT_PCMASK1 to CY_PROT_PCMASK15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file.

Status

Description

CY_PROT_SUCCESS

The function completed successfully.

CY_PROT_FAILURE

The resource is locked.

Return

Status of the function call.

Function Usage


    /* Scenario: CM0+ needs to be able to access resources protected with privileged, 
                 secure and set PC value (PC=0, PC=1 or PC=2) access settings */
    
    /* Configure the CM0+ bus master - privileged, secure, allow setting PC to PC=1 and PC=2 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM0, true, true, CY_PROT_PCMASK1 | CY_PROT_PCMASK2))
    {
        /* Insert error handling */
    }

Parameters
  • busMaster: Indicates which master needs to be configured. Refer to the CPUSS_MS_ID_X defines in the device config header file.

  • privileged: Boolean to define the privilege level of all subsequent bus transfers. True - privileged, False - not privileged. Note that this is an inherited value. If not inherited, then this bit will be used.

  • secure: Security setting for the master. True - Secure, False - Not secure.

  • pcMask: This is a 16 bit value of the allowed contexts, it is an OR’ed (|) field of the provided defines in cy_prot.h. For example: (CY_PROT_PCMASK1 | CY_PROT_PCMASK3 | CY_PROT_PCMASK4)

cy_en_prot_status_t Cy_Prot_SetActivePC(en_prot_master_t busMaster, uint32_t pc)

Sets the current/active protection context of the specified bus master.

Allowed PC values are 1-15. If this value is not inherited from another bus master, the value set through this function is used.

note

This function is applicable for both CPUSS ver_1 and ver_2.

note

The function does not have access and returns an error for the secure CYB06xx7 devices.

note

that only those protection contexts allowed by the pcMask (which was configured in Cy_Prot_ConfigBusMaster) will take effect.

note

The function accepts pcMask values from CY_PROT_PC1 to CY_PROT_PC15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file.

Status

Description

CY_PROT_SUCCESS

The function completed successfully.

CY_PROT_FAILURE

The resource is locked.

Return

Status of the function call.

Function Usage


    /* Scenario: CM0+ needs to access a protected resources that requires PC=1 attribute */
    
    /* Configure the bus master to allow setting PC to PC=1 and PC=2 */
     Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM0, true, true, CY_PROT_PCMASK1 | CY_PROT_PCMASK2);
    
    /* Get the active PC value of CM0+ */
    if(CY_PROT_PC1 != Cy_Prot_GetActivePC(CPUSS_MS_ID_CM0))
    {
        /* Set the CM0+ PC value to 1 */
        if(CY_PROT_SUCCESS != Cy_Prot_SetActivePC(CPUSS_MS_ID_CM0, CY_PROT_PC1))
        {
            /* Insert error handling */
        }
    }

Parameters
  • busMaster: The bus master to configure. Refer to the CPUSS_MS_ID_X defines in the device config header file.

  • pc: Active protection context of the specified master cy_en_prot_pc_t.

uint32_t Cy_Prot_GetActivePC(en_prot_master_t busMaster)

note

This function is applicable for both CPUSS ver_1 and ver_2.

Returns the active protection context of a master.

Return

Active protection context of the master cy_en_prot_pc_t.

Function Usage


    /* Scenario: CM0+ needs to access a protected resources that requires PC=1 attribute */
    
    /* Configure the bus master to allow setting PC to PC=1 and PC=2 */
     Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM0, true, true, CY_PROT_PCMASK1 | CY_PROT_PCMASK2);
    
    /* Get the active PC value of CM0+ */
    if(CY_PROT_PC1 != Cy_Prot_GetActivePC(CPUSS_MS_ID_CM0))
    {
        /* Set the CM0+ PC value to 1 */
        if(CY_PROT_SUCCESS != Cy_Prot_SetActivePC(CPUSS_MS_ID_CM0, CY_PROT_PC1))
        {
            /* Insert error handling */
        }
    }

Parameters
  • busMaster: The bus master, whose protection context is being read. Refer to the CPUSS_MS_ID_X defines in the device config header file.