# /space/home/slher/rel/Beken/v6_4_5/macsw/modules/common/src/co_utils.h File Reference

Common utilities definitions. More...

`#include "compiler.h"`
`#include <limits.h>`
`#include "co_math.h"`

Go to the source code of this file.

## Defines
#define | CO_STAIDX_TO_AID(sta_idx) ((sta_idx) + 1)
| Converts a STA index in an Association Index.
#define | CO_GET_INDEX(__element_ptr, __array_ptr) ((__element_ptr) - (__array_ptr))
| Get the index of an element in an array.
#define | CO_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
| Get the number of element in an array.
#define | CHAR_LEN (CHAR_BIT/8)
| Length of a char in bytes.
#define | CPU2HW(ptr) (((uint32_t)(ptr)) * CHAR_LEN)
| Converts a CPU pointer into a HW address This macro is used to convert a SW pointer into the corresponding HW address.
#define | HW2CPU(ptr) ((void *)(((uint32_t)(ptr)) / CHAR_LEN))
| Converts a HW address into a CPU pointer This macro is doing the reverse operation as CPU2HW.
#define | sizeof_b(a) (sizeof(a) * CHAR_LEN)
| Return the size of a variable or type in bytes.
#define | offsetof_b(a, b) (offsetof(a, b) * CHAR_LEN)
| Return the offset (in bytes) of a structure element.
## Functions
__INLINE uint16_t | co_read16 (void const *ptr16)
| Read an aligned 16 bits word.
__INLINE void | co_write16 (void const *ptr16, uint32_t value)
| Write an aligned 16 bits word.
__INLINE uint32_t | co_read32 (void const *ptr32)
| Read an aligned 32 bit word.
__INLINE void | co_write32 (void const *ptr32, uint32_t value)
| Write an aligned 32 bits word.
__INLINE void | co_copy32 (uint32_t *dst, uint32_t *src, uint32_t len)
| Copy a 32-bit aligned buffer into another one The length in bytes is converted to the corresponding number of 32-bit words.
__INLINE uint8_t | co_read8p (uint32_t addr)
| Read a 8 bits word.
__INLINE void | co_write8p (uint32_t addr, uint8_t value)
| Write a 8 bits word.
__INLINE uint16_t | co_read16p (uint32_t addr)
| Read a packed 16 bits word.
__INLINE void | co_write16p (uint32_t addr, uint32_t value)
| Write a packed 16 bits word.
__INLINE uint32_t | co_read24p (uint32_t addr)
| Read a packed 24 bits word.
__INLINE void | co_write24p (uint32_t addr, uint32_t value)
| Write a packed 24 bits word.
__INLINE uint32_t | co_read32p (uint32_t addr)
| Read a packed 32 bits word.
__INLINE void | co_write32p (uint32_t addr, uint32_t value)
| Write a packed 32 bits word.
__INLINE uint64_t | co_read64p (uint32_t addr)
| Read a packed 64 bits word.
__INLINE bool | co_cmp8p (uint32_t pkd, uint8_t const *ptr, uint32_t len)
| Compare a packed byte buffer with a CPU byte array.
__INLINE void | co_pack8p (uint32_t dst, uint8_t const *src, uint32_t len)
| Copy and pack a byte array to another one.
__INLINE void | co_unpack8p (uint8_t *dst, uint32_t src, uint32_t len)
| Copy and unpack a byte array to another one.
__INLINE void | co_copy8p (uint32_t dst, uint32_t src, uint32_t len)
| Copy a packed byte array to another packed byte array.
__INLINE uint8_t | co_val_get (uint8_t const array[], int lsb, int width)
| This function returns the value of bit field inside an array of bits, represented as an array of bytes.
__INLINE void | co_val_set (uint8_t array[], int lsb, int width, uint8_t val)
| This function sets a value of a bit field inside an array of bits, represented as an array of bytes.
__INLINE bool | co_bit_is_set (uint8_t const array[], int pos)
| This function returns the status of a specific bit position inside an array of bits, represented as an array of bytes.
__INLINE void | co_bit_set (uint8_t array[], uint8_t pos)
| This function sets a specific bit position inside an array of bits, represented as an array of bytes.
__INLINE void | co_bit_clr (uint8_t array[], uint8_t pos)
| This function clears a specific bit position inside an array of bits, represented as an array of bytes.

## Detailed Description

Common utilities definitions.

Copyright (C) RivieraWaves 2011-2019

Definition in file co_utils.h.