PxRegisterRead()

Read a value from a SFR register.

APPLIES TO

1.0.0

SYNOPSIS
PxULong_t PxRegisterRead (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 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 a task (not from a handler).

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
  • addr has to be a valid pointer to a special function register (V).

After call
  • PxGetError must be called 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.

USAGE
#include "pxdef.h"

PxULong_t registerReadReturn = PxRegisterRead(addr);

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