Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

▪️ 💸 Add Teensy LC support #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ examples/Demo2/PebbleApp/build

# Ignore Screenshots
pebble-screenshot_*
pebble_screenshot_*

# Ignore lock files
.lock-*
20 changes: 17 additions & 3 deletions examples/Demo2/TeensyDemo/TeensyDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,28 @@ static const size_t UPTIME_ATTRIBUTE_LENGTH = 4;
static const uint16_t SERVICES[] = {SERVICE_ID};
static const uint8_t NUM_SERVICES = 1;

static const uint8_t PEBBLE_DATA_PIN = 1;
static uint8_t buffer[GET_PAYLOAD_BUFFER_SIZE(4)];


void setup() {
pinMode(LED_BUILTIN, OUTPUT);
ArduinoPebbleSerial::begin_software(PEBBLE_DATA_PIN, buffer, sizeof(buffer), Baud57600, SERVICES,
NUM_SERVICES);

#if defined(__MK20DX256__) || defined(__MK20DX128__) || defined(__MKL26Z64__)
// Teensy 3.0/3.1/LC uses hardware serial mode (pins 0/1) with RX/TX shorted together
ArduinoPebbleSerial::begin_hardware(buffer, sizeof(buffer), Baud57600,
SERVICES, NUM_SERVICES);
#elif defined(__AVR_ATmega32U4__)
// Teensy 2.0 uses the one-wire software serial mode (pin 2);
const uint8_t PEBBLE_DATA_PIN = 1;
STATIC_ASSERT_VALID_ONE_WIRE_SOFT_SERIAL_PIN(PEBBLE_DATA_PIN);
ArduinoPebbleSerial::begin_software(PEBBLE_PIN, buffer, sizeof(buffer), Baud57600,
SERVICES, NUM_SERVICES);
#else
// TODO: add Uno check/pin from https://github.com/ishotjr/ArduinoPebbleSerial/tree/uno-debug
#error "This example will only work for the Teensy 2.0, 3.0, 3.1, and LC boards"
#endif


}

static void prv_handle_uptime_request(RequestType type, size_t length) {
Expand Down
4 changes: 2 additions & 2 deletions utility/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ static inline void board_set_even_parity(bool enabled) {
bitClear(UCSR0C, UPM01);
}
}
#elif defined(__MK20DX256__) || defined(__MK20DX128__)
/* Teensy 3.0, Teensy 3.1, etc */
#elif defined(__MK20DX256__) || defined(__MK20DX128__) || defined(__MKL26Z64__)
/* Teensy 3.0, Teensy 3.1, Teensy LC, etc */
#define BOARD_SERIAL Serial1
static inline void board_begin(void) {
// configure TX as open-drain
Expand Down