Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 505544c

Browse files
committed
v2.1: update the examples to correct issue 423 in the Apollo3 core
sparkfun/Arduino_Apollo3#423
1 parent 192588a commit 505544c

File tree

19 files changed

+364
-148
lines changed

19 files changed

+364
-148
lines changed

Software/examples/Example10_BasicSend/Example10_BasicSend.ino

+31-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Example: Basic Send
44
55
Written by Paul Clark (PaulZC)
6-
August 7th 2021
6+
August 25th 2021
77
88
** Updated for v2.1.0 of the Apollo3 core / Artemis board package **
99
** (At the time of writing, v2.1.1 of the core conatins a feature which makes communication with the u-blox GNSS problematic. Be sure to use v2.1.0) **
@@ -87,6 +87,34 @@ void gnssOFF(void) // Disable power for the GNSS
8787
digitalWrite(gnssEN, HIGH); // Disable GNSS power (HIGH = disable; LOW = enable)
8888
}
8989

90+
// Overwrite the IridiumSBD beginSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
91+
void IridiumSBD::beginSerialPort() // Start the serial port connected to the satellite modem
92+
{
93+
diagprint(F("custom IridiumSBD::beginSerialPort\r\n"));
94+
95+
// Configure the standard ATP pins for UART1 TX and RX - endSerialPort may have disabled the RX pin
96+
97+
am_hal_gpio_pincfg_t pinConfigTx = g_AM_BSP_GPIO_COM_UART_TX;
98+
pinConfigTx.uFuncSel = AM_HAL_PIN_24_UART1TX;
99+
pin_config(D24, pinConfigTx);
100+
101+
am_hal_gpio_pincfg_t pinConfigRx = g_AM_BSP_GPIO_COM_UART_RX;
102+
pinConfigRx.uFuncSel = AM_HAL_PIN_25_UART1RX;
103+
pinConfigRx.ePullup = AM_HAL_GPIO_PIN_PULLUP_WEAK; // Put a weak pull-up on the Rx pin
104+
pin_config(D25, pinConfigRx);
105+
106+
Serial1.begin(19200);
107+
}
108+
109+
// Overwrite the IridiumSBD endSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
110+
void IridiumSBD::endSerialPort()
111+
{
112+
diagprint(F("custom IridiumSBD::endSerialPort\r\n"));
113+
114+
// Disable the Serial1 RX pin to avoid the code hang
115+
am_hal_gpio_pinconfig(PinName(D25), g_AM_HAL_GPIO_DISABLE);
116+
}
117+
90118
void setup()
91119
{
92120
int signalQuality = -1;
@@ -148,14 +176,12 @@ void setup()
148176
digitalWrite(iridiumPwrEN, HIGH); // Enable Iridium Power
149177
delay(1000);
150178

151-
// Start the serial port connected to the satellite modem
152-
Serial1.begin(19200);
153-
154179
// If we're powering the device by USB, tell the library to
155180
// relax timing constraints waiting for the supercap to recharge.
156181
modem.setPowerProfile(IridiumSBD::USB_POWER_PROFILE);
157182

158183
// Begin satellite modem operation
184+
// Also begin the serial port connected to the satellite modem via IridiumSBD::beginSerialPort
159185
Serial.println(F("Starting modem..."));
160186
err = modem.begin();
161187
if (err != ISBD_SUCCESS)
@@ -207,6 +233,7 @@ void setup()
207233
}
208234

209235
// Power down the modem
236+
// Also disable the Serial1 RX pin via IridiumSBD::endSerialPort
210237
Serial.println(F("Putting the 9603N to sleep."));
211238
err = modem.sleep();
212239
if (err != ISBD_SUCCESS)

Software/examples/Example11_Ring/Example11_Ring.ino

+30-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Example: Ring
44
55
Written by Paul Clark (PaulZC)
6-
August 7th 2021
6+
August 25th 2021
77
88
** Updated for v2.1.0 of the Apollo3 core / Artemis board package **
99
** (At the time of writing, v2.1.1 of the core conatins a feature which makes communication with the u-blox GNSS problematic. Be sure to use v2.1.0) **
@@ -84,6 +84,34 @@ void gnssOFF(void) // Disable power for the GNSS
8484
digitalWrite(gnssEN, HIGH); // Disable GNSS power (HIGH = disable; LOW = enable)
8585
}
8686

87+
// Overwrite the IridiumSBD beginSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
88+
void IridiumSBD::beginSerialPort() // Start the serial port connected to the satellite modem
89+
{
90+
diagprint(F("custom IridiumSBD::beginSerialPort\r\n"));
91+
92+
// Configure the standard ATP pins for UART1 TX and RX - endSerialPort may have disabled the RX pin
93+
94+
am_hal_gpio_pincfg_t pinConfigTx = g_AM_BSP_GPIO_COM_UART_TX;
95+
pinConfigTx.uFuncSel = AM_HAL_PIN_24_UART1TX;
96+
pin_config(D24, pinConfigTx);
97+
98+
am_hal_gpio_pincfg_t pinConfigRx = g_AM_BSP_GPIO_COM_UART_RX;
99+
pinConfigRx.uFuncSel = AM_HAL_PIN_25_UART1RX;
100+
pinConfigRx.ePullup = AM_HAL_GPIO_PIN_PULLUP_WEAK; // Put a weak pull-up on the Rx pin
101+
pin_config(D25, pinConfigRx);
102+
103+
Serial1.begin(19200);
104+
}
105+
106+
// Overwrite the IridiumSBD endSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
107+
void IridiumSBD::endSerialPort()
108+
{
109+
diagprint(F("custom IridiumSBD::endSerialPort\r\n"));
110+
111+
// Disable the Serial1 RX pin to avoid the code hang
112+
am_hal_gpio_pinconfig(PinName(D25), g_AM_HAL_GPIO_DISABLE);
113+
}
114+
87115
void setup()
88116
{
89117
int signalQuality = -1;
@@ -145,14 +173,12 @@ void setup()
145173
digitalWrite(iridiumPwrEN, HIGH); // Enable Iridium Power
146174
delay(1000);
147175

148-
// Start the serial port connected to the satellite modem
149-
Serial1.begin(19200);
150-
151176
// If we're powering the device by USB, tell the library to
152177
// relax timing constraints waiting for the supercap to recharge.
153178
modem.setPowerProfile(IridiumSBD::USB_POWER_PROFILE);
154179

155180
// Begin satellite modem operation
181+
// Also begin the serial port connected to the satellite modem via IridiumSBD::beginSerialPort
156182
Serial.println(F("Starting modem..."));
157183
err = modem.begin();
158184
if (err != ISBD_SUCCESS)

Software/examples/Example14_SimpleTracker/Example14_SimpleTracker.ino

+39-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Example: Simple Tracker
44
55
Written by Paul Clark (PaulZC)
6-
August 7th 2021
6+
August 25th 2021
77
88
** Updated for v2.1.0 of the Apollo3 core / Artemis board package **
99
** (At the time of writing, v2.1.1 of the core conatins a feature which makes communication with the u-blox GNSS problematic. Be sure to use v2.1.0) **
@@ -38,6 +38,8 @@
3838
Buy a board from SparkFun!
3939
4040
Version history:
41+
August 25th 2021
42+
Added a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
4143
August 7th 2021
4244
Updated for v2.1 of the Apollo3 core
4345
December 15th, 2020:
@@ -242,6 +244,34 @@ void gnssOFF(void) // Disable power for the GNSS
242244
digitalWrite(gnssEN, HIGH); // Disable GNSS power (HIGH = disable; LOW = enable)
243245
}
244246

247+
// Overwrite the IridiumSBD beginSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
248+
void IridiumSBD::beginSerialPort() // Start the serial port connected to the satellite modem
249+
{
250+
diagprint(F("custom IridiumSBD::beginSerialPort\r\n"));
251+
252+
// Configure the standard ATP pins for UART1 TX and RX - endSerialPort may have disabled the RX pin
253+
254+
am_hal_gpio_pincfg_t pinConfigTx = g_AM_BSP_GPIO_COM_UART_TX;
255+
pinConfigTx.uFuncSel = AM_HAL_PIN_24_UART1TX;
256+
pin_config(D24, pinConfigTx);
257+
258+
am_hal_gpio_pincfg_t pinConfigRx = g_AM_BSP_GPIO_COM_UART_RX;
259+
pinConfigRx.uFuncSel = AM_HAL_PIN_25_UART1RX;
260+
pinConfigRx.ePullup = AM_HAL_GPIO_PIN_PULLUP_WEAK; // Put a weak pull-up on the Rx pin
261+
pin_config(D25, pinConfigRx);
262+
263+
Serial1.begin(19200);
264+
}
265+
266+
// Overwrite the IridiumSBD endSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
267+
void IridiumSBD::endSerialPort()
268+
{
269+
diagprint(F("custom IridiumSBD::endSerialPort\r\n"));
270+
271+
// Disable the Serial1 RX pin to avoid the code hang
272+
am_hal_gpio_pinconfig(PinName(D25), g_AM_HAL_GPIO_DISABLE);
273+
}
274+
245275
void setup()
246276
{
247277
// Let's begin by setting up the I/O pins
@@ -691,17 +721,11 @@ void loop()
691721
digitalWrite(iridiumPwrEN, HIGH); // Enable Iridium Power
692722
delay(1000);
693723

694-
// Enable the 9603N and start talking to it
695-
Serial.println(F("Beginning to talk to the 9603..."));
696-
697-
// Start the serial port connected to the satellite modem
698-
Serial1.begin(19200);
699-
delay(1000);
700-
701724
// Relax timing constraints waiting for the supercap to recharge.
702725
modem.setPowerProfile(IridiumSBD::USB_POWER_PROFILE);
703726

704727
// Begin satellite modem operation
728+
// Also begin the serial port connected to the satellite modem via IridiumSBD::beginSerialPort
705729
Serial.println(F("Starting modem..."));
706730
agtErr = modem.begin();
707731

@@ -734,8 +758,8 @@ void loop()
734758
ftoa(agtVbat,vbatStr,2,6);
735759
char speedStr[8]; // speed string
736760
ftoa(agtSpeed,speedStr,2,8);
737-
char pressureStr[8]; // pressure string
738-
ftoa(agtPascals,pressureStr,0,8);
761+
char pressureStr[9]; // pressure string
762+
ftoa(agtPascals,pressureStr,0,9);
739763
char temperatureStr[10]; // temperature string
740764
ftoa(agtTempC,temperatureStr,1,10);
741765

@@ -818,6 +842,7 @@ void loop()
818842
}
819843

820844
// Power down the modem
845+
// Also disable the Serial1 RX pin via IridiumSBD::endSerialPort
821846
Serial.println(F("Putting the 9603N to sleep."));
822847
agtErr = modem.sleep();
823848
if (agtErr != ISBD_SUCCESS)
@@ -843,6 +868,9 @@ void loop()
843868
// Power down the GNSS
844869
Serial.println(F("Powering down the GNSS..."));
845870
gnssOFF(); // Disable power for the GNSS
871+
872+
// Make sure the Serial1 RX pin is disabled
873+
modem.endSerialPort();
846874

847875
// Disable 9603N power
848876
Serial.println(F("Disabling 9603N power..."));
@@ -932,14 +960,7 @@ void loop()
932960
pin_config(PinName(48), g_AM_BSP_GPIO_COM_UART_TX);
933961
pin_config(PinName(49), g_AM_BSP_GPIO_COM_UART_RX);
934962

935-
// Renable UART1 pins: TX (24) and RX (25)
936-
am_hal_gpio_pincfg_t pinConfigTx = g_AM_BSP_GPIO_COM_UART_TX;
937-
pinConfigTx.uFuncSel = AM_HAL_PIN_24_UART1TX;
938-
pin_config(PinName(24), pinConfigTx);
939-
am_hal_gpio_pincfg_t pinConfigRx = g_AM_BSP_GPIO_COM_UART_RX;
940-
pinConfigRx.uFuncSel = AM_HAL_PIN_25_UART1RX;
941-
pinConfigRx.ePullup = AM_HAL_GPIO_PIN_PULLUP_WEAK; // Put a weak pull-up on the Rx pin
942-
pin_config(PinName(25), pinConfigRx);
963+
// Do not renable the UART1 pins here as the modem is still powered off. Let modem.begin do it via beginSerialPort.
943964

944965
// Enable ADC
945966
powerControlADC(true);

Software/examples/Example15_BetterTracker/Example15_BetterTracker.ino

+39-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Example: A Better Tracker
44
55
Written by Paul Clark (PaulZC)
6-
August 9th 2021
6+
August 25th 2021
77
88
** Updated for v2.1.0 of the Apollo3 core / Artemis board package **
99
** (At the time of writing, v2.1.1 of the core conatins a feature which makes communication with the u-blox GNSS problematic. Be sure to use v2.1.0) **
@@ -61,6 +61,8 @@
6161
Buy a board from SparkFun!
6262
6363
Version history:
64+
August 25th 2021
65+
Added a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
6466
August 7th 2021
6567
Updated for v2.1 of the Apollo3 core
6668
December 15th, 2020:
@@ -280,6 +282,34 @@ void gnssOFF(void) // Disable power for the GNSS
280282
digitalWrite(gnssEN, HIGH); // Disable GNSS power (HIGH = disable; LOW = enable)
281283
}
282284

285+
// Overwrite the IridiumSBD beginSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
286+
void IridiumSBD::beginSerialPort() // Start the serial port connected to the satellite modem
287+
{
288+
diagprint(F("custom IridiumSBD::beginSerialPort\r\n"));
289+
290+
// Configure the standard ATP pins for UART1 TX and RX - endSerialPort may have disabled the RX pin
291+
292+
am_hal_gpio_pincfg_t pinConfigTx = g_AM_BSP_GPIO_COM_UART_TX;
293+
pinConfigTx.uFuncSel = AM_HAL_PIN_24_UART1TX;
294+
pin_config(D24, pinConfigTx);
295+
296+
am_hal_gpio_pincfg_t pinConfigRx = g_AM_BSP_GPIO_COM_UART_RX;
297+
pinConfigRx.uFuncSel = AM_HAL_PIN_25_UART1RX;
298+
pinConfigRx.ePullup = AM_HAL_GPIO_PIN_PULLUP_WEAK; // Put a weak pull-up on the Rx pin
299+
pin_config(D25, pinConfigRx);
300+
301+
Serial1.begin(19200);
302+
}
303+
304+
// Overwrite the IridiumSBD endSerialPort function - a fix for https://github.com/sparkfun/Arduino_Apollo3/issues/423
305+
void IridiumSBD::endSerialPort()
306+
{
307+
diagprint(F("custom IridiumSBD::endSerialPort\r\n"));
308+
309+
// Disable the Serial1 RX pin to avoid the code hang
310+
am_hal_gpio_pinconfig(PinName(D25), g_AM_HAL_GPIO_DISABLE);
311+
}
312+
283313
void setup()
284314
{
285315
// Let's begin by setting up the I/O pins
@@ -754,17 +784,11 @@ void loop()
754784
digitalWrite(iridiumPwrEN, HIGH); // Enable Iridium Power
755785
delay(1000);
756786

757-
// Enable the 9603N and start talking to it
758-
Serial.println(F("Beginning to talk to the 9603..."));
759-
760-
// Start the serial port connected to the satellite modem
761-
Serial1.begin(19200);
762-
delay(1000);
763-
764787
// Relax timing constraints waiting for the supercap to recharge.
765788
modem.setPowerProfile(IridiumSBD::USB_POWER_PROFILE);
766789

767790
// Begin satellite modem operation
791+
// Also begin the serial port connected to the satellite modem via IridiumSBD::beginSerialPort
768792
Serial.println(F("Starting modem..."));
769793
agtErr = modem.begin();
770794

@@ -797,8 +821,8 @@ void loop()
797821
ftoa(agtVbat,vbatStr,2,6);
798822
char speedStr[8]; // speed string
799823
ftoa(agtSpeed,speedStr,2,8);
800-
char pressureStr[8]; // pressure string
801-
ftoa(agtPascals,pressureStr,0,8);
824+
char pressureStr[9]; // pressure string
825+
ftoa(agtPascals,pressureStr,0,9);
802826
char temperatureStr[10]; // temperature string
803827
ftoa(agtTempC,temperatureStr,1,10);
804828

@@ -994,6 +1018,7 @@ void loop()
9941018
}
9951019

9961020
// Power down the modem
1021+
// Also disable the Serial1 RX pin via IridiumSBD::endSerialPort
9971022
Serial.println(F("Putting the 9603N to sleep."));
9981023
agtErr = modem.sleep();
9991024
if (agtErr != ISBD_SUCCESS)
@@ -1020,6 +1045,9 @@ void loop()
10201045
Serial.println(F("Powering down the GNSS..."));
10211046
gnssOFF(); // Disable power for the GNSS
10221047

1048+
// Make sure the Serial1 RX pin is disabled
1049+
modem.endSerialPort();
1050+
10231051
// Disable 9603N power
10241052
Serial.println(F("Disabling 9603N power..."));
10251053
digitalWrite(iridiumSleep, LOW); // Disable 9603N via its ON/OFF pin (modem.sleep should have done this already)
@@ -1108,14 +1136,7 @@ void loop()
11081136
pin_config(PinName(48), g_AM_BSP_GPIO_COM_UART_TX);
11091137
pin_config(PinName(49), g_AM_BSP_GPIO_COM_UART_RX);
11101138

1111-
// Renable UART1 pins: TX (24) and RX (25)
1112-
am_hal_gpio_pincfg_t pinConfigTx = g_AM_BSP_GPIO_COM_UART_TX;
1113-
pinConfigTx.uFuncSel = AM_HAL_PIN_24_UART1TX;
1114-
pin_config(PinName(24), pinConfigTx);
1115-
am_hal_gpio_pincfg_t pinConfigRx = g_AM_BSP_GPIO_COM_UART_RX;
1116-
pinConfigRx.uFuncSel = AM_HAL_PIN_25_UART1RX;
1117-
pinConfigRx.ePullup = AM_HAL_GPIO_PIN_PULLUP_WEAK; // Put a weak pull-up on the Rx pin
1118-
pin_config(PinName(25), pinConfigRx);
1139+
// Do not renable the UART1 pins here as the modem is still powered off. Let modem.begin do it via beginSerialPort.
11191140

11201141
// Enable ADC
11211142
powerControlADC(true);

0 commit comments

Comments
 (0)