summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/avr/suspend.c27
-rw-r--r--common/command.c1
-rw-r--r--common/keycode.h10
-rw-r--r--common/matrix.h9
-rw-r--r--common/mbed/xprintf.cpp5
-rw-r--r--common/print.c12
-rw-r--r--common/print.h5
-rw-r--r--common/report.h5
-rw-r--r--common/suspend.h2
9 files changed, 52 insertions, 24 deletions
diff --git a/common/avr/suspend.c b/common/avr/suspend.c
index 66a579fd7..80243f02b 100644
--- a/common/avr/suspend.c
+++ b/common/avr/suspend.c
@@ -7,6 +7,7 @@
#include "backlight.h"
#include "suspend_avr.h"
#include "suspend.h"
+#include "timer.h"
#ifdef PROTOCOL_LUFA
#include "lufa.h"
#endif
@@ -52,11 +53,13 @@ void suspend_idle(uint8_t time)
* WDTO_4S
* WDTO_8S
*/
-void suspend_power_down(uint8_t wdto)
+static uint8_t wdt_timeout = 0;
+static void power_down(uint8_t wdto)
{
#ifdef PROTOCOL_LUFA
if (USB_DeviceState == DEVICE_STATE_Configured) return;
#endif
+ wdt_timeout = wdto;
// Watchdog Interrupt Mode
wdt_intr_enable(wdto);
@@ -67,7 +70,6 @@ void suspend_power_down(uint8_t wdto)
// - prescale clock
// - BOD disable
// - Power Reduction Register PRR
-
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sei();
@@ -78,6 +80,11 @@ void suspend_power_down(uint8_t wdto)
wdt_disable();
}
+void suspend_power_down(void)
+{
+ power_down(WDTO_15MS);
+}
+
bool suspend_wakeup_condition(void)
{
matrix_power_up();
@@ -103,15 +110,13 @@ void suspend_wakeup_init(void)
/* watchdog timeout */
ISR(WDT_vect)
{
- /* wakeup from MCU sleep mode */
-/*
- // blink LED
- static uint8_t led_state = 0;
- static uint8_t led_count = 0;
- led_count++;
- if ((led_count & 0x07) == 0) {
- led_set((led_state ^= (1<<USB_LED_CAPS_LOCK)));
+ // compensate timer for sleep
+ switch (wdt_timeout) {
+ case WDTO_15MS:
+ timer_count += 15 + 2; // WDTO_15MS + 2(from observation)
+ break;
+ default:
+ ;
}
-*/
}
#endif
diff --git a/common/command.c b/common/command.c
index 380f2d8c0..fbaa9f2d7 100644
--- a/common/command.c
+++ b/common/command.c
@@ -194,6 +194,7 @@ static bool command_common(uint8_t code)
case KC_CAPSLOCK:
if (host_get_driver()) {
host_driver = host_get_driver();
+ clear_keyboard();
host_set_driver(0);
print("Locked.\n");
} else {
diff --git a/common/keycode.h b/common/keycode.h
index 08c3cbf42..ac4ef00db 100644
--- a/common/keycode.h
+++ b/common/keycode.h
@@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
+/*
* Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes
* http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
*/
@@ -140,6 +140,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_VOLD KC_AUDIO_VOL_DOWN
#define KC_MNXT KC_MEDIA_NEXT_TRACK
#define KC_MPRV KC_MEDIA_PREV_TRACK
+#define KC_MFFD KC_MEDIA_FAST_FORWARD
+#define KC_MRWD KC_MEDIA_REWIND
#define KC_MSTP KC_MEDIA_STOP
#define KC_MPLY KC_MEDIA_PLAY_PAUSE
#define KC_MSEL KC_MEDIA_SELECT
@@ -390,7 +392,7 @@ enum hid_keyboard_keypad_usage {
KC_RALT,
KC_RGUI,
- /* NOTE: 0xE8-FF are used for internal special purpose */
+ /* NOTE: 0xE8-FF are used for internal special purpose */
};
/* Special keycodes */
@@ -420,7 +422,9 @@ enum internal_special_keycodes {
KC_WWW_FORWARD,
KC_WWW_STOP,
KC_WWW_REFRESH,
- KC_WWW_FAVORITES, /* 0xBA */
+ KC_WWW_FAVORITES,
+ KC_MEDIA_FAST_FORWARD,
+ KC_MEDIA_REWIND, /* 0xBC */
/* Fn key */
KC_FN0 = 0xC0,
diff --git a/common/matrix.h b/common/matrix.h
index 23fef78f7..107ee7265 100644
--- a/common/matrix.h
+++ b/common/matrix.h
@@ -35,6 +35,10 @@ typedef uint32_t matrix_row_t;
#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<<col))
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* number of matrix rows */
uint8_t matrix_rows(void);
/* number of matrix columns */
@@ -48,7 +52,7 @@ bool matrix_is_modified(void) __attribute__ ((deprecated));
/* whether a swtich is on */
bool matrix_is_on(uint8_t row, uint8_t col);
/* matrix state on row */
-matrix_row_t matrix_get_row(uint8_t row);
+matrix_row_t matrix_get_row(uint8_t row);
/* print matrix for debug */
void matrix_print(void);
@@ -57,5 +61,8 @@ void matrix_print(void);
void matrix_power_up(void);
void matrix_power_down(void);
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/common/mbed/xprintf.cpp b/common/mbed/xprintf.cpp
index 4342b79f8..3647ece75 100644
--- a/common/mbed/xprintf.cpp
+++ b/common/mbed/xprintf.cpp
@@ -6,6 +6,10 @@
#define STRING_STACK_LIMIT 120
+//TODO
+int xprintf(const char* format, ...) { return 0; }
+
+#if 0
/* mbed Serial */
Serial ser(UART_TX, UART_RX);
@@ -44,3 +48,4 @@ int xprintf(const char* format, ...)
return r;
*/
}
+#endif
diff --git a/common/print.c b/common/print.c
index c13a29f31..ca94e1e5d 100644
--- a/common/print.c
+++ b/common/print.c
@@ -22,13 +22,14 @@
* THE SOFTWARE.
*/
-#include <avr/io.h>
-#include <avr/pgmspace.h>
+#include <stdint.h>
#include "print.h"
#ifndef NO_PRINT
+#if defined(__AVR__)
+
#define sendchar(c) xputc(c)
@@ -37,4 +38,11 @@ void print_set_sendchar(int8_t (*sendchar_func)(uint8_t))
xdev_out(sendchar_func);
}
+#elif defined(__arm__)
+
+// TODO
+//void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { }
+
+#endif
+
#endif
diff --git a/common/print.h b/common/print.h
index a8dbbc020..c0e9e1430 100644
--- a/common/print.h
+++ b/common/print.h
@@ -38,12 +38,7 @@
#if defined(__AVR__)
#include "avr/xprintf.h"
-
-
-// TODO: avoid collision with arduino/Print.h
-#ifndef __cplusplus
#define print(s) xputs(PSTR(s))
-#endif
#define println(s) xputs(PSTR(s "\r\n"))
#ifdef __cplusplus
diff --git a/common/report.h b/common/report.h
index 62190469a..f6c0a315d 100644
--- a/common/report.h
+++ b/common/report.h
@@ -61,6 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
#define AL_LOCK 0x019E
#define TRANSPORT_RECORD 0x00B2
+#define TRANSPORT_FAST_FORWARD 0x00B3
#define TRANSPORT_REWIND 0x00B4
#define TRANSPORT_EJECT 0x00B8
#define AC_MINIMIZE 0x0206
@@ -158,6 +159,8 @@ typedef struct {
(key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
(key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
(key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
+ (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \
+ (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \
(key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
(key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \
(key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
@@ -171,7 +174,7 @@ typedef struct {
(key == KC_WWW_FORWARD ? AC_FORWARD : \
(key == KC_WWW_STOP ? AC_STOP : \
(key == KC_WWW_REFRESH ? AC_REFRESH : \
- (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))
+ (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))
#ifdef __cplusplus
}
diff --git a/common/suspend.h b/common/suspend.h
index f339c670a..80617a824 100644
--- a/common/suspend.h
+++ b/common/suspend.h
@@ -6,7 +6,7 @@
void suspend_idle(uint8_t timeout);
-void suspend_power_down(uint8_t timeout);
+void suspend_power_down(void);
bool suspend_wakeup_condition(void);
void suspend_wakeup_init(void);