mbed-os
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
hal/mbed_us_ticker_api.c@0:b74591d5ab33, 2017-12-11 (annotated)
- Committer:
- be_bryan
- Date:
- Mon Dec 11 17:54:04 2017 +0000
- Revision:
- 0:b74591d5ab33
motor ++
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
be_bryan | 0:b74591d5ab33 | 1 | /* mbed Microcontroller Library |
be_bryan | 0:b74591d5ab33 | 2 | * Copyright (c) 2015 ARM Limited |
be_bryan | 0:b74591d5ab33 | 3 | * |
be_bryan | 0:b74591d5ab33 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
be_bryan | 0:b74591d5ab33 | 5 | * you may not use this file except in compliance with the License. |
be_bryan | 0:b74591d5ab33 | 6 | * You may obtain a copy of the License at |
be_bryan | 0:b74591d5ab33 | 7 | * |
be_bryan | 0:b74591d5ab33 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
be_bryan | 0:b74591d5ab33 | 9 | * |
be_bryan | 0:b74591d5ab33 | 10 | * Unless required by applicable law or agreed to in writing, software |
be_bryan | 0:b74591d5ab33 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
be_bryan | 0:b74591d5ab33 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
be_bryan | 0:b74591d5ab33 | 13 | * See the License for the specific language governing permissions and |
be_bryan | 0:b74591d5ab33 | 14 | * limitations under the License. |
be_bryan | 0:b74591d5ab33 | 15 | */ |
be_bryan | 0:b74591d5ab33 | 16 | #include "hal/us_ticker_api.h" |
be_bryan | 0:b74591d5ab33 | 17 | |
be_bryan | 0:b74591d5ab33 | 18 | static ticker_event_queue_t events = { 0 }; |
be_bryan | 0:b74591d5ab33 | 19 | |
be_bryan | 0:b74591d5ab33 | 20 | static ticker_irq_handler_type irq_handler = ticker_irq_handler; |
be_bryan | 0:b74591d5ab33 | 21 | |
be_bryan | 0:b74591d5ab33 | 22 | static const ticker_interface_t us_interface = { |
be_bryan | 0:b74591d5ab33 | 23 | .init = us_ticker_init, |
be_bryan | 0:b74591d5ab33 | 24 | .read = us_ticker_read, |
be_bryan | 0:b74591d5ab33 | 25 | .disable_interrupt = us_ticker_disable_interrupt, |
be_bryan | 0:b74591d5ab33 | 26 | .clear_interrupt = us_ticker_clear_interrupt, |
be_bryan | 0:b74591d5ab33 | 27 | .set_interrupt = us_ticker_set_interrupt, |
be_bryan | 0:b74591d5ab33 | 28 | .fire_interrupt = us_ticker_fire_interrupt, |
be_bryan | 0:b74591d5ab33 | 29 | .get_info = us_ticker_get_info, |
be_bryan | 0:b74591d5ab33 | 30 | }; |
be_bryan | 0:b74591d5ab33 | 31 | |
be_bryan | 0:b74591d5ab33 | 32 | static const ticker_data_t us_data = { |
be_bryan | 0:b74591d5ab33 | 33 | .interface = &us_interface, |
be_bryan | 0:b74591d5ab33 | 34 | .queue = &events |
be_bryan | 0:b74591d5ab33 | 35 | }; |
be_bryan | 0:b74591d5ab33 | 36 | |
be_bryan | 0:b74591d5ab33 | 37 | const ticker_data_t* get_us_ticker_data(void) |
be_bryan | 0:b74591d5ab33 | 38 | { |
be_bryan | 0:b74591d5ab33 | 39 | return &us_data; |
be_bryan | 0:b74591d5ab33 | 40 | } |
be_bryan | 0:b74591d5ab33 | 41 | |
be_bryan | 0:b74591d5ab33 | 42 | ticker_irq_handler_type set_us_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler) |
be_bryan | 0:b74591d5ab33 | 43 | { |
be_bryan | 0:b74591d5ab33 | 44 | ticker_irq_handler_type prev_irq_handler = irq_handler; |
be_bryan | 0:b74591d5ab33 | 45 | |
be_bryan | 0:b74591d5ab33 | 46 | irq_handler = ticker_irq_handler; |
be_bryan | 0:b74591d5ab33 | 47 | |
be_bryan | 0:b74591d5ab33 | 48 | return prev_irq_handler; |
be_bryan | 0:b74591d5ab33 | 49 | } |
be_bryan | 0:b74591d5ab33 | 50 | |
be_bryan | 0:b74591d5ab33 | 51 | void us_ticker_irq_handler(void) |
be_bryan | 0:b74591d5ab33 | 52 | { |
be_bryan | 0:b74591d5ab33 | 53 | if (irq_handler) { |
be_bryan | 0:b74591d5ab33 | 54 | irq_handler(&us_data); |
be_bryan | 0:b74591d5ab33 | 55 | } |
be_bryan | 0:b74591d5ab33 | 56 | } |