From 36cf713ead58a52539c87de764b022ba0dcde27d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 27 Apr 2013 16:06:48 -0700 Subject: altos/fox: Add fox1ihu flash loader Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/Makefile | 8 ++++++++ src/fox1ihu/flash-loader/ao_pins.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/fox1ihu/flash-loader/Makefile create mode 100644 src/fox1ihu/flash-loader/ao_pins.h (limited to 'src/fox1ihu/flash-loader') diff --git a/src/fox1ihu/flash-loader/Makefile b/src/fox1ihu/flash-loader/Makefile new file mode 100644 index 00000000..454bc6fb --- /dev/null +++ b/src/fox1ihu/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=fox1ihu +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h new file mode 100644 index 00000000..bcc3cc9c --- /dev/null +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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 + +#include + +/* Detatched signal, PD6 */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiod +#define AO_BOOT_APPLICATION_PIN 6 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE 0 + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From e79202f95f0e5b4a01da31d3742a775bea62cc92 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 28 Apr 2013 00:05:39 -0700 Subject: altos/fox: Run app when PD6 is low Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/ao_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu/flash-loader') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index bcc3cc9c..3a942c9c 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -28,7 +28,7 @@ #define AO_BOOT_PIN 1 #define AO_BOOT_APPLICATION_GPIO stm_gpiod #define AO_BOOT_APPLICATION_PIN 6 -#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_VALUE 0 #define AO_BOOT_APPLICATION_MODE 0 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 6247e0c81084b59365ceca0ced33d2db92a72444 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 1 Feb 2014 00:06:30 -0800 Subject: altos/fox: Enable system timer in flash loader and prod watchdog with it This makes it possible to reflash the board without needing to disable the watchdog. Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/ao_pins.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/fox1ihu/flash-loader') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index 3a942c9c..90917a38 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -21,6 +21,20 @@ /* External crystal at 8MHz */ #define AO_HSE 8000000 +#define AO_WATCHDOG_PORT (&stm_gpiod) +#define AO_WATCHDOG_BIT 3 + +#define AO_FLASH_LOADER_INIT do { \ + ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0); \ + } while (0) + +#define AO_TIMER_HOOK do { \ + static uint8_t watchdog; \ + ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, watchdog); \ + watchdog ^= 1; \ + } while (0) + +#define HAS_TICK 1 #include /* Detatched signal, PD6 */ -- cgit v1.2.3 From 9003147a89074f8d991d1707f307fd4e41435aa3 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Mon, 5 May 2014 17:32:22 -0600 Subject: move signal that forces flash-loader on to PB8, active high --- src/fox1ihu/flash-loader/ao_pins.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/fox1ihu/flash-loader') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index 90917a38..a7afaabb 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -37,12 +37,12 @@ #define HAS_TICK 1 #include -/* Detatched signal, PD6 */ +/* Attached signal, PB8 */ #define AO_BOOT_PIN 1 -#define AO_BOOT_APPLICATION_GPIO stm_gpiod -#define AO_BOOT_APPLICATION_PIN 6 -#define AO_BOOT_APPLICATION_VALUE 0 +#define AO_BOOT_APPLICATION_GPIO stm_gpiob +#define AO_BOOT_APPLICATION_PIN 8 +#define AO_BOOT_APPLICATION_VALUE 1 #define AO_BOOT_APPLICATION_MODE 0 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From c408c773793b5a5685d95c11ba6f710200505c25 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Tue, 6 May 2014 00:38:33 -0600 Subject: had the sense backwards .. presence of 'attached' should put us in the loader --- src/fox1ihu/flash-loader/ao_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu/flash-loader') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index a7afaabb..31201eb0 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -42,7 +42,7 @@ #define AO_BOOT_PIN 1 #define AO_BOOT_APPLICATION_GPIO stm_gpiob #define AO_BOOT_APPLICATION_PIN 8 -#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_VALUE 0 #define AO_BOOT_APPLICATION_MODE 0 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 0dfaecc25a12da57248541a66dd5118161616cce Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 21 Apr 2018 16:16:18 -0700 Subject: altos/fox1ihu: Pull down radio control pin in flash loader Ensures that the radio is powered down while in the flash loader. Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/ao_pins.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/fox1ihu/flash-loader') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index 31201eb0..19f29b08 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -22,16 +22,27 @@ #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_FLASH_LOADER_INIT do { \ - ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0); \ +#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 { \ - static uint8_t watchdog; \ - ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, watchdog); \ - watchdog ^= 1; \ + AO_WATCHDOG_PORT->odr ^= (1 << AO_WATCHDOG_BIT); \ } while (0) #define HAS_TICK 1 -- cgit v1.2.3