aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authorpatrickmt <40182064+patrickmt@users.noreply.github.com>2018-08-29 15:07:52 -0400
committerJack Humbert <jack.humb@gmail.com>2018-08-29 15:07:52 -0400
commit30680c6eb396a2bb06928afd69edae9908ac84fb (patch)
treea4a6c2598faa25dec208377a70dc0fb895ee9c8a /tmk_core/common
parenta6c770432f1348c44bc199029ce17b1b9ff4191c (diff)
downloadqmk_firmware-30680c6eb396a2bb06928afd69edae9908ac84fb.tar.gz
qmk_firmware-30680c6eb396a2bb06928afd69edae9908ac84fb.zip
Massdrop keyboard support (#3780)
* Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/arm_atsam/bootloader.c19
-rw-r--r--tmk_core/common/arm_atsam/eeprom.c98
-rw-r--r--tmk_core/common/arm_atsam/printf.h8
-rw-r--r--tmk_core/common/arm_atsam/suspend.c17
-rw-r--r--tmk_core/common/arm_atsam/timer.c59
-rw-r--r--tmk_core/common/print.h30
-rw-r--r--tmk_core/common/report.h5
7 files changed, 235 insertions, 1 deletions
diff --git a/tmk_core/common/arm_atsam/bootloader.c b/tmk_core/common/arm_atsam/bootloader.c
new file mode 100644
index 000000000..5155d9ff0
--- /dev/null
+++ b/tmk_core/common/arm_atsam/bootloader.c
@@ -0,0 +1,19 @@
1/* Copyright 2017 Fred Sundvik
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "bootloader.h"
18
19void bootloader_jump(void) {}
diff --git a/tmk_core/common/arm_atsam/eeprom.c b/tmk_core/common/arm_atsam/eeprom.c
new file mode 100644
index 000000000..61cc039ef
--- /dev/null
+++ b/tmk_core/common/arm_atsam/eeprom.c
@@ -0,0 +1,98 @@
1/* Copyright 2017 Fred Sundvik
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "eeprom.h"
18
19#define EEPROM_SIZE 32
20
21static uint8_t buffer[EEPROM_SIZE];
22
23uint8_t eeprom_read_byte(const uint8_t *addr) {
24 uintptr_t offset = (uintptr_t)addr;
25 return buffer[offset];
26}
27
28void eeprom_write_byte(uint8_t *addr, uint8_t value) {
29 uintptr_t offset = (uintptr_t)addr;
30 buffer[offset] = value;
31}
32
33uint16_t eeprom_read_word(const uint16_t *addr) {
34 const uint8_t *p = (const uint8_t *)addr;
35 return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8);
36}
37
38uint32_t eeprom_read_dword(const uint32_t *addr) {
39 const uint8_t *p = (const uint8_t *)addr;
40 return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8)
41 | (eeprom_read_byte(p+2) << 16) | (eeprom_read_byte(p+3) << 24);
42}
43
44void eeprom_read_block(void *buf, const void *addr, uint32_t len) {
45 const uint8_t *p = (const uint8_t *)addr;
46 uint8_t *dest = (uint8_t *)buf;
47 while (len--) {
48 *dest++ = eeprom_read_byte(p++);
49 }
50}
51
52void eeprom_write_word(uint16_t *addr, uint16_t value) {
53 uint8_t *p = (uint8_t *)addr;
54 eeprom_write_byte(p++, value);
55 eeprom_write_byte(p, value >> 8);
56}
57
58void eeprom_write_dword(uint32_t *addr, uint32_t value) {
59 uint8_t *p = (uint8_t *)addr;
60 eeprom_write_byte(p++, value);
61 eeprom_write_byte(p++, value >> 8);
62 eeprom_write_byte(p++, value >> 16);
63 eeprom_write_byte(p, value >> 24);
64}
65
66void eeprom_write_block(const void *buf, void *addr, uint32_t len) {
67 uint8_t *p = (uint8_t *)addr;
68 const uint8_t *src = (const uint8_t *)buf;
69 while (len--) {
70 eeprom_write_byte(p++, *src++);
71 }
72}
73
74void eeprom_update_byte(uint8_t *addr, uint8_t value) {
75 eeprom_write_byte(addr, value);
76}
77
78void eeprom_update_word(uint16_t *addr, uint16_t value) {
79 uint8_t *p = (uint8_t *)addr;
80 eeprom_write_byte(p++, value);
81 eeprom_write_byte(p, value >> 8);
82}
83
84void eeprom_update_dword(uint32_t *addr, uint32_t value) {
85 uint8_t *p = (uint8_t *)addr;
86 eeprom_write_byte(p++, value);
87 eeprom_write_byte(p++, value >> 8);
88 eeprom_write_byte(p++, value >> 16);
89 eeprom_write_byte(p, value >> 24);
90}
91
92void eeprom_update_block(const void *buf, void *addr, uint32_t len) {
93 uint8_t *p = (uint8_t *)addr;
94 const uint8_t *src = (const uint8_t *)buf;
95 while (len--) {
96 eeprom_write_byte(p++, *src++);
97 }
98}
diff --git a/tmk_core/common/arm_atsam/printf.h b/tmk_core/common/arm_atsam/printf.h
new file mode 100644
index 000000000..582c83bf5
--- /dev/null
+++ b/tmk_core/common/arm_atsam/printf.h
@@ -0,0 +1,8 @@
1#ifndef _PRINTF_H_
2#define _PRINTF_H_
3
4#define __xprintf dpf
5int dpf(const char *_Format, ...);
6
7#endif //_PRINTF_H_
8
diff --git a/tmk_core/common/arm_atsam/suspend.c b/tmk_core/common/arm_atsam/suspend.c
new file mode 100644
index 000000000..01d1930ea
--- /dev/null
+++ b/tmk_core/common/arm_atsam/suspend.c
@@ -0,0 +1,17 @@
1/* Copyright 2017 Fred Sundvik
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17
diff --git a/tmk_core/common/arm_atsam/timer.c b/tmk_core/common/arm_atsam/timer.c
new file mode 100644
index 000000000..bcfe5002c
--- /dev/null
+++ b/tmk_core/common/arm_atsam/timer.c
@@ -0,0 +1,59 @@
1#include "samd51j18a.h"
2#include "timer.h"
3#include "tmk_core/protocol/arm_atsam/clks.h"
4
5void set_time(uint64_t tset)
6{
7 ms_clk = tset;
8}
9
10void timer_init(void)
11{
12 ms_clk = 0;
13}
14
15uint16_t timer_read(void)
16{
17 return (uint16_t)ms_clk;
18}
19
20uint32_t timer_read32(void)
21{
22 return (uint32_t)ms_clk;
23}
24
25uint64_t timer_read64(void)
26{
27 return ms_clk;
28}
29
30uint16_t timer_elapsed(uint16_t tlast)
31{
32 return TIMER_DIFF_16(timer_read(), tlast);
33}
34
35uint32_t timer_elapsed32(uint32_t tlast)
36{
37 return TIMER_DIFF_32(timer_read32(), tlast);
38}
39
40uint32_t timer_elapsed64(uint32_t tlast)
41{
42 uint64_t tnow = timer_read64();
43 return (tnow >= tlast ? tnow - tlast : UINT64_MAX - tlast + tnow);
44}
45
46void timer_clear(void)
47{
48 ms_clk = 0;
49}
50
51void wait_ms(uint64_t msec)
52{
53 CLK_delay_ms(msec);
54}
55
56void wait_us(uint16_t usec)
57{
58 CLK_delay_us(usec);
59}
diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h
index 8836c0fc7..9cbe67bad 100644
--- a/tmk_core/common/print.h
+++ b/tmk_core/common/print.h
@@ -99,6 +99,34 @@ void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
99 99
100# endif /* USER_PRINT / NORMAL PRINT */ 100# endif /* USER_PRINT / NORMAL PRINT */
101 101
102#elif defined(PROTOCOL_ARM_ATSAM) /* PROTOCOL_ARM_ATSAM */
103
104# include "arm_atsam/printf.h"
105
106# ifdef USER_PRINT /* USER_PRINT */
107
108// Remove normal print defines
109# define print(s)
110# define println(s)
111# define xprintf(fmt, ...)
112
113// Create user print defines
114# define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
115# define uprint(s) xprintf(s)
116# define uprintln(s) xprintf(s "\r\n")
117
118# else /* NORMAL PRINT */
119
120// Create user & normal print defines
121# define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
122# define print(s) xprintf(s)
123# define println(s) xprintf(s "\r\n")
124# define uprint(s) print(s)
125# define uprintln(s) println(s)
126# define uprintf(fmt, ...) xprintf(fmt, ...)
127
128# endif /* USER_PRINT / NORMAL PRINT */
129
102#elif defined(__arm__) /* __arm__ */ 130#elif defined(__arm__) /* __arm__ */
103 131
104# include "mbed/xprintf.h" 132# include "mbed/xprintf.h"
@@ -130,7 +158,7 @@ void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
130/* TODO: to select output destinations: UART/USBSerial */ 158/* TODO: to select output destinations: UART/USBSerial */
131# define print_set_sendchar(func) 159# define print_set_sendchar(func)
132 160
133#endif /* __AVR__ / PROTOCOL_CHIBIOS / __arm__ */ 161#endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM / __arm__ */
134 162
135// User print disables the normal print messages in the body of QMK/TMK code and 163// User print disables the normal print messages in the body of QMK/TMK code and
136// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do 164// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 6c27eb9dc..167f38275 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -84,6 +84,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
84 #define KEYBOARD_REPORT_SIZE NKRO_EPSIZE 84 #define KEYBOARD_REPORT_SIZE NKRO_EPSIZE
85 #define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2) 85 #define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2)
86 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) 86 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
87 #elif defined(PROTOCOL_ARM_ATSAM)
88 #include "protocol/arm_atsam/usb/udi_device_epsize.h"
89 #define KEYBOARD_REPORT_SIZE NKRO_EPSIZE
90 #define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2)
91 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
87 #else 92 #else
88 #error "NKRO not supported with this protocol" 93 #error "NKRO not supported with this protocol"
89#endif 94#endif