Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Luiz Fernando Lavado Villa
Core
Commits
dddc3fef
Commit
dddc3fef
authored
Jun 10, 2021
by
Clément Foucher
Browse files
Add timer 7 support to OwnTech timer module.
parent
52f34e20
Changes
3
Hide whitespace changes
Inline
Side-by-side
zephyr/modules/owntech_timer_driver/zephyr/stm32_timer_driver.c
View file @
dddc3fef
...
...
@@ -39,6 +39,10 @@ static int timer_stm32_init(const struct device* dev)
if
(
tim_dev
==
TIM6
)
init_timer_6
();
else
if
(
tim_dev
==
TIM7
)
init_timer_7
();
else
return
-
1
;
return
0
;
}
...
...
@@ -138,10 +142,31 @@ void init_timer_6()
LL_TIM_DisableMasterSlaveMode
(
TIM6
);
}
void
init_timer_7
()
{
LL_TIM_InitTypeDef
TIM_InitStruct
=
{
0
};
// Peripheral clock enable
LL_APB1_GRP1_EnableClock
(
LL_APB1_GRP1_PERIPH_TIM7
);
// TIM7 interrupt Init
NVIC_SetPriority
(
TIM7_DAC_IRQn
,
NVIC_EncodePriority
(
NVIC_GetPriorityGrouping
(),
0
,
0
));
TIM_InitStruct
.
Prescaler
=
(
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
/
1e7
)
-
1
;
// Set prescaler to tick to 0.1µs
TIM_InitStruct
.
CounterMode
=
LL_TIM_COUNTERMODE_UP
;
LL_TIM_Init
(
TIM7
,
&
TIM_InitStruct
);
LL_TIM_DisableARRPreload
(
TIM7
);
LL_TIM_SetTriggerOutput
(
TIM7
,
LL_TIM_TRGO_RESET
);
LL_TIM_DisableMasterSlaveMode
(
TIM7
);
}
/////
// Device definitions
// Timer 6
#if DT_NODE_HAS_STATUS(TIMER6_NODELABEL, okay)
struct
stm32_timer_driver_data
timer6_data
=
{
.
timer_struct
=
TIM6
,
...
...
@@ -150,13 +175,37 @@ struct stm32_timer_driver_data timer6_data =
.
timer_callback
=
NULL
};
DEVICE_DEFINE
(
stm32_timer_driver
,
TIMER6_LABEL
,
timer_stm32_init
,
device_pm_control_nop
,
&
timer6_data
,
NULL
,
PRE_KERNEL_1
,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE
,
&
timer_funcs
);
DEVICE_DT_DEFINE
(
TIMER6_NODELABEL
,
timer_stm32_init
,
device_pm_control_nop
,
&
timer6_data
,
NULL
,
PRE_KERNEL_1
,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE
,
&
timer_funcs
);
#endif // Timer 6
// Timer 7
#if DT_NODE_HAS_STATUS(TIMER7_NODELABEL, okay)
struct
stm32_timer_driver_data
timer7_data
=
{
.
timer_struct
=
TIM7
,
.
interrupt_line
=
TIMER7_INTERRUPT_LINE
,
.
interrupt_prio
=
TIMER7_INTERRUPT_PRIO
,
.
timer_callback
=
NULL
};
DEVICE_DT_DEFINE
(
TIMER7_NODELABEL
,
timer_stm32_init
,
device_pm_control_nop
,
&
timer7_data
,
NULL
,
PRE_KERNEL_1
,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE
,
&
timer_funcs
);
#endif // Timer 7
zephyr/modules/owntech_timer_driver/zephyr/stm32_timer_driver.h
View file @
dddc3fef
...
...
@@ -36,12 +36,14 @@ extern "C" {
#endif
#define TIMER6_NODELABEL DT_NODELABEL(timers6)
#define TIMER6_LABEL DT_PROP(TIMER6_NODELABEL, label)
#define TIMER6_NODELABEL DT_NODELABEL(timers6)
#define TIMER6_INTERRUPT_LINE DT_IRQN(TIMER6_NODELABEL)
#define TIMER6_INTERRUPT_PRIO DT_IRQ_BY_IDX(TIMER6_NODELABEL, 0, priority)
#define TIMER7_NODELABEL DT_NODELABEL(timers7)
#define TIMER7_INTERRUPT_LINE DT_IRQN(TIMER7_NODELABEL)
#define TIMER7_INTERRUPT_PRIO DT_IRQ_BY_IDX(TIMER7_NODELABEL, 0, priority)
/**
* Members of this structure marked with a "§"
* have to be set when calling DEVICE_DEFINE.
...
...
@@ -67,6 +69,7 @@ uint32_t timer_stm32_get_count(const struct device* dev);
void
timer_stm32_clear
(
const
struct
device
*
dev
);
void
init_timer_6
();
void
init_timer_7
();
#ifdef __cplusplus
...
...
zephyr/nucleo_g474re.overlay
View file @
dddc3fef
...
...
@@ -65,6 +65,10 @@
status = "okay";
};
&timers7 {
status = "okay";
};
/*******/
/* DMA */
/*******/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment