epicardium.h 1.52 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
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* clang-format off */
#define API_UART_WRITE         0x1
#define API_UART_READ          0x2
#define API_LEDS_SET           0x3
/* 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
30
API(API_UART_WRITE, void epic_uart_write_str(const char *str, intptr_t length));
Rahix's avatar
Rahix committed
31

Rahix's avatar
Rahix committed
32
33
34
35
36
37
38
/**
 * 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
39
40
API(API_UART_READ, char epic_uart_read_chr(void));

Rahix's avatar
Rahix committed
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
 * 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.
 */
54
55
API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));

Gerd's avatar
Gerd committed
56
57
58
59
// turn vibration motor on or off
#define API_VIBRA_SET  0x4
API(API_VIBRA_SET, void epic_vibra_set(int status));

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