]> git.zerfleddert.de Git - fnordlicht-mini/blame - firmware/fnordlicht-bootloader/global.h
reference firmware
[fnordlicht-mini] / firmware / fnordlicht-bootloader / global.h
CommitLineData
ec1bef8e 1/* vim:ts=4 sts=4 et tw=80
2 *
3 * fnordlichtmini serial bootloader
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 __GLOBAL_H
25#define __GLOBAL_H
26
27#include "config.h"
28
29/* configure primary pwm pins (MUST be three successive pins in a port) */
30#define PWM_PORT B
31#define PWM_CHANNELS 3
32#define PWM_CHANNEL_MASK (_BV(PB0) | _BV(PB1) | _BV(PB2))
33#define PWM_SHIFT 0
34
35/* configure INT pin */
36#define REMOTE_INT_PORT D
37#define REMOTE_INT_PIN PD2
38
39/* abbreviations for port, ddr and pin */
40#define P_PORT _OUTPORT(PWM_PORT)
41#define P_DDR _DDRPORT(PWM_PORT)
42#define R_PORT _OUTPORT(REMOTE_INT_PORT)
43#define R_DDR _DDRPORT(REMOTE_INT_PORT)
44#define R_PIN _INPORT(REMOTE_INT_PORT)
45#define INTPIN REMOTE_INT_PIN
46
47/* check if hardware is valid */
48#if defined(HARDWARE_fnordlicht)
49 /* specific settings for old fnordlicht hardware */
50 #if !defined(PWM_INVERTED)
51 #define PWM_INVERTED
52 #endif
53#elif defined(HARDWARE_fnordlichtmini)
54 /* specific settings for fnordlichtmini hardware */
55
56#else
57#error "unknown HARDWARE platform!"
58#endif
59
60/* turn pwm output pins on and off */
61#ifdef PWM_INVERTED
62#define PWM_PIN_ON(bit) P_PORT &= ~_BV(bit) << (PWM_SHIFT)
63#define PWM_PIN_OFF(bit) P_PORT |= _BV(bit) << (PWM_SHIFT)
64#else
65#define PWM_PIN_ON(bit) P_PORT |= _BV(bit) << (PWM_SHIFT)
66#define PWM_PIN_OFF(bit) P_PORT &= ~_BV(bit) << (PWM_SHIFT)
67#endif
68
69#define PWM_PIN_TOGGLE(bit) P_PORT ^= _BV(bit) << (PWM_SHIFT)
70
71#define PWM_RED 0
72#define PWM_GREEN 1
73#define PWM_BLUE 2
74
75/* wait 100ms before checking INT pin (for delay_loop_2(50000)) */
76#define CONFIG_DELAY F_CPU/4/50000/10
77#define CONFIG_DELAY_LOOP2 50000
78
79#endif
Impressum, Datenschutz