Andrew Boyson
/
iot
Backing up an unused program in case of future need
time.cpp@2:06fa34661f19, 2016-04-22 (annotated)
- Committer:
- andrewboyson
- Date:
- Fri Apr 22 09:23:57 2016 +0000
- Revision:
- 2:06fa34661f19
- Parent:
- 0:09f915e6f9f6
- Child:
- 6:be97d38e0b01
Added configuration file.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 0:09f915e6f9f6 | 1 | #include "mbed.h" |
andrewboyson | 0:09f915e6f9f6 | 2 | #define ONE_MILLION 1000000 |
andrewboyson | 0:09f915e6f9f6 | 3 | |
andrewboyson | 0:09f915e6f9f6 | 4 | Ticker ticker; |
andrewboyson | 0:09f915e6f9f6 | 5 | uint64_t unixTime16ths; |
andrewboyson | 0:09f915e6f9f6 | 6 | static void tick(void) |
andrewboyson | 0:09f915e6f9f6 | 7 | { |
andrewboyson | 0:09f915e6f9f6 | 8 | unixTime16ths++; |
andrewboyson | 0:09f915e6f9f6 | 9 | } |
andrewboyson | 2:06fa34661f19 | 10 | int TimeInit() |
andrewboyson | 0:09f915e6f9f6 | 11 | { |
andrewboyson | 0:09f915e6f9f6 | 12 | ticker.attach_us(&tick, ONE_MILLION >> 4); |
andrewboyson | 2:06fa34661f19 | 13 | return 0; |
andrewboyson | 0:09f915e6f9f6 | 14 | } |
andrewboyson | 0:09f915e6f9f6 | 15 | void TimeSet(uint32_t t) |
andrewboyson | 0:09f915e6f9f6 | 16 | { |
andrewboyson | 0:09f915e6f9f6 | 17 | unixTime16ths = (uint64_t)t << 4; |
andrewboyson | 0:09f915e6f9f6 | 18 | } |
andrewboyson | 0:09f915e6f9f6 | 19 | uint32_t TimeGet() |
andrewboyson | 0:09f915e6f9f6 | 20 | { |
andrewboyson | 0:09f915e6f9f6 | 21 | return unixTime16ths >> 4; |
andrewboyson | 0:09f915e6f9f6 | 22 | } |
andrewboyson | 0:09f915e6f9f6 | 23 | void TimeSet16ths(uint64_t t) |
andrewboyson | 0:09f915e6f9f6 | 24 | { |
andrewboyson | 0:09f915e6f9f6 | 25 | unixTime16ths = t; |
andrewboyson | 0:09f915e6f9f6 | 26 | } |
andrewboyson | 0:09f915e6f9f6 | 27 | uint64_t TimeGet16ths() |
andrewboyson | 0:09f915e6f9f6 | 28 | { |
andrewboyson | 0:09f915e6f9f6 | 29 | return unixTime16ths; |
andrewboyson | 0:09f915e6f9f6 | 30 | } |