I'm studying the redpitaya source code,
I have a question in rp_GenFreq->gen_setFrequency->gen_Synchronise->generate_Synchronise->cmn_SetBits((uint32_t *) generate, 0x00400040, 0xFFFFFFFF);
Here generate is the pointer point to a structure space related to the FPGA register.
Definition of cmn_SetBits :
Code: Select all
int cmn_SetBits(volatile uint32_t* field, uint32_t bits, uint32_t mask)
{
VALIDATE_BITS(bits, mask);
SET_BITS(*field, bits);
return RP_OK;
}
Code: Select all
#define VALIDATE_BITS(b,m) { \
if (((b) & ~(m)) != 0) return RP_EOOR; \
}
#define SET_BITS(x,b) ((x) |= (b))
For my understanding, "field" in cmn_SetBits is an address to a structure,
then what's the meaning of SET_BITS(*field, bits) => *field |= bits ?
What's the purpose of SET_BITS ?
I appreciate any help.
Adam