Revision 9ebb11a9 core/src/aos_system.c

View differences:

core/src/aos_system.c
79 79
 */
80 80
static systime_t _synctime;
81 81

  
82
#if (AMIROOS_CFG_SSSP_MASTER == true) || defined(__DOXYGEN__)
82
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER == true)) || defined(__DOXYGEN__)
83 83
/**
84 84
 * @brief   Timer to drive the SYS_SYNC signal for system wide time synchronization according to SSSP.
85 85
 */
......
91 91
static aos_timestamp_t _syssynctime;
92 92
#endif
93 93

  
94
#if ((AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
94
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
95 95
/**
96 96
 * @brief   Offset between local clock and system wide synchronization signal.
97 97
 */
......
101 101
 * @brief   Weighting factor for the low-pass filter used for calculating the @p _syssyncskew value.
102 102
 */
103 103
#define SYSTEM_SYSSYNCSKEW_LPFACTOR   (0.1f / AOS_SYSTEM_TIME_RESOLUTION)
104
#endif
104
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) */
105 105

  
106 106
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
107 107
/**
......
250 250
#endif
251 251
  _printSystemInfoLine(stream, "Architecture", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_ARCHITECTURE_NAME);
252 252
  _printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH);
253
#if (AMIROOS_CFG_SSSP_ENABLE == true)
253 254
  _printSystemInfoLine(stream, "AMiRo-OS" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (SSSP %u.%u)", AMIROOS_VERSION_MAJOR, AMIROOS_VERSION_MINOR, AMIROOS_VERSION_PATCH, AMIROOS_RELEASE_TYPE, AOS_SYSTEM_SSSP_VERSION_MAJOR, AOS_SYSTEM_SSSP_VERSION_MINOR);
255
#else
256
  _printSystemInfoLine(stream, "AMiRo-OS" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", AMIROOS_VERSION_MAJOR, AMIROOS_VERSION_MINOR, AMIROOS_VERSION_PATCH, AMIROOS_RELEASE_TYPE);
257
#endif
254 258
  _printSystemInfoLine(stream, "AMiRo-LLD" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (periphAL %u.%u)", AMIRO_LLD_VERSION_MAJOR, AMIRO_LLD_VERSION_MINOR, AMIRO_LLD_VERSION_PATCH, AMIRO_LLD_RELEASE_TYPE, PERIPHAL_VERSION_MAJOR, PERIPHAL_VERSION_MINOR);
255 259
  _printSystemInfoLine(stream, "ChibiOS/RT" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", CH_KERNEL_MAJOR, CH_KERNEL_MINOR, CH_KERNEL_PATCH, (CH_KERNEL_STABLE == 1) ? "stable" : "non-stable");
256 260
  _printSystemInfoLine(stream, "ChibiOS/HAL", SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", CH_HAL_MAJOR, CH_HAL_MINOR, CH_HAL_PATCH, (CH_HAL_STABLE == 1) ? "stable" : "non-stable");
......
269 273
                         (BL_CALLBACK_TABLE_ADDRESS->vBootloader.identifier == BL_VERSION_ID_AMiRoBLT_PreAlpha) ? "pre-alpha" :
270 274
                         "<release type unknown>",
271 275
                         BL_CALLBACK_TABLE_ADDRESS->vSSSP.major, BL_CALLBACK_TABLE_ADDRESS->vSSSP.minor);
276
#if (AMIROOS_CFG_SSSP_ENABLE == true)
272 277
    if (BL_CALLBACK_TABLE_ADDRESS->vSSSP.major != AOS_SYSTEM_SSSP_VERSION_MAJOR) {
273 278
      if (stream) {
274 279
        chprintf(stream, "WARNING: Bootloader and AMiRo-OS implement incompatible SSSP versions!\n");
......
276 281
        aosprintf("WARNING: Bootloader and AMiRo-OS implement incompatible SSSP versions!\n");
277 282
      }
278 283
    }
284
#endif
279 285
    _printSystemInfoLine(stream, "Compiler", SYSTEM_INFO_NAMEWIDTH, "%s %u.%u.%u", (BL_CALLBACK_TABLE_ADDRESS->vCompiler.identifier == BL_VERSION_ID_GCC) ? "GCC" : "<compiler unknown>", BL_CALLBACK_TABLE_ADDRESS->vCompiler.major, BL_CALLBACK_TABLE_ADDRESS->vCompiler.minor, BL_CALLBACK_TABLE_ADDRESS->vCompiler.patch); // TODO: support other compilers than GCC
280 286
  } else {
281 287
    if (stream) {
......
287 293

  
288 294
  // print dynamic information about the module
289 295
  _printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH);
296
#if (AMIROOS_CFG_SSSP_ENABLE == true)
290 297
  if (aos.sssp.moduleId != 0) {
291 298
    _printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "%u", aos.sssp.moduleId);
292 299
  } else {
293 300
    _printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "not available");
294 301
  }
302
#endif
295 303
  _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",
296 304
                       dt.tm_mday,
297 305
                       dt.tm_mon + 1,
......
500 508
  chprintf(stream, "%10u seconds\n", (uint8_t)(uptime % MICROSECONDS_PER_MINUTE / MICROSECONDS_PER_SECOND));
501 509
  chprintf(stream, "%10u milliseconds\n", (uint16_t)(uptime % MICROSECONDS_PER_SECOND / MICROSECONDS_PER_MILLISECOND));
502 510
  chprintf(stream, "%10u microseconds\n", (uint16_t)(uptime % MICROSECONDS_PER_MILLISECOND / MICROSECONDS_PER_MICROSECOND));
503
#if (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)
511
#if (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)
504 512
  chprintf(stream, "SSSP synchronization offset: %.3fus per %uus\n", _syssyncskew, AMIROOS_CFG_SSSP_SYSSYNCPERIOD);
505 513
#endif /* AMIROOS_CFG_SSSP_MASTER != true && AMIROOS_CFG_PROFILE == true */
506 514
  _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
......
625 633
  return;
626 634
}
627 635

  
628
#if (AMIROOS_CFG_SSSP_MASTER != true) || defined(__DOXYGEN__)
636
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true)) || defined(__DOXYGEN__)
629 637
/**
630 638
 * @brief   Callback function for the Sync signal interrupt.
631 639
 *
......
667 675

  
668 676
  return;
669 677
}
670
#endif
678
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) */
671 679

  
672 680
/**
673 681
 * @brief   Callback function for the uptime accumulation timer.
......
691 699
  return;
692 700
}
693 701

  
694
#if (AMIROOS_CFG_SSSP_MASTER == true) || defined (__DOXYGEN__)
702
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER == true)) || defined (__DOXYGEN__)
695 703
/**
696 704
 * @brief   Periodic system synchronization callback function.
697 705
 * @details Toggles the SYS_SYNC signal and reconfigures the system synchronization timer.
......
725 733

  
726 734
  return;
727 735
}
728
#endif
736
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER == true) */
729 737

  
730 738
/**
731 739
 * @brief   AMiRo-OS system initialization.
......
744 752

  
745 753
  /* set local variables */
746 754
  chVTObjectInit(&_systimer);
755
#if (AMIROOS_CFG_SSSP_ENABLE == true)
747 756
  _synctime = 0;
748 757
  _uptime = 0;
749 758
#if (AMIROOS_CFG_SSSP_MASTER == true)
......
753 762
#if (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)
754 763
  _syssyncskew = 0.0f;
755 764
#endif
765
#else /* AMIROOS_CFG_SSSP_ENABLE == false */
766
  // start the uptime counter
767
  chSysLock();
768
  _synctime = chVTGetSystemTimeX();
769
  _uptime = 0;
770
  chVTSetI(&_systimer, SYSTIMER_PERIOD, &_uptimeCallback, NULL);
771
  chSysUnlock();
772
#endif /* AMIROOS_CFG_SSSP_ENABLE */
756 773

  
757 774
  /* initialize aos configuration */
775
#if (AMIROOS_CFG_SSSP_ENABLE == true)
758 776
  aos.sssp.stage = AOS_SSSP_STARTUP_2_1;
759 777
  aos.sssp.moduleId = 0;
778
#endif
760 779
  aosIOStreamInit(&aos.iostream);
761 780
  chEvtObjectInit(&aos.events.io);
762 781
  chEvtObjectInit(&aos.events.os);
763 782

  
764 783
  /* interrupt setup */
784
#if (AMIROOS_CFG_SSSP_ENABLE == true)
765 785
  // PD signal
766 786
  palSetPadCallback(moduleSsspGpioPd.gpio->port, moduleSsspGpioPd.gpio->pad, _intCallback, &moduleSsspGpioPd.gpio->pad);
767 787
  palEnablePadEvent(moduleSsspGpioPd.gpio->port, moduleSsspGpioPd.gpio->pad, APAL2CH_EDGE(moduleSsspGpioPd.meta.edge));
......
782 802
  palSetPadCallback(moduleSsspGpioUp.gpio->port, moduleSsspGpioUp.gpio->pad, _intCallback, &moduleSsspGpioUp.gpio->pad);
783 803
  palEnablePadEvent(moduleSsspGpioUp.gpio->port, moduleSsspGpioUp.gpio->pad, APAL2CH_EDGE(moduleSsspGpioUp.meta.edge));
784 804
#endif
805
#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
785 806
#ifdef MODULE_INIT_INTERRUPTS
786 807
  // further interrupt signals
787 808
  MODULE_INIT_INTERRUPTS();
......
803 824
#if (AMIROOS_CFG_TESTS_ENABLE == true)
804 825
  aosShellAddCommand(&aos.shell, &_shellcmd_kerneltest);
805 826
#endif
806
#endif
827
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */
807 828

  
808 829
  return;
809 830
}
......
813 834
 */
814 835
inline void aosSysStart(void)
815 836
{
837
#if (AMIROOS_CFG_SSSP_ENABLE == true)
816 838
  // update the system SSSP stage
817 839
  aos.sssp.stage = AOS_SSSP_OPERATION;
818 840

  
......
828 850
    chSysUnlock();
829 851
  }
830 852
#endif
853
#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
831 854

  
832 855
  // print system information;
833 856
  _printSystemInfo((BaseSequentialStream*)&aos.iostream);
......
845 868
  return;
846 869
}
847 870

  
871
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__)
848 872
/**
849 873
 * @brief   Implements the SSSP startup synchronization step.
850 874
 *
......
895 919
    return m;
896 920
  }
897 921
}
922
#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
898 923

  
899 924
/**
900 925
 * @brief   Retrieves the system uptime.
......
953 978
  // check arguments
954 979
  aosDbgCheck(shutdown != AOS_SHUTDOWN_NONE);
955 980

  
981
#if (AMIROOS_CFG_SSSP_ENABLE == true)
956 982
#if (AMIROOS_CFG_SSSP_MASTER == true)
957 983
  // deactivate the system synchronization timer
958 984
  chVTReset(&_syssynctimer);
......
969 995
  // activate the SYS_SYNC signal
970 996
  apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_ON);
971 997
  chSysUnlock();
998
#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
972 999

  
973 1000
  switch (shutdown) {
974 1001
    case AOS_SHUTDOWN_PASSIVE:
......
997 1024
      break;
998 1025
  }
999 1026

  
1027
#if (AMIROOS_CFG_SSSP_ENABLE == true)
1000 1028
  // update the system SSSP stage
1001 1029
  aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_2;
1030
#endif
1002 1031

  
1003 1032
  return;
1004 1033
}
......
1037 1066
  // disable all interrupts
1038 1067
  irqDeinit();
1039 1068

  
1069
#if (AMIROOS_CFG_SSSP_ENABLE == true)
1040 1070
  // update the system SSSP stage
1041 1071
  aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_3;
1072
#endif
1042 1073

  
1043 1074
  // call bootloader callback depending on arguments
1044 1075
  switch (shutdown) {

Also available in: Unified diff