summaryrefslogtreecommitdiff
path: root/firmware/test
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/test')
-rw-r--r--firmware/test/i2s/Makefile8
-rw-r--r--firmware/test/i2s/i2stest.c25
-rw-r--r--firmware/test/test.c59
-rw-r--r--firmware/test/test.h33
4 files changed, 121 insertions, 4 deletions
diff --git a/firmware/test/i2s/Makefile b/firmware/test/i2s/Makefile
index c88f443..ed7860c 100644
--- a/firmware/test/i2s/Makefile
+++ b/firmware/test/i2s/Makefile
@@ -42,7 +42,9 @@ LINKER_SCRIPT = ${LPC}/LPC17xx.ld
CSRCS = \
${LPC}/system_LPC17xx.c \
${LPC}/startup_LPC17xx.c \
- ${DRV}/i2s.c
+ ${DRV}/led.c \
+ ${DRV}/i2s.c \
+ ../test.c
CSRCS += ${PROJ}.c
ASRCS =
@@ -91,8 +93,8 @@ nuke: clean
# openocd -f openocd.cfg -c 'flash write_image erase $(PROJ).hex' -c 'verify_image $(PROJ).hex' -c 'reset run'
flash: $(EXECNAME)
$(CP) -O binary $(EXECNAME) $(PROJ).bin
- ./fix-lpcchecksum $(PROJ).bin
- openocd -f openocd.cfg \
+ ../../fix-lpcchecksum $(PROJ).bin
+ openocd -f ../../openocd.cfg \
-c 'flash write_image erase $(PROJ).bin' \
-c 'verify_image $(PROJ).bin' \
-c 'reset run'
diff --git a/firmware/test/i2s/i2stest.c b/firmware/test/i2s/i2stest.c
index 16ea291..31f5c20 100644
--- a/firmware/test/i2s/i2stest.c
+++ b/firmware/test/i2s/i2stest.c
@@ -25,13 +25,36 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include <i2s.h>
+#include <led.h>
+
+#include "../test.h"
int main (void)
{
- i2s_init();
+ led_init();
+
+ // From: tools/clkcalc 48000 16 2
+ int pclkdiv = 1;
+ int bitrate = 24;
+ int x = 96;
+ int y = 125;
+
+ int bitwidth = 16;
+ int channels = 2;
+
+ int res = i2s_init(pclkdiv, bitrate, x, y, bitwidth, channels);
+
+ if(res) error();
i2s_tx_start();
+ // success();
+
+ int16_t s = 0;
while(1) {
+ //while(i2s_get_state_tx_level() < 3) {}
+ i2s_write_pcm_16_stereo(s, s);
+ if((s % 2) == 0) led_toggle();
+ s++;
}
}
diff --git a/firmware/test/test.c b/firmware/test/test.c
new file mode 100644
index 0000000..8671c5e
--- /dev/null
+++ b/firmware/test/test.c
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * test.c
+ *
+ * Sat Sep 13 21:10:33 CEST 2014
+ * Copyright 2014 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pedal2Metal.
+ *
+ * Pedal2Metal 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.
+ *
+ * Pedal2Metal 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 Pedal2Metal; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "test.h"
+
+#include <led.h>
+
+volatile int temp;
+
+static void delay(int del)
+{
+ int i;
+ for(i = 0; i < del; i++) {
+ temp = i;
+ }
+}
+
+// 21: slow, success
+// 17: fast, error
+static void blink(int t)
+{
+ while(1) {
+ led_toggle();
+ delay(1 << t);
+ }
+}
+
+void error()
+{
+ blink(17);
+}
+
+void success()
+{
+ blink(22);
+}
diff --git a/firmware/test/test.h b/firmware/test/test.h
new file mode 100644
index 0000000..9ab8484
--- /dev/null
+++ b/firmware/test/test.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * test.h
+ *
+ * Sat Sep 13 21:10:33 CEST 2014
+ * Copyright 2014 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pedal2Metal.
+ *
+ * Pedal2Metal 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.
+ *
+ * Pedal2Metal 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 Pedal2Metal; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PEDAL2METAL_TEST_H__
+#define __PEDAL2METAL_TEST_H__
+
+void error();
+void success();
+
+#endif/*__PEDAL2METAL_TEST_H__*/