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.
Fork of mbed-dev by
api/rtc_time.h@129:8a86d1aafce0, 2016-05-16 (annotated)
- Committer:
- mbed_official
- Date:
- Mon May 16 12:00:12 2016 +0100
- Revision:
- 129:8a86d1aafce0
- Parent:
- 0:9b334a45a8ff
- Child:
- 144:ef7eb2e8f9f7
Synchronized with git revision 1d1f7ab1330d44cc5697c682173f7090a7d6b1cb
Full URL: https://github.com/mbedmicro/mbed/commit/1d1f7ab1330d44cc5697c682173f7090a7d6b1cb/
* [STM32F4] Get PCLK1 clock and set initial CAN frequency
CAN bus opperates on APB1 peripheral clock due to that we need to get PCLK1 freq
in *can_frequency()* function to properly calculate CAN speed and reconfigure
BS1, BS2, SJW bits.
Also to fully communicate with other ST platform we set the initical CAN
frequency to 100kb/s to be able to work with the slowest platform which supports
CAN, which is NUCLEO_F303K8 (APB1 is 32MHz).
Change-Id: I10af3aa8d715dd61c9d1b216ef813193449fecbd
* [STM32F4] Fix for CAN2 interrupt index
CAN2 interrupt index was wrong leading to not properly registering interrupt.
Having this fix allow us to pass MBED_30 test.
Change-Id: I33f9ca7c81286f7746a8f8352619e213bdf9756a
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bogdanm | 0:9b334a45a8ff | 1 | /* mbed Microcontroller Library |
| bogdanm | 0:9b334a45a8ff | 2 | * Copyright (c) 2006-2013 ARM Limited |
| bogdanm | 0:9b334a45a8ff | 3 | * |
| bogdanm | 0:9b334a45a8ff | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| bogdanm | 0:9b334a45a8ff | 5 | * you may not use this file except in compliance with the License. |
| bogdanm | 0:9b334a45a8ff | 6 | * You may obtain a copy of the License at |
| bogdanm | 0:9b334a45a8ff | 7 | * |
| bogdanm | 0:9b334a45a8ff | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| bogdanm | 0:9b334a45a8ff | 9 | * |
| bogdanm | 0:9b334a45a8ff | 10 | * Unless required by applicable law or agreed to in writing, software |
| bogdanm | 0:9b334a45a8ff | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| bogdanm | 0:9b334a45a8ff | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| bogdanm | 0:9b334a45a8ff | 13 | * See the License for the specific language governing permissions and |
| bogdanm | 0:9b334a45a8ff | 14 | * limitations under the License. |
| bogdanm | 0:9b334a45a8ff | 15 | */ |
| bogdanm | 0:9b334a45a8ff | 16 | |
| bogdanm | 0:9b334a45a8ff | 17 | #include <time.h> |
| bogdanm | 0:9b334a45a8ff | 18 | |
| bogdanm | 0:9b334a45a8ff | 19 | #ifdef __cplusplus |
| bogdanm | 0:9b334a45a8ff | 20 | extern "C" { |
| bogdanm | 0:9b334a45a8ff | 21 | #endif |
| bogdanm | 0:9b334a45a8ff | 22 | |
| bogdanm | 0:9b334a45a8ff | 23 | /** Implementation of the C time.h functions |
| bogdanm | 0:9b334a45a8ff | 24 | * |
| bogdanm | 0:9b334a45a8ff | 25 | * Provides mechanisms to set and read the current time, based |
| bogdanm | 0:9b334a45a8ff | 26 | * on the microcontroller Real-Time Clock (RTC), plus some |
| bogdanm | 0:9b334a45a8ff | 27 | * standard C manipulation and formating functions. |
| bogdanm | 0:9b334a45a8ff | 28 | * |
| bogdanm | 0:9b334a45a8ff | 29 | * Example: |
| bogdanm | 0:9b334a45a8ff | 30 | * @code |
| bogdanm | 0:9b334a45a8ff | 31 | * #include "mbed.h" |
| bogdanm | 0:9b334a45a8ff | 32 | * |
| bogdanm | 0:9b334a45a8ff | 33 | * int main() { |
| bogdanm | 0:9b334a45a8ff | 34 | * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 |
| bogdanm | 0:9b334a45a8ff | 35 | * |
| bogdanm | 0:9b334a45a8ff | 36 | * while(1) { |
| bogdanm | 0:9b334a45a8ff | 37 | * time_t seconds = time(NULL); |
| bogdanm | 0:9b334a45a8ff | 38 | * |
| bogdanm | 0:9b334a45a8ff | 39 | * printf("Time as seconds since January 1, 1970 = %d\n", seconds); |
| bogdanm | 0:9b334a45a8ff | 40 | * |
| bogdanm | 0:9b334a45a8ff | 41 | * printf("Time as a basic string = %s", ctime(&seconds)); |
| bogdanm | 0:9b334a45a8ff | 42 | * |
| bogdanm | 0:9b334a45a8ff | 43 | * char buffer[32]; |
| bogdanm | 0:9b334a45a8ff | 44 | * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); |
| bogdanm | 0:9b334a45a8ff | 45 | * printf("Time as a custom formatted string = %s", buffer); |
| bogdanm | 0:9b334a45a8ff | 46 | * |
| bogdanm | 0:9b334a45a8ff | 47 | * wait(1); |
| bogdanm | 0:9b334a45a8ff | 48 | * } |
| bogdanm | 0:9b334a45a8ff | 49 | * } |
| bogdanm | 0:9b334a45a8ff | 50 | * @endcode |
| bogdanm | 0:9b334a45a8ff | 51 | */ |
| bogdanm | 0:9b334a45a8ff | 52 | |
| bogdanm | 0:9b334a45a8ff | 53 | /** Set the current time |
| bogdanm | 0:9b334a45a8ff | 54 | * |
| bogdanm | 0:9b334a45a8ff | 55 | * Initialises and sets the time of the microcontroller Real-Time Clock (RTC) |
| bogdanm | 0:9b334a45a8ff | 56 | * to the time represented by the number of seconds since January 1, 1970 |
| bogdanm | 0:9b334a45a8ff | 57 | * (the UNIX timestamp). |
| bogdanm | 0:9b334a45a8ff | 58 | * |
| bogdanm | 0:9b334a45a8ff | 59 | * @param t Number of seconds since January 1, 1970 (the UNIX timestamp) |
| bogdanm | 0:9b334a45a8ff | 60 | * |
| bogdanm | 0:9b334a45a8ff | 61 | * Example: |
| bogdanm | 0:9b334a45a8ff | 62 | * @code |
| bogdanm | 0:9b334a45a8ff | 63 | * #include "mbed.h" |
| bogdanm | 0:9b334a45a8ff | 64 | * |
| bogdanm | 0:9b334a45a8ff | 65 | * int main() { |
| bogdanm | 0:9b334a45a8ff | 66 | * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37 |
| bogdanm | 0:9b334a45a8ff | 67 | * } |
| bogdanm | 0:9b334a45a8ff | 68 | * @endcode |
| bogdanm | 0:9b334a45a8ff | 69 | */ |
| bogdanm | 0:9b334a45a8ff | 70 | void set_time(time_t t); |
| bogdanm | 0:9b334a45a8ff | 71 | |
| bogdanm | 0:9b334a45a8ff | 72 | /** Attach an external RTC to be used for the C time functions |
| bogdanm | 0:9b334a45a8ff | 73 | * |
| bogdanm | 0:9b334a45a8ff | 74 | * Do not call this function from an interrupt while an RTC read/write operation may be occurring |
| bogdanm | 0:9b334a45a8ff | 75 | * |
| bogdanm | 0:9b334a45a8ff | 76 | * @param read_rtc pointer to function which returns current UNIX timestamp |
| bogdanm | 0:9b334a45a8ff | 77 | * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL |
| bogdanm | 0:9b334a45a8ff | 78 | * @param init_rtc pointer to funtion which initializes RTC, can be NULL |
| bogdanm | 0:9b334a45a8ff | 79 | * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL |
| bogdanm | 0:9b334a45a8ff | 80 | */ |
| bogdanm | 0:9b334a45a8ff | 81 | void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)); |
| bogdanm | 0:9b334a45a8ff | 82 | |
| bogdanm | 0:9b334a45a8ff | 83 | #ifdef __cplusplus |
| bogdanm | 0:9b334a45a8ff | 84 | } |
| bogdanm | 0:9b334a45a8ff | 85 | #endif |
