Skip to content

Commit 88dfe77

Browse files
fauxparknoroadsleft
authored andcommitted
More Bluetooth refactoring (qmk#9905)
1 parent 0926417 commit 88dfe77

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

tmk_core/common/progmem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# include <avr/pgmspace.h>
55
#else
66
# define PROGMEM
7+
# define PGM_P const char *
78
# define memcpy_P(dest, src, n) memcpy(dest, src, n)
89
# define pgm_read_byte(address_short) *((uint8_t*)(address_short))
910
# define pgm_read_word(address_short) *((uint16_t*)(address_short))

tmk_core/protocol/lufa/adafruit_ble.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
* Author: Wez Furlong, 2016
33
* Supports the Adafruit BLE board built around the nRF51822 chip.
44
*/
5+
56
#pragma once
6-
#ifdef MODULE_ADAFRUIT_BLE
7-
# include <stdbool.h>
8-
# include <stdint.h>
9-
# include <string.h>
107

11-
# include "config_common.h"
12-
# include "progmem.h"
8+
#include <stdbool.h>
9+
#include <stdint.h>
10+
#include <string.h>
11+
12+
#include "config_common.h"
13+
#include "progmem.h"
1314

14-
# ifdef __cplusplus
15+
#ifdef __cplusplus
1516
extern "C" {
16-
# endif
17+
#endif
1718

1819
/* Instruct the module to enable HID keyboard support and reset */
1920
extern bool adafruit_ble_enable_keyboard(void);
@@ -54,8 +55,6 @@ extern uint32_t adafruit_ble_read_battery_voltage(void);
5455
extern bool adafruit_ble_set_mode_leds(bool on);
5556
extern bool adafruit_ble_set_power_level(int8_t level);
5657

57-
# ifdef __cplusplus
58+
#ifdef __cplusplus
5859
}
59-
# endif
60-
61-
#endif // MODULE_ADAFRUIT_BLE
60+
#endif

tmk_core/protocol/lufa/outputselect.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ You should have received a copy of the GNU General Public License
1212
along with this program. If not, see <http://www.gnu.org/licenses/>.
1313
*/
1414

15-
#include "lufa.h"
1615
#include "outputselect.h"
16+
17+
#if defined(PROTOCOL_LUFA)
18+
# include "lufa.h"
19+
#endif
20+
1721
#ifdef MODULE_ADAFRUIT_BLE
1822
# include "adafruit_ble.h"
1923
#endif
@@ -35,12 +39,18 @@ void set_output(uint8_t output) {
3539
*/
3640
__attribute__((weak)) void set_output_user(uint8_t output) {}
3741

42+
static bool is_usb_configured(void) {
43+
#if defined(PROTOCOL_LUFA)
44+
return USB_DeviceState == DEVICE_STATE_Configured;
45+
#endif
46+
}
47+
3848
/** \brief Auto Detect Output
3949
*
4050
* FIXME: Needs doc
4151
*/
4252
uint8_t auto_detect_output(void) {
43-
if (USB_DeviceState == DEVICE_STATE_Configured) {
53+
if (is_usb_configured()) {
4454
return OUTPUT_USB;
4555
}
4656

tmk_core/protocol/lufa/outputselect.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ You should have received a copy of the GNU General Public License
1212
along with this program. If not, see <http://www.gnu.org/licenses/>.
1313
*/
1414

15+
#pragma once
16+
17+
#include <stdint.h>
18+
1519
enum outputs {
1620
OUTPUT_AUTO,
1721

@@ -37,4 +41,4 @@ enum outputs {
3741
void set_output(uint8_t output);
3842
void set_output_user(uint8_t output);
3943
uint8_t auto_detect_output(void);
40-
uint8_t where_to_send(void);
44+
uint8_t where_to_send(void);

tmk_core/protocol/serial.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3535
POSSIBILITY OF SUCH DAMAGE.
3636
*/
3737

38-
#ifndef SERIAL_H
39-
#define SERIAL_H
38+
#pragma once
4039

4140
/* host role */
4241
void serial_init(void);
4342
uint8_t serial_recv(void);
4443
int16_t serial_recv2(void);
4544
void serial_send(uint8_t data);
46-
47-
#endif

0 commit comments

Comments
 (0)