This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
vipinranka
Date:
Wed Jan 11 11:41:30 2017 +0000
Revision:
12:9a20164dcc47
This is the final version MGAS Project for Renesas GR Peach Design Contest

Who changed what in which revision?

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