aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/avr/bootloader.c10
-rw-r--r--tmk_core/common/avr/suspend.c2
-rw-r--r--tmk_core/common/avr/timer.c33
-rw-r--r--tmk_core/common/command.c2
4 files changed, 38 insertions, 9 deletions
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c
index ad547b985..98a24d178 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,10 @@ void bootloader_jump(void) {
89 _delay_ms(5); 90 _delay_ms(5);
90 #endif 91 #endif
91 92
93 #ifdef EEPROM_BOOTLOADER_START
94 eeprom_write_byte((uint8_t *)EEPROM_BOOTLOADER_START, 0x00);
95 #endif
96
92 // watchdog reset 97 // watchdog reset
93 reset_key = BOOTLOADER_RESET_KEY; 98 reset_key = BOOTLOADER_RESET_KEY;
94 wdt_enable(WDTO_250MS); 99 wdt_enable(WDTO_250MS);
@@ -114,6 +119,11 @@ void bootloader_jump(void) {
114 #endif 119 #endif
115} 120}
116 121
122#ifdef __AVR_ATmega32A__
123// MCUSR is actually called MCUCSR in ATmega32A
124#define MCUSR MCUCSR
125#endif
126
117/* this runs before main() */ 127/* this runs before main() */
118void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); 128void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3")));
119void bootloader_jump_after_watchdog_reset(void) 129void bootloader_jump_after_watchdog_reset(void)
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index 0c81e8361..0e97892d9 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -65,6 +65,7 @@ static uint8_t wdt_timeout = 0;
65 65
66static void power_down(uint8_t wdto) 66static void power_down(uint8_t wdto)
67{ 67{
68#ifndef __AVR_ATmega32A__
68#ifdef PROTOCOL_LUFA 69#ifdef PROTOCOL_LUFA
69 if (USB_DeviceState == DEVICE_STATE_Configured) return; 70 if (USB_DeviceState == DEVICE_STATE_Configured) return;
70#endif 71#endif
@@ -99,6 +100,7 @@ static void power_down(uint8_t wdto)
99 100
100 // Disable watchdog after sleep 101 // Disable watchdog after sleep
101 wdt_disable(); 102 wdt_disable();
103#endif
102} 104}
103#endif 105#endif
104 106
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..beba768ec 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -235,8 +235,10 @@ 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
238 print_val_hex8(keyboard_protocol); 239 print_val_hex8(keyboard_protocol);
239 print_val_hex8(keyboard_idle); 240 print_val_hex8(keyboard_idle);
241#endif
240#ifdef NKRO_ENABLE 242#ifdef NKRO_ENABLE
241 print_val_hex8(keymap_config.nkro); 243 print_val_hex8(keymap_config.nkro);
242#endif 244#endif