mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 16:01:18 +01:00
Merge pull request #428 from mehlis/native-ltc-fix
Native ltc fixes and cleanup
This commit is contained in:
commit
e890b227e1
@ -22,30 +22,37 @@
|
||||
#include <err.h>
|
||||
|
||||
#include "ltc4150_arch.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "cpu.h"
|
||||
#include "cpu-conf.h"
|
||||
#include "hwtimer.h"
|
||||
#include "irq.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
#define native_ltc4150_startup_delay 10
|
||||
#define LTC_TIMER_INTERVAL (10 * 1000UL) // 10 ms
|
||||
|
||||
static int _int_enabled;
|
||||
static int hwtimer_id;
|
||||
static int _native_ltc_hwtimer_id = -1;
|
||||
|
||||
/**
|
||||
* native ltc4150 hwtimer - interrupt handler proxy
|
||||
*/
|
||||
static void _int_handler()
|
||||
static void _native_ltc_int_handler()
|
||||
{
|
||||
DEBUG("ltc4150 _int_handler()\n");
|
||||
ltc4150_interrupt();
|
||||
if (_int_enabled == 1) {
|
||||
hwtimer_id = hwtimer_set(LTC_TIMER_INTERVAL, _int_handler, NULL);
|
||||
if (hwtimer_id == -1) {
|
||||
DEBUG("_native_ltc_int_handler()\n");
|
||||
if (_native_ltc_hwtimer_id != -1) {
|
||||
ltc4150_interrupt();
|
||||
_native_ltc_hwtimer_id = hwtimer_set(LTC_TIMER_INTERVAL, _native_ltc_int_handler, NULL);
|
||||
if (_native_ltc_hwtimer_id == -1) {
|
||||
errx(1, "_int_handler: hwtimer_set");
|
||||
}
|
||||
else {
|
||||
DEBUG("_native_ltc_int_handler: _native_ltc_hwtimer_id is %d\n", _native_ltc_hwtimer_id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG("_native_ltc_int_handler was called although no hwtimer is set\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,9 +61,13 @@ static void _int_handler()
|
||||
*/
|
||||
void ltc4150_disable_int(void)
|
||||
{
|
||||
unsigned state = disableIRQ();
|
||||
DEBUG("ltc4150_disable_int()\n");
|
||||
_int_enabled = 0;
|
||||
hwtimer_remove(hwtimer_id);
|
||||
if (_native_ltc_hwtimer_id != -1) {
|
||||
hwtimer_remove(_native_ltc_hwtimer_id);
|
||||
_native_ltc_hwtimer_id = -1;
|
||||
}
|
||||
restoreIRQ(state);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,11 +76,13 @@ void ltc4150_disable_int(void)
|
||||
void ltc4150_enable_int(void)
|
||||
{
|
||||
DEBUG("ltc4150_enable_int()\n");
|
||||
_int_enabled = 1;
|
||||
hwtimer_id = hwtimer_set(LTC_TIMER_INTERVAL, _int_handler, NULL);
|
||||
if (hwtimer_id == -1) {
|
||||
_native_ltc_hwtimer_id = hwtimer_set(LTC_TIMER_INTERVAL, _native_ltc_int_handler, NULL);
|
||||
if (_native_ltc_hwtimer_id == -1) {
|
||||
errx(1, "ltc4150_enable_int: hwtimer_set");
|
||||
}
|
||||
else {
|
||||
DEBUG("ltc4150_enable_int: _native_ltc_hwtimer_id is %d\n", _native_ltc_hwtimer_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,8 +91,6 @@ void ltc4150_enable_int(void)
|
||||
void ltc4150_sync_blocking(void)
|
||||
{
|
||||
DEBUG("ltc4150_sync_blocking()\n");
|
||||
|
||||
for (int i = native_ltc4150_startup_delay; i > 0; i--);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user