1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (c) 2010 Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 extern JNIEnv
*env_ptr
;
28 extern jclass RockboxActivity_class
;
29 extern jobject RockboxActivity_instance
;
31 static jclass RockboxTimer_class
;
32 static jobject RockboxTimer_instance
;
34 int set_irq_level(int level
)
41 JNIEXPORT
void JNICALL
42 Java_org_rockbox_RockboxTimer_timerTask(JNIEnv
*env
, jobject
this)
49 void tick_start(unsigned int interval_in_ms
)
51 /* first, get the RockboxTimer instance allocated by RockboxActivity */
52 jfieldID tim
= (*env_ptr
)->GetFieldID(env_ptr
,
53 RockboxActivity_class
,
55 "Lorg/rockbox/RockboxTimer;");
57 RockboxTimer_instance
= (*env_ptr
)->GetObjectField(env_ptr
,
58 RockboxActivity_instance
,
60 RockboxTimer_class
= (*env_ptr
)->GetObjectClass(env_ptr
,
61 RockboxTimer_instance
);
63 /* now find its tick start method and call it */
64 jmethodID java_tick_start
= (*env_ptr
)->GetMethodID(env_ptr
,
68 (*env_ptr
)->CallVoidMethod(env_ptr
,
69 RockboxTimer_instance
,
71 (jlong
)interval_in_ms
);
74 bool timer_register(int reg_prio
, void (*unregister_callback
)(void),
75 long cycles
, void (*timer_callback
)(void))
78 (void)unregister_callback
;
84 bool timer_set_period(long cycles
)
90 void timer_unregister(void)