aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authormilestogo <milestogo@users.noreply.github.com>2017-02-04 20:08:07 -0800
committermilestogo <milestogo@users.noreply.github.com>2017-02-04 20:08:07 -0800
commitb0dfb037dc0b8b20fd87b3c88449a2ce20ff80e1 (patch)
treedf9fb78b55c4a9b8262e35ac7bd26ec0ebdb64db /tmk_core/common
parente8ba4838d30ef3af6d8e69ebc1d00a1910806ac2 (diff)
parentf0633f2540be3ba86797522a2075a9f5ba2ad5c6 (diff)
downloadqmk_firmware-b0dfb037dc0b8b20fd87b3c88449a2ce20ff80e1.tar.gz
qmk_firmware-b0dfb037dc0b8b20fd87b3c88449a2ce20ff80e1.zip
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/avr/bootloader.c12
-rw-r--r--tmk_core/common/avr/timer.c33
-rw-r--r--tmk_core/common/command.c3
-rw-r--r--tmk_core/common/keyboard.c2
4 files changed, 40 insertions, 10 deletions
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c
index ad547b985..34db8d0b0 100644
--- a/tmk_core/common/avr/bootloader.c
+++ b/tmk_core/common/avr/bootloader.c
@@ -1,6 +1,7 @@
1#include <stdint.h> 1#include <stdint.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#include <avr/io.h> 3#include <avr/io.h>
4#include <avr/eeprom.h>
4#include <avr/interrupt.h> 5#include <avr/interrupt.h>
5#include <avr/wdt.h> 6#include <avr/wdt.h>
6#include <util/delay.h> 7#include <util/delay.h>
@@ -89,6 +90,12 @@ void bootloader_jump(void) {
89 _delay_ms(5); 90 _delay_ms(5);
90 #endif 91 #endif
91 92
93 #ifdef BOOTLOADHID_BOOTLOADER
94 // force bootloadHID to stay in bootloader mode, so that it waits
95 // for a new firmware to be flashed
96 eeprom_write_byte((uint8_t *)1, 0x00);
97 #endif
98
92 // watchdog reset 99 // watchdog reset
93 reset_key = BOOTLOADER_RESET_KEY; 100 reset_key = BOOTLOADER_RESET_KEY;
94 wdt_enable(WDTO_250MS); 101 wdt_enable(WDTO_250MS);
@@ -114,6 +121,11 @@ void bootloader_jump(void) {
114 #endif 121 #endif
115} 122}
116 123
124#ifdef __AVR_ATmega32A__
125// MCUSR is actually called MCUCSR in ATmega32A
126#define MCUSR MCUCSR
127#endif
128
117/* this runs before main() */ 129/* this runs before main() */
118void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); 130void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3")));
119void bootloader_jump_after_watchdog_reset(void) 131void bootloader_jump_after_watchdog_reset(void)
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c
index 84af44488..369015200 100644
--- a/tmk_core/common/avr/timer.c
+++ b/tmk_core/common/avr/timer.c
@@ -29,25 +29,35 @@ volatile uint32_t timer_count;
29 29
30void timer_init(void) 30void timer_init(void)
31{ 31{
32 // Timer0 CTC mode
33 TCCR0A = 0x02;
34
35#if TIMER_PRESCALER == 1 32#if TIMER_PRESCALER == 1
36 TCCR0B = 0x01; 33 uint8_t prescaler = 0x01;
37#elif TIMER_PRESCALER == 8 34#elif TIMER_PRESCALER == 8
38 TCCR0B = 0x02; 35 uint8_t prescaler = 0x02;
39#elif TIMER_PRESCALER == 64 36#elif TIMER_PRESCALER == 64
40 TCCR0B = 0x03; 37 uint8_t prescaler = 0x03;
41#elif TIMER_PRESCALER == 256 38#elif TIMER_PRESCALER == 256
42 TCCR0B = 0x04; 39 uint8_t prescaler = 0x04;
43#elif TIMER_PRESCALER == 1024 40#elif TIMER_PRESCALER == 1024
44 TCCR0B = 0x05; 41 uint8_t prescaler = 0x05;
45#else 42#else
46# error "Timer prescaler value is NOT vaild." 43# error "Timer prescaler value is NOT vaild."
47#endif 44#endif
48 45
46#ifndef __AVR_ATmega32A__
47 // Timer0 CTC mode
48 TCCR0A = 0x02;
49
50 TCCR0B = prescaler;
51
49 OCR0A = TIMER_RAW_TOP; 52 OCR0A = TIMER_RAW_TOP;
50 TIMSK0 = (1<<OCIE0A); 53 TIMSK0 = (1<<OCIE0A);
54#else
55 // Timer0 CTC mode
56 TCCR0 = (1 << WGM01) | prescaler;
57
58 OCR0 = TIMER_RAW_TOP;
59 TIMSK = (1 << OCIE0);
60#endif
51} 61}
52 62
53inline 63inline
@@ -107,7 +117,12 @@ uint32_t timer_elapsed32(uint32_t last)
107} 117}
108 118
109// excecuted once per 1ms.(excess for just timer count?) 119// excecuted once per 1ms.(excess for just timer count?)
110ISR(TIMER0_COMPA_vect) 120#ifndef __AVR_ATmega32A__
121#define TIMER_INTERRUPT_VECTOR TIMER0_COMPA_vect
122#else
123#define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect
124#endif
125ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK)
111{ 126{
112 timer_count++; 127 timer_count++;
113} 128}
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index 5f29bc0b4..f79d5a257 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -235,8 +235,11 @@ static void print_status(void)
235 print("\n\t- Status -\n"); 235 print("\n\t- Status -\n");
236 236
237 print_val_hex8(host_keyboard_leds()); 237 print_val_hex8(host_keyboard_leds());
238#ifndef PROTOCOL_VUSB
239 // these aren't set on the V-USB protocol, so we just ignore them for now
238 print_val_hex8(keyboard_protocol); 240 print_val_hex8(keyboard_protocol);
239 print_val_hex8(keyboard_idle); 241 print_val_hex8(keyboard_idle);
242#endif
240#ifdef NKRO_ENABLE 243#ifdef NKRO_ENABLE
241 print_val_hex8(keymap_config.nkro); 244 print_val_hex8(keymap_config.nkro);
242#endif 245#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 371d93f3e..765350792 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -188,7 +188,7 @@ MATRIX_LOOP_END:
188#endif 188#endif
189 189
190#ifdef VISUALIZER_ENABLE 190#ifdef VISUALIZER_ENABLE
191 visualizer_update(default_layer_state, layer_state, host_keyboard_leds()); 191 visualizer_update(default_layer_state, layer_state, visualizer_get_mods(), host_keyboard_leds());
192#endif 192#endif
193 193
194 // update LED 194 // update LED