Skip to content

Commit

Permalink
System call abstract and implementations for interrupts.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Feb 24, 2024
1 parent 4719b1f commit a4e0b0a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
38 changes: 38 additions & 0 deletions sdk/librishka/int.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka-sdk).
* Copyright (c) 2024 Nathanne Isip.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIBRISHKA_INT_H
#define LIBRISHKA_INT_H

#include <librishka/types.h>

typedef enum {
INT_CHANGE = 0x1,
INT_FAILING = 0x2,
INT_RISING = 0x3
} int_mode_t;

class Int {
public:
static void enable();
static void disable();

static void attach(u8 pin, void (*callback)(void), int_mode_t mode);
static void detach(u8 pin);
};

#endif
17 changes: 16 additions & 1 deletion sdk/librishka_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ enum rishka_syscall {
RISHKA_SC_INT_DISABLE,
RISHKA_SC_INT_ATTACH,
RISHKA_SC_INT_DETACH,
RISHKA_SC_INT_DIGITAL_PIN,

RISHKA_SC_FS_MKDIR,
RISHKA_SC_FS_RMDIR,
Expand Down Expand Up @@ -303,3 +302,19 @@ void Gpio::tone(u8 pin, u32 frequency, u64 duration) {
void Gpio::no_tone(u8 pin) {
rishka_sc_1(RISHKA_SC_GPIO_NO_TONE, (i64) pin);
}

void Int::enable() {
rishka_sc_0(RISHKA_SC_INT_ENABLE);
}

void Int::disable() {
rishka_sc_0(RISHKA_SC_INT_DISABLE);
}

void Int::attach(u8 pin, void (*callback)(void), int_mode_t mode) {
rishka_sc_3(RISHKA_SC_INT_ATTACH, (i64) pin, (i64) callback, (i64) mode);
}

void Int::detach(u8 pin) {
rishka_sc_1(RISHKA_SC_INT_DETACH, (i64) pin);
}

0 comments on commit a4e0b0a

Please sign in to comment.