PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

Committer:
skrawool
Date:
Mon Dec 05 16:39:27 2016 +0000
Revision:
0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266

Who changed what in which revision?

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