Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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