#include <ao.h>
-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;
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 <output>\0Select relay output" },
+static const struct ao_cmds ao_fet_cmds[] = {
+ { ao_fet_select, "R <output>\0Select fet output" },
{ 0, NULL }
};
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();
}
#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
#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