Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
simon.ford@mbed.co.uk
Date:
Thu Jan 22 18:32:40 2009 +0000
Revision:
5:62573be585e9
Child:
10:fcb9359f0959
* Added initial RPC release
* Added RTC and helper functions
* Added read_u16()/write_u16() to AnalogIn/Out
* Ticker/Timeout timing fixed!
* mbedinfo() helper added
* error() and printf() added to replace DEBUG() and ERROR()
* DigitalIn supports methods on rise/fall
* SPI and Serial support NC
* LED1-4 also map to 1-4
* Timer object reset fixed
* SPI uses single mode
* SPI3 added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon.ford@mbed.co.uk 5:62573be585e9 1 /* mbed Microcontroller Library - rtc
simon.ford@mbed.co.uk 5:62573be585e9 2 * Copyright (c) 2008, sford
simon.ford@mbed.co.uk 5:62573be585e9 3 */
simon.ford@mbed.co.uk 5:62573be585e9 4
simon.ford@mbed.co.uk 5:62573be585e9 5 #ifndef MBED_RTC_TIME_H
simon.ford@mbed.co.uk 5:62573be585e9 6 #define MBED_RTC_TIME_H
simon.ford@mbed.co.uk 5:62573be585e9 7
simon.ford@mbed.co.uk 5:62573be585e9 8 #include <time.h>
simon.ford@mbed.co.uk 5:62573be585e9 9
simon.ford@mbed.co.uk 5:62573be585e9 10 #ifdef __ARMCC_VERSION
simon.ford@mbed.co.uk 5:62573be585e9 11
simon.ford@mbed.co.uk 5:62573be585e9 12 typedef unsigned long clockid_t;
simon.ford@mbed.co.uk 5:62573be585e9 13 struct timespec {
simon.ford@mbed.co.uk 5:62573be585e9 14 time_t tv_sec;
simon.ford@mbed.co.uk 5:62573be585e9 15 long tv_nsec;
simon.ford@mbed.co.uk 5:62573be585e9 16 };
simon.ford@mbed.co.uk 5:62573be585e9 17 #define CLOCK_REALTIME (clockid_t)1
simon.ford@mbed.co.uk 5:62573be585e9 18
simon.ford@mbed.co.uk 5:62573be585e9 19 #endif
simon.ford@mbed.co.uk 5:62573be585e9 20
simon.ford@mbed.co.uk 5:62573be585e9 21 /* Section: rtc
simon.ford@mbed.co.uk 5:62573be585e9 22 * Functions for manipulating the RTC (real-time clock).
simon.ford@mbed.co.uk 5:62573be585e9 23 */
simon.ford@mbed.co.uk 5:62573be585e9 24
simon.ford@mbed.co.uk 5:62573be585e9 25 extern "C" {
simon.ford@mbed.co.uk 5:62573be585e9 26
simon.ford@mbed.co.uk 5:62573be585e9 27 /* Function: time
simon.ford@mbed.co.uk 5:62573be585e9 28 * Returns the number of seconds since the epoch (00:00:00 UTC,
simon.ford@mbed.co.uk 5:62573be585e9 29 * January 1, 1970), and also stores the return value in the address
simon.ford@mbed.co.uk 5:62573be585e9 30 * pointed to by timer if it is non-NULL.
simon.ford@mbed.co.uk 5:62573be585e9 31 */
simon.ford@mbed.co.uk 5:62573be585e9 32 time_t time(time_t *timer);
simon.ford@mbed.co.uk 5:62573be585e9 33
simon.ford@mbed.co.uk 5:62573be585e9 34 /* Function: time_str
simon.ford@mbed.co.uk 5:62573be585e9 35 * Returns a pointer to a string representing the current time
simon.ford@mbed.co.uk 5:62573be585e9 36 * in human readable form, as generated by ctime()
simon.ford@mbed.co.uk 5:62573be585e9 37 */
simon.ford@mbed.co.uk 5:62573be585e9 38 char *time_str();
simon.ford@mbed.co.uk 5:62573be585e9 39
simon.ford@mbed.co.uk 5:62573be585e9 40 /* Function: stime
simon.ford@mbed.co.uk 5:62573be585e9 41 * Sets the current time, measured in seconds since the epoch, using
simon.ford@mbed.co.uk 5:62573be585e9 42 * the value pointed to by timer.
simon.ford@mbed.co.uk 5:62573be585e9 43 */
simon.ford@mbed.co.uk 5:62573be585e9 44 void stime(const time_t *timer);
simon.ford@mbed.co.uk 5:62573be585e9 45
simon.ford@mbed.co.uk 5:62573be585e9 46 /* Function: set_time
simon.ford@mbed.co.uk 5:62573be585e9 47 * Sets the current time, specifying year through to day
simon.ford@mbed.co.uk 5:62573be585e9 48 */
simon.ford@mbed.co.uk 5:62573be585e9 49 void set_time(int year, int month, int day, int hour, int minute, int second);
simon.ford@mbed.co.uk 5:62573be585e9 50
simon.ford@mbed.co.uk 5:62573be585e9 51 /* Function: clock_settime
simon.ford@mbed.co.uk 5:62573be585e9 52 * Sets the time of the clock specified by clock_id, which must be
simon.ford@mbed.co.uk 5:62573be585e9 53 * CLOCK_REALTIME, according to the value of *tp.
simon.ford@mbed.co.uk 5:62573be585e9 54 */
simon.ford@mbed.co.uk 5:62573be585e9 55 int clock_settime(clockid_t clock_id, const struct timespec *tp);
simon.ford@mbed.co.uk 5:62573be585e9 56
simon.ford@mbed.co.uk 5:62573be585e9 57 /* Function: clock_gettime
simon.ford@mbed.co.uk 5:62573be585e9 58 * Sets *tp to be the current time of the clock specified by
simon.ford@mbed.co.uk 5:62573be585e9 59 * clock_id, which must be CLOCK_REALTIME.
simon.ford@mbed.co.uk 5:62573be585e9 60 */
simon.ford@mbed.co.uk 5:62573be585e9 61 int clock_gettime(clockid_t clock_id, struct timespec *tp);
simon.ford@mbed.co.uk 5:62573be585e9 62
simon.ford@mbed.co.uk 5:62573be585e9 63 /* Function: clock_getres
simon.ford@mbed.co.uk 5:62573be585e9 64 * Sets *tp to be the resolution of the clock specified by clock_id,
simon.ford@mbed.co.uk 5:62573be585e9 65 * which must be CLOCK_REALTIME.
simon.ford@mbed.co.uk 5:62573be585e9 66 */
simon.ford@mbed.co.uk 5:62573be585e9 67 int clock_getres(clockid_t clock_id, struct timespec *tp);
simon.ford@mbed.co.uk 5:62573be585e9 68
simon.ford@mbed.co.uk 5:62573be585e9 69 /* Function: create_time
simon.ford@mbed.co.uk 5:62573be585e9 70 * A convenience function for constructing a time_t value.
simon.ford@mbed.co.uk 5:62573be585e9 71 */
simon.ford@mbed.co.uk 5:62573be585e9 72 time_t create_time(int year, int month, int day, int hour, int minute, int second);
simon.ford@mbed.co.uk 5:62573be585e9 73
simon.ford@mbed.co.uk 5:62573be585e9 74 }
simon.ford@mbed.co.uk 5:62573be585e9 75
simon.ford@mbed.co.uk 5:62573be585e9 76 #endif
simon.ford@mbed.co.uk 5:62573be585e9 77