Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

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