# include/bitops.h File Reference

Generic bit operations. More...

`#include <stdbool.h>`
`#include <types.h>`
`#include <assert.h>`
`#include <arch/bitops.h>`

Include dependency graph for bitops.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | bit_mask(nr) (1 << ((nr) & (BITS_PER_LONG - 1)))
| Generate a bit mask with only bit nr set.
#define | bit_word(nr) ((nr) / BITS_PER_LONG)
| Return the offset of the word containing bit nr in a multi-word bitfield.
## Functions
static void | set_bit (unsigned int nr, unsigned long *bitmap)
| Set bit nr in the multi-word bitfield bitmap.
static void | clear_bit (unsigned int nr, unsigned long *bitmap)
| Clear bit nr in the multi-word bitfield bitmap.
static void | toggle_bit (unsigned int nr, unsigned long *bitmap)
| Toggle bit nr in the multi-word bitfield bitmap.
static bool | test_bit (unsigned int nr, unsigned long *bitmap)
| Test bit nr in the multi-word bitfield bitmap.
static uint32_t | extract_aligned_bitfield (unsigned int start, unsigned int length, const uint32_t *bitmap)
| Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.
static uint32_t | extract_bitfield (unsigned int start, unsigned int length, const uint32_t *bitmap)
| Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.

## Detailed Description

Generic bit operations.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file bitops.h.

## Define Documentation

#define bit_mask | ( | nr |  | ) | (1 << ((nr) & (BITS_PER_LONG - 1)))

Generate a bit mask with only bit nr set.

Definition at line 49 of file bitops.h.

Referenced by atomic_clear_bit(), atomic_set_bit(), atomic_test_and_clear_bit(), atomic_test_and_set_bit(), atomic_toggle_bit(), clear_bit(), set_bit(), and toggle_bit().

#define bit_word | ( | nr |  | ) | ((nr) / BITS_PER_LONG)

Return the offset of the word containing bit nr in a multi-word bitfield.

Definition at line 54 of file bitops.h.

Referenced by atomic_clear_bit(), atomic_set_bit(), atomic_test_and_clear_bit(), atomic_test_and_set_bit(), atomic_toggle_bit(), clear_bit(), extract_aligned_bitfield(), extract_bitfield(), set_bit(), test_bit(), and toggle_bit().

## Function Documentation

static void clear_bit | ( | unsigned int | nr,
|  | unsigned long * | bitmap |
| ) |  |  | `[inline, static]`

Clear bit nr in the multi-word bitfield bitmap.

Definition at line 69 of file bitops.h.

References bit_mask, and bit_word.

Referenced by sdmmc_slot_notify_card_detect(), sdmmc_slot_power_up(), softirq_priv_do_pending(), udc_detach(), udc_ep_clear_wedge(), usbb_udc_dma_interrupt(), usbb_udc_softirq(), usbb_udc_submit_in_queue(), usbb_udc_submit_out_queue(), and usbb_udc_vbus_off().

static uint32_t extract_aligned_bitfield | ( | unsigned int | start,
|  | unsigned int | length,
|  | const uint32_t * | bitmap |
| ) |  |  | `[inline, static]`

Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.

Precondition:
  The desired bitfield must not cross word boundaries

Return values:

  | The | desired bitfield

Definition at line 102 of file bitops.h.

References bit_word, and BITS_PER_LONG.

Referenced by extract_bitfield().

static uint32_t extract_bitfield | ( | unsigned int | start,
|  | unsigned int | length,
|  | const uint32_t * | bitmap |
| ) |  |  | `[inline, static]`

Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.

Return values:

  | The | desired bitfield

Definition at line 120 of file bitops.h.

References assert, bit_word, BITS_PER_LONG, and extract_aligned_bitfield().

Referenced by sdmmc_decode_mmc_cid(), sdmmc_decode_mmc_csd(), sdmmc_decode_sd_cid(), and sdmmc_decode_sd_csd().

Here is the call graph for this function:

static void set_bit | ( | unsigned int | nr,
|  | unsigned long * | bitmap |
| ) |  |  | `[inline, static]`

Set bit nr in the multi-word bitfield bitmap.

Definition at line 61 of file bitops.h.

References bit_mask, and bit_word.

Referenced by dummy_blkdev_init(), sdmmc_req_prep_transfer(), sdmmc_slot_notify_card_detect(), udc_attach(), udc_ep0_submit_in_req(), udc_ep0_submit_out_req(), udc_ep_create(), udc_ep_flush(), udc_ep_set_wedge(), usb_func_get_descriptor(), usbb_udc_submit_in_queue(), usbb_udc_submit_out_queue(), and usbb_udc_vbus_on().

static bool test_bit | ( | unsigned int | nr,
|  | unsigned long * | bitmap |
| ) |  |  | `[inline, static]`

Test bit nr in the multi-word bitfield bitmap.

Return values:

  | true | if the bit is set
  | false | if the bit is clear

Definition at line 88 of file bitops.h.

References bit_word, and BITS_PER_LONG.

Referenced by sdmmc_slot_is_card_present(), udc_attach(), udc_detach(), udc_ep0_expect_status(), udc_ep0_send_status(), udc_ep0_submit_in_req(), udc_ep0_submit_out_req(), udc_ep0_write_sync(), udc_ep_clear_halt(), udc_ep_clear_wedge(), udc_ep_is_wedged(), udc_ep_submit_in_req(), udc_ep_submit_out_req(), udc_state(), usbb_udc_submit_in_queue(), usbb_udc_submit_out_queue(), usbb_udc_vbus_off(), and usbb_udc_vbus_on().

static void toggle_bit | ( | unsigned int | nr,
|  | unsigned long * | bitmap |
| ) |  |  | `[inline, static]`

Toggle bit nr in the multi-word bitfield bitmap.

Definition at line 77 of file bitops.h.

References bit_mask, and bit_word.