hollyhock
Loading...
Searching...
No Matches
mcs.h
Go to the documentation of this file.
1
6#pragma once
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <stdint.h>
13
14#define __UCONCAT(a, b) #a b
15#define _UCONCAT(a, b) __UCONCAT(a, b)
16#define UCONCAT(b) _UCONCAT(__USER_LABEL_PREFIX__, b)
17
18#ifndef __clang__
19#define cstr(x) __attribute__((null_terminated_string_arg(x)))
20#define ro(...) __attribute__((access(read_only, __VA_ARGS__)))
21#define rw(...) __attribute__((access(read_write, __VA_ARGS__)))
22#define wo(...) __attribute__((access(write_only, __VA_ARGS__)))
23#else
24#define cstr(x)
25#define ro(...)
26#define rw(...)
27#define wo(...)
28#endif
29
30#define wu __attribute__((warn_unused_result))
31#define inline inline __attribute__((always_inline))
32
38
43
48
53
58
63
68
72 VARTYPE_GEO = 0x54
73};
74
76 MCS_OK = 0x00,
77
82
87
92
97
102
106 MCS_INDEX_OOB = 0x63
108
116#define GET_BCD_DIGIT(n, i) (((n) >> ((i) * 4)) & 0xF)
117
123struct OBCD {
124 uint8_t mantissa[10];
125 uint16_t exponent;
126};
127
133struct CBCD {
134 struct OBCD re;
135 struct OBCD im;
136};
137
152extern enum MCS_Error (*MCS_CreateFolder)(const char *folder, uint8_t *folderIndex) wu cstr(1);
153
154extern enum MCS_Error (*MCS_GetVariableU)(
155 const char *folder, const char *name,
156 uint8_t *variableType, char **name2, void **data, uint32_t *size
157) __asm__ (UCONCAT("MCS_GetVariable")) wu cstr(1) cstr(2) ro(1) ro(2) wo(3) wo(4) wo(5);
158
171static inline wu cstr(1) cstr(2) ro(1) ro(2) wo(3) wo(4) wo(5) enum MCS_Error MCS_GetVariable(
172 const char *folder, const char *name,
173 enum MCS_VariableType *variableType, char **name2, void **data, uint32_t *size
174) {
175 return MCS_GetVariableU(folder, name, (uint8_t *)variableType, name2, data, size);
176}
177
178extern enum MCS_Error (*MCS_List_CreateU)(
179 const char *folder, const char *name,
180 uint32_t size, uint16_t length, uint8_t variableType
181) __asm__ (UCONCAT("MCS_List_Create")) wu cstr(1) cstr(2) ro(1) ro(2);
182
199static inline wu cstr(1) cstr(2) ro(1) ro(2) enum MCS_Error MCS_List_Create(
200 const char *folder, const char *name,
201 uint32_t size, uint16_t length, enum MCS_VariableType variableType
202) {
203 return MCS_List_CreateU(folder, name, size, length, (uint8_t)variableType);
204}
205
206extern enum MCS_Error (*MCS_List_SetU)(
207 const char *folder, const char *name,
208 uint32_t size, unsigned int index, uint8_t variableType, void *data
209) __asm__ (UCONCAT("MCS_List_Set")) wu cstr(1) cstr(2) ro(1) ro(2) ro(6, 3);
210
226static inline wu cstr(1) cstr(2) ro(1) ro(2) ro(6, 3) enum MCS_Error MCS_List_Set(
227 const char *folder, const char *name,
228 uint32_t size, unsigned int index, enum MCS_VariableType variableType, void *data
229) {
230 return MCS_List_SetU(folder, name, size, index, (uint8_t)variableType, data);
231}
232
233extern enum MCS_Error (*MCS_SetVariableU)(
234 const char *folder, const char *name,
235 uint8_t variableType, uint32_t size, void *data
236) __asm__ (UCONCAT("MCS_SetVariable")) wu cstr(1) cstr(2) ro(1) ro(2) ro(5, 4);
237
254static inline wu cstr(1) cstr(2) ro(1) ro(2) ro(5, 4) enum MCS_Error MCS_SetVariable(
255 const char *folder, const char *name,
256 enum MCS_VariableType variableType, uint32_t size, void *data
257) {
258 return MCS_SetVariableU(folder, name, (uint8_t)variableType, size, data);
259}
260
261#undef cstr
262#undef ro
263#undef rw
264#undef wo
265#undef __UCONCAT
266#undef _UCONCAT
267#undef UCONCAT
268#undef wu
269#undef inline
270
271#ifdef __cplusplus
272}
273#endif
MCS_VariableType
Definition mcs.h:33
@ VARTYPE_STR
Definition mcs.h:47
@ VARTYPE_MAT
Definition mcs.h:57
@ VARTYPE_GEO
Definition mcs.h:72
@ VARTYPE_LIST
Definition mcs.h:52
@ VARTYPE_PRGM
Definition mcs.h:62
@ VARTYPE_OBCD
Definition mcs.h:37
@ VARTYPE_FUNC
Definition mcs.h:67
@ VARTYPE_CBCD
Definition mcs.h:42
MCS_Error
Definition mcs.h:75
@ MCS_NOT_LIST
Definition mcs.h:101
@ MCS_INDEX_OOB
Definition mcs.h:106
@ MCS_FOLDER_EXISTS
Definition mcs.h:91
@ MCS_NO_FOLDER
Definition mcs.h:86
@ MCS_NO_VARIABLE
Definition mcs.h:81
@ MCS_SIZE_NOT_PO2
Definition mcs.h:96
enum MCS_Error(* MCS_CreateFolder)(const char *folder, uint8_t *folderIndex) wu cstr(1)
Definition mcs.h:133
Definition mcs.h:123