mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
98:8ab26030e058
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

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