mbed library sources, include can_api for nucleo-f091rc
Dependents: CanNucleoF0_example
Fork of mbed-src by
targets/hal/TARGET_WIZNET/TARGET_W7500x/rtc_api.c@645:13c87cbecd54, 2016-01-07 (annotated)
- Committer:
- ptpaterson
- Date:
- Thu Jan 07 05:49:05 2016 +0000
- Revision:
- 645:13c87cbecd54
- Parent:
- 619:034e698bc035
corrected freeze on CAN_RECEIVE_IT
Who changed what in which revision?
User | Revision | Line number | New 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 | } |