I have a
#define PROT_EN_DAT 0x140
//(320 in decimal)
Its loaded into 64 bit value register(ex setup_data[39:8]=PROT_EN_DATA)
Now i want to put this value(0x140)into
uint8_t bRequest
uint16_t wValue
uint16_t wIndex
How can load the value so that i don’t have to manually do it for other values again.
I think we can do with shift operators but don know how.
EDIT:Ya its related to USB. bRequest(8:15),wValue(16:31),wIndex(32:47) but setup_data is 64 bit value.I want to know how can i load proper values into the these fields.
For example say next time i am using #define PROT_EN2_REG 0x1D8.
and say setup_data[39:8]=PROT_EN2_DATA
General read form:
General write form:
where:
aRegisteris the value you read from the bit-field-packed register,kBitFieldLSBIndexis the index of the least significant bit of the bit field, andkBitFieldWidthis the width of the bit field, andaFieldis the value of the bit fieldThese are generalized, and some operations (such as bit-masking) may be unnecessary in your case. Replace the
1with1Lif the register is larger than 32 bits.EDIT: In your example case (setup_data[39:8]=PROT_EN_DATA):
Read:
Write: