Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lypinator 0:bb348c97df44 1 /* mbed Microcontroller Library
lypinator 0:bb348c97df44 2 * Copyright (c) 2015 ARM Limited
lypinator 0:bb348c97df44 3 *
lypinator 0:bb348c97df44 4 * Licensed under the Apache License, Version 2.0 (the "License");
lypinator 0:bb348c97df44 5 * you may not use this file except in compliance with the License.
lypinator 0:bb348c97df44 6 * You may obtain a copy of the License at
lypinator 0:bb348c97df44 7 *
lypinator 0:bb348c97df44 8 * http://www.apache.org/licenses/LICENSE-2.0
lypinator 0:bb348c97df44 9 *
lypinator 0:bb348c97df44 10 * Unless required by applicable law or agreed to in writing, software
lypinator 0:bb348c97df44 11 * distributed under the License is distributed on an "AS IS" BASIS,
lypinator 0:bb348c97df44 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
lypinator 0:bb348c97df44 13 * See the License for the specific language governing permissions and
lypinator 0:bb348c97df44 14 * limitations under the License.
lypinator 0:bb348c97df44 15 */
lypinator 0:bb348c97df44 16 #include "hal/lp_ticker_api.h"
lypinator 0:bb348c97df44 17
lypinator 0:bb348c97df44 18 #if DEVICE_LPTICKER
lypinator 0:bb348c97df44 19
lypinator 0:bb348c97df44 20 void lp_ticker_set_interrupt_wrapper(timestamp_t timestamp);
lypinator 0:bb348c97df44 21
lypinator 0:bb348c97df44 22 static ticker_event_queue_t events = { 0 };
lypinator 0:bb348c97df44 23
lypinator 0:bb348c97df44 24 static ticker_irq_handler_type irq_handler = ticker_irq_handler;
lypinator 0:bb348c97df44 25
lypinator 0:bb348c97df44 26 static const ticker_interface_t lp_interface = {
lypinator 0:bb348c97df44 27 .init = lp_ticker_init,
lypinator 0:bb348c97df44 28 .read = lp_ticker_read,
lypinator 0:bb348c97df44 29 .disable_interrupt = lp_ticker_disable_interrupt,
lypinator 0:bb348c97df44 30 .clear_interrupt = lp_ticker_clear_interrupt,
lypinator 0:bb348c97df44 31 #if LPTICKER_DELAY_TICKS > 0
lypinator 0:bb348c97df44 32 .set_interrupt = lp_ticker_set_interrupt_wrapper,
lypinator 0:bb348c97df44 33 #else
lypinator 0:bb348c97df44 34 .set_interrupt = lp_ticker_set_interrupt,
lypinator 0:bb348c97df44 35 #endif
lypinator 0:bb348c97df44 36 .fire_interrupt = lp_ticker_fire_interrupt,
lypinator 0:bb348c97df44 37 .get_info = lp_ticker_get_info,
lypinator 0:bb348c97df44 38 };
lypinator 0:bb348c97df44 39
lypinator 0:bb348c97df44 40 static const ticker_data_t lp_data = {
lypinator 0:bb348c97df44 41 .interface = &lp_interface,
lypinator 0:bb348c97df44 42 .queue = &events,
lypinator 0:bb348c97df44 43 };
lypinator 0:bb348c97df44 44
lypinator 0:bb348c97df44 45 const ticker_data_t *get_lp_ticker_data(void)
lypinator 0:bb348c97df44 46 {
lypinator 0:bb348c97df44 47 return &lp_data;
lypinator 0:bb348c97df44 48 }
lypinator 0:bb348c97df44 49
lypinator 0:bb348c97df44 50 ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler)
lypinator 0:bb348c97df44 51 {
lypinator 0:bb348c97df44 52 ticker_irq_handler_type prev_irq_handler = irq_handler;
lypinator 0:bb348c97df44 53
lypinator 0:bb348c97df44 54 irq_handler = ticker_irq_handler;
lypinator 0:bb348c97df44 55
lypinator 0:bb348c97df44 56 return prev_irq_handler;
lypinator 0:bb348c97df44 57 }
lypinator 0:bb348c97df44 58
lypinator 0:bb348c97df44 59 void lp_ticker_irq_handler(void)
lypinator 0:bb348c97df44 60 {
lypinator 0:bb348c97df44 61 if (irq_handler) {
lypinator 0:bb348c97df44 62 irq_handler(&lp_data);
lypinator 0:bb348c97df44 63 }
lypinator 0:bb348c97df44 64 }
lypinator 0:bb348c97df44 65
lypinator 0:bb348c97df44 66 #endif