temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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