1
1
//! # Embassy-rs support for the Vorago VA108xx MCU family
2
2
//!
3
- //! This repository contains the [embassy-rs](https://github.com/embassy-rs/embassy) support for the
4
- //! VA108xx family. Currently, it contains the time driver to allow using embassy-rs. It uses the TIM
5
- //! peripherals provided by the VA108xx family for this purpose.
3
+ //! This repository contains the [embassy-rs](https://github.com/embassy-rs/embassy) support for
4
+ //! the VA108xx family. Currently, it contains the time driver to allow using embassy-rs. It uses
5
+ //! the TIM peripherals provided by the VA108xx family for this purpose.
6
6
//!
7
7
//! ## Usage
8
8
//!
9
- //! This library only exposes the [embassy:: init] method which sets up the time driver. This
10
- //! function must be called once at the start of the application.
9
+ //! This library exposes the [init] or the [init_with_custom_irqs] functions which set up the time
10
+ //! driver. This function must be called once at the start of the application.
11
11
//!
12
12
//! This implementation requires two TIM peripherals provided by the VA108xx device.
13
13
//! The user can freely specify the two used TIM peripheral by passing the concrete TIM instances
14
- //! into the [embassy:: init_with_custom_irqs] and [embassy:: init] method.
14
+ //! into the [init_with_custom_irqs] and [init] method.
15
15
//!
16
16
//! The application also requires two interrupt handlers to handle the timekeeper and alarm
17
17
//! interrupts. By default, this library will define the interrupt handler inside the library
24
24
//! You can disable the default features and then specify one of the features above to use the
25
25
//! documented combination of IRQs. It is also possible to specify custom IRQs by importing and
26
26
//! using the [embassy_time_driver_irqs] macro to declare the IRQ handlers in the
27
- //! application code. If this is done, [embassy:: init_with_custom_irqs] must be used
27
+ //! application code. If this is done, [init_with_custom_irqs] must be used
28
28
//! method to pass the IRQ numbers to the library.
29
29
//!
30
30
//! ## Examples
@@ -76,7 +76,7 @@ macro_rules! embassy_time_driver_irqs {
76
76
#[ allow( non_snake_case) ]
77
77
fn $timekeeper_irq( ) {
78
78
// Safety: We call it once here.
79
- unsafe { $crate:: embassy :: time_driver( ) . on_interrupt_timekeeping( ) }
79
+ unsafe { $crate:: time_driver( ) . on_interrupt_timekeeping( ) }
80
80
}
81
81
82
82
const ALARM_IRQ : pac:: Interrupt = pac:: Interrupt :: $alarm_irq;
@@ -85,7 +85,7 @@ macro_rules! embassy_time_driver_irqs {
85
85
#[ allow( non_snake_case) ]
86
86
fn $alarm_irq( ) {
87
87
// Safety: We call it once here.
88
- unsafe { $crate:: embassy :: time_driver( ) . on_interrupt_alarm( ) }
88
+ unsafe { $crate:: time_driver( ) . on_interrupt_alarm( ) }
89
89
}
90
90
} ;
91
91
}
@@ -99,71 +99,58 @@ embassy_time_driver_irqs!(timekeeper_irq = OC30, alarm_irq = OC29);
99
99
#[ cfg( feature = "irq-oc28-oc29" ) ]
100
100
embassy_time_driver_irqs ! ( timekeeper_irq = OC29 , alarm_irq = OC28 ) ;
101
101
102
- pub mod embassy {
103
- use super :: * ;
104
- use va108xx_hal:: { pac, timer:: TimRegInterface } ;
105
-
106
- /// Expose the time driver so the user can specify the IRQ handlers themselves.
107
- pub fn time_driver ( ) -> & ' static TimerDriver {
108
- & TIME_DRIVER
109
- }
102
+ /// Expose the time driver so the user can specify the IRQ handlers themselves.
103
+ pub fn time_driver ( ) -> & ' static TimerDriver {
104
+ & TIME_DRIVER
105
+ }
110
106
111
- /// Initialization method for embassy
112
- ///
113
- /// # Safety
114
- ///
115
- /// This has to be called once at initialization time to initiate the time driver for
116
- /// embassy.
117
- #[ cfg( feature = "irqs-in-lib" ) ]
118
- pub unsafe fn init <
119
- TimekeeperTim : TimRegInterface + ValidTim ,
120
- AlarmTim : TimRegInterface + ValidTim ,
121
- > (
122
- syscfg : & mut pac:: Sysconfig ,
123
- irqsel : & pac:: Irqsel ,
124
- sysclk : impl Into < Hertz > ,
125
- timekeeper_tim : TimekeeperTim ,
126
- alarm_tim : AlarmTim ,
127
- ) {
128
- TIME_DRIVER . init (
129
- syscfg,
130
- irqsel,
131
- sysclk,
132
- timekeeper_tim,
133
- alarm_tim,
134
- TIMEKEEPER_IRQ ,
135
- ALARM_IRQ ,
136
- )
137
- }
107
+ /// Initialization method for embassy.
108
+ ///
109
+ /// This should be used if the interrupt handler is provided by the library, which is the
110
+ /// default case.
111
+ #[ cfg( feature = "irqs-in-lib" ) ]
112
+ pub fn init < TimekeeperTim : TimRegInterface + ValidTim , AlarmTim : TimRegInterface + ValidTim > (
113
+ syscfg : & mut pac:: Sysconfig ,
114
+ irqsel : & pac:: Irqsel ,
115
+ sysclk : impl Into < Hertz > ,
116
+ timekeeper_tim : TimekeeperTim ,
117
+ alarm_tim : AlarmTim ,
118
+ ) {
119
+ TIME_DRIVER . init (
120
+ syscfg,
121
+ irqsel,
122
+ sysclk,
123
+ timekeeper_tim,
124
+ alarm_tim,
125
+ TIMEKEEPER_IRQ ,
126
+ ALARM_IRQ ,
127
+ )
128
+ }
138
129
139
- /// Initialization method for embassy
140
- ///
141
- /// # Safety
142
- ///
143
- /// This has to be called once at initialization time to initiate the time driver for
144
- /// embassy.
145
- pub unsafe fn init_with_custom_irqs <
146
- TimekeeperTim : TimRegInterface + ValidTim ,
147
- AlarmTim : TimRegInterface + ValidTim ,
148
- > (
149
- syscfg : & mut pac:: Sysconfig ,
150
- irqsel : & pac:: Irqsel ,
151
- sysclk : impl Into < Hertz > ,
152
- timekeeper_tim : TimekeeperTim ,
153
- alarm_tim : AlarmTim ,
154
- timekeeper_irq : pac:: Interrupt ,
155
- alarm_irq : pac:: Interrupt ,
156
- ) {
157
- TIME_DRIVER . init (
158
- syscfg,
159
- irqsel,
160
- sysclk,
161
- timekeeper_tim,
162
- alarm_tim,
163
- timekeeper_irq,
164
- alarm_irq,
165
- )
166
- }
130
+ /// Initialization method for embassy when using custom IRQ handlers.
131
+ ///
132
+ /// Requires an explicit [pac::Interrupt] argument for the timekeeper and alarm IRQs.
133
+ pub fn init_with_custom_irqs <
134
+ TimekeeperTim : TimRegInterface + ValidTim ,
135
+ AlarmTim : TimRegInterface + ValidTim ,
136
+ > (
137
+ syscfg : & mut pac:: Sysconfig ,
138
+ irqsel : & pac:: Irqsel ,
139
+ sysclk : impl Into < Hertz > ,
140
+ timekeeper_tim : TimekeeperTim ,
141
+ alarm_tim : AlarmTim ,
142
+ timekeeper_irq : pac:: Interrupt ,
143
+ alarm_irq : pac:: Interrupt ,
144
+ ) {
145
+ TIME_DRIVER . init (
146
+ syscfg,
147
+ irqsel,
148
+ sysclk,
149
+ timekeeper_tim,
150
+ alarm_tim,
151
+ timekeeper_irq,
152
+ alarm_irq,
153
+ )
167
154
}
168
155
169
156
struct AlarmState {
0 commit comments