clockInterface.c (1633B)
1 /** 2 * @file clockInterface.c 3 * @author Adrian STEINER (steia19@bfh.ch) 4 * @brief Clock interface class to get and set the current time from the device 5 * time. 6 * @version 0.1 7 * @date 17-02-2025 8 * 9 * @copyright (C) 2025 Adrian STEINER 10 * This program is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation, either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <https: //www.gnu.org/licenses/>. 22 * 23 */ 24 25 #include "clockInterface.h" 26 #include <stdlib.h> 27 28 uint8_t clock_initInterface(clockInterface *interfaceHandler, 29 clockPwrCB powerOnCB, 30 clockPwrCB powerOffCB, 31 clockGetTimeCB getUnixTimeCB, 32 clockSetTimeCB setUnixTimeCB) 33 { 34 if (NULL == interfaceHandler || NULL == powerOnCB || NULL == powerOffCB || 35 NULL == getUnixTimeCB || NULL == setUnixTimeCB) { 36 return EXIT_FAILURE; 37 } 38 interfaceHandler->powerOn = powerOnCB; 39 interfaceHandler->powerOff = powerOffCB; 40 interfaceHandler->getUnixTime = getUnixTimeCB; 41 interfaceHandler->setUnixTime = setUnixTimeCB; 42 interfaceHandler->lastUpdateTime = 0; 43 return EXIT_SUCCESS; 44 }