include config.mk
# Include subtargets
-include app/demo/demo.mk
-#include app/triface/triface.mk
+#include app/demo/demo.mk
+include app/triface/triface.mk
#include app/at91sam7s/at91sam7s.mk
include rules.mk
* \author Stefano Fedrigo <aleph@develer.com>
*/
-/*#*
- *#* $Log$
- *#* Revision 1.5 2006/09/20 13:54:40 marco
- *#* Added new SPI definitions.
- *#*
- *#* Revision 1.4 2006/07/19 12:56:25 bernie
- *#* Convert to new Doxygen style.
- *#*
- *#* Revision 1.3 2006/06/12 21:37:01 marco
- *#* implemented some commands (ver and sleep)
- *#*
- *#* Revision 1.2 2006/06/01 12:29:21 marco
- *#* Add first simple protocol command (version request).
- *#*
- *#* Revision 1.1 2006/05/18 00:41:47 bernie
- *#* New triface devlib application.
- *#*
- *#*/
-
#ifndef APPCONFIG_TRIFACE_H
#define APPCONFIG_TRIFACE_H
/** Baud-rate for the kdebug console */
-#define CONFIG_KDEBUG_BAUDRATE 38400
+#define CONFIG_KDEBUG_BAUDRATE 115200
/** Serial port number for kdebug console */
-#define CONFIG_KDEBUG_PORT 0
+#define CONFIG_KDEBUG_PORT 1
/**
/** Default baud rate (set to 0 to disable) */
#define CONFIG_SER_DEFBAUDRATE 0
+ /** Host Port Baud Rate */
+ #define CONFIG_SER_HOSTPORTBAUDRATE 115200
+
+ /** Host Port */
+ #define CONFIG_SER_HOSTPORT 1
+
/** Enable ser_gets() and ser_gets_echo() */
- #define CONFIG_SER_GETS 1
+ #define CONFIG_SER_GETS 0
/** Enable second serial port in emulator. */
#define CONFIG_EMUL_UART1 0
/*\}*/
/// Hardware timer selection for drv/timer.c
-#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE0
+#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE2
/// Debug timer interrupt using a strobe pin.
#define CONFIG_TIMER_STROBE 0
+/// Enable ADS strobe.
+#define CONFIG_ADC_STROBE 0
+
/// Enable watchdog timer.
#define CONFIG_WATCHDOG 0
-/// Enable internal parser commands.
-#define CONFIG_INTERNAL_COMMANDS 0
+/// EEPROM type for drv/eeprom.c
+#define CONFIG_EEPROM_TYPE EEPROM_24XX256
+
+/// Select bitmap pixel format.
+#define CONFIG_BITMAP_FMT BITMAP_FMT_PLANAR_V_LSB
+
+/// Enable line clipping algorithm.
+#define CONFIG_GFX_CLIPPING 1
+
+/// Enable text rendering in bitmaps.
+#define CONFIG_GFX_TEXT 1
+
+/// Enable virtual coordinate system.
+#define CONFIG_GFX_VCOORDS 1
+
+/// Keyboard polling method
+#define CONFIG_KBD_POLL KBD_POLL_SOFTINT
+
+/// Enable keyboard event delivery to observers
+#define CONFIG_KBD_OBSERVER 0
+
+/// Enable key beeps
+#define CONFIG_KBD_BEEP 1
+
+/// Enable long pression handler for keys
+#define CONFIG_KBD_LONGPRESS 1
+
+/**
+ * \name Type for the chart dataset
+ * \{
+ */
+#define CONFIG_CHART_TYPE_X uint8_t
+#define CONFIG_CHART_TYPE_Y uint8_t
+/*\}*/
+
+/// Enable button bar behind menus
+#define CONFIG_MENU_MENUBAR 0
+
+/// Enable smooth scrolling in menus
+#define CONFIG_MENU_SMOOTH 1
+
+/// Size of block for MD2 algorithm.
+#define CONFIG_MD2_BLOCK_LEN 16
+
+/// Use standard permutation in MD2 algorithm.
+#define CONFIG_MD2_STD_PERM 0
+
+/// Define a size, in byte, of entropy pool.
+#define CONFIG_SIZE_ENTROPY_POOL 64
+
+/// Turn on or off timer support in Randpool.
+#define CONFIG_RANDPOOL_TIMER 1
#endif /* APPCONFIG_TRIFACE_H */
*
* \author Marco Benelli <marco@develer.com>
*/
+
#ifndef CMD_CTOR_H
#define CMD_CTOR_H
#define REGISTER_CMD(NAME) REGISTER_FUNCTION(&cmd_ ## NAME ## _template)
-#define MAKE_TEMPLATE(NAME, ARGS, RES) \
+#define MAKE_TEMPLATE(NAME, ARGS, RES, FLAGS) \
const struct CmdTemplate cmd_ ## NAME ## _template = \
{ \
- #NAME, ARGS, RES, cmd_ ## NAME, 0 \
+ #NAME, ARGS, RES, cmd_ ## NAME, FLAGS \
};
-#define MAKE_CMD(NAME, ARGS, RES, BODY) \
+#define MAKE_CMD(NAME, ARGS, RES, BODY, FLAGS) \
static ResultCode cmd_ ## NAME (parms *args) \
{ \
return (ResultCode)BODY; \
} \
-MAKE_TEMPLATE(NAME, ARGS, RES)
+MAKE_TEMPLATE(NAME, ARGS, RES, FLAGS)
#endif // CMD_CTOR_H
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernardo Innocenti <bernie@codewiz.org>
+ *
+ * --> Rights Reserved.
*
* \brief Hardware-specific definitions
*
* \author Bernardo Innocenti <bernie@develer.com>
*/
-/*#*
- *#* $Log$
- *#* Revision 1.1 2006/05/18 00:41:47 bernie
- *#* New triface devlib application.
- *#*
- *#*/
-
#ifndef TRIFACE_HW_H
#define TRIFACE_HW_H
//#endif /* CONFIG_TIMER_STROBE */
#endif /* TRIFACE_HW_H */
+
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernardo Innocenti <bernie@codewiz.org>
+ *
* -->
*
* \brief Implementation of the command protocol between the board and the host
#include "protocol.h"
-#include <drv/ser.h>
+
#include <drv/timer.h>
+#include <drv/ser.h>
#include <mware/readline.h>
#include <mware/parser.h>
#include <cfg/compiler.h>
#include <cfg/debug.h>
-#include <verstag.h>
+#include <drv/sipo.h>
+#include <drv/wdt.h>
+#include "hw_adc.h"
#include <stdlib.h>
#include <string.h>
//#include <cmd_hunk.h>
#include "cmd_ctor.h" // MAKE_CMD, REGISTER_CMD
+#include "hw_input.h"
+#include "verstag.h"
+#include <drv/buzzer.h>
+
+// Define the format string for ADC
+#define ADC_FORMAT_STR "dddd"
// DEBUG: set to 1 to force interactive mode
#define FORCE_INTERACTIVE 1
/// Readline context, used for interactive mode.
static struct RLContext rl_ctx;
-
+uint8_t reg_status_dout;
/**
* Send a NAK asking the host to send the current message again.
*
- * \param ser serial port handle to output to.
* \param err human-readable description of the error for debug purposes.
*/
INLINE void NAK(Serial *ser, const char *err)
#endif
}
+static void protocol_prompt(Serial *ser)
+{
+ ser_print(ser, ">> ");
+}
+
/*
* Print args on s, with format specified in t->result_fmt.
* Return number of valid arguments or -1 in case of error.
unsigned short offset = strlen(t->arg_fmt) + 1;
unsigned short nres = strlen(t->result_fmt);
- ser_printf(s, "0");
for (unsigned short i = 0; i < nres; ++i)
{
if (t->result_fmt[i] == 'd')
{
ser_printf(s, " %s", args[offset+i].s);
}
+
else
{
abort();
templ = parser_get_cmd_template(buf);
if (!templ)
{
- ser_print(ser, "-1 Invalid command.");
+ ser_print(ser, "-1 Invalid command.\r\n");
+ protocol_prompt(ser);
return;
}
/* Args Check. TODO: Handle different case. see doc/PROTOCOL . */
if (!parser_get_cmd_arguments(buf, templ, args))
{
- ser_print(ser, "-2 Invalid arguments.");
+ ser_print(ser, "-2 Invalid arguments.\r\n");
+ protocol_prompt(ser);
return;
}
{
NAK(ser, "Invalid return format.");
}
+
+ protocol_prompt(ser);
return;
}
// check message minimum length
if (linebuf[0])
{
- if (linebuf[0] == 0x1B && linebuf[1] == 0x1B) // ESC
+ /* If we enter lines beginning with sharp(#)
+ they are stripped out from commands */
+ if(linebuf[0] != '#')
{
- interactive = true;
- ser_printf(ser,
- "Entering interactive mode\r\n");
- }
- else
- {
- protocol_parse(ser, linebuf);
+ if (linebuf[0] == 0x1B && linebuf[1] == 0x1B) // ESC
+ {
+ interactive = true;
+ ser_printf(ser,
+ "Entering interactive mode\r\n");
+ }
+ else
+ {
+ protocol_parse(ser, linebuf);
+ }
}
}
}
*/
buf = rl_readline(&rl_ctx);
- if (buf && buf[0] != '\0')
+ /* If we enter lines beginning with sharp(#)
+ they are stripped out from commands */
+ if(buf && buf[0] != '#')
{
- // exit special case to immediately change serial input
- if (!strcmp(buf, "exit") || !strcmp(buf, "quit"))
+ if (buf[0] != '\0')
{
- rl_clear_history(&rl_ctx);
- ser_printf(ser,
- "Leaving interactive mode...\r\n");
- interactive = FORCE_INTERACTIVE;
- }
- else
- {
- //TODO: remove sequence numbers
- linebuf[0] = '0';
- linebuf[1] = ' ';
-
- strncpy(linebuf + 2, buf, sizeof(linebuf) - 3);
- linebuf[sizeof(linebuf) - 1] = '\0';
- protocol_parse(ser, linebuf);
+ // exit special case to immediately change serial input
+ if (!strcmp(buf, "exit") || !strcmp(buf, "quit"))
+ {
+ rl_clear_history(&rl_ctx);
+ ser_printf(ser,
+ "Leaving interactive mode...\r\n");
+ interactive = FORCE_INTERACTIVE;
+ }
+ else
+ {
+ //TODO: remove sequence numbers
+ linebuf[0] = '0';
+ linebuf[1] = ' ';
+
+ strncpy(linebuf + 2, buf, sizeof(linebuf) - 3);
+ linebuf[sizeof(linebuf) - 1] = '\0';
+ protocol_parse(ser, linebuf);
+ }
}
}
}
*
*/
-/* Version. Example of declaring function and passing it to MAKE_CMD. */
-static int ver_fn(const char **str)
-{
- *str = VERS_TAG;
- return 0;
-}
-MAKE_CMD(ver, "", "s", ver_fn(&args[1].s))
+MAKE_CMD(ver, "", "ddd",
+({
+ args[1].l = VERS_MAJOR;
+ args[2].l = VERS_MINOR;
+ args[3].l = VERS_REV;
+ 0;
+}), 0);
/* Sleep. Example of declaring function body directly in macro call. */
MAKE_CMD(sleep, "d", "",
({
timer_delay((mtime_t)args[1].l);
0;
-}))
+}), 0)
/* Ping. */
MAKE_CMD(ping, "", "",
({
+ //Silence "args not used" warning.
+ (void)args;
+ 0;
+}), 0)
+
+/* Dout */
+MAKE_CMD(dout, "d", "",
+({
+ sipo_putchar((uint8_t)args[1].l);
+
+ //Store status of dout ports.
+ reg_status_dout = (uint8_t)args[1].l;
+ 0;
+}), 0)
+
+/* rdout read the status of out ports.*/
+MAKE_CMD(rdout, "", "d",
+({
+ args[1].l = reg_status_dout;
+ 0;
+}), 0)
+
+/* Doutx sperimentale....... */
+MAKE_CMD(doutx, "d", "",
+ ({
+ sipo_putchar((uint8_t)args[1].l);
+
+ //Store status of dout ports.
+ reg_status_dout = (uint8_t)args[1].l;
+ 0;
+ }), 0)
+
+/* Reset */
+MAKE_CMD(reset, "", "",
+({
+ //Silence "args not used" warning.
+ (void)args;
+ wdt_init(7);
+ wdt_start();
+ 0;
+}), 0)
+
+/* Din */
+MAKE_CMD(din, "", "d",
+({
+ args[1].l = INPUT_GET();
0;
-}))
+}), 0)
+
+
+
+/* Ain */
+MAKE_CMD(ain, "", ADC_FORMAT_STR,
+({
+ STATIC_ASSERT((sizeof(ADC_FORMAT_STR) - 1) == ADC_CHANNEL_NUM);
+ for(int i = 0; i < ADC_CHANNEL_NUM; i++)
+ args[i+1].l = adc_read_ai_channel(i);
+
+ 0;
+}), 0)
+
+/* Beep */
+MAKE_CMD(beep, "d", "",
+({
+ buz_beep(args[1].l);
+ 0;
+}), 0)
/* Register commands. */
static void protocol_registerCmds(void)
REGISTER_CMD(ver);
REGISTER_CMD(sleep);
REGISTER_CMD(ping);
+ REGISTER_CMD(dout);
+ //Set off all dout ports.
+ reg_status_dout = 0;
+ REGISTER_CMD(rdout);
+ REGISTER_CMD(doutx);
+ REGISTER_CMD(reset);
+ REGISTER_CMD(din);
+ REGISTER_CMD(ain);
+ REGISTER_CMD(beep);
}
/* Initialization: readline context, parser and register commands. */
interactive = FORCE_INTERACTIVE;
rl_init_ctx(&rl_ctx);
- rl_setprompt(&rl_ctx, ">> ");
+ //rl_setprompt(&rl_ctx, ">> ");
rl_sethook_get(&rl_ctx, (getc_hook)ser_getchar, ser);
rl_sethook_put(&rl_ctx, (putc_hook)ser_putchar, ser);
rl_sethook_match(&rl_ctx, parser_rl_match, NULL);
+ rl_sethook_clear(&rl_ctx, (clear_hook)ser_clearstatus,ser);
parser_init();
protocol_registerCmds();
+
+ protocol_prompt(ser);
}
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernardo Innocenti <bernie@codewiz.org>
+ *
* -->
*
* \brief Implementation of the command protocol between the board and the host
* \author Marco Benelli <marco@develer.com>
*/
+
#ifndef PROTOCOL_H
#define PROTOCOL_H
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernardo Innocenti <bernie@codewiz.org>
*
* -->
*
* \brief Windowing system test.
*/
+
#include <drv/timer.h>
#include <drv/buzzer.h>
#include <drv/ser.h>
#include <cfg/macros.h>
#include <mware/parser.h>
+#include <net/keytag.h>
+#include <drv/sipo.h>
#include "protocol.h"
+#include "hw_input.h"
+#include "hw_adc.h"
int main(void)
{
+ /* SPI Port Initialization */
+ sipo_init();
+
kdbg_init();
timer_init();
-// buz_init();
+ adc_init();
+ buz_init();
IRQ_ENABLE;
+ INPUT_INIT;
+
+ /* Initialize Tag serial port and data structure */
+ TagPacket pkt;
+
+ /* Open the main communication port */
+ Serial *host_port = ser_open(CONFIG_SER_HOSTPORT);
+ ser_setbaudrate(host_port, CONFIG_SER_HOSTPORTBAUDRATE);
+
+ pkt.tag_ser = ser_open(TAG_SER_PORT);
+ ser_setbaudrate(pkt.tag_ser, TAG_SER_BAUDRATE);
+ pkt.comm_ser = host_port;
+ keytag_init(&pkt);
+
- Serial *host_port = ser_open(0);
- ser_setbaudrate(host_port, 38400);
protocol_init(host_port);
for(;;)
{
protocol_run(host_port);
+ keytag_poll(&pkt);
}
return 0;
#
# Author: Bernardo Innocenti <bernie@develer.com>
#
+#
+
# Set to 1 for debug builds
triface_DEBUG = 1
# Our target application
TRG += triface
+triface_hfuse = 0x88
+triface_lfuse = 0xff
+triface_efuse = 0xff
+triface_lock = 0x2f
triface_CSRC = \
app/triface/triface.c \
app/triface/protocol.c \
drv/timer.c \
drv/ser.c \
cpu/avr/drv/ser_avr.c \
+ cpu/avr/drv/sipo.c \
mware/formatwr.c \
mware/hex.c \
mware/hashtable.c \
mware/readline.c \
mware/parser.c \
-
-# drv/buzzer.c
+ mware/event.c \
+ net/keytag.c \
+ hw/hw_adc.c \
+ drv/buzzer.c \
triface_PCSRC += mware/formatwr.c
-#triface_CFLAGS = -O3 -D'ARCH=0' -Iapp/triface/hw -Iapp/triface
-triface_CFLAGS = -O0 -D'ARCH=0' -Iapp/triface/hw -Iapp/triface -Icpu/avr
-triface_MCU = atmega128
+
+triface_CFLAGS = -O2 -D'ARCH=0' -Iapp/triface/hw -Iapp/triface -Icpu/avr
+triface_LDFLAGS = -Wl
+
+triface_MCU = atmega64
# Debug stuff
ifeq ($(triface_DEBUG),1)
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001, 2002, 2003 by Bernardo Innocenti <bernie@codewiz.org>
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernardo Innocenti <bernie@codewiz.org>
*
* -->
*
#define APP_AUTHOR "Develer"
#define APP_COPYRIGHT "Copyright 2006 Develer (http://www.develer.com/)"
-#define VERS_MAJOR 0
+#define VERS_MAJOR 1
#define VERS_MINOR 1
#define VERS_REV 0
#define VERS_LETTER ""
#
# define some variables based on the AVR base path in $(AVR)
#
-#CROSS = avr-
-CC = gcc
-CXX = g++
+CROSS = avr-
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
AS = $(CC) -x assembler-with-cpp
LD = $(CC)
-LDXX = $(CXX)
-OBJCOPY = objcopy
-STRIP = strip
+OBJCOPY = $(CROSS)objcopy
+STRIP = $(CROSS)strip
INSTALL = cp -a
RM = rm -f
RM_R = rm -rf
WARNFLAGS = \
-W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wsign-compare \
- -Wmissing-noreturn \
+ -Wmissing-prototypes -Wmissing-noreturn \
-Wextra -Wstrict-aliasing=2 \
# -Wunsafe-loop-optimizations