Skip to content

Commit

Permalink
Change all libdsp to libsx1262, preserve case
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Dec 14, 2021
1 parent 6596edd commit 9fe76d3
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 175 deletions.
22 changes: 11 additions & 11 deletions libs/libsx1262/Kconfig
Expand Up @@ -3,35 +3,35 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#

menuconfig LIBDSP
menuconfig LIBSX1262
bool "Digital Signal Processing Library"
default n
---help---
Enable build for various DSP functions

if LIBDSP
if LIBSX1262

config LIBDSP_DEBUG
bool "Libdsp debugging"
config LIBSX1262_DEBUG
bool "Libsx1262 debugging"
default n
---help---
Enable debugging for libdsp. This option enables additional parameters
Enable debugging for libsx1262. This option enables additional parameters
checking. It can drastically reduce performance and be potentially
dangerous to hardware, so it should be used carefully (probably only
at an early stage of application development).

config LIBDSP_PRECISION
int "Libdsp precision [0/1/2]"
config LIBSX1262_PRECISION
int "Libsx1262 precision [0/1/2]"
default 0
---help---
With this option we can select libdsp precision for
With this option we can select libsx1262 precision for
some of calculations. There are 3 available options:
0 - the fastest calculation but the lowest precision,
1 - increased precision than for option 0 at the expense
of a longer execution time,
2 - the most accuracte but the slowest one, use standard math functions.

config LIBDSP_FOC_VABC
bool "Libdsp FOC includes voltage abc frame"
config LIBSX1262_FOC_VABC
bool "Libsx1262 FOC includes voltage abc frame"

endif # LIBDSP
endif # LIBSX1262
6 changes: 3 additions & 3 deletions libs/libsx1262/Makefile
@@ -1,5 +1,5 @@
############################################################################
# libs/libdsp/Makefile
# libs/libsx1262/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
Expand All @@ -20,7 +20,7 @@

include $(TOPDIR)/Make.defs

ifeq ($(CONFIG_LIBDSP),y)
ifeq ($(CONFIG_LIBSX1262),y)
CSRCS += lib_pid.c
CSRCS += lib_svm.c
CSRCS += lib_transform.c
Expand All @@ -45,7 +45,7 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)

BIN ?= libdsp$(LIBEXT)
BIN ?= libsx1262$(LIBEXT)

all: $(BIN)
.PHONY: depend clean distclean
Expand Down
8 changes: 3 additions & 5 deletions libs/libsx1262/README.txt
@@ -1,6 +1,4 @@
libdsp
======
libsx1262
=========

This directory contains various DSP functions.

At the moment you will find here mainly functions related to BLDC/PMSM control.
This directory contains functions for Semtech SX1262 LoRa Transceiver.
38 changes: 19 additions & 19 deletions libs/libsx1262/lib_foc.c
@@ -1,5 +1,5 @@
/****************************************************************************
* libs/libdsp/lib_foc.c
* libs/libsx1262/lib_foc.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -52,8 +52,8 @@ static void foc_current_controller(FAR struct foc_data_f32_s *foc,
FAR pid_controller_f32_t *id_pid = &foc->id_pid;
FAR pid_controller_f32_t *iq_pid = &foc->iq_pid;

LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(v_dq_req != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(v_dq_req != NULL);

/* Get dq current error */

Expand Down Expand Up @@ -88,7 +88,7 @@ static void foc_current_controller(FAR struct foc_data_f32_s *foc,
static void foc_vab_mod_scale_set(FAR struct foc_data_f32_s *foc,
float scale)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

foc->vab_mod_scale = scale;
}
Expand All @@ -110,7 +110,7 @@ static void foc_vab_mod_scale_set(FAR struct foc_data_f32_s *foc,

static void foc_vdq_mag_max_set(FAR struct foc_data_f32_s *foc, float max)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

foc->vdq_mag_max = max;

Expand Down Expand Up @@ -138,8 +138,8 @@ static void foc_vdq_mag_max_set(FAR struct foc_data_f32_s *foc, float max)
static void foc_vdq_ref_set(FAR struct foc_data_f32_s *foc,
FAR dq_frame_f32_t *vdq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(vdq_ref != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(vdq_ref != NULL);

foc->v_dq.d = vdq_ref->d;
foc->v_dq.q = vdq_ref->q;
Expand All @@ -163,8 +163,8 @@ static void foc_vdq_ref_set(FAR struct foc_data_f32_s *foc,
static void foc_idq_ref_set(FAR struct foc_data_f32_s *foc,
FAR dq_frame_f32_t *idq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(idq_ref != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(idq_ref != NULL);

foc->i_dq_ref.d = idq_ref->d;
foc->i_dq_ref.q = idq_ref->q;
Expand Down Expand Up @@ -271,8 +271,8 @@ void foc_vbase_update(FAR struct foc_data_f32_s *foc, float vbase)
void foc_angle_update(FAR struct foc_data_f32_s *foc,
FAR phase_angle_f32_t *angle)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(angle != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(angle != NULL);

/* Copy angle to foc data */

Expand Down Expand Up @@ -304,8 +304,8 @@ void foc_iabc_update(FAR struct foc_data_f32_s *foc,
{
dq_frame_f32_t i_dq;

LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(i_abc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(i_abc != NULL);

/* Reset data */

Expand Down Expand Up @@ -350,7 +350,7 @@ void foc_iabc_update(FAR struct foc_data_f32_s *foc,
void foc_voltage_control(FAR struct foc_data_f32_s *foc,
FAR dq_frame_f32_t *vdq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

/* Update VDQ request */

Expand All @@ -360,7 +360,7 @@ void foc_voltage_control(FAR struct foc_data_f32_s *foc,

inv_park_transform(&foc->angle, &foc->v_dq, &foc->v_ab);

#ifdef CONFIG_LIBDSP_FOC_VABC
#ifdef CONFIG_LIBSX1262_FOC_VABC
/* Inverse Clarke transform (voltage alpha-beta -> voltage abc) */

inv_clarke_transform(&foc->v_ab, &foc->v_abc);
Expand Down Expand Up @@ -398,7 +398,7 @@ void foc_current_control(FAR struct foc_data_f32_s *foc,
FAR dq_frame_f32_t *vdq_comp,
FAR dq_frame_f32_t *vdq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

/* Update IDQ reference */

Expand Down Expand Up @@ -433,8 +433,8 @@ void foc_current_control(FAR struct foc_data_f32_s *foc,
void foc_vabmod_get(FAR struct foc_data_f32_s *foc,
FAR ab_frame_f32_t *v_ab_mod)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(v_ab_mod != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(v_ab_mod != NULL);

v_ab_mod->a = foc->v_ab_mod.a;
v_ab_mod->b = foc->v_ab_mod.b;
Expand All @@ -457,7 +457,7 @@ void foc_vabmod_get(FAR struct foc_data_f32_s *foc,

void foc_vdq_mag_max_get(FAR struct foc_data_f32_s *foc, FAR float *max)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

*max = foc->vdq_mag_max;
}
38 changes: 19 additions & 19 deletions libs/libsx1262/lib_foc_b16.c
@@ -1,5 +1,5 @@
/****************************************************************************
* libs/libdsp/lib_foc_b16.c
* libs/libsx1262/lib_foc_b16.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -52,8 +52,8 @@ static void foc_current_controller_b16(FAR struct foc_data_b16_s *foc,
FAR pid_controller_b16_t *id_pid = &foc->id_pid;
FAR pid_controller_b16_t *iq_pid = &foc->iq_pid;

LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(v_dq_req != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(v_dq_req != NULL);

/* Get dq current error */

Expand Down Expand Up @@ -88,7 +88,7 @@ static void foc_current_controller_b16(FAR struct foc_data_b16_s *foc,
static void foc_vab_mod_scale_set_b16(FAR struct foc_data_b16_s *foc,
b16_t scale)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

foc->vab_mod_scale = scale;
}
Expand All @@ -111,7 +111,7 @@ static void foc_vab_mod_scale_set_b16(FAR struct foc_data_b16_s *foc,
static void foc_vdq_mag_max_set_b16(FAR struct foc_data_b16_s *foc,
b16_t max)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

foc->vdq_mag_max = max;

Expand Down Expand Up @@ -139,8 +139,8 @@ static void foc_vdq_mag_max_set_b16(FAR struct foc_data_b16_s *foc,
static void foc_vdq_ref_set_b16(FAR struct foc_data_b16_s *foc,
FAR dq_frame_b16_t *vdq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(vdq_ref != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(vdq_ref != NULL);

foc->v_dq.d = vdq_ref->d;
foc->v_dq.q = vdq_ref->q;
Expand All @@ -164,8 +164,8 @@ static void foc_vdq_ref_set_b16(FAR struct foc_data_b16_s *foc,
static void foc_idq_ref_set_b16(FAR struct foc_data_b16_s *foc,
FAR dq_frame_b16_t *idq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(idq_ref != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(idq_ref != NULL);

foc->i_dq_ref.d = idq_ref->d;
foc->i_dq_ref.q = idq_ref->q;
Expand Down Expand Up @@ -272,8 +272,8 @@ void foc_vbase_update_b16(FAR struct foc_data_b16_s *foc, b16_t vbase)
void foc_angle_update_b16(FAR struct foc_data_b16_s *foc,
FAR phase_angle_b16_t *angle)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(angle != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(angle != NULL);

/* Copy angle to foc data */

Expand Down Expand Up @@ -305,8 +305,8 @@ void foc_iabc_update_b16(FAR struct foc_data_b16_s *foc,
{
dq_frame_b16_t i_dq;

LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(i_abc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(i_abc != NULL);

/* Reset data */

Expand Down Expand Up @@ -351,7 +351,7 @@ void foc_iabc_update_b16(FAR struct foc_data_b16_s *foc,
void foc_voltage_control_b16(FAR struct foc_data_b16_s *foc,
FAR dq_frame_b16_t *vdq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

/* Update VDQ request */

Expand All @@ -361,7 +361,7 @@ void foc_voltage_control_b16(FAR struct foc_data_b16_s *foc,

inv_park_transform_b16(&foc->angle, &foc->v_dq, &foc->v_ab);

#ifdef CONFIG_LIBDSP_FOC_VABC
#ifdef CONFIG_LIBSX1262_FOC_VABC
/* Inverse Clarke transform (voltage alpha-beta -> voltage abc) */

inv_clarke_transform_b16(&foc->v_ab, &foc->v_abc);
Expand Down Expand Up @@ -399,7 +399,7 @@ void foc_current_control_b16(FAR struct foc_data_b16_s *foc,
FAR dq_frame_b16_t *vdq_comp,
FAR dq_frame_b16_t *vdq_ref)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

/* Update IDQ reference */

Expand Down Expand Up @@ -434,8 +434,8 @@ void foc_current_control_b16(FAR struct foc_data_b16_s *foc,
void foc_vabmod_get_b16(FAR struct foc_data_b16_s *foc,
FAR ab_frame_b16_t *v_ab_mod)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBDSP_DEBUGASSERT(v_ab_mod != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(v_ab_mod != NULL);

v_ab_mod->a = foc->v_ab_mod.a;
v_ab_mod->b = foc->v_ab_mod.b;
Expand All @@ -458,7 +458,7 @@ void foc_vabmod_get_b16(FAR struct foc_data_b16_s *foc,

void foc_vdq_mag_max_get_b16(FAR struct foc_data_b16_s *foc, FAR b16_t *max)
{
LIBDSP_DEBUGASSERT(foc != NULL);
LIBSX1262_DEBUGASSERT(foc != NULL);

*max = foc->vdq_mag_max;
}
8 changes: 4 additions & 4 deletions libs/libsx1262/lib_misc.c
@@ -1,5 +1,5 @@
/****************************************************************************
* libs/libdsp/lib_misc.c
* libs/libsx1262/lib_misc.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -433,7 +433,7 @@ void angle_norm_2pi(FAR float *angle, float bottom, float top)

void phase_angle_update(FAR struct phase_angle_f32_s *angle, float val)
{
LIBDSP_DEBUGASSERT(angle != NULL);
LIBSX1262_DEBUGASSERT(angle != NULL);

/* Normalize angle to <0.0, 2PI> */

Expand All @@ -443,10 +443,10 @@ void phase_angle_update(FAR struct phase_angle_f32_s *angle, float val)

angle->angle = val;

#if CONFIG_LIBDSP_PRECISION == 1
#if CONFIG_LIBSX1262_PRECISION == 1
angle->sin = fast_sin2(val);
angle->cos = fast_cos2(val);
#elif CONFIG_LIBDSP_PRECISION == 2
#elif CONFIG_LIBSX1262_PRECISION == 2
angle->sin = sin(val);
angle->cos = cos(val);
#else
Expand Down
8 changes: 4 additions & 4 deletions libs/libsx1262/lib_misc_b16.c
@@ -1,5 +1,5 @@
/****************************************************************************
* libs/libdsp/lib_misc_b16.c
* libs/libsx1262/lib_misc_b16.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -100,7 +100,7 @@ b16_t vector2d_mag_b16(b16_t x, b16_t y)
return 0;
}

#if CONFIG_LIBDSP_PRECISION == 0
#if CONFIG_LIBSX1262_PRECISION == 0
/* Use ub8 sqrt */

return ub8toub16(ub16sqrtub8(t3));
Expand Down Expand Up @@ -435,7 +435,7 @@ void angle_norm_2pi_b16(FAR b16_t *angle, b16_t bottom, b16_t top)

void phase_angle_update_b16(FAR struct phase_angle_b16_s *angle, b16_t val)
{
LIBDSP_DEBUGASSERT(angle != NULL);
LIBSX1262_DEBUGASSERT(angle != NULL);

/* Normalize angle to <0.0, 2PI> */

Expand All @@ -445,7 +445,7 @@ void phase_angle_update_b16(FAR struct phase_angle_b16_s *angle, b16_t val)

angle->angle = val;

#if CONFIG_LIBDSP_PRECISION == 0
#if CONFIG_LIBSX1262_PRECISION == 0
angle->sin = fast_sin_b16(val);
angle->cos = fast_cos_b16(val);
#else
Expand Down

0 comments on commit 9fe76d3

Please sign in to comment.