29 #include "subsystems/chibios-libopencm3/chibios_sdlog.h"
31 #include "usbStorage.h"
32 #include "pprz_stub.h"
33 #include "rtcAccess.h"
34 #include "generated/airframe.h"
38 #ifndef SDLOG_START_DELAY
39 #define SDLOG_START_DELAY 30
43 #ifndef SYS_TIME_FREQUENCY
44 #error SYS_TIME_FREQUENCY should be defined in Makefile.chibios or airframe.xml and be equal to CH_FREQUENCY
45 #elif SYS_TIME_FREQUENCY != CH_FREQUENCY
46 #error SYS_TIME_FREQUENCY should be equal to CH_FREQUENCY
47 #elif CH_FREQUENCY < (2 * PERIODIC_FREQUENCY)
48 #error CH_FREQUENCY and SYS_TIME_FREQUENCY should be >= 2 x PERIODIC_FREQUENCY
51 static __attribute__((noreturn)) msg_t
thd_heartbeat(
void *arg);
52 #define MAX(x , y) (((x) > (y)) ? (x) : (y))
53 #define ARRAY_LEN(a) (sizeof(a)/sizeof(a[0]))
70 PWR->CSR &= ~PWR_CSR_BRE;
71 DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
73 chThdCreateStatic(wa_thd_heartbeat,
sizeof(wa_thd_heartbeat),
76 usbStorageStartPolling ();
83 pprzThdPtr = chThdCreateStatic(pprzThd,
sizeof(pprzThd), NORMALPRIO+1, thd, NULL);
93 chRegSetThreadName(
"pprz heartbeat");
96 if (usbStorageIsItRunning ())
97 chThdSleepSeconds (20000);
99 sdOk = chibios_logInit();
102 palTogglePad (
GPIOC, GPIOC_LED3);
103 chThdSleepMilliseconds (sdOk ==
TRUE ? 1000 : 200);
108 if (chTimeNow() - timestamp > 5000) {
109 timestamp = chTimeNow();
110 if (getGpsTimeOfWeek() != 0) {
111 setRtcFromGps (getGpsWeek(), getGpsTimeOfWeek());
static msg_t thd_heartbeat(void *arg)
void chibios_launch_heartbeat(void)
static WORKING_AREA(wa_thd_heartbeat, 2048)
bool_t chibios_init(void)
#define SDLOG_START_DELAY
void launch_pprz_thd(int32_t(*thd)(void *arg))