extracted structs from vnproglib and made them usable for uC

This commit is contained in:
r.koeppe
2024-05-16 01:40:25 +02:00
parent d73e593f9e
commit 63ca3e03b2
14 changed files with 2116 additions and 146 deletions

View File

@ -0,0 +1,3 @@
#include "vn-interface/vn200.h"
namespace vn {} // namespace vn

View File

@ -0,0 +1,20 @@
#include "vn-interface/math/matrix.h"
#include "vn-interface/types.h"
void vn_m3_init_fa(mat3f *m, const float *fa) {
size_t i;
for (i = 0; i < 9; i++)
m->e[i] = fa[i];
}
mat3f vnm_negative_mat3f(mat3f m) {
mat3f r;
size_t i;
for (i = 0; i < 3 * 3; i++)
r.e[i] = -m.e[i];
return r;
}

View File

@ -0,0 +1,118 @@
#include "vn/math/vector.h"
#include <stdio.h>
vec3d create_v3d(double x, double y, double z)
{
vec3d v;
v.c[0] = x;
v.c[1] = y;
v.c[2] = z;
return v;
}
void vn_v3_init_fa(vec3f* v, const float* fa)
{
size_t i;
for (i = 0; i < 3; i++)
v->c[i] = fa[i];
}
vec3f add_v3f_v3f(vec3f lhs, vec3f rhs)
{
vec3f r;
r.c[0] = lhs.c[0] + rhs.c[0];
r.c[1] = lhs.c[1] + rhs.c[1];
r.c[2] = lhs.c[2] + rhs.c[2];
return r;
}
vec3d add_v3d_v3d(vec3d lhs, vec3d rhs)
{
vec3d r;
r.c[0] = lhs.c[0] + rhs.c[0];
r.c[1] = lhs.c[1] + rhs.c[1];
r.c[2] = lhs.c[2] + rhs.c[2];
return r;
}
vec4f add_v4f_v4f(vec4f lhs, vec4f rhs)
{
vec4f r;
r.c[0] = lhs.c[0] + rhs.c[0];
r.c[1] = lhs.c[1] + rhs.c[1];
r.c[2] = lhs.c[2] + rhs.c[2];
r.c[3] = lhs.c[3] + rhs.c[3];
return r;
}
vec3f sub_v3f_v3f(vec3f lhs, vec3f rhs)
{
vec3f r;
r.c[0] = lhs.c[0] - rhs.c[0];
r.c[1] = lhs.c[1] - rhs.c[1];
r.c[2] = lhs.c[2] - rhs.c[2];
return r;
}
vec3d sub_v3d_v3d(vec3d lhs, vec3d rhs)
{
vec3d r;
r.c[0] = lhs.c[0] - rhs.c[0];
r.c[1] = lhs.c[1] - rhs.c[1];
r.c[2] = lhs.c[2] - rhs.c[2];
return r;
}
vec4f sub_v4f_v4f(vec4f lhs, vec4f rhs)
{
vec4f r;
r.c[0] = lhs.c[0] - rhs.c[0];
r.c[1] = lhs.c[1] - rhs.c[1];
r.c[2] = lhs.c[2] - rhs.c[2];
r.c[3] = lhs.c[3] - rhs.c[3];
return r;
}
#if defined(_MSC_VER)
/* Disable warnings regarding using sprintf_s since these
* function signatures do not provide us with information
* about the length of 'out'. */
#pragma warning(push)
#pragma warning(disable:4996)
#endif
void str_vec3f(char* out, vec3f v)
{
sprintf(out, "(%f; %f; %f)", v.c[0], v.c[1], v.c[2]);
}
void str_vec3d(char* out, vec3d v)
{
sprintf(out, "(%f; %f; %f)", v.c[0], v.c[1], v.c[2]);
}
void str_vec4f(char* out, vec4f v)
{
sprintf(out, "(%f; %f; %f; %f)", v.c[0], v.c[1], v.c[2], v.c[3]);
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

View File

@ -0,0 +1,15 @@
#include "vn-interface/registers.h"
void BinaryOutputRegister_initialize(BinaryOutputRegister *reg, AsyncMode asyncMode, uint32_t rateDivisor, CommonGroup commonField,
TimeGroup timeField, ImuGroup imuField, GpsGroup gpsField, AttitudeGroup attitudeField, InsGroup insField,
GpsGroup gps2Field) {
reg->asyncMode = asyncMode;
reg->rateDivisor = (uint16_t)rateDivisor;
reg->commonField = commonField;
reg->timeField = timeField;
reg->imuField = imuField;
reg->gpsField = gpsField;
reg->attitudeField = attitudeField;
reg->insField = insField;
reg->gps2Field = gps2Field;
}

View File

@ -1,5 +0,0 @@
#include "vn-interface/vn200.h"
namespace VN200 {
namespace SPI {} // namespace SPI
} // namespace VN200