summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2020-08-19 22:46:15 +1000
committerJames Young <18669334+noroadsleft@users.noreply.github.com>2020-08-29 14:30:02 -0700
commit3f392c09b60d46d9e4a4d3cc150a26294dea4da7 (patch)
tree87fe710bbfd25890a106ea54b33e2b86fce02075 /tmk_core
parent47f8947bf5aa3ff1cbb484a2d6dc3fa818987700 (diff)
More Bluetooth refactoring (#9905)
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/progmem.h1
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.h23
-rw-r--r--tmk_core/protocol/lufa/outputselect.c14
-rw-r--r--tmk_core/protocol/lufa/outputselect.h6
-rw-r--r--tmk_core/protocol/serial.h5
5 files changed, 30 insertions, 19 deletions
diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h
index 39a918fe98..41b5b537ce 100644
--- a/tmk_core/common/progmem.h
+++ b/tmk_core/common/progmem.h
@@ -4,6 +4,7 @@
# include <avr/pgmspace.h>
#else
# define PROGMEM
+# define PGM_P const char *
# define memcpy_P(dest, src, n) memcpy(dest, src, n)
# define pgm_read_byte(address_short) *((uint8_t*)(address_short))
# define pgm_read_word(address_short) *((uint16_t*)(address_short))
diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h
index cef46fe9f7..aebded7b31 100644
--- a/tmk_core/protocol/lufa/adafruit_ble.h
+++ b/tmk_core/protocol/lufa/adafruit_ble.h
@@ -2,18 +2,19 @@
* Author: Wez Furlong, 2016
* Supports the Adafruit BLE board built around the nRF51822 chip.
*/
+
#pragma once
-#ifdef MODULE_ADAFRUIT_BLE
-# include <stdbool.h>
-# include <stdint.h>
-# include <string.h>
-# include "config_common.h"
-# include "progmem.h"
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "config_common.h"
+#include "progmem.h"
-# ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
-# endif
+#endif
/* Instruct the module to enable HID keyboard support and reset */
extern bool adafruit_ble_enable_keyboard(void);
@@ -54,8 +55,6 @@ extern uint32_t adafruit_ble_read_battery_voltage(void);
extern bool adafruit_ble_set_mode_leds(bool on);
extern bool adafruit_ble_set_power_level(int8_t level);
-# ifdef __cplusplus
+#ifdef __cplusplus
}
-# endif
-
-#endif // MODULE_ADAFRUIT_BLE
+#endif
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c
index b115ea9691..f758c65280 100644
--- a/tmk_core/protocol/lufa/outputselect.c
+++ b/tmk_core/protocol/lufa/outputselect.c
@@ -12,8 +12,12 @@ 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 "lufa.h"
#include "outputselect.h"
+
+#if defined(PROTOCOL_LUFA)
+# include "lufa.h"
+#endif
+
#ifdef MODULE_ADAFRUIT_BLE
# include "adafruit_ble.h"
#endif
@@ -35,12 +39,18 @@ void set_output(uint8_t output) {
*/
__attribute__((weak)) void set_output_user(uint8_t output) {}
+static bool is_usb_configured(void) {
+#if defined(PROTOCOL_LUFA)
+ return USB_DeviceState == DEVICE_STATE_Configured;
+#endif
+}
+
/** \brief Auto Detect Output
*
* FIXME: Needs doc
*/
uint8_t auto_detect_output(void) {
- if (USB_DeviceState == DEVICE_STATE_Configured) {
+ if (is_usb_configured()) {
return OUTPUT_USB;
}
diff --git a/tmk_core/protocol/lufa/outputselect.h b/tmk_core/protocol/lufa/outputselect.h
index 24fe4daa24..7f7ed00b95 100644
--- a/tmk_core/protocol/lufa/outputselect.h
+++ b/tmk_core/protocol/lufa/outputselect.h
@@ -12,6 +12,10 @@ 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 <stdint.h>
+
enum outputs {
OUTPUT_AUTO,
@@ -37,4 +41,4 @@ enum outputs {
void set_output(uint8_t output);
void set_output_user(uint8_t output);
uint8_t auto_detect_output(void);
-uint8_t where_to_send(void); \ No newline at end of file
+uint8_t where_to_send(void);
diff --git a/tmk_core/protocol/serial.h b/tmk_core/protocol/serial.h
index 93ac998983..b70d117d7c 100644
--- a/tmk_core/protocol/serial.h
+++ b/tmk_core/protocol/serial.h
@@ -35,13 +35,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SERIAL_H
-#define SERIAL_H
+#pragma once
/* host role */
void serial_init(void);
uint8_t serial_recv(void);
int16_t serial_recv2(void);
void serial_send(uint8_t data);
-
-#endif