This shows you the differences between two versions of the page.
encoder_tables_in_c [2008/07/25 14:09] |
encoder_tables_in_c [2008/07/25 14:09] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Encoder Tables in C Applications ====== | ||
+ | |||
+ | ===== makefile ===== | ||
+ | |||
+ | Add the "-DDONT_INCLUDE_MIOS_ENC_TABLE" define: | ||
+ | <code make> | ||
+ | # pass parameters to MIOS wrapper | ||
+ | MIOS_WRAPPER_DEFINES = -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f \ | ||
+ | -DDONT_INCLUDE_MIOS_ENC_TABLE | ||
+ | </code> | ||
+ | |||
+ | ===== main.c ===== | ||
+ | |||
+ | Add your table as such: | ||
+ | <code c> | ||
+ | ///////////////////////////////////////////////////////////////////////////// | ||
+ | // Application specific encoder table | ||
+ | // the default (dummy) table has been disabled via -DDONT_INCLUDE_MIOS_ENC_TABLE | ||
+ | ///////////////////////////////////////////////////////////////////////////// | ||
+ | MIOS_ENC_TABLE { | ||
+ | // sr pin mode | ||
+ | MIOS_ENC_ENTRY(1, 0, MIOS_ENC_MODE_DETENTED2), | ||
+ | MIOS_ENC_EOT | ||
+ | }; | ||
+ | </code> | ||
+ | |||
+ | ===== Reference ===== | ||
+ | |||
+ | Taken from mios wrapper | ||
+ | |||
+ | <code asm> | ||
+ | ;; ---[ configuration table for rotary encoders ]--- | ||
+ | #ifndef DONT_INCLUDE_MIOS_ENC_TABLE | ||
+ | ;; dummy table located in $MIOS_PATH/include/asm | ||
+ | ;; If the application should use ENC entries, | ||
+ | ;; just add "-DDONT_INCLUDE_MIOS_ENC_TABLE" to MIOS_WRAPPER_DEFINES | ||
+ | ;; and build the table within the C program with: | ||
+ | ;; | ||
+ | ;; MIOS_ENC_TABLE { | ||
+ | ;; // sr pin mode | ||
+ | ;; MIOS_ENC_ENTRY(1, 0, MIOS_ENC_MODE_DETENTED), // VPot #1 | ||
+ | ;; MIOS_ENC_ENTRY(1, 2, MIOS_ENC_MODE_DETENTED), // VPot #2 | ||
+ | ;; MIOS_ENC_ENTRY(1, 4, MIOS_ENC_MODE_DETENTED), // VPot #3 | ||
+ | ;; MIOS_ENC_EOT | ||
+ | ;; }; | ||
+ | ;; | ||
+ | ;; The MIOS_MT_* macros are defined in $MIOS_PATH/include/c/cmios.h | ||
+ | #include <mios_enc_table.inc> | ||
+ | #endif | ||
+ | </code> | ||
+ | |||
+ | Check out the clockbox app for a real world example. | ||
+ | |||
+ | Enjoy! |