00001 /* wall clock */ 00002 /* Copyright (C) 2010 Holger Dietze 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) version 3. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with this program; if not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CLOCK_H 00019 #define CLOCK_H 00020 00021 #ifdef HAVE_STDINT_H 00022 #include <stdint.h> 00023 #endif 00024 00033 typedef struct clock_status_s { 00034 uint8_t is_set:1; 00035 uint8_t valid_time:1; 00036 uint8_t valid_date:1; 00037 uint8_t valid_century:1; 00038 } clock_status_t; 00039 00041 typedef struct clock_time_s { 00042 uint16_t year; 00043 uint8_t month; 00044 uint8_t day; 00045 uint8_t hour; 00046 uint8_t min; 00047 uint8_t sec; 00048 } clock_time_t; 00049 00052 typedef enum { 00053 CLOCKADJ_NONE, 00054 CLOCKADJ_GPS_MOD, 00055 CLOCKADJ_GPS_EXT, 00056 CLOCKADJ_USER, 00057 } clock_adj_source_t; 00058 00067 clock_status_t clock_get_time (clock_time_t * time); 00068 00085 void clock_adjust (uint16_t ticks, uint8_t t2_val, clock_adj_source_t src, 00086 const clock_time_t * time); 00087 00088 #endif