Relocate protocol files within tmk_core/common/ (#14972)
* Relocate non platform files within tmk_core/common/ * clang
This commit is contained in:
		
							parent
							
								
									0c87e2e702
								
							
						
					
					
						commit
						dcfffa7b67
					
				
					 17 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -94,6 +94,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#ifdef DIGITIZER_ENABLE
 | 
			
		||||
#    include "digitizer.h"
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef VIRTSER_ENABLE
 | 
			
		||||
#    include "virtser.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static uint32_t last_input_modification_time = 0;
 | 
			
		||||
uint32_t        last_input_activity_time(void) { return last_input_modification_time; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								quantum/raw_hid.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								quantum/raw_hid.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
void raw_hid_receive(uint8_t *data, uint8_t length);
 | 
			
		||||
 | 
			
		||||
void raw_hid_send(uint8_t *data, uint8_t length);
 | 
			
		||||
							
								
								
									
										58
									
								
								quantum/sync_timer.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								quantum/sync_timer.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,58 @@
 | 
			
		|||
/*
 | 
			
		||||
Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2>
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
 | 
			
		||||
this software and associated documentation files (the "Software"), to deal in
 | 
			
		||||
the Software without restriction, including without limitation the rights to
 | 
			
		||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
of the Software, and to permit persons to whom the Software is furnished to do
 | 
			
		||||
so, subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice shall be included in all
 | 
			
		||||
copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
If you happen to meet one of the copyright holders in a bar you are obligated
 | 
			
		||||
to buy them one pint of beer.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
SOFTWARE.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "sync_timer.h"
 | 
			
		||||
#include "keyboard.h"
 | 
			
		||||
 | 
			
		||||
#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
 | 
			
		||||
volatile int32_t sync_timer_ms;
 | 
			
		||||
 | 
			
		||||
void sync_timer_init(void) { sync_timer_ms = 0; }
 | 
			
		||||
 | 
			
		||||
void sync_timer_update(uint32_t time) {
 | 
			
		||||
    if (is_keyboard_master()) return;
 | 
			
		||||
    sync_timer_ms = time - timer_read32();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t sync_timer_read(void) {
 | 
			
		||||
    if (is_keyboard_master()) return timer_read();
 | 
			
		||||
    return sync_timer_read32();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t sync_timer_read32(void) {
 | 
			
		||||
    if (is_keyboard_master()) return timer_read32();
 | 
			
		||||
    return sync_timer_ms + timer_read32();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t sync_timer_elapsed(uint16_t last) {
 | 
			
		||||
    if (is_keyboard_master()) return timer_elapsed(last);
 | 
			
		||||
    return TIMER_DIFF_16(sync_timer_read(), last);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t sync_timer_elapsed32(uint32_t last) {
 | 
			
		||||
    if (is_keyboard_master()) return timer_elapsed32(last);
 | 
			
		||||
    return TIMER_DIFF_32(sync_timer_read32(), last);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										54
									
								
								quantum/sync_timer.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								quantum/sync_timer.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,54 @@
 | 
			
		|||
/*
 | 
			
		||||
Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2>
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
 | 
			
		||||
this software and associated documentation files (the "Software"), to deal in
 | 
			
		||||
the Software without restriction, including without limitation the rights to
 | 
			
		||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
of the Software, and to permit persons to whom the Software is furnished to do
 | 
			
		||||
so, subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice shall be included in all
 | 
			
		||||
copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
If you happen to meet one of the copyright holders in a bar you are obligated
 | 
			
		||||
to buy them one pint of beer.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
SOFTWARE.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "timer.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
 | 
			
		||||
void     sync_timer_init(void);
 | 
			
		||||
void     sync_timer_update(uint32_t time);
 | 
			
		||||
uint16_t sync_timer_read(void);
 | 
			
		||||
uint32_t sync_timer_read32(void);
 | 
			
		||||
uint16_t sync_timer_elapsed(uint16_t last);
 | 
			
		||||
uint32_t sync_timer_elapsed32(uint32_t last);
 | 
			
		||||
#else
 | 
			
		||||
#    define sync_timer_init()
 | 
			
		||||
#    define sync_timer_clear()
 | 
			
		||||
#    define sync_timer_update(t)
 | 
			
		||||
#    define sync_timer_read() timer_read()
 | 
			
		||||
#    define sync_timer_read32() timer_read32()
 | 
			
		||||
#    define sync_timer_elapsed(t) timer_elapsed(t)
 | 
			
		||||
#    define sync_timer_elapsed32(t) timer_elapsed32(t)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,51 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2021 Andrei Purdea <andrei@purdea.ro>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "usb_device_state.h"
 | 
			
		||||
 | 
			
		||||
enum usb_device_state usb_device_state = USB_DEVICE_STATE_NO_INIT;
 | 
			
		||||
 | 
			
		||||
__attribute__((weak)) void notify_usb_device_state_change_kb(enum usb_device_state usb_device_state) { notify_usb_device_state_change_user(usb_device_state); }
 | 
			
		||||
 | 
			
		||||
__attribute__((weak)) void notify_usb_device_state_change_user(enum usb_device_state usb_device_state) {}
 | 
			
		||||
 | 
			
		||||
static void notify_usb_device_state_change(enum usb_device_state usb_device_state) { notify_usb_device_state_change_kb(usb_device_state); }
 | 
			
		||||
 | 
			
		||||
void usb_device_state_set_configuration(bool isConfigured, uint8_t configurationNumber) {
 | 
			
		||||
    usb_device_state = isConfigured ? USB_DEVICE_STATE_CONFIGURED : USB_DEVICE_STATE_INIT;
 | 
			
		||||
    notify_usb_device_state_change(usb_device_state);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void usb_device_state_set_suspend(bool isConfigured, uint8_t configurationNumber) {
 | 
			
		||||
    usb_device_state = USB_DEVICE_STATE_SUSPEND;
 | 
			
		||||
    notify_usb_device_state_change(usb_device_state);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void usb_device_state_set_resume(bool isConfigured, uint8_t configurationNumber) {
 | 
			
		||||
    usb_device_state = isConfigured ? USB_DEVICE_STATE_CONFIGURED : USB_DEVICE_STATE_INIT;
 | 
			
		||||
    notify_usb_device_state_change(usb_device_state);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void usb_device_state_set_reset(void) {
 | 
			
		||||
    usb_device_state = USB_DEVICE_STATE_INIT;
 | 
			
		||||
    notify_usb_device_state_change(usb_device_state);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void usb_device_state_init(void) {
 | 
			
		||||
    usb_device_state = USB_DEVICE_STATE_INIT;
 | 
			
		||||
    notify_usb_device_state_change(usb_device_state);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,39 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2021 Andrei Purdea <andrei@purdea.ro>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
void usb_device_state_set_configuration(bool isConfigured, uint8_t configurationNumber);
 | 
			
		||||
void usb_device_state_set_suspend(bool isConfigured, uint8_t configurationNumber);
 | 
			
		||||
void usb_device_state_set_resume(bool isConfigured, uint8_t configurationNumber);
 | 
			
		||||
void usb_device_state_set_reset(void);
 | 
			
		||||
void usb_device_state_init(void);
 | 
			
		||||
 | 
			
		||||
enum usb_device_state {
 | 
			
		||||
    USB_DEVICE_STATE_NO_INIT    = 0,  // We're in this state before calling usb_device_state_init()
 | 
			
		||||
    USB_DEVICE_STATE_INIT       = 1,  // Can consume up to 100mA
 | 
			
		||||
    USB_DEVICE_STATE_CONFIGURED = 2,  // Can consume up to what is specified in configuration descriptor, typically 500mA
 | 
			
		||||
    USB_DEVICE_STATE_SUSPEND    = 3   // Can consume only suspend current
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern enum usb_device_state usb_device_state;
 | 
			
		||||
 | 
			
		||||
void notify_usb_device_state_change_kb(enum usb_device_state usb_device_state);
 | 
			
		||||
void notify_usb_device_state_change_user(enum usb_device_state usb_device_state);
 | 
			
		||||
							
								
								
									
										9
									
								
								quantum/virtser.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								quantum/virtser.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
void virtser_init(void);
 | 
			
		||||
 | 
			
		||||
/* Define this function in your code to process incoming bytes */
 | 
			
		||||
void virtser_recv(const uint8_t ch);
 | 
			
		||||
 | 
			
		||||
/* Call this to send a character over the Virtual Serial Device */
 | 
			
		||||
void virtser_send(const uint8_t byte);
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue