Skip to content

Commit

Permalink
Config PowerOutputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon-Knight committed Oct 27, 2024
1 parent 02c2656 commit 69bb6da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/Analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace Analog

if(address == 15)
{
DEBUG_LOG_TOPIC("MUX", "%04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d\n", adc_value[0], adc_value[1], adc_value[2], adc_value[3], adc_value[4],
adc_value[5], adc_value[6], adc_value[7], adc_value[8], adc_value[9], adc_value[10], adc_value[11], adc_value[12], adc_value[13], adc_value[14], adc_value[15]);
//DEBUG_LOG_TOPIC("MUX", "%04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d %04d\n", adc_value[0], adc_value[1], adc_value[2], adc_value[3], adc_value[4],
//adc_value[5], adc_value[6], adc_value[7], adc_value[8], adc_value[9], adc_value[10], adc_value[11], adc_value[12], adc_value[13], adc_value[14], adc_value[15]);
}

return;
Expand Down
38 changes: 28 additions & 10 deletions include/OutputLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,44 @@ extern ADC_HandleTypeDef hadc1;
namespace Outputs
{
/* Настройки */
static constexpr uint8_t CFG_PortCount = 6; // Кол-во портов управления.
static constexpr uint32_t CFG_RefVoltage = 3324000; // Опорное напряжение, микровольты.
static constexpr uint8_t CFG_PortCount = 8; // Кол-во портов управления.
static constexpr uint32_t CFG_RefVoltage = 3300000; // Опорное напряжение, микровольты.
static constexpr uint8_t CFG_INA180_Gain = 50; // Усиление микросхемы INA180.
static constexpr uint8_t CFG_ShuntResistance = 5; // Сопротивление шунта, миллиомы.
/* */

PowerOut<CFG_PortCount> outObj(&hadc1, CFG_RefVoltage, CFG_INA180_Gain, CFG_ShuntResistance);



void OnExternalControl(uint8_t external_id, GPIO_PinState state)
{
SPI::hc595.SetState(0, external_id, state);
}

void OnShortCircuit(uint8_t num, uint16_t current)
{

}


inline void Setup()
{
/*
outObj.AddPort( {GPIOA, GPIO_PIN_8}, {GPIOA, ADC_CHANNEL_6}, 5000 );
outObj.AddPort( {GPIOB, GPIO_PIN_15}, {GPIOA, ADC_CHANNEL_5}, 5000 );
outObj.AddPort( {GPIOB, GPIO_PIN_14}, {GPIOA, ADC_CHANNEL_4}, 5000 );
outObj.AddPort( {GPIOB, GPIO_PIN_13}, {GPIOA, ADC_CHANNEL_3}, 5000 );
outObj.AddPort( {GPIOB, GPIO_PIN_12}, {GPIOA, ADC_CHANNEL_2}, 5000 );
outObj.AddPort( {GPIOB, GPIO_PIN_2}, {GPIOA, ADC_CHANNEL_1}, 10000 );
outObj.AddPort( 0, {GPIOA, GPIO_PIN_1, ADC_CHANNEL_1}, 20000 ); // Выход HiPower-1
outObj.AddPort( 7, {GPIOB, GPIO_PIN_0, ADC_CHANNEL_8}, 5000 ); // Выход 1
outObj.AddPort( 1, {GPIOA, GPIO_PIN_2, ADC_CHANNEL_2}, 5000 ); // Выход 2
outObj.AddPort( 2, {GPIOA, GPIO_PIN_3, ADC_CHANNEL_3}, 5000 ); // Выход 3
outObj.AddPort( 3, {GPIOA, GPIO_PIN_4, ADC_CHANNEL_4}, 5000 ); // Выход 4
outObj.AddPort( 4, {GPIOA, GPIO_PIN_5, ADC_CHANNEL_5}, 5000 ); // Выход 5
outObj.AddPort( 5, {GPIOA, GPIO_PIN_6, ADC_CHANNEL_6}, 5000 ); // Выход 6
outObj.AddPort( 6, {GPIOA, GPIO_PIN_7, ADC_CHANNEL_7}, 5000 ); // Выход 7

outObj.Init();
*/

//outObj.On(4);
//outObj.On(6);
//outObj.Off(1);
outObj.RegExternalControlEvent(OnExternalControl);
outObj.RegShortCircuitEvent(OnShortCircuit);
//outObj.Current(1);

Expand All @@ -41,6 +52,9 @@ namespace Outputs

return;
}


uint8_t test_iter = 1;

inline void Loop(uint32_t &current_time)
{
Expand All @@ -50,6 +64,10 @@ namespace Outputs
if(current_time - last_time > 250)
{
last_time = current_time;

outObj.SetOff(test_iter++);
if(test_iter == 9) test_iter = 1;
outObj.SetOn(test_iter);

for(uint8_t i = 1; i < CFG_PortCount+1; ++i)
{
Expand Down

0 comments on commit 69bb6da

Please sign in to comment.