summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e5b04dc)
+ *#* Revision 1.2 2006/02/10 12:36:20 bernie
+ *#* Add preliminary FreeRTOS support; Enforce CONFIG_* definitions.
+ *#*
*#* Revision 1.1 2005/06/27 21:28:45 bernie
*#* Import generic keyboard driver.
*#*
*#* Revision 1.1 2005/06/27 21:28:45 bernie
*#* Import generic keyboard driver.
*#*
+/* Configuration sanity checks */
+#if !defined(CONFIG_KBD_POLL) || (CONFIG_KBD_POLL != KBD_POLL_SOFTINT && CONFIG_KBD_POLL != CONFIG_POLL_FREERTOS)
+ #error CONFIG_KBD_POLL must be defined to either KBD_POLL_SOFTINT or CONFIG_POLL_FREERTOS
+#endif
#define KBD_CHECK_INTERVAL 10 /*!< (ms) Timing for kbd softint */
#define KBD_CHECK_INTERVAL 10 /*!< (ms) Timing for kbd softint */
static volatile keymask_t kbd_buf; /*!< Single entry keyboard buffer */
static volatile keymask_t kbd_cnt; /*!< Number of keypress events in \c kbd_buf */
static volatile keymask_t kbd_buf; /*!< Single entry keyboard buffer */
static volatile keymask_t kbd_cnt; /*!< Number of keypress events in \c kbd_buf */
-static Timer kbd_timer; /*!< KeyboardKBD_BEEP_TIME softtimer */
+static Timer kbd_timer; /*!< Keyboard softtimer */
static List kbd_rawHandlers; /*!< Raw keyboard handlers */
static List kbd_handlers; /*!< Cooked keyboard handlers */
static List kbd_rawHandlers; /*!< Raw keyboard handlers */
static List kbd_handlers; /*!< Cooked keyboard handlers */
- * Keyboard soft-irq handler.
+ * Poll keyboard and dispatch keys to handlers.
+ *
+ * Read the key states and invoke all keyboard
+ * handlers to process the new state.
+ *
+ * Call this function periodically using a software
+ * timer, an interrupt or a process.
-static void kbd_softint(UNUSED_ARG(iptr_t, arg))
+static void kbd_poll(void)
{
/*! Currently depressed key */
static keymask_t current_key;
{
/*! Currently depressed key */
static keymask_t current_key;
FOREACHNODE(handler, &kbd_handlers)
key = handler->hook(key);
}
FOREACHNODE(handler, &kbd_handlers)
key = handler->hook(key);
}
+#if CONFIG_KBD_POLL == KBD_POLL_SOFTINT
+
+/*!
+ * Keyboard soft-irq handler.
+ */
+static void kbd_softint(UNUSED_ARG(iptr_t, arg))
+{
+ kbd_poll();
+#elif CONFIG_KBD_POLL == CONFIG_POLL_FREERTOS
+
+#include "FreeRTOS.h"
+#include "task.h"
+
+static portTASK_FUNCTION(kbd_poll, arg)
+{
+ for (;;)
+ {
+ kbd_poll(0);
+ timer_delay(KBD_CHECK_INTERVAL);
+ }
+}
+
+#endif /* CONFIG_KBD_POLL */
/*!
* \brief Read a key from the keyboard buffer.
/*!
* \brief Read a key from the keyboard buffer.
+// FIXME
+ extern void schedule(void);
+ schedule();
+
/* Extract an event from the keyboard buffer */
IRQ_DISABLE;
if (kbd_cnt)
/* Extract an event from the keyboard buffer */
IRQ_DISABLE;
if (kbd_cnt)
kbd_buf = key;
kbd_cnt = 1;
kbd_buf = key;
kbd_cnt = 1;
if (!(key & K_REPEAT))
buz_beep(KBD_BEEP_TIME);
if (!(key & K_REPEAT))
buz_beep(KBD_BEEP_TIME);
-
- cpuflags_t flags;
- IRQ_SAVE_DISABLE(flags);
-
/* Init handlers lists */
LIST_INIT(&kbd_handlers);
LIST_INIT(&kbd_rawHandlers);
/* Init handlers lists */
LIST_INIT(&kbd_handlers);
LIST_INIT(&kbd_rawHandlers);
kbd_defHandler.pri = -128; /* lowest priority */
kbd_addHandler(&kbd_defHandler);
kbd_defHandler.pri = -128; /* lowest priority */
kbd_addHandler(&kbd_defHandler);
+#if CONFIG_KBD_POLL == KBD_POLL_SOFTINT
/* Add kbd handler to soft timers list */
event_initSoftInt(&kbd_timer.expire, kbd_softint, 0);
timer_setDelay(&kbd_timer, ms_to_ticks(KBD_CHECK_INTERVAL));
timer_add(&kbd_timer);
/* Add kbd handler to soft timers list */
event_initSoftInt(&kbd_timer.expire, kbd_softint, 0);
timer_setDelay(&kbd_timer, ms_to_ticks(KBD_CHECK_INTERVAL));
timer_add(&kbd_timer);
+#elif CONFIG_KBD_POLL == CONFIG_POLL_FREERTOS
+ /* Create a timer specific thread */
+ xTaskCreate(kbd_poll, "kbd_poll", CONFIG_STACK_KBD,
+ NULL, CONFIG_PRI_KBD, NULL);
+#else
+ #error "Define keyboard poll method"
+#endif
+ *#* Revision 1.2 2006/02/10 12:38:16 bernie
+ *#* Add preliminary FreeRTOS support; Enforce CONFIG_* definitions.
+ *#*
*#* Revision 1.1 2005/06/27 21:28:45 bernie
*#* Import generic keyboard driver.
*#*
*#* Revision 1.1 2005/06/27 21:28:45 bernie
*#* Import generic keyboard driver.
*#*
#include <kbd_map.h>
#include <cfg/compiler.h>
#include <kbd_map.h>
#include <cfg/compiler.h>
-#include <arch_config.h>
+#define KBD_POLL_SOFTINT 1
+#define KBD_POLL_FREERTOS 2
/*!
* Keyboard handler descriptor
/*!
* Keyboard handler descriptor