Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MSF_Time.h
00001 /*This library will decode an MSF signal on a digital input pin and turn it 00002 into a timestamp. 00003 Copyright (C) 2017 Duncan Wood 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 00021 00022 #include "mbed.h" 00023 class MSF_Time 00024 { 00025 public: 00026 /* Start MSF_Time with this function 00027 InputPin is the data coming from your reciever 00028 Polarity is 0 if your receiver output is high for no carrier 00029 polarity is 1 to invert this logic. */ 00030 00031 00032 MSF_Time(PinName InputPin, int polarity,int OffsetTuning =48000); 00033 00034 bool Valid(); // Is the time valid 00035 time_t Read(); 00036 00037 protected: 00038 struct MSF_Data { 00039 int BCDYear; 00040 int BCDMonth; 00041 int DayOfWeek; 00042 int BCDTime; 00043 int SyncByte; //This is sent and allows you to detect leap seconds 00044 int DUT; 00045 int BST; 00046 }; 00047 00048 struct MSF_Data MyData; 00049 struct tm Received_Time; // Normal data coming in 00050 time_t Received_timestamp; //Data converted to timestamp 00051 unsigned int Time_Data_Duration; //Pulse length - The minute marker is 500ms 00052 bool Time_Data_Sync; // True when a 500ms pulse is detected denoting the start of a minute 00053 Ticker Time_Data_Ticker; // A 50ms clock used to clock in data 00054 unsigned int Time_Data_Count;// counts the 50ms for clocking in the data 00055 void Time_Data_Strobe(); // When the ticker ticks do this 00056 void Falling(); 00057 void Rising(); 00058 bool DataValid; 00059 Timeout offset; // used to fine tune the seconds 50ms equals zero offset 00060 InterruptIn Time_Data; 00061 DigitalIn MyInput; 00062 int Polarity; 00063 int OffsetTuning; 00064 Timer Time_Data_timer; 00065 void LogicOne(); 00066 void LogicZero(); 00067 int ParityCheck(unsigned int CheckMe); 00068 void ProcessData(); 00069 void IncrementSeconds(); 00070 void IncrementSecondsNow(); 00071 //int const OffsetTuning=48000; //in microseconds 00072 bool debug; //turn on off debugging noise 00073 bool DV; 00074 00075 };
Generated on Wed Jul 20 2022 04:44:34 by
1.7.2