mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Sep 04 09:30:10 2015 +0100
Revision:
619:034e698bc035
Parent:
585:a1ed5b41f74f
Synchronized with git revision 92d1bfad30082571776c810a56fd471d30514ccf

Full URL: https://github.com/mbedmicro/mbed/commit/92d1bfad30082571776c810a56fd471d30514ccf/

Change directory structure and move files.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 585:a1ed5b41f74f 1 /* mbed Microcontroller Library
mbed_official 585:a1ed5b41f74f 2 * Copyright (c) 2006-2013 ARM Limited
mbed_official 585:a1ed5b41f74f 3 *
mbed_official 585:a1ed5b41f74f 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 585:a1ed5b41f74f 5 * you may not use this file except in compliance with the License.
mbed_official 585:a1ed5b41f74f 6 * You may obtain a copy of the License at
mbed_official 585:a1ed5b41f74f 7 *
mbed_official 585:a1ed5b41f74f 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 585:a1ed5b41f74f 9 *
mbed_official 585:a1ed5b41f74f 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 585:a1ed5b41f74f 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 585:a1ed5b41f74f 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 585:a1ed5b41f74f 13 * See the License for the specific language governing permissions and
mbed_official 585:a1ed5b41f74f 14 * limitations under the License.
mbed_official 585:a1ed5b41f74f 15 */
mbed_official 585:a1ed5b41f74f 16 #include "rtc_api.h"
mbed_official 619:034e698bc035 17 #include "cmsis.h"
mbed_official 619:034e698bc035 18 #include "W7500x_pwm.h"
mbed_official 585:a1ed5b41f74f 19
mbed_official 585:a1ed5b41f74f 20 time_t wiz_rtc_time;
mbed_official 585:a1ed5b41f74f 21 char rtc_enabled = 0;
mbed_official 585:a1ed5b41f74f 22
mbed_official 585:a1ed5b41f74f 23 #ifdef __cplusplus
mbed_official 585:a1ed5b41f74f 24 extern "C"{
mbed_official 585:a1ed5b41f74f 25 #endif
mbed_official 585:a1ed5b41f74f 26 void PWM3_Handler(void)
mbed_official 585:a1ed5b41f74f 27 {
mbed_official 585:a1ed5b41f74f 28
mbed_official 585:a1ed5b41f74f 29 wiz_rtc_time++;
mbed_official 585:a1ed5b41f74f 30 PWM_CH3_ClearOverflowInt();
mbed_official 585:a1ed5b41f74f 31
mbed_official 585:a1ed5b41f74f 32 }
mbed_official 585:a1ed5b41f74f 33 #ifdef __cplusplus
mbed_official 585:a1ed5b41f74f 34 }
mbed_official 585:a1ed5b41f74f 35 #endif
mbed_official 585:a1ed5b41f74f 36
mbed_official 585:a1ed5b41f74f 37
mbed_official 585:a1ed5b41f74f 38
mbed_official 585:a1ed5b41f74f 39 void rtc_init(void) {
mbed_official 585:a1ed5b41f74f 40 PWM_TimerModeInitTypeDef TimerModeStructure;
mbed_official 585:a1ed5b41f74f 41 *(volatile uint32_t *)(0x410010e0) = 0x03;
mbed_official 585:a1ed5b41f74f 42
mbed_official 585:a1ed5b41f74f 43 /* Timer mode configuration */
mbed_official 585:a1ed5b41f74f 44 TimerModeStructure.PWM_CHn_PR = 7;
mbed_official 585:a1ed5b41f74f 45 TimerModeStructure.PWM_CHn_MR = 1;
mbed_official 585:a1ed5b41f74f 46 TimerModeStructure.PWM_CHn_LR = 0xF4240;
mbed_official 585:a1ed5b41f74f 47 TimerModeStructure.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
mbed_official 585:a1ed5b41f74f 48 TimerModeStructure.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
mbed_official 585:a1ed5b41f74f 49
mbed_official 585:a1ed5b41f74f 50 PWM_TimerModeInit(PWM_CH3, &TimerModeStructure);
mbed_official 585:a1ed5b41f74f 51
mbed_official 585:a1ed5b41f74f 52 /* PWM interrupt configuration */
mbed_official 585:a1ed5b41f74f 53 PWM_IntConfig(PWM_CH3, ENABLE);
mbed_official 585:a1ed5b41f74f 54 PWM_CHn_IntConfig(PWM_CH3, PWM_CHn_IER_OIE, ENABLE);
mbed_official 585:a1ed5b41f74f 55
mbed_official 585:a1ed5b41f74f 56 /* PWM channel 0 start */
mbed_official 585:a1ed5b41f74f 57 PWM_CHn_Start(PWM_CH3);
mbed_official 585:a1ed5b41f74f 58 NVIC_SetVector(PWM3_IRQn, (uint32_t)PWM3_Handler);
mbed_official 585:a1ed5b41f74f 59 NVIC_EnableIRQ(PWM3_IRQn);
mbed_official 585:a1ed5b41f74f 60 rtc_enabled = 1;
mbed_official 585:a1ed5b41f74f 61 }
mbed_official 585:a1ed5b41f74f 62
mbed_official 585:a1ed5b41f74f 63 void rtc_free(void) {
mbed_official 585:a1ed5b41f74f 64 // [TODO]
mbed_official 585:a1ed5b41f74f 65 }
mbed_official 585:a1ed5b41f74f 66
mbed_official 585:a1ed5b41f74f 67
mbed_official 585:a1ed5b41f74f 68 int rtc_isenabled(void) {
mbed_official 585:a1ed5b41f74f 69 return rtc_enabled;
mbed_official 585:a1ed5b41f74f 70 }
mbed_official 585:a1ed5b41f74f 71
mbed_official 585:a1ed5b41f74f 72
mbed_official 585:a1ed5b41f74f 73 time_t rtc_read(void) {
mbed_official 585:a1ed5b41f74f 74 return wiz_rtc_time;
mbed_official 585:a1ed5b41f74f 75 }
mbed_official 585:a1ed5b41f74f 76
mbed_official 585:a1ed5b41f74f 77 void rtc_write(time_t t) {
mbed_official 585:a1ed5b41f74f 78 //*(volatile uint32_t *)(0x41001008) = 0x42; // timer disable, interrupt disable
mbed_official 585:a1ed5b41f74f 79 wiz_rtc_time = t;
mbed_official 585:a1ed5b41f74f 80 //*(volatile uint32_t *)(0x41001008) = 0x72; // timer enable interrupt enable
mbed_official 585:a1ed5b41f74f 81 }