pristal
pristal

Reputation: 3

uint8_t * const LCDMem = (uint8_t *) &LCDM3; meaning

uint8_t * const LCDMem = (uint8_t *) &LCDM3;

This code is used in msp430fg4618 trainer kit for lcd configuration. Could any one please explain the meaning of the above mentioned code?

It allows use of array LCDMem[]? I don't know how.

Upvotes: 0

Views: 396

Answers (2)

user4815162342
user4815162342

Reputation: 155156

The operator (type) value is called a cast and implements conversion from one type to another.

The code in your example casts one pointer, the address of LCDM3, to a pointer of a different type. This enables access to the contents of LCDM3 through the LCDMem pointer as if it were a contiguous array of bytes (8-bit unsigned integers).

For example, LDCM3 could be a structure object, or the first element of an array of structures. The above cast would allow one to read and write the individual bytes of the underlying object(s).

Upvotes: 2

J X
J X

Reputation: 55

LCDMem is not arrray, it is a pointer. This code assigns to LCDMem new address - LCDM3's, so after execution LCDMem will point to LCDM3. Can't say how many bytes allocated for LCDM3, may be array, may be just one.

Upvotes: 3

Related Questions