-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Src/applications/dronecan/default_params.yml → ...applications/dronecan/default_params.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*** | ||
* Copyright (C) 2024 Anastasiia Stepanova <[email protected]> | ||
* Distributed under the terms of the GPL v3 license, available in the file LICENSE. | ||
***/ | ||
|
||
#ifndef SRC_PERIPHERY_GPIO_HPP_ | ||
#define SRC_PERIPHERY_GPIO_HPP_ | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
enum class GPIOPin { | ||
CAN_TERMINATOR1, | ||
CAN_TERMINATOR2, | ||
GPIO_AMOUNT, | ||
}; | ||
|
||
class GPIOPeriphery { | ||
public: | ||
static void set(const GPIOPin gpio_pin); | ||
static bool get(const GPIOPin gpio_pin); | ||
static void toggle(GPIOPin gpio_pin, uint32_t toggle_period_ms, uint32_t duty_cycle_ms); | ||
static void reset(GPIOPin gpio_pin); | ||
static void reset(); | ||
}; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // SRC_PERIPHERY_GPIO_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*** | ||
* Copyright (C) 2024 Anastasiia Stepanova <[email protected]> | ||
* Distributed under the terms of the GPL v3 license, available in the file | ||
*LICENSE. | ||
***/ | ||
|
||
#include "periphery/gpio/gpio.hpp" | ||
|
||
#include "main.h" | ||
|
||
void GPIOPeriphery::set(GPIOPin gpio_pin) { | ||
switch (gpio_pin) { | ||
case GPIOPin::CAN_TERMINATOR1: | ||
HAL_GPIO_WritePin(CAN1_TERMINATOR_GPIO_Port, CAN1_TERMINATOR_Pin, GPIO_PIN_SET); | ||
break; | ||
|
||
case GPIOPin::CAN_TERMINATOR2: | ||
HAL_GPIO_WritePin(CAN2_TERMINATOR_GPIO_Port, CAN2_TERMINATOR_Pin, GPIO_PIN_SET); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
bool GPIOPeriphery::get(GPIOPin gpio_pin) { | ||
switch (gpio_pin) { | ||
case GPIOPin::CAN_TERMINATOR1: | ||
return HAL_GPIO_ReadPin(CAN1_TERMINATOR_GPIO_Port, CAN1_TERMINATOR_Pin); | ||
|
||
case GPIOPin::CAN_TERMINATOR2: | ||
return HAL_GPIO_ReadPin(CAN2_TERMINATOR_GPIO_Port, CAN2_TERMINATOR_Pin); | ||
|
||
default: | ||
return GPIO_PIN_SET; | ||
} | ||
} | ||
|
||
void GPIOPeriphery::reset() { | ||
HAL_GPIO_WritePin(CAN1_TERMINATOR_GPIO_Port, CAN1_TERMINATOR_Pin, GPIO_PIN_RESET); | ||
HAL_GPIO_WritePin(CAN2_TERMINATOR_GPIO_Port, CAN2_TERMINATOR_Pin, GPIO_PIN_RESET); | ||
} | ||
|
||
void GPIOPeriphery::reset(GPIOPin gpio_pin) { | ||
switch (gpio_pin) { | ||
case GPIOPin::CAN_TERMINATOR1: | ||
HAL_GPIO_WritePin(CAN1_TERMINATOR_GPIO_Port, CAN1_TERMINATOR_Pin, GPIO_PIN_RESET); | ||
break; | ||
case GPIOPin::CAN_TERMINATOR2: | ||
HAL_GPIO_WritePin(CAN2_TERMINATOR_GPIO_Port, CAN2_TERMINATOR_Pin, GPIO_PIN_RESET); | ||
break; | ||
default: | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*** | ||
* Copyright (C) 2024 Anastasiia Stepanova <[email protected]> | ||
* Distributed under the terms of the GPL v3 license, available in the file | ||
*LICENSE. | ||
***/ | ||
|
||
#include "periphery/gpio/gpio.hpp" | ||
|
||
#include <vector> | ||
#include "main.h" | ||
|
||
static std::vector<bool> gpio((int)GPIOPin::GPIO_AMOUNT, false); | ||
|
||
void GPIOPeriphery::set(GPIOPin gpio_pin) { | ||
gpio[(int)gpio_pin] = true; | ||
} | ||
bool GPIOPeriphery::get(GPIOPin gpio_pin) { | ||
return gpio[(int)gpio_pin]; | ||
} | ||
void GPIOPeriphery::reset() { | ||
for (auto gpio_val : gpio) { | ||
gpio_val = false; | ||
} | ||
} | ||
void GPIOPeriphery::reset(GPIOPin gpio_pin) { | ||
gpio[(int)gpio_pin] = false; | ||
} |