47 lines
2.2 KiB
C
47 lines
2.2 KiB
C
/** SETCAN/GAS Altera Logic online stream, shared by CAN and UART.
|
|
* Caller-owned context; one serialized caller. No heap, OS or Qt dependencies.
|
|
*/
|
|
#ifndef ALTERA_STREAM_H
|
|
#define ALTERA_STREAM_H
|
|
#include "pcan_abi.h"
|
|
#include "pcan_frame.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#define LAS_DEVICE_TYPE 6U
|
|
#define LAS_DEVICE_ID 14U
|
|
#define LAS_GAS_META 0xFE00U
|
|
#define LAS_GAS_DATA 0xFF00U
|
|
#define LAS_CAPACITY 8192U
|
|
#define LAS_TAG 0x4C01U
|
|
enum { LAS_COUNT, LAS_PERIOD_NS, LAS_SESSION, LAS_RECEIVED, LAS_MISSING,
|
|
LAS_DUPLICATES, LAS_INVALID, LAS_IGNORED, LAS_CRC_ERRORS, LAS_HAS_META };
|
|
PCAN_ABI_API size_t las_context_size(void);
|
|
PCAN_ABI_API int las_init(void *ctx, uint32_t device_id);
|
|
PCAN_ABI_API void las_can(void *ctx, uint32_t id, const uint8_t *data, size_t size,
|
|
uint32_t extended, uint32_t remote);
|
|
PCAN_ABI_API void las_uart(void *ctx, const uint8_t *data, size_t size);
|
|
PCAN_ABI_API uint32_t las_get(const void *ctx, uint32_t field);
|
|
/** Chronological bounded history. breaks[i]=1 marks a discontinuity before i. */
|
|
PCAN_ABI_API size_t las_snapshot(const void *ctx, uint64_t *indices, uint16_t *samples,
|
|
uint8_t *breaks, size_t capacity);
|
|
/** Sparse step trace for rendering; capacity >= 2*LAS_COUNT, move=pen-up. */
|
|
PCAN_ABI_API size_t las_trace(const void *ctx, uint32_t channel, uint64_t *indices,
|
|
uint8_t *levels, uint8_t *moves, size_t capacity);
|
|
PCAN_ABI_API uint32_t las_device_type(void);
|
|
PCAN_ABI_API uint32_t las_device_id(void);
|
|
PCAN_ABI_API const char *las_device_name(void);
|
|
PCAN_ABI_API void las_demo_step(void *ctx, uint32_t count);
|
|
/** Device-side packet builders; return zero for invalid arguments.
|
|
* uart=0: 8-byte CAN data + *id; uart=1: complete AA55 transport + *id.
|
|
* Same builders are used by firmware ports, tests and the demo producer.
|
|
*/
|
|
PCAN_ABI_API size_t las_metadata(uint32_t device, uint32_t session, uint32_t period_ns,
|
|
uint32_t uart, uint32_t *id, uint8_t *out, size_t capacity);
|
|
PCAN_ABI_API size_t las_data(uint32_t device, uint32_t session, uint32_t index,
|
|
uint32_t sample, uint32_t uart, uint32_t *id, uint8_t *out, size_t capacity);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|