You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.1 KiB
C
134 lines
4.1 KiB
C
4 weeks ago
|
/*
|
||
|
* PWMABCInterace.h
|
||
|
*
|
||
|
* Author: Aleksey Gerasimenko
|
||
|
* gerasimenko.aleksey.n@gmail.com
|
||
|
*/
|
||
|
|
||
|
#include "PERIPHERY/PWMInterface.h"
|
||
|
|
||
|
|
||
|
|
||
|
#ifndef PERIPHERY_PWMABCINTERACE_H_
|
||
|
#define PERIPHERY_PWMABCINTERACE_H_
|
||
|
|
||
|
namespace PERIPHERY
|
||
|
{
|
||
|
|
||
|
struct PWMABCInterfaceConfiguration: public PWMInterfaceConfiguration
|
||
|
{
|
||
|
uint16_t cascade_quantity[3];
|
||
|
uint16_t cell_quantity[3];
|
||
|
uint16_t cell_quantity_in_cascade[3][18];
|
||
|
PWMABCInterfaceConfiguration():
|
||
|
PWMInterfaceConfiguration(),
|
||
|
cascade_quantity(),
|
||
|
cell_quantity(),
|
||
|
cell_quantity_in_cascade()
|
||
|
{}
|
||
|
};//PWMInterfaceConfiguration
|
||
|
|
||
|
|
||
|
struct PWMABCPhaseValueStructure
|
||
|
{
|
||
|
uint16_t pwm_frequency;
|
||
|
uint16_t adc_isr_multiplier;
|
||
|
uint16_t cascade_quantity[3];
|
||
|
uint16_t cell_quantity_in_phase[3];
|
||
|
uint16_t cmp[3];
|
||
|
uint16_t order;
|
||
|
uint16_t pwm_state[3];
|
||
|
uint16_t pwm_version[3];
|
||
|
uint16_t cell_quantity_in_cascade[3][18];
|
||
|
uint16_t breakdown_cell_state[3];
|
||
|
PWMBreakdownCellAddressRegister breakdown_cell_address[3];
|
||
|
PWMABCPhaseValueStructure():
|
||
|
pwm_frequency(0),
|
||
|
adc_isr_multiplier(1),
|
||
|
cascade_quantity(),
|
||
|
cell_quantity_in_phase(),
|
||
|
cmp(),
|
||
|
order(0),
|
||
|
pwm_state(),
|
||
|
pwm_version(),
|
||
|
cell_quantity_in_cascade(),
|
||
|
breakdown_cell_state(),
|
||
|
breakdown_cell_address()
|
||
|
{}
|
||
|
};//PWMABCPhaseValueStructure
|
||
|
|
||
|
|
||
|
struct PWMABCStructureReference: public PWMABCPhaseValueStructure
|
||
|
{
|
||
|
uint16_t broadcast_order;
|
||
|
uint16_t broadcast_cell_quantity;
|
||
|
uint16_t broadcast_freq;
|
||
|
PWMHardFaultRegister hard_fault;
|
||
|
PWMABCStructureReference():
|
||
|
PWMABCPhaseValueStructure(),
|
||
|
broadcast_order(),
|
||
|
broadcast_cell_quantity(),
|
||
|
broadcast_freq(),
|
||
|
hard_fault()
|
||
|
{}
|
||
|
};//PWMABCStructureReference
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class PWMABCInterace: public PWMInterface
|
||
|
{
|
||
|
private:
|
||
|
uint16_t m_counter_phase;
|
||
|
private:
|
||
|
uint16_t m_telemetry_phase_counter;
|
||
|
uint16_t m_telemetry_phase_quantity;
|
||
|
private:
|
||
|
PWMPhaseStructure m_phase[3];
|
||
|
public:
|
||
|
PWMABCInterace();
|
||
|
public:
|
||
|
void setup(uint16_t *memzone);
|
||
|
void setup(const PWMStructureSetup& setup);
|
||
|
void setup(uint16_t *memzone, const PWMStructureSetup& setup);
|
||
|
public:
|
||
|
void initialization(PWMABCInterfaceConfiguration& config);
|
||
|
private:
|
||
|
void _setup_phase(PWMPhaseStructure& phase, uint16_t *base);
|
||
|
//
|
||
|
public:
|
||
|
void set_frequency(uint16_t freq);
|
||
|
void set_cascade_quantity();
|
||
|
void set_cell_quantity_phase(uint16_t quant_a, uint16_t quant_b, uint16_t quant_c);
|
||
|
void set_cmp(uint16_t cmpra, uint16_t cmprb, uint16_t cmprc);
|
||
|
void set_order(uint16_t order);
|
||
|
void get_board_state(uint16_t& state_pwm_a, uint16_t& state_pwm_b, uint16_t& state_pwm_c);
|
||
|
void get_sw_version(uint16_t& version_pwm_a, uint16_t& version_pwm_b, uint16_t& version_pwm_c);
|
||
|
void get_breakdown_cell_state(uint16_t& cellstate_pwm_a, uint16_t& cellstate_pwm_b, uint16_t& cellstate_pwm_c);
|
||
|
void get_breakdown_cell_index(uint16_t& cellindex_pwm_a, uint16_t& cellindex_pwm_b, uint16_t& cellindex_pwm_c);
|
||
|
void set_cell_quantity_cascade(uint16_t phase_index, uint16_t cascadenum, uint16_t quant);
|
||
|
//
|
||
|
void broadcast_order(uint16_t order);
|
||
|
void broadcast_cell_quantity_phase(uint16_t quant);
|
||
|
void broadcast_freq(uint16_t freq);
|
||
|
//
|
||
|
void get_hard_fault(uint16_t& hard_fault);
|
||
|
//
|
||
|
void get_indirect_access(uint16_t phase, uint16_t cascade, uint16_t cell, uint16_t offset, uint16_t& telemetry);
|
||
|
//
|
||
|
void telemetry_execute(PWMABCInterfaceConfiguration& config, PWMPhaseTelemetryValue telemetry_phase[3]);
|
||
|
void reset_telemetry();
|
||
|
void set_telemetry_sequence_one();
|
||
|
void set_telemetry_sequence_two();
|
||
|
//
|
||
|
private:
|
||
|
void (PWMABCInterace::*_telemetry_execute)(PWMABCInterfaceConfiguration& config, PWMPhaseTelemetryValue telemetry_phase[3]);
|
||
|
void _telemetry_sequence_one(PWMABCInterfaceConfiguration& config, PWMPhaseTelemetryValue telemetry_phase[3]);
|
||
|
void _telemetry_sequence_two(PWMABCInterfaceConfiguration& config, PWMPhaseTelemetryValue telemetry_phase[3]);
|
||
|
//
|
||
|
};
|
||
|
|
||
|
} /* namespace PERIPHERY */
|
||
|
|
||
|
#endif /* PERIPHERY_PWMABCINTERACE_H_ */
|