devices working
This commit is contained in:
30
src/device.h
30
src/device.h
@@ -1,18 +1,30 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct {
|
||||
#define DEVICE_BUFFER_LENGTH 128
|
||||
|
||||
typedef struct Device Device;
|
||||
struct Device {
|
||||
char name[32];
|
||||
|
||||
void (*sendToDevice)(uint16_t number);
|
||||
uint16_t (*receiveFromDevice)();
|
||||
void (*update)();
|
||||
} Device;
|
||||
uint16_t in[DEVICE_BUFFER_LENGTH];
|
||||
uint8_t inPos;
|
||||
|
||||
uint16_t out[DEVICE_BUFFER_LENGTH];
|
||||
uint8_t outPos;
|
||||
|
||||
void (*update)(Device* self);
|
||||
};
|
||||
|
||||
Device* createDevice(
|
||||
const char* name,
|
||||
void (*sendToDevice)(uint16_t number),
|
||||
uint16_t (*receiveFromDevice)(),
|
||||
void (*update)()
|
||||
);
|
||||
void (*update)(Device* self)
|
||||
);
|
||||
|
||||
uint16_t deviceRead(Device* self);
|
||||
void deviceSend(Device* self, uint16_t value);
|
||||
bool deviceCanRead(Device* self);
|
||||
Reference in New Issue
Block a user