diff --git a/library/stm32f072xb/dma/abstract-dma/abstract-dma.cpp b/library/stm32f072xb/dma/abstract-dma/abstract-dma.cpp index f4176d6b22cab8b8141bafbc8b46e31d55f0b688..c5bb305fa9399a168b9ebc023816446e48fe5981 100644 --- a/library/stm32f072xb/dma/abstract-dma/abstract-dma.cpp +++ b/library/stm32f072xb/dma/abstract-dma/abstract-dma.cpp @@ -42,16 +42,16 @@ void AbstractDma::setupRegister() { void AbstractDma::setPeripheral(DmaPeripheral peripheral) { switch (peripheral) { case DmaPeripheral::USART2_RX: - WRITE_REG(_dmaChannel->CPAR, (uint32_t)&USART2->RDR); + _dmaChannel->CPAR = (uintptr_t)&USART2->RDR; break; case DmaPeripheral::USART2_TX: - WRITE_REG(_dmaChannel->CPAR, (uint32_t)&USART2->TDR); + _dmaChannel->CPAR = (uintptr_t)&USART2->TDR; break; } } void AbstractDma::setMemory(volatile const uint8_t* buffer) { - WRITE_REG(_dmaChannel->CMAR, (uint32_t)(buffer)); + _dmaChannel->CMAR = (uintptr_t)(buffer); } void AbstractDma::setNumberOfDataTransfer(uint16_t numberOfDataTransfer) { diff --git a/library/stm32f072xb/gpio/i2c-gpio/i2c-gpio-init.hpp b/library/stm32f072xb/gpio/i2c-gpio/i2c-gpio-init.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5eebfc11c0e1cd2f453133f514dc424d4862b51c --- /dev/null +++ b/library/stm32f072xb/gpio/i2c-gpio/i2c-gpio-init.hpp @@ -0,0 +1,12 @@ +#include "alternate-gpio-init.hpp" + +#ifndef I2C_GPIO_INIT_H +#define I2C_GPIO_INIT_H + +namespace stm32f072xb { + +struct I2cGpioInit : public AlternateGpioInit {}; + +} // namespace stm32f072xb + +#endif diff --git a/library/stm32f072xb/gpio/i2c-gpio/i2c-gpio.hpp b/library/stm32f072xb/gpio/i2c-gpio/i2c-gpio.hpp new file mode 100644 index 0000000000000000000000000000000000000000..89f66a08159d6a329a0833543d96ef702ea85358 --- /dev/null +++ b/library/stm32f072xb/gpio/i2c-gpio/i2c-gpio.hpp @@ -0,0 +1,23 @@ +#include "alternate-gpio.hpp" +#include "i2c-gpio-init.hpp" + +#ifndef I2C_GPIO_H +#define I2C_GPIO_H + +namespace stm32f072xb { + +template <Port T> +class I2cGpio : public Gpio<T> { + public: + I2cGpio(const I2cGpioInit& gpioInit) : AlternateGpio<T>(gpioInit) { + // Select open drain output type + SET_BIT(this->getGpio()->OTYPER, 1UL << (this->getPin())); + + // Select high speed output + SET_BIT(this->getGpio()->OSPEEDR, 0x3UL << (this->getPin() * 2)); + } +}; + +}; // namespace stm32f072xb + +#endif