summaryrefslogtreecommitdiffhomepage
path: root/digital/avr/modules/utils/utils.txt
blob: 23c92a5c87244f5b51c11b9aeaf72b5d47c01aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
==================
 Utils AVR module
==================
:Author: Nicolas Schodet

Introduction
============

This module provides general purpose utilities.

Byte packing/unpacking
======================

Theses functions are here to override bad code production with avr-gcc with the
classic shift idiom.

Functions which unpack from a large type to a smaller type take a ``pos``
parameter which is the position of the byte or word to extract from the large
type.  Small values are for LSB.  For example, ``v32_to_v8 (a, 0)`` will
extract the least significant byte from ``a``.

Functions which pack from a small type to a larger type take as many small
type values as needed to fill the large type number.  The first argument is
the MSB.  For example, ``v8_to_v32 (0x12, 0x34, 0x56, 0x78)`` will return
``0x12345678``.

API
===

.. include:: utils.exd