Skip to content

Commit a7759bb

Browse files
authored
Merge pull request #1 from gigapod/main
tweaks to get working on the rp2350 w/ arduino
2 parents 4bf3376 + 7c848cd commit a7759bb

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

examples/xbee_lr/xbee_lr.ino

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ void setup() {
125125
serialPort = &Serial1;
126126

127127
delay(6000);
128+
Serial.println("");
129+
Serial.println("----------------------------------------------------------------------");
128130
Serial.println("XBee LR Example App");
129131

130132
// Initialize the XBee module
@@ -136,7 +138,18 @@ void setup() {
136138

137139
// Read LoRaWAN DevEUI and print
138140
uint8_t devEui[17];
139-
if (xbee->getLoRaWANDevEUI(devEui,sizeof(devEui))){
141+
142+
// This might take a few trys ...
143+
bool status = false;
144+
for(int i = 0; i < 3; i++){
145+
if (xbee->getLoRaWANDevEUI(devEui,sizeof(devEui))){
146+
status = true;
147+
break;
148+
}
149+
delay(100);
150+
}
151+
// if (xbee->getLoRaWANDevEUI(devEui,sizeof(devEui))){
152+
if (status){
140153
Serial.print("DEVEUI: ");
141154
Serial.print((char*)devEui);
142155
Serial.println();

src/XBeeArduino.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool XBeeArduino::sendData(const T& data) {
134134
if (moduleType_ == XBEE_LORA) {
135135
return XBeeSendData(xbee_, &data) == 0;
136136
}
137-
//return false;
137+
return false;
138138
}
139139

140140
// Explicit template instantiation for XBeeLRPacket_s

src/port_arduino.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ int portUartInit(uint32_t baudrate, void *device) {
5858
((HardwareSerial*)serialPort)->begin(baudrate);
5959
// }
6060

61+
// KDB - The arduino core doesn't set our pins to the correct function for the UART
62+
// see the helpful table here: https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_gpio/include/hardware/gpio.h
63+
#if defined(PICO_RP2350)
64+
if (PIN_SERIAL1_TX == 18 && PIN_SERIAL1_RX == 19 && device == &Serial1) {
65+
gpio_set_function(PIN_SERIAL1_TX, (gpio_function_t)11);
66+
gpio_set_function(PIN_SERIAL1_RX, (gpio_function_t)11);
67+
uart_init(uart0, baudrate);
68+
}
69+
#endif
6170
return 0; // Indicate success
6271
}
6372

@@ -162,4 +171,5 @@ void portDebugPrintf(const char *format, ...) {
162171
vsnprintf(buffer, sizeof(buffer), format, args);
163172
va_end(args);
164173
Serial.print(buffer);
174+
Serial.println();
165175
}

src/xbee_api_frames.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ int apiSendFrame(XBee* self, uint8_t frameType, const uint8_t *data, uint16_t le
129129
portDelay(1);
130130
}
131131

132+
#if API_FRAME_DEBUG_PRINT_ENABLED
132133
uint32_t elapsed_time = portMillis() - startTime;
134+
#endif
133135
APIFrameDebugPrint("UART write completed in %lu ms\n", elapsed_time);
134136

135137
// Return success if everything went well
@@ -435,6 +437,7 @@ int apiSendAtCommandAndGetResponse(XBee* self, at_command_t command, const uint8
435437

436438
//Print out AT Response
437439
void xbeeHandleAtResponse(XBee* self, xbee_api_frame_t *frame) {
440+
#if API_FRAME_DEBUG_PRINT_ENABLED
438441
// The first byte of frame->data is the Frame ID
439442
uint8_t frame_id = frame->data[1];
440443

@@ -444,8 +447,10 @@ void xbeeHandleAtResponse(XBee* self, xbee_api_frame_t *frame) {
444447
at_command[1] = frame->data[3];
445448
at_command[2] = '\0'; // Null-terminate the string
446449

450+
447451
// The next byte is the command status
448452
uint8_t command_status = frame->data[4];
453+
#endif
449454

450455
// Print the basic information
451456
APIFrameDebugPrint("AT Response:\n");

0 commit comments

Comments
 (0)