added prescaler for 16 bit pwm in LPC1347 target
Fork of mbed-dev by
targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/api/rtc_api.c@121:7f86b4238bec, 2016-05-03 (annotated)
- Committer:
- mbed_official
- Date:
- Tue May 03 00:15:16 2016 +0100
- Revision:
- 121:7f86b4238bec
Synchronized with git revision 9cef243de23875778f461bbe9a8c1bc47e65212b
Full URL: https://github.com/mbedmicro/mbed/commit/9cef243de23875778f461bbe9a8c1bc47e65212b/
Switch to KSDK 2.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 121:7f86b4238bec | 1 | /* mbed Microcontroller Library |
mbed_official | 121:7f86b4238bec | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 121:7f86b4238bec | 3 | * |
mbed_official | 121:7f86b4238bec | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 121:7f86b4238bec | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 121:7f86b4238bec | 6 | * You may obtain a copy of the License at |
mbed_official | 121:7f86b4238bec | 7 | * |
mbed_official | 121:7f86b4238bec | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 121:7f86b4238bec | 9 | * |
mbed_official | 121:7f86b4238bec | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 121:7f86b4238bec | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 121:7f86b4238bec | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 121:7f86b4238bec | 13 | * See the License for the specific language governing permissions and |
mbed_official | 121:7f86b4238bec | 14 | * limitations under the License. |
mbed_official | 121:7f86b4238bec | 15 | */ |
mbed_official | 121:7f86b4238bec | 16 | #include "rtc_api.h" |
mbed_official | 121:7f86b4238bec | 17 | |
mbed_official | 121:7f86b4238bec | 18 | #if DEVICE_RTC |
mbed_official | 121:7f86b4238bec | 19 | |
mbed_official | 121:7f86b4238bec | 20 | #include "pinmap.h" |
mbed_official | 121:7f86b4238bec | 21 | #include "fsl_rtc.h" |
mbed_official | 121:7f86b4238bec | 22 | #include "PeripheralPins.h" |
mbed_official | 121:7f86b4238bec | 23 | |
mbed_official | 121:7f86b4238bec | 24 | extern void rtc_setup_oscillator(RTC_Type *base); |
mbed_official | 121:7f86b4238bec | 25 | |
mbed_official | 121:7f86b4238bec | 26 | void rtc_init(void) { |
mbed_official | 121:7f86b4238bec | 27 | rtc_config_t rtcConfig; |
mbed_official | 121:7f86b4238bec | 28 | |
mbed_official | 121:7f86b4238bec | 29 | RTC_GetDefaultConfig(&rtcConfig); |
mbed_official | 121:7f86b4238bec | 30 | RTC_Init(RTC, &rtcConfig); |
mbed_official | 121:7f86b4238bec | 31 | |
mbed_official | 121:7f86b4238bec | 32 | /* Setup the RTC 32KHz oscillator */ |
mbed_official | 121:7f86b4238bec | 33 | rtc_setup_oscillator(RTC); |
mbed_official | 121:7f86b4238bec | 34 | RTC_StartTimer(RTC); |
mbed_official | 121:7f86b4238bec | 35 | } |
mbed_official | 121:7f86b4238bec | 36 | |
mbed_official | 121:7f86b4238bec | 37 | void rtc_free(void) { |
mbed_official | 121:7f86b4238bec | 38 | RTC_Deinit(RTC); |
mbed_official | 121:7f86b4238bec | 39 | } |
mbed_official | 121:7f86b4238bec | 40 | |
mbed_official | 121:7f86b4238bec | 41 | /* |
mbed_official | 121:7f86b4238bec | 42 | * Little check routine to see if the RTC has been enabled |
mbed_official | 121:7f86b4238bec | 43 | * 0 = Disabled, 1 = Enabled |
mbed_official | 121:7f86b4238bec | 44 | */ |
mbed_official | 121:7f86b4238bec | 45 | int rtc_isenabled(void) { |
mbed_official | 121:7f86b4238bec | 46 | CLOCK_EnableClock(kCLOCK_Rtc0); |
mbed_official | 121:7f86b4238bec | 47 | return (int)((RTC->SR & RTC_SR_TCE_MASK) >> RTC_SR_TCE_SHIFT); |
mbed_official | 121:7f86b4238bec | 48 | } |
mbed_official | 121:7f86b4238bec | 49 | |
mbed_official | 121:7f86b4238bec | 50 | time_t rtc_read(void) { |
mbed_official | 121:7f86b4238bec | 51 | return (time_t)RTC->TSR; |
mbed_official | 121:7f86b4238bec | 52 | } |
mbed_official | 121:7f86b4238bec | 53 | |
mbed_official | 121:7f86b4238bec | 54 | void rtc_write(time_t t) { |
mbed_official | 121:7f86b4238bec | 55 | if (t == 0) { |
mbed_official | 121:7f86b4238bec | 56 | t = 1; |
mbed_official | 121:7f86b4238bec | 57 | } |
mbed_official | 121:7f86b4238bec | 58 | RTC_StopTimer(RTC); |
mbed_official | 121:7f86b4238bec | 59 | RTC->TSR = t; |
mbed_official | 121:7f86b4238bec | 60 | RTC_StartTimer(RTC); |
mbed_official | 121:7f86b4238bec | 61 | } |
mbed_official | 121:7f86b4238bec | 62 | |
mbed_official | 121:7f86b4238bec | 63 | #endif |