Ibiltari Nora / OSC
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OSCTiming.cpp Source File

OSCTiming.cpp

00001 /*
00002  Written by Adrian Freed, The Center for New Music and Audio Technologies,
00003  University of California, Berkeley.  Copyright (c) 2013, The Regents of
00004  the University of California (Regents).
00005  
00006  Permission to use, copy, modify, distribute, and distribute modified versions
00007  of this software and its documentation without fee and without a signed
00008  licensing agreement, is hereby granted, provided that the above copyright
00009  notice, this paragraph and the following two paragraphs appear in all copies,
00010  modifications, and distributions.
00011  
00012  IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
00013  SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
00014  OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
00015  BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00016  
00017  REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00018  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00019  PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
00020  HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
00021  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00022  
00023  For bug reports and feature requests please email me at yotam@cnmat.berkeley.edu
00024  */
00025 
00026 
00027 #include "OSCTiming.h"
00028 #include "mbed.h"
00029 
00030 
00031 
00032 extern volatile uint32_t timer0_millis_count;
00033 static uint32_t savedcount, savedmicros;
00034 
00035 /*
00036 static void latchOscTime()
00037 {
00038   //  noInterrupts();
00039     savedcount = timer0_millis_count;
00040  //   savedmicros = micros();
00041 //    interrupts();
00042 }   */
00043 
00044 static osctime_t computeOscTime()
00045 { //4,294,967,296
00046 
00047     osctime_t t;
00048 
00049     time_t seconds = time(NULL); // TODO: Increase precision, only seconds for now
00050 
00051     t.seconds = (unsigned int)seconds;
00052     return t;
00053     
00054     ;
00055 
00056     
00057 }
00058 
00059     
00060 
00061 osctime_t oscTime()
00062 {
00063  //   latchOscTime();
00064     return computeOscTime();
00065 
00066 }
00067 
00068 
00069 
00070 
00071 
00072