Revision 23437e98

View differences:

core/inc/aos_system.h
225 225
  eventmask_t aosSysSsspStartupOsInitSyncCheck(event_listener_t* syncEvtListener);
226 226
#endif
227 227
  void aosSysGetUptimeX(aos_timestamp_t* ut);
228
#if (HAL_USE_RTC == TRUE)
228 229
  void aosSysGetDateTime(struct tm* dt);
229 230
  void aosSysSetDateTime(struct tm* dt);
231
#endif /* HAL_USE_RTC == TRUE */
230 232
  void aosSysShutdownInit(aos_shutdown_t shutdown);
231 233
  void aosSysStop(void);
232 234
  void aosSysDeinit(void);
core/src/aos_main.cpp
217 217
  return result;
218 218
}
219 219

  
220
#if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
221

  
220 222
/**
221 223
 * @brief   Converter function to encode a TM value to a single unsigned 64 bit integer.
222 224
 *
......
274 276
  return;
275 277
}
276 278

  
279
#endif /* HAL_USE_RTC == TRUE */
280

  
277 281
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__)
278 282
/**
279 283
 * @brief   Implementation of the SSSP module stack initialization sequence (startup phase 3).
......
1098 1102
   * There must be no delays at this point, thus no hook is allowed.
1099 1103
   */
1100 1104

  
1101
#if (AMIROOS_CFG_SSSP_ENABLE == true)
1105
#if (AMIROOS_CFG_SSSP_ENABLE == true) && (HAL_USE_RTC == TRUE)
1102 1106
  /* synchronize calendars */
1103 1107
  if (shutdown == AOS_SHUTDOWN_NONE) {
1104 1108
#if (AMIROOS_CFG_SSSP_MASTER == true)
......
1156 1160
#endif /* AMIROOS_CFG_SSSP_MASTER == false */
1157 1161
    aosDbgPrintf("\n");
1158 1162
  }
1159
#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
1163
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (HAL_USE_RTC == TRUE) */
1160 1164

  
1161 1165
#if defined(AMIROOS_CFG_MAIN_INIT_HOOK_8)
1162 1166
#if defined(AMIROOS_CFG_MAIN_INIT_HOOK_8_ARGS)
core/src/aos_shell.c
323 323
               (uint16_t)(uptime % MICROSECONDS_PER_SECOND / MICROSECONDS_PER_MILLISECOND),
324 324
               (uint16_t)(uptime % MICROSECONDS_PER_MILLISECOND / MICROSECONDS_PER_MICROSECOND));
325 325
    }
326
#if (HAL_USE_RTC == TRUE)
326 327
    else if ((shell->config & (AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME)) == AOS_SHELL_CONFIG_PROMPT_DATETIME) {
327 328
      // get current RTC time
328 329
      struct tm dt;
......
335 336
               dt.tm_min,
336 337
               dt.tm_sec);
337 338
    }
339
#endif /* HAL_USE_RTC == TRUE */
338 340
    else {
339 341
      aosDbgAssert(false);
340 342
    }
core/src/aos_system.c
260 260
  aosDbgCheck(stream != NULL);
261 261

  
262 262
  // local variables
263
#if (HAL_USE_RTC == TRUE)
263 264
  struct tm dt;
264 265
  aosSysGetDateTime(&dt);
266
#endif /* HAL_USE_RTC == TRUE */
265 267

  
266 268
  // print static information about module and operating system
267 269
  _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
......
324 326
    _printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "not available");
325 327
  }
326 328
#endif
329
#if (HAL_USE_RTC == TRUE)
327 330
  _printSystemInfoLine(stream, "Date", SYSTEM_INFO_NAMEWIDTH, "%s %02u-%02u-%04u", (dt.tm_wday == 0) ? "Sunday" : (dt.tm_wday == 1) ? "Monday" : (dt.tm_wday == 2) ? "Tuesday" : (dt.tm_wday == 3) ? "Wednesday" : (dt.tm_wday == 4) ? "Thursday" : (dt.tm_wday == 5) ? "Friday" : "Saturday",
328 331
                       dt.tm_mday,
329 332
                       dt.tm_mon + 1,
330 333
                       dt.tm_year + 1900);
331 334
  _printSystemInfoLine(stream, "Time", SYSTEM_INFO_NAMEWIDTH, "%02u:%02u:%02u", dt.tm_hour, dt.tm_min, dt.tm_sec);
335
#endif /* HAL_USE_RTC == TRUE */
332 336

  
333 337
  _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
334 338

  
......
432 436
        retval = AOS_OK;
433 437
      }
434 438
    }
439
# if (HAL_USE_RTC == TRUE)
435 440
    // if the user wants to configure the date or time
436 441
    else if (strcmp(argv[1], "--date&time") == 0 && argc == 4) {
437 442
      struct tm dt;
438 443
      aosSysGetDateTime(&dt);
439
      unsigned int val = atoi(argv[3]);
440
      if (strcmp(argv[2], "year") == 0) {
444
      int val = atoi(argv[3]);
445
      if (strcmp(argv[2], "year") == 0 && val >= 1900) {
441 446
        dt.tm_year = val - 1900;
442 447
      }
443
      else if (strcmp(argv[2], "month") == 0 && val <= 12) {
448
      else if (strcmp(argv[2], "month") == 0 && val > 0 && val <= 12) {
444 449
        dt.tm_mon = val - 1;
445 450
      }
446
      else if (strcmp(argv[2], "day") == 0 && val <= 31) {
451
      else if (strcmp(argv[2], "day") == 0 && val > 0 && val <= 31) {
447 452
        dt.tm_mday = val;
448 453
      }
449
      else if (strcmp(argv[2], "hour") == 0 && val < 24) {
454
      else if (strcmp(argv[2], "hour") == 0 && val >= 0 && val < 24) {
450 455
        dt.tm_hour = val;
451 456
      }
452
      else if (strcmp(argv[2], "minute") == 0 && val < 60) {
457
      else if (strcmp(argv[2], "minute") == 0 && val >= 0 && val < 60) {
453 458
        dt.tm_min = val;
454 459
      }
455
      else if (strcmp(argv[2], "second") == 0 && val < 60) {
460
      else if (strcmp(argv[2], "second") == 0 && val >= 0 && val < 60) {
456 461
        dt.tm_sec = val;
457 462
      }
458 463
      else {
459
        chprintf(stream, "unknown option '%s' or value '%s'\n", argv[2], argv[3]);
464
        chprintf(stream, "unknown option '%s' or invalid value '%s'\n", argv[2], argv[3]);
460 465
        return AOS_INVALID_ARGUMENTS;
461 466
      }
462 467
      dt.tm_wday = aosTimeDayOfWeekFromDate(dt.tm_mday, dt.tm_mon+1, dt.tm_year+1900) % 7;
......
470 475

  
471 476
      retval = AOS_OK;
472 477
    }
478
#endif /* HAL_USE_RTC == TRUE */
473 479
  }
474 480

  
475 481
  // print help, if required
......
485 491
    chprintf(stream, "        Configures the prompt.\n");
486 492
    chprintf(stream, "      match casesensitive|caseinsenitive\n");
487 493
    chprintf(stream, "        Configures string matching.\n");
494
#if (HAL_USE_RTC == TRUE)
488 495
    chprintf(stream, "  --date&time OPT VAL\n");
489 496
    chprintf(stream, "    Set the date/time value of OPT to VAL.\n");
490 497
    chprintf(stream, "    Possible OPTs are:\n");
......
494 501
    chprintf(stream, "      hour\n");
495 502
    chprintf(stream, "      minute\n");
496 503
    chprintf(stream, "      second\n");
504
#endif /* HAL_USE_RTC == TRUE */
497 505
  }
498 506

  
499 507
  return (argc > 1 && strcmp(argv[1], "--help") == 0) ? AOS_OK : retval;
......
976 984
  return;
977 985
}
978 986

  
987
#if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
988

  
979 989
/**
980 990
 * @brief   retrieves the date and time from the MCU clock.
981 991
 *
......
1008 1018
  return;
1009 1019
}
1010 1020

  
1021
#endif /* HAL_USE_RTC == TRUE */
1022

  
1011 1023
/**
1012 1024
 * @brief   Initializes/Acknowledges a system shutdown/restart request.
1013 1025
 * @note    This functions should be called from the thread with highest priority.

Also available in: Unified diff