diff options
| author | Ryan <fauxpark@gmail.com> | 2020-08-19 22:46:15 +1000 |
|---|---|---|
| committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-08-29 14:30:02 -0700 |
| commit | 3f392c09b60d46d9e4a4d3cc150a26294dea4da7 (patch) | |
| tree | 87fe710bbfd25890a106ea54b33e2b86fce02075 | |
| parent | 47f8947bf5aa3ff1cbb484a2d6dc3fa818987700 (diff) | |
| download | qmk_firmware-3f392c09b60d46d9e4a4d3cc150a26294dea4da7.tar.gz qmk_firmware-3f392c09b60d46d9e4a4d3cc150a26294dea4da7.zip | |
More Bluetooth refactoring (#9905)
| -rw-r--r-- | tmk_core/common/progmem.h | 1 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 23 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.c | 14 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.h | 6 | ||||
| -rw-r--r-- | tmk_core/protocol/serial.h | 5 |
5 files changed, 30 insertions, 19 deletions
diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h index 39a918fe9..41b5b537c 100644 --- a/tmk_core/common/progmem.h +++ b/tmk_core/common/progmem.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | # include <avr/pgmspace.h> | 4 | # include <avr/pgmspace.h> |
| 5 | #else | 5 | #else |
| 6 | # define PROGMEM | 6 | # define PROGMEM |
| 7 | # define PGM_P const char * | ||
| 7 | # define memcpy_P(dest, src, n) memcpy(dest, src, n) | 8 | # define memcpy_P(dest, src, n) memcpy(dest, src, n) |
| 8 | # define pgm_read_byte(address_short) *((uint8_t*)(address_short)) | 9 | # define pgm_read_byte(address_short) *((uint8_t*)(address_short)) |
| 9 | # define pgm_read_word(address_short) *((uint16_t*)(address_short)) | 10 | # 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 cef46fe9f..aebded7b3 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.h +++ b/tmk_core/protocol/lufa/adafruit_ble.h | |||
| @@ -2,18 +2,19 @@ | |||
| 2 | * Author: Wez Furlong, 2016 | 2 | * Author: Wez Furlong, 2016 |
| 3 | * Supports the Adafruit BLE board built around the nRF51822 chip. | 3 | * Supports the Adafruit BLE board built around the nRF51822 chip. |
| 4 | */ | 4 | */ |
| 5 | |||
| 5 | #pragma once | 6 | #pragma once |
| 6 | #ifdef MODULE_ADAFRUIT_BLE | ||
| 7 | # include <stdbool.h> | ||
| 8 | # include <stdint.h> | ||
| 9 | # include <string.h> | ||
| 10 | 7 | ||
| 11 | # include "config_common.h" | 8 | #include <stdbool.h> |
| 12 | # include "progmem.h" | 9 | #include <stdint.h> |
| 10 | #include <string.h> | ||
| 11 | |||
| 12 | #include "config_common.h" | ||
| 13 | #include "progmem.h" | ||
| 13 | 14 | ||
| 14 | # ifdef __cplusplus | 15 | #ifdef __cplusplus |
| 15 | extern "C" { | 16 | extern "C" { |
| 16 | # endif | 17 | #endif |
| 17 | 18 | ||
| 18 | /* Instruct the module to enable HID keyboard support and reset */ | 19 | /* Instruct the module to enable HID keyboard support and reset */ |
| 19 | extern bool adafruit_ble_enable_keyboard(void); | 20 | extern bool adafruit_ble_enable_keyboard(void); |
| @@ -54,8 +55,6 @@ extern uint32_t adafruit_ble_read_battery_voltage(void); | |||
| 54 | extern bool adafruit_ble_set_mode_leds(bool on); | 55 | extern bool adafruit_ble_set_mode_leds(bool on); |
| 55 | extern bool adafruit_ble_set_power_level(int8_t level); | 56 | extern bool adafruit_ble_set_power_level(int8_t level); |
| 56 | 57 | ||
| 57 | # ifdef __cplusplus | 58 | #ifdef __cplusplus |
| 58 | } | 59 | } |
| 59 | # endif | 60 | #endif |
| 60 | |||
| 61 | #endif // MODULE_ADAFRUIT_BLE | ||
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c index b115ea969..f758c6528 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 | |||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | #include "lufa.h" | ||
| 16 | #include "outputselect.h" | 15 | #include "outputselect.h" |
| 16 | |||
| 17 | #if defined(PROTOCOL_LUFA) | ||
| 18 | # include "lufa.h" | ||
| 19 | #endif | ||
| 20 | |||
| 17 | #ifdef MODULE_ADAFRUIT_BLE | 21 | #ifdef MODULE_ADAFRUIT_BLE |
| 18 | # include "adafruit_ble.h" | 22 | # include "adafruit_ble.h" |
| 19 | #endif | 23 | #endif |
| @@ -35,12 +39,18 @@ void set_output(uint8_t output) { | |||
| 35 | */ | 39 | */ |
| 36 | __attribute__((weak)) void set_output_user(uint8_t output) {} | 40 | __attribute__((weak)) void set_output_user(uint8_t output) {} |
| 37 | 41 | ||
| 42 | static bool is_usb_configured(void) { | ||
| 43 | #if defined(PROTOCOL_LUFA) | ||
| 44 | return USB_DeviceState == DEVICE_STATE_Configured; | ||
| 45 | #endif | ||
| 46 | } | ||
| 47 | |||
| 38 | /** \brief Auto Detect Output | 48 | /** \brief Auto Detect Output |
| 39 | * | 49 | * |
| 40 | * FIXME: Needs doc | 50 | * FIXME: Needs doc |
| 41 | */ | 51 | */ |
| 42 | uint8_t auto_detect_output(void) { | 52 | uint8_t auto_detect_output(void) { |
| 43 | if (USB_DeviceState == DEVICE_STATE_Configured) { | 53 | if (is_usb_configured()) { |
| 44 | return OUTPUT_USB; | 54 | return OUTPUT_USB; |
| 45 | } | 55 | } |
| 46 | 56 | ||
diff --git a/tmk_core/protocol/lufa/outputselect.h b/tmk_core/protocol/lufa/outputselect.h index 24fe4daa2..7f7ed00b9 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 | |||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | #pragma once | ||
| 16 | |||
| 17 | #include <stdint.h> | ||
| 18 | |||
| 15 | enum outputs { | 19 | enum outputs { |
| 16 | OUTPUT_AUTO, | 20 | OUTPUT_AUTO, |
| 17 | 21 | ||
| @@ -37,4 +41,4 @@ enum outputs { | |||
| 37 | void set_output(uint8_t output); | 41 | void set_output(uint8_t output); |
| 38 | void set_output_user(uint8_t output); | 42 | void set_output_user(uint8_t output); |
| 39 | uint8_t auto_detect_output(void); | 43 | uint8_t auto_detect_output(void); |
| 40 | uint8_t where_to_send(void); \ No newline at end of file | 44 | uint8_t where_to_send(void); |
diff --git a/tmk_core/protocol/serial.h b/tmk_core/protocol/serial.h index 93ac99898..b70d117d7 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 | |||
| 35 | POSSIBILITY OF SUCH DAMAGE. | 35 | POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | #ifndef SERIAL_H | 38 | #pragma once |
| 39 | #define SERIAL_H | ||
| 40 | 39 | ||
| 41 | /* host role */ | 40 | /* host role */ |
| 42 | void serial_init(void); | 41 | void serial_init(void); |
| 43 | uint8_t serial_recv(void); | 42 | uint8_t serial_recv(void); |
| 44 | int16_t serial_recv2(void); | 43 | int16_t serial_recv2(void); |
| 45 | void serial_send(uint8_t data); | 44 | void serial_send(uint8_t data); |
| 46 | |||
| 47 | #endif | ||
