Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/core/io/CANopen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ void initializeCANopenNode(CO_NODE* canNode, CANDevice* canDevice, CO_IF_DRV* ca
*/
void processCANopenNode(CO_NODE* canNode);

/**
* Alert a canOpen TPDO to send the TPDO's values.
* DISCLAIMER: Does not immediately send said TPDO, just flags it for the next time processCANopenNode() runs.
*
* @param canNode the can node
* @param tpdoNum the TPDO number to be sent
*/
void alertTPDO(CO_NODE* canNode, uint16_t tpdoNum);

/**
* This function starts an asynchronous SDO download (write) request to transfer data
* to the specified object dictionary entry on the target CANopen node.
Expand Down
5 changes: 5 additions & 0 deletions include/core/io/GPIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class GPIO {
*/
virtual void writePin(State state) = 0;

/**
* Set the output of this pin to the opposite of the current logic state.
*/
virtual void togglePin() = 0;

/**
* Read the current logic state of this pin.
*
Expand Down
2 changes: 2 additions & 0 deletions include/core/io/platform/f3xx/GPIOf3xx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class GPIOf3xx : public GPIO {

void writePin(State state) override;

void togglePin() override;

State readPin() override;

void registerIRQ(TriggerEdge edge, void (*irqHandler)(GPIO* pin, void* priv), void* priv) override;
Expand Down
2 changes: 2 additions & 0 deletions include/core/io/platform/f4xx/GPIOf4xx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class GPIOf4xx : public GPIO {

void writePin(State state) override;

void togglePin() override;

State readPin() override;

void registerIRQ(TriggerEdge edge, void (*irqHandler)(GPIO* pin, void* priv), void* priv) override;
Expand Down
8 changes: 1 addition & 7 deletions src/core/dev/LED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ LED::LED(core::io::GPIO& gpio, LED::ActiveState activeState) : gpio(gpio) {
}

void LED::toggle() {
core::io::GPIO::State currentState = this->gpio.readPin();

if (core::io::GPIO::State::LOW == currentState) {
this->gpio.writePin(core::io::GPIO::State::HIGH);
} else {
this->gpio.writePin(core::io::GPIO::State::LOW);
}
this->gpio.togglePin();
}

void LED::setState(core::io::GPIO::State state) {
Expand Down
4 changes: 4 additions & 0 deletions src/core/io/CANopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ void processCANopenNode(CO_NODE* canNode) {
COTmrProcess(&canNode->Tmr);
}

void alertTPDO(CO_NODE* canNode, uint16_t tpdoNum) {
COTPdoTrigPdo(canNode->TPdo, tpdoNum);
}

CO_ERR SDOTransfer(CO_NODE& node, uint8_t* data, uint8_t size, uint32_t entry, csdo_callback_t transferCallback,
void* transferContext) {
while (state.inProgress == true) {
Expand Down
4 changes: 4 additions & 0 deletions src/core/io/platform/f3xx/GPIOf3xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ void GPIOf3xx::writePin(GPIO::State state) {
HAL_GPIO_WritePin(this->port, this->halPin, static_cast<GPIO_PinState>(state));
}

void GPIOf3xx::togglePin() {
HAL_GPIO_TogglePin(this->port, this->halPin);
}

GPIO::State GPIOf3xx::readPin() {
return static_cast<GPIO::State>(HAL_GPIO_ReadPin(this->port, this->halPin));
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/io/platform/f4xx/GPIOf4xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ void GPIOf4xx::writePin(GPIO::State state) {
HAL_GPIO_WritePin(this->port, this->halPin, static_cast<GPIO_PinState>(state));
}

void GPIOf4xx::togglePin() {
HAL_GPIO_TogglePin(this->port, this->halPin);
}

GPIO::State GPIOf4xx::readPin() {
return static_cast<GPIO::State>(HAL_GPIO_ReadPin(this->port, this->halPin));
}
Expand Down
Loading