29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Compiler</strong> Features<br />

4.16 <strong>Compiler</strong> type attribute, __attribute__((bitband))<br />

__attribute__((bitband)) is a type attribute that is used to bit-band type definitions of<br />

structures.<br />

In Example 4-7, <strong>the</strong> unplaced bit-banded objects must be relocated into <strong>the</strong> bit-band region. This<br />

can be achieved by ei<strong>the</strong>r using an appropriate scatter-loading description file or by using <strong>the</strong><br />

--rw_base linker command-line option.<br />

Example 4-7 Unplaced object<br />

/* foo.c */<br />

typedef struct {<br />

int i : 1;<br />

int j : 2;<br />

int k : 3;<br />

} BB __attribute__((bitband));<br />

BB value; // Unplaced object<br />

void update_value(void)<br />

{<br />

value.i = 1;<br />

value.j = 0;<br />

}<br />

/* end of foo.c */<br />

Alternatively, __attribute__((at())) can be used to place bit-banded objects at a particular<br />

address in <strong>the</strong> bit-band region. See Example 4-8.<br />

Example 4-8 Placed object<br />

/* foo.c */<br />

typedef struct {<br />

int i : 1;<br />

int j : 2;<br />

int k : 3;<br />

} BB __attribute((bitband));<br />

BB value __attribute__((at(0x20000040))); // Placed object<br />

void update_value(void)<br />

{<br />

value.i = 1;<br />

value.j = 0;<br />

}<br />

/* end of foo.c */<br />

4.16.1 See also<br />

Concepts<br />

• <strong>Compiler</strong> and processor support <strong>for</strong> bit-banding on page 4-21.<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 4-22<br />

ID061811<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!