Skip to content

Commit 4dff326

Browse files
committed
Modify LoadSwitch to use ZephyrGpioDriver Component
1 parent d7fce15 commit 4dff326

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

FprimeZephyrReference/Components/LoadSwitch/LoadSwitch.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Components {
1111

12-
const struct device* LoadSwitch::m_device = nullptr;
1312
// ----------------------------------------------------------------------
1413
// Component construction and destruction
1514
// ----------------------------------------------------------------------
@@ -23,34 +22,31 @@ LoadSwitch ::~LoadSwitch() {}
2322
// ----------------------------------------------------------------------
2423

2524
void LoadSwitch ::Reset_handler(FwIndexType portNum) {
26-
gpio_pin_set(m_device, m_pinNum, 0);
25+
this->gpioSet_out(0, Fw::Logic::LOW);
26+
this->log_ACTIVITY_HI_StatusChanged(Fw::On::OFF);
27+
this->tlmWrite_IsOn(Fw::On::OFF);
2728
k_sleep(K_MSEC(100));
28-
gpio_pin_set(m_device, m_pinNum, 1);
29+
this->gpioSet_out(0, Fw::Logic::HIGH);
30+
this->log_ACTIVITY_HI_StatusChanged(Fw::On::ON);
31+
this->tlmWrite_IsOn(Fw::On::ON);
2932
}
3033

3134
// ----------------------------------------------------------------------
3235
// Handler implementations for commands
3336
// ----------------------------------------------------------------------
3437

3538
void LoadSwitch ::TURN_ON_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
36-
gpio_pin_set(m_device, m_pinNum, 1);
39+
this->gpioSet_out(0, Fw::Logic::HIGH);
3740
this->log_ACTIVITY_HI_StatusChanged(Fw::On::ON);
38-
// I think some code needed to send this status to the port as well
41+
this->tlmWrite_IsOn(Fw::On::ON);
3942
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
4043
}
4144

4245
void LoadSwitch ::TURN_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
43-
gpio_pin_set(m_device, m_pinNum, 0);
46+
this->gpioSet_out(0, Fw::Logic::LOW);
4447
this->log_ACTIVITY_HI_StatusChanged(Fw::On::OFF);
45-
// I think some code needed to send this status to the port as well
48+
this->tlmWrite_IsOn(Fw::On::OFF);
4649
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
4750
}
4851

49-
// This is meant to be used in Topology.cpp to configure the pin and device
50-
void LoadSwitch ::pin_configuration(const struct device* device, uint8_t pinNum) {
51-
this->m_pinNum = pinNum;
52-
this->m_device = device;
53-
gpio_pin_configure(m_device, m_pinNum, GPIO_OUTPUT_INACTIVE);
54-
}
55-
5652
} // namespace Components

FprimeZephyrReference/Components/LoadSwitch/LoadSwitch.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ class LoadSwitch final : public LoadSwitchComponentBase {
2828
//! Destroy LoadSwitch object
2929
~LoadSwitch();
3030

31-
// ----------------------------------------------------------------------
32-
// Configuration Meant to be used in ***Topology.cpp
33-
// ----------------------------------------------------------------------
34-
35-
void pin_configuration(const struct device* device, uint8_t pinNum);
36-
3731
private:
3832
// ----------------------------------------------------------------------
3933
// Handler implementations for commands
@@ -57,12 +51,6 @@ class LoadSwitch final : public LoadSwitchComponentBase {
5751
void Reset_handler(FwIndexType portNum //!< The port number
5852
) override;
5953

60-
// ----------------------------------------------------------------------
61-
// Member variables
62-
// ----------------------------------------------------------------------
63-
64-
uint8_t m_pinNum;
65-
static const struct device* m_device;
6654
};
6755

6856
} // namespace Components

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void configureTopology() {
6161
gpioDriver.open(ledGpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT);
6262
gpioBurnwire0.open(burnwire0Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT);
6363
gpioBurnwire1.open(burnwire1Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT);
64+
/*
6465
face4LoadSwitch.pin_configuration(mcp23017_dev, 0); // Pin 0 on MCP23017
6566
face0LoadSwitch.pin_configuration(mcp23017_dev, 1); // Pin 1 on MCP23017
6667
face1LoadSwitch.pin_configuration(mcp23017_dev, 2); // Pin 2 on MCP23017
@@ -69,6 +70,7 @@ void configureTopology() {
6970
face5LoadSwitch.pin_configuration(mcp23017_dev, 5); // Pin 5 on MCP23017
7071
payloadPowerLoadSwitch.pin_configuration(mcp23017_dev, 7); // Pin 7 on MCP23017
7172
payloadBatteryLoadSwitch.pin_configuration(mcp23017_dev, 9); // Pin 9 on MCP23017
73+
*/
7274
}
7375

7476
// Public functions for use in main program are namespaced with deployment name ReferenceDeployment

0 commit comments

Comments
 (0)