#ifndef INC_CLOCK_SYNC_H_ #define INC_CLOCK_SYNC_H_ /** * @file Clock_Sync.h * @author Jasper v. Blanckenburg (j.blanckenburg@fasttube.de) * @brief Clock synchronization mechanism -- master side * @version 0.1 * @date 2022-08-01 * * @copyright Copyright (c) 2022 * * The slaves' clocks are fairly inaccurate -- too inaccurate for reliable CAN * communication. In order to synchronize the clock frequencies, the slaves need * an external clock source. Since the HSE doesn't work on all slaves, we use * the master as the external clock source. For more detail, take a look at the * clock sync section in the slave code. * * This file handles the master part of the clock sync mechanism: It sends * CLOCK_SYNC frames every 1000 ms and MASTER_HEARTBEAT frames every 100 ms. In * order to keep the time between packets accurate, they are sent from timer * interrupts. */ #include "stm32g4xx_hal.h" #include "stm32g4xx_hal_fdcan.h" #include "stm32g4xx_hal_tim.h" void clock_sync_init(FDCAN_HandleTypeDef* can, TIM_HandleTypeDef* sync_timer, TIM_HandleTypeDef* heartbeat_timer); void clock_sync_handle_timer_complete(TIM_HandleTypeDef* timer); #endif // INC_CLOCK_SYNC_H_