5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

Who changed what in which revision?

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