From: Bdale Garbee Date: Thu, 2 May 2024 18:42:26 +0000 (-0600) Subject: code working to wiggle one output using existing LED functions X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=7f397e075616003abddf7edaac583a0ddbe96c65;p=fw%2Faltos code working to wiggle one output using existing LED functions --- diff --git a/src/fctester-v0.1/ao_fctester.c b/src/fctester-v0.1/ao_fctester.c index 6e8ba18f..4e3a1bca 100644 --- a/src/fctester-v0.1/ao_fctester.c +++ b/src/fctester-v0.1/ao_fctester.c @@ -18,36 +18,25 @@ #include -uint8_t relay_output; +uint8_t fet_output; -void ao_relay_init(void); - -void -ao_relay_init(void) -{ - lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_GPIO); - lpc_gpio.dir[RELAY_PORT] |= RELAY_BIT; -} - -// switch relay to selected output, turn correct LED on as a side effect +// switch fet to selected output, red LED on as a side effect static void -ao_relay_control(uint8_t output) +ao_fet_control(uint8_t output) { switch (output) { case 1: - lpc_gpio.pin[RELAY_PORT] |= RELAY_BIT; + ao_led_on(FET_A); ao_led_on(AO_LED_RED); - ao_led_off(AO_LED_GREEN); break; default: - lpc_gpio.pin[RELAY_PORT] &= (uint8_t) ~RELAY_BIT; + ao_led_off(FET_A); ao_led_off(AO_LED_RED); - ao_led_on(AO_LED_GREEN); } } static void -ao_relay_select(void) +ao_fet_select(void) { uint8_t output; @@ -55,13 +44,13 @@ ao_relay_select(void) if (ao_cmd_status != ao_cmd_success) return; if (output > 1) - printf ("Invalid relay position %u\n", output); + printf ("Invalid fet position %u\n", output); else - ao_relay_control(output); + ao_fet_control(output); } -static const struct ao_cmds ao_relay_cmds[] = { - { ao_relay_select, "R \0Select relay output" }, +static const struct ao_cmds ao_fet_cmds[] = { + { ao_fet_select, "R \0Select fet output" }, { 0, NULL } }; @@ -74,17 +63,12 @@ main(void) ao_usb_init(); - ao_led_init(); - - ao_relay_init(); - - // initialize to default output - relay_output = 0; - ao_relay_control(relay_output); + ao_led_init(); // also handles FET switches + ao_led_on(AO_LED_GREEN); // indicate we're alive ao_cmd_init(); - ao_cmd_register(ao_relay_cmds); + ao_cmd_register(ao_fet_cmds); ao_start_scheduler(); } diff --git a/src/fctester-v0.1/ao_pins.h b/src/fctester-v0.1/ao_pins.h index 35c89250..18088a39 100644 --- a/src/fctester-v0.1/ao_pins.h +++ b/src/fctester-v0.1/ao_pins.h @@ -57,7 +57,7 @@ #define SPI_MISO1_P0_22 0 #define SPI_MOSI1_P0_21 0 -/* LED */ +/* LEDs and FET switches (treat them like LEDs to avoid code duplication) */ #define LED_PORT 0 #define LED_PIN_RED 7 @@ -65,13 +65,26 @@ #define AO_LED_RED (1 << LED_PIN_RED) #define AO_LED_GREEN (1 << LED_PIN_GREEN) -#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN) - -/* RELAY */ - -#define RELAY_PORT 0 -#define RELAY_PIN 3 -#define RELAY_BIT (1 << RELAY_PIN) +#define FET_PIN_A 11 +#define FET_A (1 << FET_PIN_A) +#define FET_PIN_B 22 +#define FET_B (1 << FET_PIN_B) +#define FET_PIN_C 12 +#define FET_C (1 << FET_PIN_C) +#define FET_PIN_D 9 +#define FET_D (1 << FET_PIN_D) +#define FET_PIN_E 13 +#define FET_E (1 << FET_PIN_E) +#define FET_PIN_F 16 +#define FET_F (1 << FET_PIN_F) + +/* ignore the 'short' FET for now +#define FET_PORT_SHORT 1 +#define FET_PIN_SHORT 16 +#define FET_SHORT (1 << FET_PIN_SHORT) +*/ + +#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN | FET_A | FET_B | FET_C | FET_D | FET_E | FET_F) /* Kludge the SPI driver to not configure any * pin for SCK or MOSI