epicardium.h 1.82 KB
Newer Older
Rahix's avatar
Rahix committed
1
2
3
4
5
#ifndef _EPICARDIUM_H
#define _EPICARDIUM_H
#include <stdint.h>

#ifndef API
Rahix's avatar
Rahix committed
6
#define API(id, def) def
Rahix's avatar
Rahix committed
7
8
#endif

Rahix's avatar
Rahix committed
9
10
11
12
/* clang-format off */
#define API_UART_WRITE         0x1
#define API_UART_READ          0x2
#define API_LEDS_SET           0x3
Rahix's avatar
Rahix committed
13
#define API_VIBRA_SET          0x4
14
#define API_VIBRA_VIBRATE      0x5
Rahix's avatar
Rahix committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* clang-format on */

/**
 * UART/Serial Interface
 * =====================
 */

/**
 * Write a string to all connected serial devices.  This includes:
 *
 * - Real UART, whose pins are mapped onto USB-C pins.  Accessible via the HW-debugger.
 * - A CDC-ACM device available via USB.
 * - Maybe, in the future, bluetooth serial?
 *
 * :param str:  String to write.  Does not necessarily have to be NULL-terminated.
 * :param length:  Amount of bytes to print.
 */
Rahix's avatar
Rahix committed
32
API(API_UART_WRITE, void epic_uart_write_str(const char *str, intptr_t length));
Rahix's avatar
Rahix committed
33

Rahix's avatar
Rahix committed
34
35
36
37
38
39
40
/**
 * Blocking read a single character from any connected serial device.
 * ``epic_uart_read_chr`` only returns
 * once one byte has been read.
 *
 * :return:  The byte.
 */
Rahix's avatar
Rahix committed
41
42
API(API_UART_READ, char epic_uart_read_chr(void));

Rahix's avatar
Rahix committed
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * LEDs
 * ====
 */

/**
 * Set one of card10's RGB LEDs to a certain color.
 *
 * :param led:  Which led to set.  0-10 are the leds on the top and 11-14 are the 4 "ambient" leds.
 * :param r:  Red component of the color.
 * :param g:  Green component of the color.
 * :param b:  Blue component of the color.
 */
56
57
API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));

Rahix's avatar
Rahix committed
58
59
60
61
62
63
64
65
66
67
/**
 * Misc
 * ====
 */

/**
 * Turn vibration motor on or off
 *
 * :param status: 1 to turn on, 0 to turn off.
 */
Gerd's avatar
Gerd committed
68
69
API(API_VIBRA_SET, void epic_vibra_set(int status));

70
71
72
73
74
75
76
/**
 * Turn vibration motor on for a given time
 *
 * :param millis: number of milliseconds to run the vibration motor.
 */
API(API_VIBRA_VIBRATE, void epic_vibra_vibrate(int millis));

Rahix's avatar
Rahix committed
77
#endif /* _EPICARDIUM_H */