More Bluetooth refactoring (#9905)

This commit is contained in:
Ryan 2020-08-19 22:46:15 +10:00 committed by James Young
parent 47f8947bf5
commit 3f392c09b6
5 changed files with 30 additions and 19 deletions

View file

@ -4,6 +4,7 @@
# include <avr/pgmspace.h> # include <avr/pgmspace.h>
#else #else
# define PROGMEM # define PROGMEM
# define PGM_P const char *
# define memcpy_P(dest, src, n) memcpy(dest, src, n) # define memcpy_P(dest, src, n) memcpy(dest, src, n)
# define pgm_read_byte(address_short) *((uint8_t*)(address_short)) # define pgm_read_byte(address_short) *((uint8_t*)(address_short))
# define pgm_read_word(address_short) *((uint16_t*)(address_short)) # define pgm_read_word(address_short) *((uint16_t*)(address_short))

View file

@ -2,8 +2,9 @@
* Author: Wez Furlong, 2016 * Author: Wez Furlong, 2016
* Supports the Adafruit BLE board built around the nRF51822 chip. * Supports the Adafruit BLE board built around the nRF51822 chip.
*/ */
#pragma once #pragma once
#ifdef MODULE_ADAFRUIT_BLE
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@ -57,5 +58,3 @@ extern bool adafruit_ble_set_power_level(int8_t level);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // MODULE_ADAFRUIT_BLE

View file

@ -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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "lufa.h"
#include "outputselect.h" #include "outputselect.h"
#if defined(PROTOCOL_LUFA)
# include "lufa.h"
#endif
#ifdef MODULE_ADAFRUIT_BLE #ifdef MODULE_ADAFRUIT_BLE
# include "adafruit_ble.h" # include "adafruit_ble.h"
#endif #endif
@ -35,12 +39,18 @@ void set_output(uint8_t output) {
*/ */
__attribute__((weak)) void set_output_user(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 /** \brief Auto Detect Output
* *
* FIXME: Needs doc * FIXME: Needs doc
*/ */
uint8_t auto_detect_output(void) { uint8_t auto_detect_output(void) {
if (USB_DeviceState == DEVICE_STATE_Configured) { if (is_usb_configured()) {
return OUTPUT_USB; return OUTPUT_USB;
} }

View file

@ -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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#include <stdint.h>
enum outputs { enum outputs {
OUTPUT_AUTO, OUTPUT_AUTO,

View file

@ -35,13 +35,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef SERIAL_H #pragma once
#define SERIAL_H
/* host role */ /* host role */
void serial_init(void); void serial_init(void);
uint8_t serial_recv(void); uint8_t serial_recv(void);
int16_t serial_recv2(void); int16_t serial_recv2(void);
void serial_send(uint8_t data); void serial_send(uint8_t data);
#endif