Use MPU9250 with nRF51822

Dependencies:   eMPL_MPU

Fork of Seeed_Tiny_BLE_Flash by Darren Huang

Committer:
yihui
Date:
Thu Dec 10 08:00:18 2015 +0000
Revision:
5:9b240c1d5251
get 9dof data from mpu9250

Who changed what in which revision?

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