rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
hal_st_lld.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2014-2015 Fabio Utzig
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file PITv1/hal_st_lld.c
19 * @brief ST Driver subsystem low level driver code.
20 * @author andreika <prometheus.pcb@gmail.com>
21 *
22 * @addtogroup ST
23 * @{
24 */
25
26#include "hal.h"
27
28#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver local definitions. */
32/*===========================================================================*/
33
34/*===========================================================================*/
35/* Driver exported variables. */
36/*===========================================================================*/
37
38/*===========================================================================*/
39/* Driver local types. */
40/*===========================================================================*/
41
42/*===========================================================================*/
43/* Driver local variables and types. */
44/*===========================================================================*/
45
46/*===========================================================================*/
47/* Driver local functions. */
48/*===========================================================================*/
49
50/*===========================================================================*/
51/* Driver interrupt handlers. */
52/*===========================================================================*/
53
54#if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) || defined(__DOXYGEN__)
55/**
56 * @brief System Timer vector.
57 * @details This interrupt is used for system tick in periodic mode.
58 *
59 * @isr
60 */
61OSAL_IRQ_HANDLER(SysTick_Handler) {
62
63 OSAL_IRQ_PROLOGUE();
64
65 osalSysLockFromISR();
66 osalOsTimerHandlerI();
67 osalSysUnlockFromISR();
68
69 OSAL_IRQ_EPILOGUE();
70}
71#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
72
73/*===========================================================================*/
74/* Driver exported functions. */
75/*===========================================================================*/
76
77/**
78 * @brief Low level ST driver initialization.
79 *
80 * @notapi
81 */
82void st_lld_init(void) {
83#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
84 /* Periodic systick mode, the Cortex-Mx internal systick timer is used
85 in this mode.*/
86 SysTick->LOAD = (KINETIS_SYSCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1;
87 SysTick->VAL = 0;
88 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
89 SysTick_CTRL_ENABLE_Msk |
90 SysTick_CTRL_TICKINT_Msk;
91
92 /* IRQ enabled.*/
93 nvicSetSystemHandlerPriority(HANDLER_SYSTICK, KINETIS_ST_IRQ_PRIORITY);
94#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
95}
96
97#endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */
98
99/** @} */
void st_lld_init(void)
Low level ST driver initialization.
Definition hal_st_lld.c:82
OSAL_IRQ_HANDLER(SysTick_Handler)
System Timer vector.
Definition hal_st_lld.c:61