cortexelf-v1: Hook up AS1107 in test mode
authorKeith Packard <keithp@keithp.com>
Mon, 3 Apr 2017 00:39:26 +0000 (17:39 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 3 Apr 2017 00:39:26 +0000 (17:39 -0700)
Provide a 'L' command to display values

Signed-off-by: Keith Packard <keithp@keithp.com>
src/cortexelf-v1/Makefile
src/cortexelf-v1/ao_cortexelf.c
src/cortexelf-v1/ao_pins.h

index f7c892bcfd7a9e1ac2dcd174fa770588a885ad69..65f16c2cdc620de84828fb6f961a60e137071125 100644 (file)
@@ -56,6 +56,7 @@ ALTOS_SRC = \
        ao_usb_stm.c \
        ao_exti_stm.c \
        ao_i2c_stm.c \
+       ao_as1107.c \
        ao_vga.c \
        ao_blt.c \
        ao_copy.c \
index 8be7ef151457acd362733157709f0684dd7ff159..77fbd0c0e44b2b108919d0aae2687c505f666544 100644 (file)
@@ -30,6 +30,7 @@
 #include <ao_lisp.h>
 #include <ao_button.h>
 #include <ao_event.h>
+#include <ao_as1107.h>
 
 struct ao_task ball_task;
 
@@ -200,6 +201,21 @@ ao_serial_blather(void)
        }
 }
 
+static void
+led_cmd(void)
+{
+       uint8_t start;
+       uint8_t value;
+       ao_cmd_decimal();
+
+       start = ao_cmd_lex_i;
+       ao_cmd_hex();
+       value = ao_cmd_lex_i;
+       if (ao_cmd_status != ao_cmd_success)
+               return;
+       ao_as1107_write_8(start, value);
+}
+
 __code struct ao_cmds ao_demo_cmds[] = {
        { ao_video_toggle, "V\0Toggle video" },
        { ao_ball_toggle, "B\0Toggle ball" },
@@ -207,6 +223,7 @@ __code struct ao_cmds ao_demo_cmds[] = {
        { ao_console_send, "C\0Send data to console, end with ~" },
        { ao_serial_blather, "S\0Blather on serial ports briefly" },
        { lisp_cmd, "l\0Run lisp interpreter" },
+       { led_cmd, "L start value\0Show value (byte) at digit start" },
        { 0, NULL }
 };
 
@@ -255,6 +272,8 @@ main(void)
 
        ao_button_init();
 
+       ao_as1107_init();
+
        ao_config_init();
 
        ao_add_task(&ball_task, ao_ball, "ball");
index d39f402234d915c0434a414c1279fd2e071bdfb4..9721c56de6648aebf02fea22133846b951e0b60d 100644 (file)
 #define AO_BUTTON_3_PORT       (&stm_gpioc)
 #define AO_BUTTON_3            11
 
+/* AS1107 */
+#define AO_AS1107_NUM_DIGITS   8
+
+/* Set the hex digits up for decode, leave the extra leds alone */
+
+#define AO_AS1107_DECODE       ((1 << 7) | \
+                                (1 << 6) | \
+                                (1 << 4) | \
+                                (1 << 3) | \
+                                (1 << 1) | \
+                                (1 << 0))
+
+#define AO_AS1107_SPI_INDEX    AO_SPI_2_PD1_PD3_PD4
+#define AO_AS1107_SPI_SPEED    AO_SPI_SPEED_8MHz
+#define AO_AS1107_CS_PORT      (&stm_gpiod)
+#define AO_AS1107_CS_PIN       0
 
 #endif /* _AO_PINS_H_ */