-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.c
38 lines (35 loc) · 1.46 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "pico/stdlib.h"
#include "src/mrubyc.h"
#include "hardware/timer.h"
#include "hardware/clocks.h"
#include "hardware/irq.h"
#include "hardware/structs/scb.h"
#include "hardware/sync.h"
#define MEMORY_SIZE (1024*20)
uint8_t sample1[] = {
0x52,0x49,0x54,0x45,0x30,0x30,0x30,0x36,0xa3,0x22,0x00,0x00,0x00,0xa0,0x4d,0x41,
0x54,0x5a,0x30,0x30,0x30,0x30,0x49,0x52,0x45,0x50,0x00,0x00,0x00,0x82,0x30,0x30,
0x30,0x32,0x00,0x00,0x01,0x1f,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x37,
0x21,0x00,0x2c,0x10,0x01,0x4f,0x02,0x00,0x2e,0x01,0x00,0x01,0x10,0x01,0x07,0x02,
0x2e,0x01,0x01,0x01,0x10,0x01,0x07,0x02,0x2e,0x01,0x02,0x01,0x10,0x01,0x06,0x02,
0x2e,0x01,0x01,0x01,0x10,0x01,0x07,0x02,0x2e,0x01,0x02,0x01,0x11,0x01,0x22,0x01,
0x00,0x03,0x0f,0x01,0x37,0x01,0x67,0x00,0x00,0x00,0x01,0x00,0x00,0x0a,0x6f,0x6b,
0x20,0x6d,0x72,0x75,0x62,0x79,0x2f,0x63,0x00,0x00,0x00,0x03,0x00,0x04,0x70,0x75,
0x74,0x73,0x00,0x00,0x0a,0x6c,0x65,0x64,0x31,0x5f,0x77,0x72,0x69,0x74,0x65,0x00,
0x00,0x05,0x73,0x6c,0x65,0x65,0x70,0x00,0x45,0x4e,0x44,0x00,0x00,0x00,0x00,0x08,
};
static uint8_t memory_pool[MEMORY_SIZE];
static void c_led1_write(mrb_vm *vm, mrb_value *v, int argc) {
int set_value = GET_INT_ARG(1);
gpio_put(25,set_value);
}
int main() {
stdio_init_all();
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
mrbc_init(memory_pool, MEMORY_SIZE);
mrbc_define_method(0, mrbc_class_object, "led1_write", c_led1_write);
mrbc_create_task(sample1, 0);
mrbc_run();
return 1;
}