test test test

Dependencies:   mbed

Committer:
mohamedmoawya
Date:
Mon May 25 19:06:11 2020 +0000
Revision:
0:e4c5e6ec922e
snake game tteest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mohamedmoawya 0:e4c5e6ec922e 1 /** \addtogroup hal */
mohamedmoawya 0:e4c5e6ec922e 2 /** @{*/
mohamedmoawya 0:e4c5e6ec922e 3 /* mbed Microcontroller Library
mohamedmoawya 0:e4c5e6ec922e 4 * Copyright (c) 2006-2017 ARM Limited
mohamedmoawya 0:e4c5e6ec922e 5 *
mohamedmoawya 0:e4c5e6ec922e 6 * Licensed under the Apache License, Version 2.0 (the "License");
mohamedmoawya 0:e4c5e6ec922e 7 * you may not use this file except in compliance with the License.
mohamedmoawya 0:e4c5e6ec922e 8 * You may obtain a copy of the License at
mohamedmoawya 0:e4c5e6ec922e 9 *
mohamedmoawya 0:e4c5e6ec922e 10 * http://www.apache.org/licenses/LICENSE-2.0
mohamedmoawya 0:e4c5e6ec922e 11 *
mohamedmoawya 0:e4c5e6ec922e 12 * Unless required by applicable law or agreed to in writing, software
mohamedmoawya 0:e4c5e6ec922e 13 * distributed under the License is distributed on an "AS IS" BASIS,
mohamedmoawya 0:e4c5e6ec922e 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mohamedmoawya 0:e4c5e6ec922e 15 * See the License for the specific language governing permissions and
mohamedmoawya 0:e4c5e6ec922e 16 * limitations under the License.
mohamedmoawya 0:e4c5e6ec922e 17 */
mohamedmoawya 0:e4c5e6ec922e 18 #ifndef MBED_CRITICAL_SECTION_API_H
mohamedmoawya 0:e4c5e6ec922e 19 #define MBED_CRITICAL_SECTION_API_H
mohamedmoawya 0:e4c5e6ec922e 20
mohamedmoawya 0:e4c5e6ec922e 21 #include <stdbool.h>
mohamedmoawya 0:e4c5e6ec922e 22
mohamedmoawya 0:e4c5e6ec922e 23 #ifdef __cplusplus
mohamedmoawya 0:e4c5e6ec922e 24 extern "C" {
mohamedmoawya 0:e4c5e6ec922e 25 #endif
mohamedmoawya 0:e4c5e6ec922e 26
mohamedmoawya 0:e4c5e6ec922e 27 /**
mohamedmoawya 0:e4c5e6ec922e 28 * \defgroup hal_critical Critical Section HAL functions
mohamedmoawya 0:e4c5e6ec922e 29 * @{
mohamedmoawya 0:e4c5e6ec922e 30 */
mohamedmoawya 0:e4c5e6ec922e 31
mohamedmoawya 0:e4c5e6ec922e 32 /**
mohamedmoawya 0:e4c5e6ec922e 33 * Mark the start of a critical section
mohamedmoawya 0:e4c5e6ec922e 34 *
mohamedmoawya 0:e4c5e6ec922e 35 * This function will be called by core_util_critical_section_enter() each time
mohamedmoawya 0:e4c5e6ec922e 36 * the application requests to enter a critical section. The purpose of the
mohamedmoawya 0:e4c5e6ec922e 37 * critical section is to ensure mutual-exclusion synchronisation of the
mohamedmoawya 0:e4c5e6ec922e 38 * processor by preventing any change in processor control, the default
mohamedmoawya 0:e4c5e6ec922e 39 * behaviour requires storing the state of interrupts in the system before
mohamedmoawya 0:e4c5e6ec922e 40 * disabling them.
mohamedmoawya 0:e4c5e6ec922e 41 *
mohamedmoawya 0:e4c5e6ec922e 42 * The critical section code supports nesting. When a thread has entered a
mohamedmoawya 0:e4c5e6ec922e 43 * critical section it can make additional calls to
mohamedmoawya 0:e4c5e6ec922e 44 * core_util_critical_section_enter() without deadlocking itself. The critical
mohamedmoawya 0:e4c5e6ec922e 45 * section driver API tracks the number of nested calls to the critical section.
mohamedmoawya 0:e4c5e6ec922e 46 * The critical section will only be exited when
mohamedmoawya 0:e4c5e6ec922e 47 * core_util_critical_section_exit() has been called once for each time it
mohamedmoawya 0:e4c5e6ec922e 48 * entered the critical section.
mohamedmoawya 0:e4c5e6ec922e 49 *
mohamedmoawya 0:e4c5e6ec922e 50 * On the first call to enter a critical section this function MUST store the
mohamedmoawya 0:e4c5e6ec922e 51 * state of any interrupts or other application settings it will modify to
mohamedmoawya 0:e4c5e6ec922e 52 * facilitate the critical section.
mohamedmoawya 0:e4c5e6ec922e 53 *
mohamedmoawya 0:e4c5e6ec922e 54 * Each successive call to enter the critical section MUST ignore storing or
mohamedmoawya 0:e4c5e6ec922e 55 * modifying any application state.
mohamedmoawya 0:e4c5e6ec922e 56 *
mohamedmoawya 0:e4c5e6ec922e 57 * The default implementation of this function which will save the current state
mohamedmoawya 0:e4c5e6ec922e 58 * of interrupts before disabling them. This implementation can be found in
mohamedmoawya 0:e4c5e6ec922e 59 * mbed_critical_section_api.c. This behaviour is can be overridden on a per
mohamedmoawya 0:e4c5e6ec922e 60 * platform basis by providing a different implementation within the correct
mohamedmoawya 0:e4c5e6ec922e 61 * targets directory.
mohamedmoawya 0:e4c5e6ec922e 62 */
mohamedmoawya 0:e4c5e6ec922e 63 void hal_critical_section_enter(void);
mohamedmoawya 0:e4c5e6ec922e 64
mohamedmoawya 0:e4c5e6ec922e 65
mohamedmoawya 0:e4c5e6ec922e 66 /** Mark the end of a critical section.
mohamedmoawya 0:e4c5e6ec922e 67 *
mohamedmoawya 0:e4c5e6ec922e 68 * The purpose of this function is to restore any state that was modified upon
mohamedmoawya 0:e4c5e6ec922e 69 * entering the critical section, allowing other threads or interrupts to change
mohamedmoawya 0:e4c5e6ec922e 70 * the processor control.
mohamedmoawya 0:e4c5e6ec922e 71 *
mohamedmoawya 0:e4c5e6ec922e 72 * This function will be called once by core_util_critical_section_exit() per
mohamedmoawya 0:e4c5e6ec922e 73 * critical section on last call to exit. When called, the application MUST
mohamedmoawya 0:e4c5e6ec922e 74 * restore the saved interrupt/application state that was saved when entering
mohamedmoawya 0:e4c5e6ec922e 75 * the critical section.
mohamedmoawya 0:e4c5e6ec922e 76 *
mohamedmoawya 0:e4c5e6ec922e 77 * There is a default implementation of this function, it will restore the state
mohamedmoawya 0:e4c5e6ec922e 78 * of interrupts that were previously saved when hal_critical_section_enter was
mohamedmoawya 0:e4c5e6ec922e 79 * first called, this implementation can be found in
mohamedmoawya 0:e4c5e6ec922e 80 * mbed_critical_section_api.c. This behaviour is overridable by providing a
mohamedmoawya 0:e4c5e6ec922e 81 * different function implementation within the correct targets directory.
mohamedmoawya 0:e4c5e6ec922e 82 */
mohamedmoawya 0:e4c5e6ec922e 83 void hal_critical_section_exit(void);
mohamedmoawya 0:e4c5e6ec922e 84
mohamedmoawya 0:e4c5e6ec922e 85
mohamedmoawya 0:e4c5e6ec922e 86 /** Determine if the application is currently running in a critical section
mohamedmoawya 0:e4c5e6ec922e 87 *
mohamedmoawya 0:e4c5e6ec922e 88 * The purpose of this function is to inform the caller whether or not the
mohamedmoawya 0:e4c5e6ec922e 89 * application is running in a critical section. This is done by checking if
mohamedmoawya 0:e4c5e6ec922e 90 * the current interrupt state has been saved in the underlying implementation,
mohamedmoawya 0:e4c5e6ec922e 91 * this could also be done by checking the state of the interrupts at the time
mohamedmoawya 0:e4c5e6ec922e 92 * of calling.
mohamedmoawya 0:e4c5e6ec922e 93 *
mohamedmoawya 0:e4c5e6ec922e 94 * @return True if running in a critical section, false if not.
mohamedmoawya 0:e4c5e6ec922e 95 */
mohamedmoawya 0:e4c5e6ec922e 96 bool hal_in_critical_section(void);
mohamedmoawya 0:e4c5e6ec922e 97
mohamedmoawya 0:e4c5e6ec922e 98
mohamedmoawya 0:e4c5e6ec922e 99 /**@}*/
mohamedmoawya 0:e4c5e6ec922e 100
mohamedmoawya 0:e4c5e6ec922e 101 #ifdef __cplusplus
mohamedmoawya 0:e4c5e6ec922e 102 }
mohamedmoawya 0:e4c5e6ec922e 103 #endif
mohamedmoawya 0:e4c5e6ec922e 104
mohamedmoawya 0:e4c5e6ec922e 105 #endif // MBED_CRITICAL_SECTION_API_H
mohamedmoawya 0:e4c5e6ec922e 106
mohamedmoawya 0:e4c5e6ec922e 107 /** @}*/