1
- // Copyright 2023 RT Corporation
1
+ // Copyright 2024 RT Corporation
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
@@ -136,7 +136,7 @@ void IRAM_ATTR isrR(void)
136
136
portENTER_CRITICAL_ISR (&g_timer_mux); // 割り込み禁止
137
137
if (g_motor_move) {
138
138
if (g_step_hz_r < 30 ) g_step_hz_r = 30 ;
139
- timerAlarmWrite (g_timer2, 2000000 / g_step_hz_r, true );
139
+ timerAlarm (g_timer2, 2000000 / g_step_hz_r, true , 0 );
140
140
digitalWrite (PWM_R, HIGH);
141
141
for (int i = 0 ; i < 100 ; i++) {
142
142
asm (" nop \n " );
@@ -153,7 +153,7 @@ void IRAM_ATTR isrL(void)
153
153
portENTER_CRITICAL_ISR (&g_timer_mux); // 割り込み禁止
154
154
if (g_motor_move) {
155
155
if (g_step_hz_l < 30 ) g_step_hz_l = 30 ;
156
- timerAlarmWrite (g_timer3, 2000000 / g_step_hz_l, true );
156
+ timerAlarm (g_timer3, 2000000 / g_step_hz_l, true , 0 );
157
157
digitalWrite (PWM_L, HIGH);
158
158
for (int i = 0 ; i < 100 ; i++) {
159
159
asm (" nop \n " );
@@ -201,20 +201,20 @@ void setup()
201
201
202
202
delay (2000 );
203
203
204
- g_timer0 = timerBegin (0 , 80 , true ); // 1us
205
- timerAttachInterrupt (g_timer0, &onTimer0, true );
206
- timerAlarmWrite (g_timer0, 1000 , true ); // 1kHz
207
- timerAlarmEnable (g_timer0);
204
+ g_timer0 = timerBegin (1000000 ); // 1us
205
+ timerAttachInterrupt (g_timer0, &onTimer0);
206
+ timerAlarm (g_timer0, 1000 , true , 0 ); // 1kHz
207
+ timerStart (g_timer0);
208
208
209
- g_timer2 = timerBegin (2 , 40 , true ); // 0.5us
210
- timerAttachInterrupt (g_timer2, &isrR, true );
211
- timerAlarmWrite (g_timer2, 13333 , true ); // 150Hz
212
- timerAlarmEnable (g_timer2);
209
+ g_timer2 = timerBegin (2000000 ); // 0.5us
210
+ timerAttachInterrupt (g_timer2, &isrR);
211
+ timerAlarm (g_timer2, 13333 , true , 0 ); // 150Hz
212
+ timerStart (g_timer2);
213
213
214
- g_timer3 = timerBegin (3 , 40 , true ); // 0.5us
215
- timerAttachInterrupt (g_timer3, &isrL, true );
216
- timerAlarmWrite (g_timer3, 13333 , true ); // 150Hz
217
- timerAlarmEnable (g_timer3);
214
+ g_timer3 = timerBegin (2000000 ); // 0.5us
215
+ timerAttachInterrupt (g_timer3, &isrL);
216
+ timerAlarm (g_timer3, 13333 , true , 0 ); // 150Hz
217
+ timerStart (g_timer3);
218
218
219
219
g_allocator = rcl_get_default_allocator ();
220
220
0 commit comments