-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#45 Fixes to compilation issues in pins system
- Loading branch information
Robert
committed
Dec 23, 2022
1 parent
33d53dd
commit 897f6b2
Showing
11 changed files
with
209 additions
and
216 deletions.
There are no files selected for viewing
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 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.zcode</groupId> | ||
<artifactId>zcode-receivers-pins</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>zcode-receivers-pins-all</artifactId> | ||
<packaging>nar</packaging> | ||
<name>Zcode full peripheral set</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.zcode</groupId> | ||
<artifactId>zcode-receivers-pins-core</artifactId> | ||
<version>${project.version}</version> | ||
<type>nar</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.zcode</groupId> | ||
<artifactId>zcode-receivers-pins-ll</artifactId> | ||
<version>${project.version}</version> | ||
<type>nar</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.zcode</groupId> | ||
<artifactId>zcode-receivers-pins-ll-stm32</artifactId> | ||
<version>${project.version}</version> | ||
<type>nar</type> | ||
</dependency> | ||
</dependencies> | ||
</project> |
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
87 changes: 87 additions & 0 deletions
87
.../peripherals/pins/pins-ll-stm32/src/main/c++/pins-ll-stm32/lowlevel/specific/GpioPort.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Zcode Library - Command System for Microcontrollers) | ||
* Copyright (c) 2022 Zcode team (Susan Witts, Alicia Witts) | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#ifndef SRC_MAIN_CPP_ARM_NO_OS_PINS_MODULE_LOWLEVEL_SPECIFIC_GPIOPORT_HPP_ | ||
#define SRC_MAIN_CPP_ARM_NO_OS_PINS_MODULE_LOWLEVEL_SPECIFIC_GPIOPORT_HPP_ | ||
|
||
#include <llIncludes.hpp> | ||
|
||
enum OutputMode { | ||
PushPull, OpenDrain | ||
}; | ||
|
||
enum PullMode { | ||
NoPull, PullUp, PullDown | ||
}; | ||
|
||
enum PinSpeed { | ||
LowSpeed, MediumSpeed, HighSpeed, VeryHighSpeed | ||
}; | ||
|
||
enum PinMode { | ||
Input, Output, AlternateFunction, Analog | ||
}; | ||
|
||
class GpioPort { | ||
private: | ||
volatile uint32_t MODE; | ||
volatile uint32_t OTYPE; | ||
volatile uint32_t OSPEED; | ||
volatile uint32_t PUPD; | ||
volatile uint32_t ID; | ||
volatile uint32_t OD; | ||
volatile uint32_t BSR; | ||
volatile uint32_t LCK; | ||
volatile uint32_t AFRL; | ||
volatile uint32_t AFRH; | ||
volatile uint32_t BR; | ||
|
||
public: | ||
void setMode(GpioPinName pin, PinMode mode) { | ||
MODE &= ~(0x3 << (pin.pin * 2)); | ||
MODE |= (mode) << (pin.pin * 2); | ||
} | ||
|
||
void setOutputType(GpioPinName pin, OutputMode mode) { | ||
OTYPE &= ~(0x1 << (pin.pin)); | ||
OTYPE |= (mode) << (pin.pin); | ||
} | ||
|
||
void setOutputSpeed(GpioPinName pin, PinSpeed mode) { | ||
OSPEED &= ~(0x3 << (pin.pin * 2)); | ||
OSPEED |= (mode) << (pin.pin * 2); | ||
} | ||
|
||
void setPullMode(GpioPinName pin, PullMode mode) { | ||
PUPD &= ~(0x3 << (pin.pin * 2)); | ||
PUPD |= (mode) << (pin.pin * 2); | ||
} | ||
|
||
bool getPinValue(GpioPinName pin) { | ||
return ID & (1 << pin.pin); | ||
} | ||
|
||
void setPin(GpioPinName pin) { | ||
BSR = (1 << pin.pin); | ||
} | ||
|
||
void resetPin(GpioPinName pin) { | ||
BSR = (0x10000 << pin.pin); | ||
} | ||
|
||
void setAlternateFunction(GpioPinName pin, uint8_t function) { | ||
if (pin.pin < 8) { | ||
AFRL &= ~(0xF << (pin.pin * 4)); | ||
AFRL |= (function << (pin.pin * 4)); | ||
} else { | ||
AFRH &= ~(0xF << (pin.pin * 4 - 32)); | ||
AFRH |= (function << (pin.pin * 4 - 32)); | ||
} | ||
} | ||
}; | ||
|
||
#endif /* SRC_MAIN_CPP_ARM_NO_OS_PINS_MODULE_LOWLEVEL_SPECIFIC_GPIOPORT_HPP_ */ |
69 changes: 69 additions & 0 deletions
69
...m/peripherals/pins/pins-ll-stm32/src/main/c++/pins-ll-stm32/lowlevel/specific/Gpiocpp.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Zcode Library - Command System for Microcontrollers) | ||
* Copyright (c) 2022 Zcode team (Susan Witts, Alicia Witts) | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#ifndef SRC_MAIN_CPP_ARM_NO_OS_PINS_MODULE_LOWLEVEL_SPECIFIC_GPIOCPP_HPP_ | ||
#define SRC_MAIN_CPP_ARM_NO_OS_PINS_MODULE_LOWLEVEL_SPECIFIC_GPIOCPP_HPP_ | ||
|
||
#include <pins-ll/lowlevel/Gpio.hpp> | ||
|
||
#include <pins-ll/lowlevel/GpioManager.hpp> | ||
|
||
template<class LL> | ||
void GpioPin<LL>::init() { | ||
GpioManager<LL>::activateClock(pin); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::write(bool value) { | ||
if (value) { | ||
GpioManager<LL>::getPort(pin)->setPin(pin); | ||
} else { | ||
GpioManager<LL>::getPort(pin)->resetPin(pin); | ||
} | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::set() { | ||
GpioManager<LL>::getPort(pin)->setPin(pin); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::reset() { | ||
GpioManager<LL>::getPort(pin)->resetPin(pin); | ||
} | ||
|
||
template<class LL> | ||
bool GpioPin<LL>::read() { | ||
return GpioManager<LL>::getPort(pin)->getPinValue(pin); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::setOutputMode(OutputMode mode) { | ||
GpioManager<LL>::getPort(pin)->setOutputType(pin, mode); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::setPullMode(PullMode mode) { | ||
GpioManager<LL>::getPort(pin)->setPullMode(pin, mode); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::setMode(PinMode mode) { | ||
GpioManager<LL>::getPort(pin)->setMode(pin, mode); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::setOutputSpeed(PinSpeed speed) { | ||
GpioManager<LL>::getPort(pin)->setOutputSpeed(pin, speed); | ||
} | ||
|
||
template<class LL> | ||
void GpioPin<LL>::setAlternateFunction(uint8_t function) { | ||
GpioManager<LL>::getPort(pin)->setAlternateFunction(pin, function); | ||
} | ||
|
||
#endif /* SRC_MAIN_CPP_ARM_NO_OS_PINS_MODULE_LOWLEVEL_SPECIFIC_GPIOCPP_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
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
15 changes: 0 additions & 15 deletions
15
.../native/arm/peripherals/pins/pins-ll/src/main/c++/pins-ll/lowlevel/specific/GpioNames.hpp
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.