initialize ad9833 and mcp41

This commit is contained in:
2023-05-21 21:09:07 +02:00
parent 26f5cfe3ce
commit 40e0ca1d0c
15 changed files with 237 additions and 178 deletions

View File

@@ -3,6 +3,7 @@
#include "ctrl_bottom_button.h"
#include "ctrl_channel_button.h"
#include "ctrl_encoder.h"
#include "ctrl_generator.h"
#include "ctrl_app.h"
@@ -24,7 +25,7 @@ static const uint32_t pow_of_10[7] = {1, 10, 100, 1000, 10000, 100000, 1000000};
static HW_BotBtnName_t last_key;
static APP_data_t *_app_data;
static const GENERATOR_t generators[CHANNEL_MAX] = {
static GENERATOR_t generators[CHANNEL_MAX] = {
{.gen_type = GEN_FG_TYPE, .gen = &func_gen[0]},
{.gen_type = GEN_FG_TYPE, .gen = &func_gen[1]},
{.gen_type = GEN_FG_TYPE, .gen = &func_gen[2]},
@@ -55,13 +56,15 @@ void APP_init(APP_data_t *app_data)
_app_data->isButtonBlink = 1;
CTRL_buttonsInit();
HAL_GPIO_WritePin(LED_CH1_GPIO_Port, LED_CH1_Pin, GPIO_PIN_SET);
gen_init();
}
void CTRL_buttonsInit(void)
{
CTRL_bottomButtonInit();
// CTRL_channelButtonInit();
CTRL_channelButtonInit();
}
void CTRL_buttonsHandler(void)
@@ -84,6 +87,25 @@ void CTRL_pushedChanBtnEvent(ButtonKey_t *key)
UNUSED(key);
}
void CTRL_longPushedChanBtnEvent(ButtonKey_t *key)
{
ULOG_TRACE("Chan btn(long): %d", key->instance);
GEN_fg_t *dds_ch0 = generators[key->instance].gen;
if (dds_ch0->enabled)
{
dds_ch0->enabled = FALSE;
setEnabled(&generators[CHANNEL1], CHANNEL1);
HAL_GPIO_WritePin(LED_CH1_GPIO_Port, LED_CH1_Pin, GPIO_PIN_SET);
}
else
{
dds_ch0->enabled = TRUE;
setEnabled(&generators[CHANNEL1], CHANNEL1);
HAL_GPIO_WritePin(LED_CH1_GPIO_Port, LED_CH1_Pin, GPIO_PIN_RESET);
}
UNUSED(key);
}
static void _changeValueFunGen(int8_t dir)
{
GEN_fg_t *gen = (GEN_fg_t *)_app_data->generator;
@@ -99,6 +121,7 @@ static void _changeValueFunGen(int8_t dir)
return;
}
gen->frequency = new_freq;
setFreq(&generators[CHANNEL1], CHANNEL1);
break;
}
case LAY_AMPL:
@@ -110,6 +133,7 @@ static void _changeValueFunGen(int8_t dir)
return;
}
gen->amplitude = new_ampl;
setAmplitude(&generators[CHANNEL1], CHANNEL1);
break;
}
case LAY_OFFS:
@@ -121,6 +145,7 @@ static void _changeValueFunGen(int8_t dir)
return;
}
gen->offset = new_offs;
setOfsset(&generators[CHANNEL1], CHANNEL1);
break;
}
case LAY_PHAS:
@@ -158,6 +183,7 @@ static void _changeValuePwmGen(int8_t dir)
return;
}
gen->frequency = new_freq;
break;
}
case LAY_AMPL:
@@ -169,6 +195,7 @@ static void _changeValuePwmGen(int8_t dir)
return;
}
gen->amplitude = new_ampl;
break;
}
case LAY_OFFS:
@@ -180,6 +207,7 @@ static void _changeValuePwmGen(int8_t dir)
return;
}
gen->offset = new_offs;
break;
}
case LAY_PHAS: