77 lines
2.4 KiB
C
77 lines
2.4 KiB
C
#ifndef LINUXCNC_WEB_WASM_SIM_HAL_H
|
|
#define LINUXCNC_WEB_WASM_SIM_HAL_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define SIM_HAL_NAME_CAPACITY 48U
|
|
#define SIM_HAL_PIN_CAPACITY 256U
|
|
#define SIM_HAL_THREAD_CAPACITY 16U
|
|
#define SIM_HAL_FUNCTION_CAPACITY 64U
|
|
#define SIM_HAL_COMPONENT_CAPACITY 64U
|
|
#define SIM_HAL_PARAM_CAPACITY 256U
|
|
|
|
enum sim_hal_result {
|
|
SIM_HAL_OK = 0,
|
|
SIM_HAL_ERR_ARGUMENT = -300,
|
|
SIM_HAL_ERR_FULL = -301,
|
|
SIM_HAL_ERR_DUPLICATE = -302,
|
|
SIM_HAL_ERR_NOT_FOUND = -303,
|
|
SIM_HAL_ERR_TYPE = -304,
|
|
SIM_HAL_ERR_RANGE = -305,
|
|
SIM_HAL_ERR_CONNECTION = -306,
|
|
SIM_HAL_ERR_FUNCTION = -307,
|
|
SIM_HAL_ERR_REAL_EXCLUDED = -308,
|
|
};
|
|
|
|
enum sim_hal_type {
|
|
SIM_HAL_BIT = 1,
|
|
SIM_HAL_S32 = 2,
|
|
SIM_HAL_U32 = 3,
|
|
SIM_HAL_FLOAT = 4,
|
|
};
|
|
|
|
typedef struct sim_hal_value {
|
|
uint32_t type;
|
|
union {
|
|
uint32_t bit;
|
|
int32_t s32;
|
|
uint32_t u32;
|
|
float real;
|
|
} value;
|
|
} sim_hal_value;
|
|
|
|
void sim_hal_reset(void);
|
|
int32_t sim_hal_register_pin(const char *name, uint32_t type);
|
|
int32_t sim_hal_set_pin(const char *name, sim_hal_value value);
|
|
int32_t sim_hal_get_pin(const char *name, sim_hal_value *out);
|
|
int32_t sim_hal_connect(const char *source, const char *target);
|
|
int32_t sim_hal_register_thread(const char *name, uint32_t period_ticks);
|
|
int32_t sim_hal_register_function(const char *thread, const char *name);
|
|
/* Register a statically linked .comp component instance on a HAL thread. */
|
|
int32_t sim_hal_register_component(const char *instance, const char *type, const char *thread);
|
|
int32_t sim_hal_set_param(const char *name, sim_hal_value value);
|
|
int32_t sim_hal_get_param(const char *name, sim_hal_value *out);
|
|
uint32_t sim_hal_component_count(void);
|
|
uint32_t sim_hal_param_count(void);
|
|
/* Register the static LinuxCNC corexy_by_hal component and its servo pins. */
|
|
int32_t sim_hal_register_corexy_by_hal(const char *component, const char *thread);
|
|
/* Execute one deterministic CoreXY command/feedback transform immediately. */
|
|
int32_t sim_hal_corexy_transform(const char *component);
|
|
int32_t sim_hal_set_function_failure(const char *name, uint32_t fail);
|
|
int32_t sim_hal_step(uint32_t ticks);
|
|
uint32_t sim_hal_tick(void);
|
|
uint32_t sim_hal_function_calls(const char *name);
|
|
uint32_t sim_hal_pin_count(void);
|
|
uint32_t sim_hal_thread_count(void);
|
|
uint32_t sim_hal_function_count(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|