Skip to content

Commit 37fa8a7

Browse files
felseradbridge
authored andcommitted
Fix rev D radio init/power/reset and add back bootloader capability
1 parent 7f2684f commit 37fa8a7

File tree

3 files changed

+17
-53
lines changed

3 files changed

+17
-53
lines changed

targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/onboard_modem_api.c

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
static void press_power_button(int time_us)
2828
{
2929
gpio_t gpio;
30-
31-
#if defined(TARGET_UBLOX_C030_R410M)
32-
gpio_init_inout(&gpio, MDMPWRON, PIN_OUTPUT, OpenDrain, 0);
33-
#else
34-
gpio_init_inout(&gpio, MDMPWRON, PIN_OUTPUT, OpenDrainNoPull, 1);
35-
#endif
36-
30+
gpio_init_out_ex(&gpio, MDMPWRON, 1);
3731
wait_us(time_us);
3832
gpio_write(&gpio, 0);
3933
}
@@ -45,71 +39,52 @@ void onboard_modem_init()
4539
// Take us out of reset
4640
gpio_init_inout(&gpio, RADIO_PWR, PIN_OUTPUT, PushPullNoPull, 1);
4741
gpio_init_inout(&gpio, BUF_EN, PIN_OUTPUT, OpenDrainNoPull, 0);
48-
gpio_init_inout(&gpio, MDMRST, PIN_OUTPUT, OpenDrainNoPull, 0);
49-
gpio_init_inout(&gpio, MDMPWRON, PIN_OUTPUT, OpenDrainNoPull, 0);
42+
gpio_init_out_ex(&gpio, MDMRST, 0);
43+
gpio_init_out_ex(&gpio, MDMPWRON, 0);
5044
gpio_init_inout(&gpio, RADIO_DTR, PIN_OUTPUT, OpenDrainNoPull, 0);
5145
}
5246

5347
void onboard_modem_deinit()
5448
{
49+
onboard_modem_power_down();
5550
gpio_t gpio;
5651

5752
// Back into reset
58-
gpio_init_inout(&gpio, MDMRST,PIN_OUTPUT, OpenDrainNoPull, 1);
53+
gpio_init_out_ex(&gpio, MDMRST, 1);
54+
gpio_init_out_ex(&gpio, MDMPWRON, 1);
5955
gpio_init_inout(&gpio, BUF_EN, PIN_OUTPUT, OpenDrainNoPull, 1);
6056
gpio_init_inout(&gpio, RADIO_PWR, PIN_OUTPUT, PushPullNoPull, 0);
6157
gpio_init_inout(&gpio, RADIO_DTR, PIN_OUTPUT, OpenDrainNoPull, 1);
6258
}
6359

64-
65-
66-
6760
void onboard_modem_power_up()
6861
{
69-
#if defined(TARGET_UBLOX_C030_R410M)
70-
/* keep the power line low for 1 seconds */
71-
press_power_button(1000000);
72-
#else
73-
/* keep the power line low for 50 microseconds */
62+
onboard_modem_init();
63+
7464
gpio_t gpio;
7565
gpio_init_in(&gpio, MON_1V8);
7666

77-
if(gpio_is_connected(&gpio) != 0 && gpio_read(&gpio) != 0) {
67+
if(gpio_is_connected(&gpio) && !gpio_read(&gpio)) {
7868
unsigned int i = 0;
79-
while(i < 5)
69+
while(i < 3)
8070
{
81-
press_power_button( 2000000);
82-
wait_ms(1000);
83-
onboard_modem_deinit();
84-
wait_ms(1000);
85-
onboard_modem_init();
71+
press_power_button(150000);
8672
wait_ms(250);
8773

88-
if(gpio_is_connected(&gpio) != 0 && gpio_read(&gpio) == 0)
74+
if(gpio_read(&gpio))
8975
{
9076
break;
9177
}
9278
i++;
9379
}
9480
}
95-
96-
press_power_button( 2000000);
97-
98-
#endif
99-
100-
/* give modem a little time to respond */
101-
wait_ms(500);
10281
}
10382

10483
void onboard_modem_power_down()
10584
{
106-
#if defined(TARGET_UBLOX_C030_R410M)
107-
/* keep the power line low for 1.5 seconds */
85+
/* Activate PWR_ON for 1.5s to switch off */
10886
press_power_button(1500000);
109-
#else
110-
/* keep the power line low for 1 seconds */
111-
press_power_button(300000);
112-
#endif
87+
// check for 1.8v low if not, take reset low for 10s
11388
}
11489

11590
#endif //MODEM_ON_BOARD

targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/ublox_low_level_api.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,8 @@ void ublox_board_init(void) {
2626
gpio_init_inout(&gpio, VUSB_EN, PIN_OUTPUT, OpenDrainNoPull, 0);
2727

2828
// start with modem disabled
29-
gpio_init_out_ex(&gpio, MDMRST, 1);
30-
#if defined(TARGET_UBLOX_C030_R410M)
31-
gpio_init_inout(&gpio, MDMPWRON, PIN_OUTPUT, OpenDrain, 0);
32-
#else
33-
gpio_init_inout(&gpio, MDMPWRON, PIN_OUTPUT, OpenDrainNoPull, 0);
34-
#endif
35-
gpio_init_out_ex(&gpio, MDMRTS, 1);
36-
//gpio_init_in_ex(&gpio, MDMCURRENTSENSE, PullNone);
37-
38-
#if !defined (TARGET_UBLOX_C030_R410M)
39-
// start with GNSS disabled, this is ONLY TEMPORARY and that once the HW issue with the GNSSEN pin on the R410M board is resolved then this line will become default for all platforms.
40-
// gpio_init_inout(&gpio, GNSSEN, PIN_OUTPUT, PushPullNoPull, 0);
41-
#endif
42-
29+
gpio_init_out_ex(&gpio, MDMRST, 1);
30+
gpio_init_out_ex(&gpio, MDMPWRON, 0);
4331
}
4432

4533
// End Of File

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,7 @@
21862186
"device_has_add": ["ANALOGOUT", "CAN", "LOWPOWERTIMER", "SERIAL_ASYNCH", "SERIAL_FC", "TRNG", "FLASH", "ANALOGIN", "I2C", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "SERIAL", "SLEEP", "SPI", "SPISLAVE"],
21872187
"release_versions": ["2", "5"],
21882188
"device_name": "STM32L471QG",
2189+
"bootloader_supported": true
21892190
},
21902191
"MTB_MTS_DRAGONFLY": {
21912192
"inherits": ["FAMILY_STM32"],

0 commit comments

Comments
 (0)