libnile
Loading...
Searching...
No Matches
protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Adrian "asie" Siekierka
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 *
17 * 2. Altered source versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software.
19 *
20 * 3. This notice may not be removed or altered from any source distribution.
21 */
22
23#ifndef NILE_MCU_PROTOCOL_H_
24#define NILE_MCU_PROTOCOL_H_
25
26#ifndef __ASSEMBLER__
27
28#include <stdint.h>
29
55
56typedef struct __attribute__((packed)) {
57 uint16_t status;
58 uint16_t caps;
59 uint16_t bat_voltage;
61
69
70typedef struct {
71 uint16_t major;
72 uint16_t minor;
74
75#endif /* __ASSEMBLER__ */
76
77#define NILE_MCU_NATIVE_SAVE_ID_DOMAIN_SRAM2 0x01
78#define NILE_MCU_NATIVE_SAVE_ID_DOMAIN_RTC 0x02
79
80#define NILE_MCU_NATIVE_REG_IRQ_ENABLE 0x000
81#define NILE_MCU_NATIVE_REG_IRQ_STATUS 0x001
82#define NILE_MCU_NATIVE_REG_IRQ_STATUS_AUTOACK 0x002
83
84#define NILE_MCU_NATIVE_IRQ_TF_INSERT 0x0001
85#define NILE_MCU_NATIVE_IRQ_TF_REMOVE 0x0002
86#define NILE_MCU_NATIVE_IRQ_RTC_ALARM 0x0004
87
88#define NILE_MCU_NATIVE_INFO_CAP_EEPROM 0x0001
89#define NILE_MCU_NATIVE_INFO_CAP_USB 0x0002
90#define NILE_MCU_NATIVE_INFO_CAP_ACCEL 0x0004
91#define NILE_MCU_NATIVE_INFO_CAP_RTC 0x0008
92#define NILE_MCU_NATIVE_INFO_RTC_LSE 0x0001
93#define NILE_MCU_NATIVE_INFO_RTC_ENABLED 0x0002
94#define NILE_MCU_NATIVE_INFO_USB_DETECT 0x0004
95#define NILE_MCU_NATIVE_INFO_USB_CONNECT 0x0008
96#define NILE_MCU_NATIVE_INFO_BATTERY_OK 0x0010
97
98#endif /* NILE_MCU_PROTOCOL_H_ */
nile_mcu_native_cmd_t
Definition protocol.h:30
@ NILE_MCU_NATIVE_CMD_REG_WRITE
Definition protocol.h:37
@ NILE_MCU_NATIVE_CMD_USB_CDC_WRITE
Definition protocol.h:48
@ NILE_MCU_NATIVE_CMD_FREQ
Definition protocol.h:33
@ NILE_MCU_NATIVE_CMD_VERSION
Definition protocol.h:38
@ NILE_MCU_NATIVE_CMD_ACCEL_READ
Definition protocol.h:53
@ NILE_MCU_NATIVE_CMD_ECHO
Definition protocol.h:31
@ NILE_MCU_NATIVE_CMD_USB_HID_WRITE
Definition protocol.h:49
@ NILE_MCU_NATIVE_CMD_SET_SAVE_ID
Definition protocol.h:45
@ NILE_MCU_NATIVE_CMD_MODE
Definition protocol.h:32
@ NILE_MCU_NATIVE_CMD_ID
Definition protocol.h:34
@ NILE_MCU_NATIVE_CMD_EEPROM_READ
Definition protocol.h:41
@ NILE_MCU_NATIVE_CMD_EEPROM_ERASE
Definition protocol.h:40
@ NILE_MCU_NATIVE_CMD_INFO
Definition protocol.h:35
@ NILE_MCU_NATIVE_CMD_USB_CDC_READ
Definition protocol.h:47
@ NILE_MCU_NATIVE_CMD_USB_CDC_FLUSH
Definition protocol.h:51
@ NILE_MCU_NATIVE_CMD_EEPROM_WRITE
Definition protocol.h:42
@ NILE_MCU_NATIVE_CMD_ACCEL_POLL
Definition protocol.h:52
@ NILE_MCU_NATIVE_CMD_USB_CDC_AVAILABLE
Definition protocol.h:50
@ NILE_MCU_NATIVE_CMD_GET_SAVE_ID
Definition protocol.h:46
@ NILE_MCU_NATIVE_CMD_REG_READ
Definition protocol.h:36
@ NILE_MCU_NATIVE_CMD_RTC_COMMAND
Definition protocol.h:43
@ NILE_MCU_NATIVE_CMD_EEPROM_GET_MODE
Definition protocol.h:44
@ NILE_MCU_NATIVE_CMD_EEPROM_MODE
Definition protocol.h:39
nile_mcu_native_mode_t
Definition protocol.h:62
@ NILE_MCU_NATIVE_MODE_STANDBY
MCU standby mode - will not respond to further SPI messages until reset.
Definition protocol.h:67
@ NILE_MCU_NATIVE_MODE_RTC
RTC emulation mode.
Definition protocol.h:65
@ NILE_MCU_NATIVE_MODE_CDC
CDC output-only mode.
Definition protocol.h:66
@ NILE_MCU_NATIVE_MODE_EEPROM
EEPROM emulation mode.
Definition protocol.h:64
@ NILE_MCU_NATIVE_MODE_CMD
Native command mode.
Definition protocol.h:63