]> git.gag.com Git - fw/altos/commitdiff
first cut at some code for fctester-v0.1 (a decade later)
authorBdale Garbee <bdale@gag.com>
Sat, 20 Apr 2024 19:29:02 +0000 (13:29 -0600)
committerBdale Garbee <bdale@gag.com>
Sat, 20 Apr 2024 19:29:02 +0000 (13:29 -0600)
src/fctester-v0.1/Makefile [new file with mode: 0644]
src/fctester-v0.1/ao_fctester.c [new file with mode: 0644]
src/fctester-v0.1/ao_pins.h [new file with mode: 0644]
src/fctester-v0.1/flash-loader/Makefile [new file with mode: 0644]
src/fctester-v0.1/flash-loader/ao_pins.h [new file with mode: 0644]

diff --git a/src/fctester-v0.1/Makefile b/src/fctester-v0.1/Makefile
new file mode 100644 (file)
index 0000000..11bfc89
--- /dev/null
@@ -0,0 +1,69 @@
+#
+# AltOS build
+#
+#
+
+include ../lpc/Makefile.defs
+
+INC = \
+       ao.h \
+       ao_arch.h \
+       ao_arch_funcs.h \
+       ao_pins.h \
+       ao_product.h \
+       lpc.h
+
+#
+# Common AltOS sources
+#
+
+ALTOS_SRC = \
+       ao_led_lpc.c \
+       ao_interrupt.c \
+       ao_boot_chain.c \
+       ao_romconfig.c \
+       ao_product.c \
+       ao_mutex.c \
+       ao_panic.c \
+       ao_stdio.c \
+       ao_data.c \
+       ao_convert_volt.c \
+       ao_task.c \
+       ao_log.c \
+       ao_cmd.c \
+       ao_config.c \
+       ao_timer_lpc.c \
+       ao_exti_lpc.c \
+       ao_adc_lpc.c \
+       ao_usb_lpc.c \
+       ao_beep_lpc.c
+
+PRODUCT=FCtester-v0.1
+PRODUCT_DEF=-DFCTESTER_V_0_1
+IDPRODUCT=0x000a
+
+CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS)
+
+PROGNAME=fctester-v3
+PROG=$(PROGNAME)-$(VERSION).elf
+HEX=$(PROGNAME)-$(VERSION).ihx
+
+SRC=$(ALTOS_SRC) ao_fctester.c
+OBJ=$(SRC:.c=.o)
+
+all: $(PROG) $(HEX)
+
+$(PROG): Makefile $(OBJ)
+       $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+
+$(OBJ): $(INC)
+
+distclean:     clean
+
+clean:
+       rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx $(PROGNAME)-*.map
+       rm -f ao_product.h
+
+install:
+
+uninstall:
diff --git a/src/fctester-v0.1/ao_fctester.c b/src/fctester-v0.1/ao_fctester.c
new file mode 100644 (file)
index 0000000..7f00171
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright © 2024 Bdale Garbee <bdale@gag.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; 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.
+ */
+
+#include <ao.h>
+#include <ao_led.h>
+
+/*
+ * define the FET outputs
+ */
+
+#define NUM_FETS       7
+int on_count = 0;
+
+typedef struct 
+{
+       int     port;
+       int     pin;
+} fet;
+
+fet outputs[] = {
+       {0, 11},                /* test_a */
+       {0, 22},                /* test_b */
+       {0, 12},                /* test_c */
+       {0, 9},                 /* test_d */
+       {0, 13},                /* test_e */
+       {0, 16},                /* test_f */
+       {1, 19},                /* short  */
+};
+
+static void
+ao_fet_control(uint32_t output, uint8_t value)
+{
+       /* map output to corresponding GPIO port and pin, set to value */
+       ao_gpio_set(outputs[output].port, outputs[output].pin, value);
+}
+
+static void
+ao_fet_init(void)
+{
+       int i;
+
+       /* initialize GPIO outputs and turn them all off */
+       for (i = 0; i < NUM_FETS; i++) 
+       {
+               ao_enable_output(outputs[i].port, outputs[i].pin, 0);
+       }
+}
+
+static void
+ao_fet_on(void)
+{
+       uint32_t output;
+
+       output = ao_cmd_decimal();
+        if (ao_cmd_status != ao_cmd_success)
+                return;
+       if (output > NUM_FETS-1)        /* can't be < 0 since unsigned! */
+               printf ("Invalid FET %lu, must be 0..%u\n", output, NUM_FETS);
+       else {
+               ao_fet_control(output, 1);
+               on_count++;
+       }
+       if (on_count > 0) ao_led_on(AO_LED_RED);
+}
+
+static void
+ao_fet_off(void)
+{
+       uint32_t output;
+
+       output = ao_cmd_decimal();
+        if (ao_cmd_status != ao_cmd_success)
+                return;
+       if (output > NUM_FETS-1)        /* can't be < 0 since unsigned! */
+               printf ("Invalid FET %lu, must be 0..%u\n", output, NUM_FETS);
+       else {
+               ao_fet_control(output, 0);
+               on_count--;
+       }
+       if (on_count == 0) ao_led_off(AO_LED_RED);
+}
+
+static const struct ao_cmds ao_fet_cmds[] = {
+       { ao_fet_on,  "S <output>\0Set (turn on) FET" },
+       { ao_fet_off, "R <output>\0Reset (turn off) FET" },
+       { 0, NULL }
+};
+
+int
+main(void)
+{
+       ao_fet_init();          /* turn all outputs off ASAP */
+       ao_clock_init();
+
+       ao_task_init();
+       ao_led_init();
+
+       /* both LEDs on briefly as system test */
+       ao_led_on(LEDS_AVAILABLE);
+
+       ao_timer_init();
+       ao_adc_init();
+       ao_cmd_init();
+       ao_usb_init();
+
+       ao_cmd_register(ao_fet_cmds);
+
+       /* turn red off, leave green on as a "power indicator" */
+       ao_led_off(AO_LED_RED);
+
+       ao_start_scheduler();
+}
diff --git a/src/fctester-v0.1/ao_pins.h b/src/fctester-v0.1/ao_pins.h
new file mode 100644 (file)
index 0000000..386c0b8
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright © 2024 Bdale Garbee <bdale@gag.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; 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.
+ */
+
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+#define AO_STACK_SIZE           352
+#define SLEEP_HASH_SIZE         3
+#define AO_NUM_TASKS            6
+
+#define HAS_TASK_QUEUE         1
+#define IS_FLASH_LOADER                0
+
+/* Crystal on the board */
+#define AO_LPC_CLKIN    12000000
+
+/* Main clock frequency. 48MHz for USB so we don't use the USB PLL */
+#define AO_LPC_CLKOUT   48000000
+
+/* System clock frequency */
+#define AO_LPC_SYSCLK   24000000
+
+#define HAS_USB                        1
+#define HAS_USB_CONNECT                0
+#define HAS_USB_VBUS           0
+#define HAS_USB_PULLUP         1
+#define AO_USB_PULLUP_PORT      0
+#define AO_USB_PULLUP_PIN       20
+
+#define PACKET_HAS_SLAVE       0
+
+#define HAS_SERIAL             0
+
+#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX       (1984 * 1024)
+#define AO_CONFIG_MAX_SIZE                     1024
+#define LOG_ERASE_MARK                         0x55
+#define LOG_MAX_ERASE                          128
+#define AO_LOG_FORMAT                          AO_LOG_FORMAT_EASYMOTOR
+
+#define HAS_EEPROM             1
+#define USE_INTERNAL_FLASH     0
+#define USE_EEPROM_CONFIG      0
+#define USE_STORAGE_CONFIG     1
+#define AO_PA11_PA12_RMP       1
+#define HAS_BEEP               1
+#define HAS_BATTERY_REPORT     0
+#define HAS_PAD_REPORT         0
+
+/* Beeper is on pio0_1 ct32b0_mat2 .. requires wire mod on board! */
+#define AO_LPC_BEEP_PORT       0
+#define AO_LPC_BEEP_PIN                1
+#define AO_LPC_BEEP_TIMER      0
+#define AO_LPC_BEEP_CHANNEL    2
+
+#define LOW_LEVEL_DEBUG                0
+
+/*
+ * ADC
+ */
+#define HAS_ADC                        1
+
+#define AO_NUM_ADC             1
+
+#define AO_ADC_0               3
+
+#define AO_DATA_RING           32
+
+#define AO_ADC_DUMP(p) \
+       printf("tick: %5lu pyro_current: %5d\n", \
+              (p)->tick, \
+              (p)->adc.pyro_current); 
+
+struct ao_adc {
+       int16_t                 pyro_current;
+};
+
+/*
+ * ADC reference in decivolts
+ */
+#define AO_ADC_REFERENCE_DV    33
+
+/* LEDs */
+#define LED_PORT               0
+#define LED_PIN_RED            7
+#define AO_LED_RED             (1 << LED_PIN_RED)
+#define LED_PIN_GREEN          8
+#define AO_LED_GREEN           (1 << LED_PIN_GREEN)
+
+#define LEDS_AVAILABLE         (AO_LED_RED | AO_LED_GREEN)
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/fctester-v0.1/flash-loader/Makefile b/src/fctester-v0.1/flash-loader/Makefile
new file mode 100644 (file)
index 0000000..ddb9758
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=fctester-v0.1
+include $(TOPDIR)/lpc/Makefile-flash.defs
diff --git a/src/fctester-v0.1/flash-loader/ao_pins.h b/src/fctester-v0.1/flash-loader/ao_pins.h
new file mode 100644 (file)
index 0000000..5bc49e2
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2024 Bdale Garbee <bdale@gag.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; 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.
+ */
+
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+#include <ao_flash_lpc_pins.h>
+
+#define AO_BOOT_PIN            1
+#define AO_BOOT_APPLICATION_GPIO       0
+#define AO_BOOT_APPLICATION_PIN                19
+#define AO_BOOT_APPLICATION_VALUE      1
+#define AO_BOOT_APPLICATION_MODE       AO_EXTI_MODE_PULL_UP
+
+#define HAS_USB_PULLUP 1
+#define AO_USB_PULLUP_PORT     0
+#define AO_USB_PULLUP_PIN      6
+
+#endif /* _AO_PINS_H_ */