diff options
Diffstat (limited to 'tmk_core/common')
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 11 | ||||
| -rw-r--r-- | tmk_core/common/avr/timer.c | 36 | ||||
| -rw-r--r-- | tmk_core/common/backlight.c | 4 | ||||
| -rw-r--r-- | tmk_core/common/host_driver.h | 9 | ||||
| -rw-r--r-- | tmk_core/common/raw_hid.h | 8 |
5 files changed, 40 insertions, 28 deletions
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 8a7272bbc..0c81e8361 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -47,6 +47,7 @@ void suspend_idle(uint8_t time) | |||
| 47 | sleep_disable(); | 47 | sleep_disable(); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | #ifndef NO_SUSPEND_POWER_DOWN | ||
| 50 | /* Power down MCU with watchdog timer | 51 | /* Power down MCU with watchdog timer |
| 51 | * wdto: watchdog timer timeout defined in <avr/wdt.h> | 52 | * wdto: watchdog timer timeout defined in <avr/wdt.h> |
| 52 | * WDTO_15MS | 53 | * WDTO_15MS |
| @@ -61,6 +62,7 @@ void suspend_idle(uint8_t time) | |||
| 61 | * WDTO_8S | 62 | * WDTO_8S |
| 62 | */ | 63 | */ |
| 63 | static uint8_t wdt_timeout = 0; | 64 | static uint8_t wdt_timeout = 0; |
| 65 | |||
| 64 | static void power_down(uint8_t wdto) | 66 | static void power_down(uint8_t wdto) |
| 65 | { | 67 | { |
| 66 | #ifdef PROTOCOL_LUFA | 68 | #ifdef PROTOCOL_LUFA |
| @@ -98,19 +100,19 @@ static void power_down(uint8_t wdto) | |||
| 98 | // Disable watchdog after sleep | 100 | // Disable watchdog after sleep |
| 99 | wdt_disable(); | 101 | wdt_disable(); |
| 100 | } | 102 | } |
| 103 | #endif | ||
| 101 | 104 | ||
| 102 | void suspend_power_down(void) | 105 | void suspend_power_down(void) |
| 103 | { | 106 | { |
| 107 | #ifndef NO_SUSPEND_POWER_DOWN | ||
| 104 | power_down(WDTO_15MS); | 108 | power_down(WDTO_15MS); |
| 109 | #endif | ||
| 105 | } | 110 | } |
| 106 | 111 | ||
| 107 | __attribute__ ((weak)) void matrix_power_up(void) {} | 112 | __attribute__ ((weak)) void matrix_power_up(void) {} |
| 108 | __attribute__ ((weak)) void matrix_power_down(void) {} | 113 | __attribute__ ((weak)) void matrix_power_down(void) {} |
| 109 | bool suspend_wakeup_condition(void) | 114 | bool suspend_wakeup_condition(void) |
| 110 | { | 115 | { |
| 111 | #ifdef BACKLIGHT_ENABLE | ||
| 112 | backlight_set(0); | ||
| 113 | #endif | ||
| 114 | matrix_power_up(); | 116 | matrix_power_up(); |
| 115 | matrix_scan(); | 117 | matrix_scan(); |
| 116 | matrix_power_down(); | 118 | matrix_power_down(); |
| @@ -126,10 +128,9 @@ void suspend_wakeup_init(void) | |||
| 126 | // clear keyboard state | 128 | // clear keyboard state |
| 127 | clear_keyboard(); | 129 | clear_keyboard(); |
| 128 | #ifdef BACKLIGHT_ENABLE | 130 | #ifdef BACKLIGHT_ENABLE |
| 129 | backlight_set(0); | ||
| 130 | backlight_init(); | 131 | backlight_init(); |
| 131 | #endif | 132 | #endif |
| 132 | led_set(host_keyboard_leds()); | 133 | led_set(host_keyboard_leds()); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | #ifndef NO_SUSPEND_POWER_DOWN | 136 | #ifndef NO_SUSPEND_POWER_DOWN |
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c index 292b41c3a..84af44488 100644 --- a/tmk_core/common/avr/timer.c +++ b/tmk_core/common/avr/timer.c | |||
| @@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include <avr/io.h> | 18 | #include <avr/io.h> |
| 19 | #include <avr/interrupt.h> | 19 | #include <avr/interrupt.h> |
| 20 | #include <util/atomic.h> | ||
| 20 | #include <stdint.h> | 21 | #include <stdint.h> |
| 21 | #include "timer_avr.h" | 22 | #include "timer_avr.h" |
| 22 | #include "timer.h" | 23 | #include "timer.h" |
| @@ -24,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | 25 | ||
| 25 | // counter resolution 1ms | 26 | // counter resolution 1ms |
| 26 | // NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} | 27 | // NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} |
| 27 | volatile uint32_t timer_count = 0; | 28 | volatile uint32_t timer_count; |
| 28 | 29 | ||
| 29 | void timer_init(void) | 30 | void timer_init(void) |
| 30 | { | 31 | { |
| @@ -52,10 +53,9 @@ void timer_init(void) | |||
| 52 | inline | 53 | inline |
| 53 | void timer_clear(void) | 54 | void timer_clear(void) |
| 54 | { | 55 | { |
| 55 | uint8_t sreg = SREG; | 56 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 56 | cli(); | ||
| 57 | timer_count = 0; | 57 | timer_count = 0; |
| 58 | SREG = sreg; | 58 | } |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | inline | 61 | inline |
| @@ -63,10 +63,9 @@ uint16_t timer_read(void) | |||
| 63 | { | 63 | { |
| 64 | uint32_t t; | 64 | uint32_t t; |
| 65 | 65 | ||
| 66 | uint8_t sreg = SREG; | 66 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 67 | cli(); | 67 | t = timer_count; |
| 68 | t = timer_count; | 68 | } |
| 69 | SREG = sreg; | ||
| 70 | 69 | ||
| 71 | return (t & 0xFFFF); | 70 | return (t & 0xFFFF); |
| 72 | } | 71 | } |
| @@ -76,10 +75,9 @@ uint32_t timer_read32(void) | |||
| 76 | { | 75 | { |
| 77 | uint32_t t; | 76 | uint32_t t; |
| 78 | 77 | ||
| 79 | uint8_t sreg = SREG; | 78 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 80 | cli(); | 79 | t = timer_count; |
| 81 | t = timer_count; | 80 | } |
| 82 | SREG = sreg; | ||
| 83 | 81 | ||
| 84 | return t; | 82 | return t; |
| 85 | } | 83 | } |
| @@ -89,10 +87,9 @@ uint16_t timer_elapsed(uint16_t last) | |||
| 89 | { | 87 | { |
| 90 | uint32_t t; | 88 | uint32_t t; |
| 91 | 89 | ||
| 92 | uint8_t sreg = SREG; | 90 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 93 | cli(); | 91 | t = timer_count; |
| 94 | t = timer_count; | 92 | } |
| 95 | SREG = sreg; | ||
| 96 | 93 | ||
| 97 | return TIMER_DIFF_16((t & 0xFFFF), last); | 94 | return TIMER_DIFF_16((t & 0xFFFF), last); |
| 98 | } | 95 | } |
| @@ -102,10 +99,9 @@ uint32_t timer_elapsed32(uint32_t last) | |||
| 102 | { | 99 | { |
| 103 | uint32_t t; | 100 | uint32_t t; |
| 104 | 101 | ||
| 105 | uint8_t sreg = SREG; | 102 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 106 | cli(); | 103 | t = timer_count; |
| 107 | t = timer_count; | 104 | } |
| 108 | SREG = sreg; | ||
| 109 | 105 | ||
| 110 | return TIMER_DIFF_32(t, last); | 106 | return TIMER_DIFF_32(t, last); |
| 111 | } | 107 | } |
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c index c9e8fd3fd..0e0ad2d15 100644 --- a/tmk_core/common/backlight.c +++ b/tmk_core/common/backlight.c | |||
| @@ -36,9 +36,9 @@ void backlight_increase(void) | |||
| 36 | if(backlight_config.level < BACKLIGHT_LEVELS) | 36 | if(backlight_config.level < BACKLIGHT_LEVELS) |
| 37 | { | 37 | { |
| 38 | backlight_config.level++; | 38 | backlight_config.level++; |
| 39 | backlight_config.enable = 1; | ||
| 40 | eeconfig_update_backlight(backlight_config.raw); | ||
| 41 | } | 39 | } |
| 40 | backlight_config.enable = 1; | ||
| 41 | eeconfig_update_backlight(backlight_config.raw); | ||
| 42 | dprintf("backlight increase: %u\n", backlight_config.level); | 42 | dprintf("backlight increase: %u\n", backlight_config.level); |
| 43 | backlight_set(backlight_config.level); | 43 | backlight_set(backlight_config.level); |
| 44 | } | 44 | } |
diff --git a/tmk_core/common/host_driver.h b/tmk_core/common/host_driver.h index edb9e5dd9..588d1c0be 100644 --- a/tmk_core/common/host_driver.h +++ b/tmk_core/common/host_driver.h | |||
| @@ -20,7 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | #include <stdint.h> | 21 | #include <stdint.h> |
| 22 | #include "report.h" | 22 | #include "report.h" |
| 23 | 23 | #ifdef MIDI_ENABLE | |
| 24 | #include "midi.h" | ||
| 25 | #endif | ||
| 24 | 26 | ||
| 25 | typedef struct { | 27 | typedef struct { |
| 26 | uint8_t (*keyboard_leds)(void); | 28 | uint8_t (*keyboard_leds)(void); |
| @@ -28,6 +30,11 @@ typedef struct { | |||
| 28 | void (*send_mouse)(report_mouse_t *); | 30 | void (*send_mouse)(report_mouse_t *); |
| 29 | void (*send_system)(uint16_t); | 31 | void (*send_system)(uint16_t); |
| 30 | void (*send_consumer)(uint16_t); | 32 | void (*send_consumer)(uint16_t); |
| 33 | #ifdef MIDI_ENABLE | ||
| 34 | void (*usb_send_func)(MidiDevice *, uint16_t, uint8_t, uint8_t, uint8_t); | ||
| 35 | void (*usb_get_midi)(MidiDevice *); | ||
| 36 | void (*midi_usb_init)(MidiDevice *); | ||
| 37 | #endif | ||
| 31 | } host_driver_t; | 38 | } host_driver_t; |
| 32 | 39 | ||
| 33 | #endif | 40 | #endif |
diff --git a/tmk_core/common/raw_hid.h b/tmk_core/common/raw_hid.h new file mode 100644 index 000000000..86da02fd1 --- /dev/null +++ b/tmk_core/common/raw_hid.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef _RAW_HID_H_ | ||
| 2 | #define _RAW_HID_H_ | ||
| 3 | |||
| 4 | void raw_hid_receive( uint8_t *data, uint8_t length ); | ||
| 5 | |||
| 6 | void raw_hid_send( uint8_t *data, uint8_t length ); | ||
| 7 | |||
| 8 | #endif | ||
