PxRegisterRead_Hnd()

Read a value from a SFR register (handler function).

APPLIES TO

8.2.0

SYNOPSIS
PxULong_t PxRegisterRead_Hnd (volatile PxULong_t *addr);
ARGUMENTS
addr

Address of the desired register to read

RETURN VALUES
  • Value of the desired register

  • 0 on error. If 0 is returned, the caller has to check the task error code with 'PxGetError()'.

ERROR CODES

PXERR_ACCESS_RIGHT

The task has not the right to access peripheral registers

PXERR_PROT_ILL_REGION

addr is not within additional protection region

DESCRIPTION

PxRegisterRead_Hnd returns the content of the peripheral register addr if the calling task has read access right to this special function register. It should only be used from handlers running in a task’s context.

The peripheral register addr must be covered in the additional protection region table passed in the element ts_protect_region of PxTaskSpec_t during PxTaskCreate.

IMPLEMENTATION GUIDELINES
Before call
  • This function should be called from handlers only. (V)

  • addr has to be a valid pointer to a special function register (V).

After call
  • The function returns 0 if an error occurred. In this case the appropriate task must call PxGetError to check if an error has occurred (F).

Best Practice
  • The peripheral register addr must be covered in the additional protection region table passed in the element ts_protect_region of PxTaskSpec_t during PxTaskCreate of the task which has installed the handler.

USAGE
#include "pxdef.h"

PxULong_t registerReadReturn = PxRegisterRead_Hnd(addr);

if (0 == registerReadReturn) {
    // Report error
    errorCode = PxGetError();
}