takashi kadono / Mbed OS Nucleo446_SSD1331

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 /* mbed Microcontroller Library
kadonotakashi 0:8fdf9a60065b 2 * Copyright (c) 2017-2017 ARM Limited
kadonotakashi 0:8fdf9a60065b 3 *
kadonotakashi 0:8fdf9a60065b 4 * Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 5 * you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 6 * You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 7 *
kadonotakashi 0:8fdf9a60065b 8 * http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 9 *
kadonotakashi 0:8fdf9a60065b 10 * Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 11 * distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 13 * See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 14 * limitations under the License.
kadonotakashi 0:8fdf9a60065b 15 */
kadonotakashi 0:8fdf9a60065b 16
kadonotakashi 0:8fdf9a60065b 17 /** \addtogroup hal_ticker_tests */
kadonotakashi 0:8fdf9a60065b 18 /** @{*/
kadonotakashi 0:8fdf9a60065b 19
kadonotakashi 0:8fdf9a60065b 20 #ifndef TICKER_API_TESTS_H
kadonotakashi 0:8fdf9a60065b 21 #define TICKER_API_TESTS_H
kadonotakashi 0:8fdf9a60065b 22
kadonotakashi 0:8fdf9a60065b 23 #include "device.h"
kadonotakashi 0:8fdf9a60065b 24
kadonotakashi 0:8fdf9a60065b 25
kadonotakashi 0:8fdf9a60065b 26 #ifdef __cplusplus
kadonotakashi 0:8fdf9a60065b 27 extern "C" {
kadonotakashi 0:8fdf9a60065b 28 #endif
kadonotakashi 0:8fdf9a60065b 29
kadonotakashi 0:8fdf9a60065b 30 /** Test that ticker_init can be called multiple times and
kadonotakashi 0:8fdf9a60065b 31 * ticker_init resets the internal count and disables the ticker interrupt.
kadonotakashi 0:8fdf9a60065b 32 *
kadonotakashi 0:8fdf9a60065b 33 * Given ticker is initialised and interrupt is set.
kadonotakashi 0:8fdf9a60065b 34 * When ticker is re-initialised.
kadonotakashi 0:8fdf9a60065b 35 * Then ticker keeps counting and disables the ticker interrupt.
kadonotakashi 0:8fdf9a60065b 36 */
kadonotakashi 0:8fdf9a60065b 37 void ticker_init_test(void);
kadonotakashi 0:8fdf9a60065b 38
kadonotakashi 0:8fdf9a60065b 39 /** Test that ticker frequency is non-zero and counter is at least 8 bits
kadonotakashi 0:8fdf9a60065b 40 *
kadonotakashi 0:8fdf9a60065b 41 * Given ticker is available.
kadonotakashi 0:8fdf9a60065b 42 * When ticker information data is obtained.
kadonotakashi 0:8fdf9a60065b 43 * Then ticker information indicate that frequency is non-zero and counter is at least 8 bits.
kadonotakashi 0:8fdf9a60065b 44 */
kadonotakashi 0:8fdf9a60065b 45 void ticker_info_test(void);
kadonotakashi 0:8fdf9a60065b 46
kadonotakashi 0:8fdf9a60065b 47 /** Test that the ticker increments by one on each tick.
kadonotakashi 0:8fdf9a60065b 48 *
kadonotakashi 0:8fdf9a60065b 49 * We have the following assumption for the timer clock frequency:
kadonotakashi 0:8fdf9a60065b 50 *
kadonotakashi 0:8fdf9a60065b 51 * NOTE:
kadonotakashi 0:8fdf9a60065b 52 * high freq ticker: 250 KHz (1 tick per 4 us) - 8 Mhz (1 tick per 1/8 us)
kadonotakashi 0:8fdf9a60065b 53 * low power ticker: 8 KHz (1 tick per 125 us) - 64 KHz (1 tick per ~15.6 us)
kadonotakashi 0:8fdf9a60065b 54 *
kadonotakashi 0:8fdf9a60065b 55 * Lowest CPU speed is 16 MHz (1 tick per 1/16 us).
kadonotakashi 0:8fdf9a60065b 56 *
kadonotakashi 0:8fdf9a60065b 57 * For the boards with ticker clock freq less than or equal to 250 KHz we will try to prove that ticker is incremented by one
kadonotakashi 0:8fdf9a60065b 58 * straightforward by reading ticker count value in the loop in order to detect a single ticker value update (hopefully by one).
kadonotakashi 0:8fdf9a60065b 59 * For faster tickers we need to prove this indirectly using additional count_ticks() function which returns number of
kadonotakashi 0:8fdf9a60065b 60 * ticks needed to perform N cycles of the empty while loop. For the same number of cycles function result should be the same with
kadonotakashi 0:8fdf9a60065b 61 * accuracy +/- 1 tick. After the first test we will call count_ticks again with number of cycles equal N, N+1, N+2, ...
kadonotakashi 0:8fdf9a60065b 62 * until we get other ticks result.
kadonotakashi 0:8fdf9a60065b 63 *
kadonotakashi 0:8fdf9a60065b 64 * Given ticker is available.
kadonotakashi 0:8fdf9a60065b 65 * When ticker is initialised.
kadonotakashi 0:8fdf9a60065b 66 * Then ticker counter is incremented by one.
kadonotakashi 0:8fdf9a60065b 67 */
kadonotakashi 0:8fdf9a60065b 68 void ticker_increment_test(void);
kadonotakashi 0:8fdf9a60065b 69
kadonotakashi 0:8fdf9a60065b 70 /** Test that ticker interrupt fires only when the ticker counter increments to the value set by ticker_set_interrupt.
kadonotakashi 0:8fdf9a60065b 71 *
kadonotakashi 0:8fdf9a60065b 72 * Given ticker is available, initialised.
kadonotakashi 0:8fdf9a60065b 73 * When ticker interrupt is set.
kadonotakashi 0:8fdf9a60065b 74 * Then ticker interrupt fires at the valid time.
kadonotakashi 0:8fdf9a60065b 75 */
kadonotakashi 0:8fdf9a60065b 76 void ticker_interrupt_test(void);
kadonotakashi 0:8fdf9a60065b 77
kadonotakashi 0:8fdf9a60065b 78 /** Test that ticker interrupt is not triggered when ticker_set_interrupt is called with a time from the past
kadonotakashi 0:8fdf9a60065b 79 *
kadonotakashi 0:8fdf9a60065b 80 * Given ticker is available, initialised.
kadonotakashi 0:8fdf9a60065b 81 * When ticker interrupt is set to the time in the past.
kadonotakashi 0:8fdf9a60065b 82 * Then ticker interrupt is not triggered.
kadonotakashi 0:8fdf9a60065b 83 */
kadonotakashi 0:8fdf9a60065b 84 void ticker_past_test(void);
kadonotakashi 0:8fdf9a60065b 85
kadonotakashi 0:8fdf9a60065b 86 /** Test that ticker can be rescheduled repeatedly before the handler has been called.
kadonotakashi 0:8fdf9a60065b 87 *
kadonotakashi 0:8fdf9a60065b 88 * Given ticker is available, initialised.
kadonotakashi 0:8fdf9a60065b 89 * When ticker interrupt is set and then rescheduled (interrupt time is modified).
kadonotakashi 0:8fdf9a60065b 90 * Then ticker interrupt is triggered according the rescheduled time.
kadonotakashi 0:8fdf9a60065b 91 */
kadonotakashi 0:8fdf9a60065b 92 void ticker_repeat_reschedule_test(void);
kadonotakashi 0:8fdf9a60065b 93
kadonotakashi 0:8fdf9a60065b 94 /** Test that ticker_fire_interrupt causes the interrupt to get fired immediately.
kadonotakashi 0:8fdf9a60065b 95 *
kadonotakashi 0:8fdf9a60065b 96 * Given ticker is available.
kadonotakashi 0:8fdf9a60065b 97 * When ticker_fire_interrupt is called.
kadonotakashi 0:8fdf9a60065b 98 * Then ticker interrupt is triggered.
kadonotakashi 0:8fdf9a60065b 99 */
kadonotakashi 0:8fdf9a60065b 100 void ticker_fire_now_test(void);
kadonotakashi 0:8fdf9a60065b 101
kadonotakashi 0:8fdf9a60065b 102 /** Test that common ticker functions complete with the required amount of time.
kadonotakashi 0:8fdf9a60065b 103 *
kadonotakashi 0:8fdf9a60065b 104 * Given ticker is available.
kadonotakashi 0:8fdf9a60065b 105 * When ticker_read, ticker_clear_interrupt, ticker_set_interrupt, ticker_fire_interrupt or ticker_disable_interrupt function is called.
kadonotakashi 0:8fdf9a60065b 106 * Then its execution is not longer than 20 us.
kadonotakashi 0:8fdf9a60065b 107 */
kadonotakashi 0:8fdf9a60065b 108 void ticker_speed_test(void);
kadonotakashi 0:8fdf9a60065b 109
kadonotakashi 0:8fdf9a60065b 110 /** Test that the ticker correctly handles overflow.
kadonotakashi 0:8fdf9a60065b 111 *
kadonotakashi 0:8fdf9a60065b 112 * Note that for high frequency timers we will only prove that ticker counter rollovers and
kadonotakashi 0:8fdf9a60065b 113 * continue counting (it is not possible to prove in deterministic way that after rollover next value is 0).
kadonotakashi 0:8fdf9a60065b 114 *
kadonotakashi 0:8fdf9a60065b 115 * Given ticker is available.
kadonotakashi 0:8fdf9a60065b 116 * When ticker has overflows.
kadonotakashi 0:8fdf9a60065b 117 * Then ticker continues counting from the beginning and interrupt scheduling works.
kadonotakashi 0:8fdf9a60065b 118 */
kadonotakashi 0:8fdf9a60065b 119 void ticker_overflow_test(void);
kadonotakashi 0:8fdf9a60065b 120
kadonotakashi 0:8fdf9a60065b 121 /**@}*/
kadonotakashi 0:8fdf9a60065b 122
kadonotakashi 0:8fdf9a60065b 123 #ifdef __cplusplus
kadonotakashi 0:8fdf9a60065b 124 }
kadonotakashi 0:8fdf9a60065b 125 #endif
kadonotakashi 0:8fdf9a60065b 126
kadonotakashi 0:8fdf9a60065b 127 #endif
kadonotakashi 0:8fdf9a60065b 128
kadonotakashi 0:8fdf9a60065b 129 /**@}*/