this hurts

Dependencies:   FFT

Committer:
shyamgatech
Date:
Thu Dec 03 18:15:35 2020 +0000
Revision:
7:0d62545e6d73
Parent:
0:d6c9b09b4042
addded gui mbed code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
annieluo2 0:d6c9b09b4042 1
annieluo2 0:d6c9b09b4042 2 /** \addtogroup hal */
annieluo2 0:d6c9b09b4042 3 /** @{*/
annieluo2 0:d6c9b09b4042 4 /* mbed Microcontroller Library
annieluo2 0:d6c9b09b4042 5 * Copyright (c) 2015 ARM Limited
annieluo2 0:d6c9b09b4042 6 *
annieluo2 0:d6c9b09b4042 7 * Licensed under the Apache License, Version 2.0 (the "License");
annieluo2 0:d6c9b09b4042 8 * you may not use this file except in compliance with the License.
annieluo2 0:d6c9b09b4042 9 * You may obtain a copy of the License at
annieluo2 0:d6c9b09b4042 10 *
annieluo2 0:d6c9b09b4042 11 * http://www.apache.org/licenses/LICENSE-2.0
annieluo2 0:d6c9b09b4042 12 *
annieluo2 0:d6c9b09b4042 13 * Unless required by applicable law or agreed to in writing, software
annieluo2 0:d6c9b09b4042 14 * distributed under the License is distributed on an "AS IS" BASIS,
annieluo2 0:d6c9b09b4042 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
annieluo2 0:d6c9b09b4042 16 * See the License for the specific language governing permissions and
annieluo2 0:d6c9b09b4042 17 * limitations under the License.
annieluo2 0:d6c9b09b4042 18 */
annieluo2 0:d6c9b09b4042 19 #ifndef MBED_TICKER_API_H
annieluo2 0:d6c9b09b4042 20 #define MBED_TICKER_API_H
annieluo2 0:d6c9b09b4042 21
annieluo2 0:d6c9b09b4042 22 #include <stdint.h>
annieluo2 0:d6c9b09b4042 23 #include "device.h"
annieluo2 0:d6c9b09b4042 24
annieluo2 0:d6c9b09b4042 25 typedef uint32_t timestamp_t;
annieluo2 0:d6c9b09b4042 26
annieluo2 0:d6c9b09b4042 27 /** Ticker's event structure
annieluo2 0:d6c9b09b4042 28 */
annieluo2 0:d6c9b09b4042 29 typedef struct ticker_event_s {
annieluo2 0:d6c9b09b4042 30 timestamp_t timestamp; /**< Event's timestamp */
annieluo2 0:d6c9b09b4042 31 uint32_t id; /**< TimerEvent object */
annieluo2 0:d6c9b09b4042 32 struct ticker_event_s *next; /**< Next event in the queue */
annieluo2 0:d6c9b09b4042 33 } ticker_event_t;
annieluo2 0:d6c9b09b4042 34
annieluo2 0:d6c9b09b4042 35 typedef void (*ticker_event_handler)(uint32_t id);
annieluo2 0:d6c9b09b4042 36
annieluo2 0:d6c9b09b4042 37 /** Ticker's interface structure - required API for a ticker
annieluo2 0:d6c9b09b4042 38 */
annieluo2 0:d6c9b09b4042 39 typedef struct {
annieluo2 0:d6c9b09b4042 40 void (*init)(void); /**< Init function */
annieluo2 0:d6c9b09b4042 41 uint32_t (*read)(void); /**< Read function */
annieluo2 0:d6c9b09b4042 42 void (*disable_interrupt)(void); /**< Disable interrupt function */
annieluo2 0:d6c9b09b4042 43 void (*clear_interrupt)(void); /**< Clear interrupt function */
annieluo2 0:d6c9b09b4042 44 void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */
annieluo2 0:d6c9b09b4042 45 } ticker_interface_t;
annieluo2 0:d6c9b09b4042 46
annieluo2 0:d6c9b09b4042 47 /** Ticker's event queue structure
annieluo2 0:d6c9b09b4042 48 */
annieluo2 0:d6c9b09b4042 49 typedef struct {
annieluo2 0:d6c9b09b4042 50 ticker_event_handler event_handler; /**< Event handler */
annieluo2 0:d6c9b09b4042 51 ticker_event_t *head; /**< A pointer to head */
annieluo2 0:d6c9b09b4042 52 } ticker_event_queue_t;
annieluo2 0:d6c9b09b4042 53
annieluo2 0:d6c9b09b4042 54 /** Ticker's data structure
annieluo2 0:d6c9b09b4042 55 */
annieluo2 0:d6c9b09b4042 56 typedef struct {
annieluo2 0:d6c9b09b4042 57 const ticker_interface_t *interface; /**< Ticker's interface */
annieluo2 0:d6c9b09b4042 58 ticker_event_queue_t *queue; /**< Ticker's event queue */
annieluo2 0:d6c9b09b4042 59 } ticker_data_t;
annieluo2 0:d6c9b09b4042 60
annieluo2 0:d6c9b09b4042 61 #ifdef __cplusplus
annieluo2 0:d6c9b09b4042 62 extern "C" {
annieluo2 0:d6c9b09b4042 63 #endif
annieluo2 0:d6c9b09b4042 64
annieluo2 0:d6c9b09b4042 65 /**
annieluo2 0:d6c9b09b4042 66 * \defgroup hal_ticker Ticker HAL functions
annieluo2 0:d6c9b09b4042 67 * @{
annieluo2 0:d6c9b09b4042 68 */
annieluo2 0:d6c9b09b4042 69
annieluo2 0:d6c9b09b4042 70 /** Initialize a ticker and set the event handler
annieluo2 0:d6c9b09b4042 71 *
annieluo2 0:d6c9b09b4042 72 * @param data The ticker's data
annieluo2 0:d6c9b09b4042 73 * @param handler A handler to be set
annieluo2 0:d6c9b09b4042 74 */
annieluo2 0:d6c9b09b4042 75 void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);
annieluo2 0:d6c9b09b4042 76
annieluo2 0:d6c9b09b4042 77 /** IRQ handler that goes through the events to trigger overdue events.
annieluo2 0:d6c9b09b4042 78 *
annieluo2 0:d6c9b09b4042 79 * @param data The ticker's data
annieluo2 0:d6c9b09b4042 80 */
annieluo2 0:d6c9b09b4042 81 void ticker_irq_handler(const ticker_data_t *const data);
annieluo2 0:d6c9b09b4042 82
annieluo2 0:d6c9b09b4042 83 /** Remove an event from the queue
annieluo2 0:d6c9b09b4042 84 *
annieluo2 0:d6c9b09b4042 85 * @param data The ticker's data
annieluo2 0:d6c9b09b4042 86 * @param obj The event object to be removed from the queue
annieluo2 0:d6c9b09b4042 87 */
annieluo2 0:d6c9b09b4042 88 void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj);
annieluo2 0:d6c9b09b4042 89
annieluo2 0:d6c9b09b4042 90 /** Insert an event to the queue
annieluo2 0:d6c9b09b4042 91 *
annieluo2 0:d6c9b09b4042 92 * @param data The ticker's data
annieluo2 0:d6c9b09b4042 93 * @param obj The event object to be inserted to the queue
annieluo2 0:d6c9b09b4042 94 * @param timestamp The event's timestamp
annieluo2 0:d6c9b09b4042 95 * @param id The event object
annieluo2 0:d6c9b09b4042 96 */
annieluo2 0:d6c9b09b4042 97 void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
annieluo2 0:d6c9b09b4042 98
annieluo2 0:d6c9b09b4042 99 /** Read the current ticker's timestamp
annieluo2 0:d6c9b09b4042 100 *
annieluo2 0:d6c9b09b4042 101 * @param data The ticker's data
annieluo2 0:d6c9b09b4042 102 * @return The current timestamp
annieluo2 0:d6c9b09b4042 103 */
annieluo2 0:d6c9b09b4042 104 timestamp_t ticker_read(const ticker_data_t *const data);
annieluo2 0:d6c9b09b4042 105
annieluo2 0:d6c9b09b4042 106 /** Read the next event's timestamp
annieluo2 0:d6c9b09b4042 107 *
annieluo2 0:d6c9b09b4042 108 * @param data The ticker's data
annieluo2 0:d6c9b09b4042 109 * @return 1 if timestamp is pending event, 0 if there's no event pending
annieluo2 0:d6c9b09b4042 110 */
annieluo2 0:d6c9b09b4042 111 int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp);
annieluo2 0:d6c9b09b4042 112
annieluo2 0:d6c9b09b4042 113 /**@}*/
annieluo2 0:d6c9b09b4042 114
annieluo2 0:d6c9b09b4042 115 #ifdef __cplusplus
annieluo2 0:d6c9b09b4042 116 }
annieluo2 0:d6c9b09b4042 117 #endif
annieluo2 0:d6c9b09b4042 118
annieluo2 0:d6c9b09b4042 119 #endif
annieluo2 0:d6c9b09b4042 120
annieluo2 0:d6c9b09b4042 121 /** @}*/