]> git.zerfleddert.de Git - fnordlicht-mini/blame - firmware/common/common.h
more lean and mean, switching still doesn't work... :-(
[fnordlicht-mini] / firmware / common / common.h
CommitLineData
ec1bef8e 1/* vim:ts=4 sts=4 et tw=80
2 *
3 * fnordlicht firmware
4 *
5 * for additional information please
6 * see http://lochraster.org/fnordlichtmini
7 *
8 * (c) by Alexander Neumann <alexander@bumpern.de>
9 * Lars Noschinski <lars@public.noschinski.de>
10 *
11 * This program is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 3 as published by
13 * the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#ifndef COMMON_H
25#define COMMON_H
26
27#include <stdint.h>
28
29/* macros for extracting low and high byte */
30#define LO8(x) (uint8_t)(0x00ff & (x))
31#define HI8(x) (uint8_t)((0xff00 & (x)) >> 8)
32
33/* macros for concatenating PORT, PIN and DDR */
34#define _CONCAT(a, b) a ## b
35#define _OUTPORT(name) _CONCAT(PORT, name)
36#define _INPORT(name) _CONCAT(PIN, name)
37#define _DDRPORT(name) _CONCAT(DDR, name)
38#define _PCIE(name) _CONCAT(PCIE, name)
39#define _PCIF(name) _CONCAT(PCIF, name)
40#define _PCMSK(name) _CONCAT(PCMSK, name)
41#define _PCINT(name) _CONCAT(PCINT, name)
42
43/* __noinline attribute (opposite of inline attribute */
44#define __noinline __attribute__((noinline))
45
46/* structure for accessing bytes and words in an uint32_t */
47union uint32_t_access {
48 uint8_t bytes[4];
49 uint16_t words[2];
50 uint32_t raw;
51};
52
53#endif
Impressum, Datenschutz