2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <jni.h>
|
2018-05-13 17:09:56 -07:00
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
#include <wpi/jni_util.h>
|
|
|
|
|
|
|
|
|
|
#include "SimulatorJNI.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "hal/Types.h"
|
2019-09-23 23:28:49 -07:00
|
|
|
#include "hal/Value.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "hal/handles/UnlimitedHandleResource.h"
|
2020-06-27 22:11:24 -07:00
|
|
|
#include "hal/simulation/NotifyListener.h"
|
|
|
|
|
#include "hal/simulation/SPIData.h"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-12-28 01:19:59 -08:00
|
|
|
namespace hal::sim {
|
2018-05-11 12:38:23 -07:00
|
|
|
class SpiReadAutoReceiveBufferCallbackStore {
|
|
|
|
|
public:
|
|
|
|
|
void create(JNIEnv* env, jobject obj);
|
2018-12-06 22:29:20 -08:00
|
|
|
int32_t performCallback(const char* name, uint32_t* buffer,
|
2018-05-11 12:38:23 -07:00
|
|
|
int32_t numToRead);
|
|
|
|
|
void free(JNIEnv* env);
|
|
|
|
|
void setCallbackId(int32_t id) { callbackId = id; }
|
|
|
|
|
int32_t getCallbackId() { return callbackId; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
wpi::java::JGlobal<jobject> m_call;
|
|
|
|
|
int32_t callbackId;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void InitializeSpiBufferStore();
|
|
|
|
|
|
2020-12-27 22:52:53 -08:00
|
|
|
using RegisterSpiBufferCallbackFunc = int32_t (*)(
|
2018-05-11 12:38:23 -07:00
|
|
|
int32_t index, HAL_SpiReadAutoReceiveBufferCallback callback, void* param);
|
2020-12-27 22:52:53 -08:00
|
|
|
using FreeSpiBufferCallbackFunc = void (*)(int32_t index, int32_t uid);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
SIM_JniHandle AllocateSpiBufferCallback(
|
|
|
|
|
JNIEnv* env, jint index, jobject callback,
|
|
|
|
|
RegisterSpiBufferCallbackFunc createCallback);
|
|
|
|
|
void FreeSpiBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
|
|
|
|
FreeSpiBufferCallbackFunc freeCallback);
|
2020-12-28 01:19:59 -08:00
|
|
|
} // namespace hal::sim
|