MAX14778 Module - smartel99/NilaiTFO GitHub Wiki
To instantiate a Max14778Module
in your application, you must first configure how it should function. This is done using the MAX14778::Config
structure.
This structure is used by the Max14778Module
to know how to accomplish the various operations on the physical MAX14778 chip.
If you do not wish to setup any of the functions in the structure (because, for example, a pin is connected to ground), simply leave it empty.
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the ENA pin of the MAX14778 chip.
The function should do all the actions necessary to set the ENA pin to the desired state.
Example:
void SetEnA(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_EN1_GPIO_Port,
OUT_REL_LOW_EN1_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setEnAFunc = &SetEnA;
// Using a lambda function:
maxConfig.setEnAFunc = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_EN1_GPIO_Port,
OUT_REL_LOW_EN1_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the ENB pin of the MAX14778 chip.
The function should do all the actions necessary to set the ENB pin to the desired state.
Example:
void SetEnB(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_EN2_GPIO_Port,
OUT_REL_LOW_EN2_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setEnBFunc = &SetEnB;
// Using a lambda function:
maxConfig.setEnBFunc = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_EN2_GPIO_Port,
OUT_REL_LOW_EN2_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the SA0 pin of the MAX14778 chip.
The function should do all the actions necessary to set the SA0 pin to the desired state.
Example:
void SetSA0(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL0_GPIO_Port,
OUT_REL_LOW_CTRL0_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setSA0Func = &SetSA0;
// Using a lambda function:
maxConfig.setSA0Func = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL0_GPIO_Port,
OUT_REL_LOW_CTRL0_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the SA1 pin of the MAX14778 chip.
The function should do all the actions necessary to set the SA1 pin to the desired state.
Example:
void SetSA1(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL1_GPIO_Port,
OUT_REL_LOW_CTRL1_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setSA1Func = &SetSA1;
// Using a lambda function:
maxConfig.setSA1Func = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL1_GPIO_Port,
OUT_REL_LOW_CTRL1_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the SB0 pin of the MAX14778 chip.
The function should do all the actions necessary to set the SB0 pin to the desired state.
Example:
void SetSB0(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL0_GPIO_Port,
OUT_REL_LOW_CTRL0_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setSB0Func = &SetSB0;
// Using a lambda function:
maxConfig.setSB0Func = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL0_GPIO_Port,
OUT_REL_LOW_CTRL0_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the SB1 pin of the MAX14778 chip.
The function should do all the actions necessary to set the SB1 pin to the desired state.
Example:
void SetSB1(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL1_GPIO_Port,
OUT_REL_LOW_CTRL1_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setSB1Func = &SetSB1;
// Using a lambda function:
maxConfig.setSB1Func = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_CTRL1_GPIO_Port,
OUT_REL_LOW_CTRL1_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the ACOM pin of the MAX14778 chip.
The function should do all the actions necessary to set the pin to the desired state.
Example:
void SetACom(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_ACOM_GPIO_Port,
OUT_REL_LOW_ACOM_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setAComFunc = &SetACom;
// Using a lambda function:
maxConfig.setAComFunc = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_ACOM_GPIO_Port,
OUT_REL_LOW_ACOM_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<void(bool)>
Description: This function pointer points to a function of type void
that takes a bool
as parameter.
This Boolean represents the desired state of the BCOM pin of the MAX14778 chip.
The function should do all the actions necessary to set the BCOM pin to the desired state.
Example:
void SetBCom(bool state)
{
HAL_GPIO_WritePin(OUT_REL_LOW_BCOM_GPIO_Port,
OUT_REL_LOW_BCOM_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.setBComFunc = &SetBCom;
// Using a lambda function:
maxConfig.setBComFunc = [](bool state){
HAL_GPIO_WritePin(OUT_REL_LOW_BCOM_GPIO_Port,
OUT_REL_LOW_BCOM_Pin,
(state ? GPIO_PIN_SET : GPIO_PIN_RESET));
};
}
Type: std::function<bool()>
Description: This function pointer points to a function of type bool
that does not take any parameters.
The function should do all the actions necessary to get the state of the ACOM pin on the MAX14778 chip.
Example:
void GetACom()
{
return HAL_GPIO_ReadPin(OUT_REL_LOW_ACOM_GPIO_Port,
OUT_REL_LOW_ACOM_Pin);
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.getAComFunc = &GetACom;
// Using a lambda function:
maxConfig.getAComFunc = []()-> bool {
return HAL_GPIO_ReadPin(OUT_REL_LOW_ACOM_GPIO_Port,
OUT_REL_LOW_ACOM_Pin);
};
}
Type: std::function<bool()>
Description: This function pointer points to a function of type bool
that does not take any parameters.
The function should do all the actions necessary to get the state of the BCOM pin on the MAX14778 chip.
Example:
void GetBCom()
{
return HAL_GPIO_ReadPin(OUT_REL_LOW_BCOM_GPIO_Port,
OUT_REL_LOW_BCOM_Pin);
}
void MyApplication::InitializeModule()
{
MAX14778::Config maxConfig;
// Using a function pointer:
maxConfig.getBComFunc = &GetBCom;
// Using a lambda function:
maxConfig.getBComFunc = []()-> bool {
return HAL_GPIO_ReadPin(OUT_REL_LOW_BCOM_GPIO_Port,
OUT_REL_LOW_BCOM_Pin);
};
}
Once you have setup the MAX14778::Config
in the way you desire, you can now add an instance of Max14778Module
in your application.
void MyApplication::InitializeModules()
{
MAX14778::Config maxConfig;
// Setup maxConfig...
AddModule(new Max14778Module(maxConfig, "myMax1");
}
To simplify access to this new instance, you can create a macro that will get that instance in the application:
#define MUX1_MODULE static_cast<Max14778Module*>(MyApplication::GetModule("myMax1"))
This macro allows you to use the module like this:
MUX1_MODULE->SelectB0();
This API does not offer any configuration utilities once the module has been instantiated.
Method: void Max14778Module::SetEnA(bool state)
Parameters:
-
bool state
: The desired state of the pin.
Returns: None
Description: Set the ENA pin to the desired state using the function specified by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SetEnA(true);
Method: void Max14778Module::SetEnB(bool state)
Parameters:
-
bool state
: The desired state of the pin.
Returns: None
Description: Set the ENB pin to the desired state using the function specified by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SetEnB(false);
Method: void Max14778Module::SelectA0()
Parameters: None
Returns: None
Description: Select the A0 pin of the MAX14778 by using the setSA0Func
and setSA1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectA0();
Method: void Max14778Module::SelectA1()
Parameters: None
Returns: None
Description: Select the A1 pin of the MAX14778 by using the setSA0Func
and setSA1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectA1();
Method: void Max14778Module::SelectA2()
Parameters: None
Returns: None
Description: Select the A2 pin of the MAX14778 by using the setSA0Func
and setSA1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectA2();
Method: void Max14778Module::SelectA3()
Parameters: None
Returns: None
Description: Select the A3 pin of the MAX14778 by using the setSA0Func
and setSA1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectA3();
Method: void Max14778Module::SelectB0()
Parameters: None
Returns: None
Description: Select the B0 pin of the MAX14778 by using the setSB0Func
and setSB1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectB0();
Method: void Max14778Module::SelectB1()
Parameters: None
Returns: None
Description: Select the B1 pin of the MAX14778 by using the setSB0Func
and setSB1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectB1();
Method: void Max14778Module::SelectB2()
Parameters: None
Returns: None
Description: Select the B2 pin of the MAX14778 by using the setSB0Func
and setSB1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectB2();
Method: void Max14778Module::SelectB3()
Parameters: None
Returns: None
Description: Select the B3 pin of the MAX14778 by using the setSB0Func
and setSB1Func
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SelectB3();
Method: void Max14778Module::SetACom(bool state)
Parameters:
-
bool state
: The desired state of the pin.
Returns: None
Description: Set the state of the ACOM pin of the MAX14778 by using the setAComFunc
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SetACom(true);
Method: void Max14778Module::SetBCom(bool state)
Parameters:
-
bool state
: The desired state of the pin.
Returns: None
Description: Set the state of the BCOM pin of the MAX14778 by using the setBComFunc
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
MUX1_MODULE->SetBCom(false);
Method: bool Max14778Module::GetACom()
Parameters: None
Returns: bool
The state of ACOM.
Description: Get the state of the ACOM pin on the MAX14778 using the getAComFunc
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
bool state = MUX1_MODULE->GetACom();
Method: bool Max14778Module::GetBCom()
Parameters: None
Returns: bool
The state of BCOM.
Description: Get the state of the BCOM pin on the MAX14778 using the getBComFunc
function set by the configuration.
Note: If no function was set in the configuration when instantiating the Max14778Module
, this method does nothing.
Example:
bool state = MUX1_MODULE->GetBCom();