summaryrefslogtreecommitdiff
path: root/src/fox1ihu/flash-loader/ao_pins.h
blob: c4fa69bde8191be1ab4459e0df4005459a9c1301 (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright © 2013 Keith Packard <keithp@keithp.com>
 *
 * 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; version 2 of the License.
 *
 * 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.
 */

#ifndef _AO_PINS_H_
#define _AO_PINS_H_

/* External crystal at 8MHz */
#define AO_HSE		8000000

#define AO_WATCHDOG_PORT	(&stm_gpiod)
#define AO_WATCHDOG_PORT_BIT	(1 << STM_RCC_AHBENR_GPIODEN)
#define AO_WATCHDOG_BIT		3
#define AO_WATCHDOG_VALUE	0

#define AO_RADIO_CONTROL_PORT		(&stm_gpioe)
#define AO_RADIO_CONTROL_PORT_BIT	(1 << STM_RCC_AHBENR_GPIOEEN)
#define AO_RADIO_CONTROL_BIT		12
#define AO_RADIO_CONTROL_VALUE		1

#define AO_FLASH_LOADER_INIT do {					\
		stm_rcc.ahbenr |= AO_WATCHDOG_PORT_BIT | AO_RADIO_CONTROL_PORT_BIT; \
									\
		stm_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_VALUE); \
		stm_moder_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, STM_MODER_OUTPUT); \
									\
		stm_gpio_set(AO_RADIO_CONTROL_PORT, AO_RADIO_CONTROL_BIT, AO_RADIO_CONTROL_VALUE); \
		stm_moder_set(AO_RADIO_CONTROL_PORT, AO_RADIO_CONTROL_BIT, STM_MODER_OUTPUT); \
	} while (0)

#define AO_TIMER_HOOK	do {						\
		AO_WATCHDOG_PORT->odr ^= (1 << AO_WATCHDOG_BIT);	\
	} while (0)

#define HAS_TICK		0
#include <ao_flash_stm_pins.h>

/* Attached signal, PB8 */

#define AO_BOOT_PIN		1
#define AO_BOOT_APPLICATION_GPIO	stm_gpiob
#define AO_BOOT_APPLICATION_PIN		8
#define AO_BOOT_APPLICATION_VALUE	0
#define AO_BOOT_APPLICATION_MODE	0

#endif /* _AO_PINS_H_ */