Skip to content

Commit

Permalink
Reorganize system initialization
Browse files Browse the repository at this point in the history
Initialize the LPUART1 port for the AT command interface early before
all other subsystems so that we catch AT commands transmitted by the
host early upon reboot.

Remove the one second delay that was enforced at the beginning of the
main function in DEBUG mode. The goal of that delay was to make it
possible for the developer to see early debugging output on the USART
interface. Without the delay, that output will be lost of the
application isn't fast enough to read from the port upon flashing the
firmware. To see such early debugging output, issue a AT+REBOOT.
  • Loading branch information
janakj committed Apr 5, 2022
1 parent ba3a6fd commit da331b5
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,21 @@
int main(void)
{
system_init();
cmd_init(sysconf.uart_baudrate);

#ifdef DEBUG
log_init(LOG_LEVEL_DUMP, LOG_TIMESTAMP_ABS);
#else
log_init(LOG_LEVEL_OFF, LOG_TIMESTAMP_ABS);
#endif

#ifdef DEBUG
// If we are in debugging mode, delay initialization a bit so that we won't
// miss any debugging or warning messages sent to the UART interface by the
// initialization code that follow.
rtc_delay_ms(1000);
log_info("LoRa Module %s [LoRaMac %s] built on %s", VERSION, LIB_VERSION, BUILD_DATE);
#endif

adc_init();
spi_init(10000000);
sx1276io_init();

nvm_init();
lrw_init();
cmd_init(sysconf.uart_baudrate);

log_debug("LoRaMac: Starting");
LoRaMacStart();
Expand Down

0 comments on commit da331b5

Please sign in to comment.