function [neg_on_err, dat] = pb_get_data_direct(num_points, data)
% FUNCTION NAME:
%   pb_get_data_direct
%
% DESCRIPTION:
%   For RadioProcessor boards used to bypass the Diital Quadrature Detection.
%
% OUTPUTS:
%   neg_on_err - A negative number is returned on failure, and spinerr is set to a 
%                description of the error. 0 is returned on success.
%
%   dat - Data stored in this array
%
% $Revision: R2017a$ 
% $Author: SpinCore Technologies, Inc.$
% $Date: November 17, 2023$
% ------------------------------------------------------------------------------

global SPINAPI_DLL_NAME;

% Create a C-style array of shorts using MATLAB's int16 type
c_data = zeros(1, num_points, 'int16');

% Assign the memory address of the c_data array to the pointer argument
data_pointer = libpointer('int16Ptr', c_data);

neg_on_err = calllib(SPINAPI_DLL_NAME, 'pb_get_data_direct', num_points, data_pointer);

% Retrieve the data from the pointer
dat = data_pointer.Value;

end
