summaryrefslogtreecommitdiff
path: root/analog/motor-power-avr/src/utils.h
blob: 54cb978ea9d3c81463338729de841da95cd90a84 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef utils_h
#define utils_h
/* utils.h */
/*  {{{
 *
 * Copyright (C) 2008 Pierre Prot
 *
 * APBTeam:
 *        Web: http://apbteam.org/
 *      Email: team AT apbteam DOT org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * }}} */


/* Concatenate 8 bits values.
 *  vx: bit value
 *  bx: bit shift
 */
#define regv(b0, b1, b2, b3, b4, b5, b6, b7, v0, v1, v2, v3, v4, v5, v6, v7) \
    ( \
        ((v0 && 1) << b0) | \
        ((v1 && 1) << b1) | \
        ((v2 && 1) << b2) | \
        ((v3 && 1) << b3) | \
        ((v4 && 1) << b4) | \
        ((v5 && 1) << b5) | \
        ((v6 && 1) << b6) | \
        ((v7 && 1) << b7)   \
    )

#endif