Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: apply clang-format #58

Merged
merged 2 commits into from
Jan 23, 2023
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ endif()

add_subdirectory(hal_st)
add_subdirectory(hal_st_lwip)

emil_clangformat_directories(hal_st DIRECTORIES .)
2 changes: 2 additions & 0 deletions hal_st/cmsis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(startup)
add_subdirectory(cortex)
add_subdirectory(cmsis_arm)

emil_exclude_directory_from_clang_format(.)
2 changes: 1 addition & 1 deletion hal_st/cortex/EventDispatcherCortex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace hal
{
public:
template<std::size_t StorageSize>
using WithSize = infra::WithStorage<EventDispatcherCortexWorker, std::array<std::pair<infra::Function<void()>, std::atomic<bool>>, StorageSize>>;
using WithSize = infra::WithStorage<EventDispatcherCortexWorker, std::array<std::pair<infra::Function<void()>, std::atomic<bool>>, StorageSize>>;

EventDispatcherCortexWorker(infra::MemoryRange<std::pair<infra::Function<void()>, std::atomic<bool>>> scheduledActionsStorage);

Expand Down
7 changes: 4 additions & 3 deletions hal_st/cortex/InterruptCortex.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "infra/event/EventDispatcher.hpp"
#include "hal_st/cortex/InterruptCortex.hpp"
#include "infra/event/EventDispatcher.hpp"
#include <cstdlib>

namespace hal
{
namespace
{
void EnableInterrupt(IRQn_Type irq, InterruptPriority priority)
{
{
if (irq >= 0)
{
NVIC_SetPriority(irq, static_cast<uint32_t>(priority));
Expand Down Expand Up @@ -170,7 +170,8 @@ namespace hal

IRQn_Type irq = Irq();
DispatchedInterruptHandler& handler = *this;
infra::EventDispatcher::Instance().Schedule([irq, &handler]() { InvokeScheduled(irq, handler); });
infra::EventDispatcher::Instance().Schedule([irq, &handler]()
{ InvokeScheduled(irq, handler); });
}

void DispatchedInterruptHandler::SetInvoke(const infra::Function<void()>& onInvoke)
Expand Down
4 changes: 2 additions & 2 deletions hal_st/cortex/InterruptCortex.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef HAL_INTERRUPT_CORTEX_HPP
#define HAL_INTERRUPT_CORTEX_HPP

#include "cmsis_device.h"
#include "infra/util/Function.hpp"
#include "infra/util/InterfaceConnector.hpp"
#include "infra/util/MemoryRange.hpp"
#include "infra/util/WithStorage.hpp"
#include "cmsis_device.h"
#include <array>

namespace hal
Expand Down Expand Up @@ -46,7 +46,7 @@ namespace hal
{
public:
template<std::size_t Size>
using WithStorage = infra::WithStorage<InterruptTable, std::array<InterruptHandler*, Size>>;
using WithStorage = infra::WithStorage<InterruptTable, std::array<InterruptHandler*, Size>>;

InterruptTable(infra::MemoryRange<InterruptHandler*> table);

Expand Down
2 changes: 1 addition & 1 deletion hal_st/instantiations/NucleoUi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace main_

struct NucleoWb55rgNucleoUi
{
hal::GpioPinStm buttonOne{ hal::Port::C, 4, hal::Drive::Default, hal::Speed::Default, hal::WeakPull::Up };
hal::GpioPinStm buttonOne{ hal::Port::C, 4, hal::Drive::Default, hal::Speed::Default, hal::WeakPull::Up };
hal::GpioPinStm buttonTwo{ hal::Port::D, 0, hal::Drive::Default, hal::Speed::Default, hal::WeakPull::Up };
hal::GpioPinStm buttonThree{ hal::Port::D, 1, hal::Drive::Default, hal::Speed::Default, hal::WeakPull::Up };
hal::GpioPinStm ledRed{ hal::Port::B, 1 };
Expand Down
2 changes: 1 addition & 1 deletion hal_st/instantiations/StmEventInfrastructure.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "generated/stm32fxxx/PinoutTableDefault.hpp"
#include "hal_st/instantiations/StmEventInfrastructure.hpp"
#include "generated/stm32fxxx/PinoutTableDefault.hpp"

namespace main_
{
Expand Down
9 changes: 7 additions & 2 deletions hal_st/instantiations/StmTracerInfrastructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ namespace main_
: public hal::TimeKeeper
{
public:
virtual bool Timeout() override { return false; }
virtual void Reset() override {}
virtual bool Timeout() override
{
return false;
}

virtual void Reset() override
{}
};

struct StmTracerInfrastructure
Expand Down
2 changes: 2 additions & 0 deletions hal_st/middlewares/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_subdirectory(STM32_WPAN)
add_subdirectory(ble_middleware)

emil_exclude_directory_from_clang_format(.)
2 changes: 2 additions & 0 deletions hal_st/std_periph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ function(halst_target_linker_scripts)

set_property(TARGET ${HALST_TARGET} PROPERTY INTERFACE_LINK_DEPENDS ${HALST_LINKER_SCRIPTS})
endfunction()

emil_exclude_directory_from_clang_format(.)
5 changes: 3 additions & 2 deletions hal_st/stm32fxxx/AnalogToDigitalPinStm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "hal_st/stm32fxxx/AnalogToDigitalPinStm.hpp"
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include <cassert>

namespace hal
Expand Down Expand Up @@ -29,7 +29,8 @@ namespace hal
AdcStm::AdcStm(uint8_t oneBasedIndex)
: index(oneBasedIndex - 1)
, handle()
, interruptHandler(ADC_IRQn, [this]() { MeasurementDone(); })
, interruptHandler(ADC_IRQn, [this]()
{ MeasurementDone(); })
{
EnableClockAdc(index);

Expand Down
2 changes: 1 addition & 1 deletion hal_st/stm32fxxx/AnalogToDigitalPinStm.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef HAL_ANALOG_TO_DIGITAL_PIN_STM_HPP
#define HAL_ANALOG_TO_DIGITAL_PIN_STM_HPP

#include "cmsis_device.h"
#include "hal/interfaces/AnalogToDigitalPin.hpp"
#include "hal_st/cortex/InterruptCortex.hpp"
#include "hal_st/stm32fxxx/GpioStm.hpp"
#include "infra/util/AutoResetFunction.hpp"
#include "cmsis_device.h"

namespace hal
{
Expand Down
47 changes: 25 additions & 22 deletions hal_st/stm32fxxx/CanStm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "hal_st/stm32fxxx/CanStm.hpp"
#include "generated/stm32fxxx/PeripheralTable.hpp"

#if defined(HAS_PERIPHERAL_CAN)

Expand All @@ -9,15 +9,18 @@ namespace hal
: canIndex(oneBasedCanIndex - 1)
, tx(tx, hal::PinConfigTypeStm::canTx, oneBasedCanIndex)
, rx(rx, hal::PinConfigTypeStm::canRx, oneBasedCanIndex)
, canTxInterruptDispatcher(peripheralCanTxIrq[canIndex], [this]() { HandleTxInterrupt(); })
, canRxInterruptDispatcher(peripheralCanRx0Irq[canIndex], [this]() { HandleRxInterrupt(); })
, canErrorInterruptDispatcher(peripheralCanSceIrq[canIndex], [this]() { HandleErrorInterrupt(); })
, canTxInterruptDispatcher(peripheralCanTxIrq[canIndex], [this]()
{ HandleTxInterrupt(); })
, canRxInterruptDispatcher(peripheralCanRx0Irq[canIndex], [this]()
{ HandleRxInterrupt(); })
, canErrorInterruptDispatcher(peripheralCanSceIrq[canIndex], [this]()
{ HandleErrorInterrupt(); })
{
EnableClockCan(canIndex);

peripheralHandle.Instance = peripheralCan[canIndex];
peripheralHandle.Init.Prescaler = config.prescaler;
peripheralHandle.Init.Mode = CAN_MODE_NORMAL; //CAN_MODE_SILENT_LOOPBACK
peripheralHandle.Init.Mode = CAN_MODE_NORMAL; // CAN_MODE_SILENT_LOOPBACK
peripheralHandle.Init.SJW = CAN_SJW_4TQ;
peripheralHandle.Init.BS1 = CAN_BS1_6TQ;
peripheralHandle.Init.BS2 = CAN_BS2_8TQ;
Expand All @@ -33,25 +36,25 @@ namespace hal
peripheralCan[canIndex]->IER |= CAN_IER_TMEIE;
peripheralCan[canIndex]->IER |= CAN_IER_BOFIE | CAN_IER_ERRIE;

//peripheralCan[canIndex]->FMR |= CAN_FMR_FINIT; // Start filter initialization
//peripheralCan[canIndex]->FS1R |= CAN_FS1R_FSC0; // 32 bit address
//peripheralCan[canIndex]->FM1R &= ~CAN_FM1R_FBM0; // Mask
//peripheralCan[canIndex]->sFilterRegister[0].FR1 = 0; // No significant bits
//peripheralCan[canIndex]->sFilterRegister[0].FR2 = 0; // No significant bits
//peripheralCan[canIndex]->FA1R |= CAN_FA1R_FACT0; // Make filter active
//peripheralCan[canIndex]->FMR &= ~CAN_FMR_FINIT; // End filter initialization
// peripheralCan[canIndex]->FMR |= CAN_FMR_FINIT; // Start filter initialization
// peripheralCan[canIndex]->FS1R |= CAN_FS1R_FSC0; // 32 bit address
// peripheralCan[canIndex]->FM1R &= ~CAN_FM1R_FBM0; // Mask
// peripheralCan[canIndex]->sFilterRegister[0].FR1 = 0; // No significant bits
// peripheralCan[canIndex]->sFilterRegister[0].FR2 = 0; // No significant bits
// peripheralCan[canIndex]->FA1R |= CAN_FA1R_FACT0; // Make filter active
// peripheralCan[canIndex]->FMR &= ~CAN_FMR_FINIT; // End filter initialization

CAN_FilterConfTypeDef CAN_FilterStruct;
CAN_FilterStruct.FilterIdHigh = 0x0000; /* Upper 16bit filter ID */
CAN_FilterStruct.FilterIdLow = 0x0000; /* Filter lower 16bit ID */
CAN_FilterStruct.FilterMaskIdHigh = 0x0000; /* Upper 16bit filter mask */
CAN_FilterStruct.FilterMaskIdLow = 0x0000; /* Lower 16bit filter mask */
CAN_FilterStruct.FilterIdHigh = 0x0000; /* Upper 16bit filter ID */
CAN_FilterStruct.FilterIdLow = 0x0000; /* Filter lower 16bit ID */
CAN_FilterStruct.FilterMaskIdHigh = 0x0000; /* Upper 16bit filter mask */
CAN_FilterStruct.FilterMaskIdLow = 0x0000; /* Lower 16bit filter mask */
CAN_FilterStruct.FilterFIFOAssignment = CAN_FILTER_FIFO0; /* Which FIFO will be assigned to filter */
CAN_FilterStruct.FilterNumber = 0;
CAN_FilterStruct.FilterMode = CAN_FILTERMODE_IDMASK; /* Identifier mask mode */
CAN_FilterStruct.FilterScale = CAN_FILTERSCALE_32BIT; /* 32bit ID filter */
CAN_FilterStruct.FilterActivation = ENABLE; /* Enable this filter */
CAN_FilterStruct.BankNumber = 14; /* Start slave bank filter (?) */
CAN_FilterStruct.FilterMode = CAN_FILTERMODE_IDMASK; /* Identifier mask mode */
CAN_FilterStruct.FilterScale = CAN_FILTERSCALE_32BIT; /* 32bit ID filter */
CAN_FilterStruct.FilterActivation = ENABLE; /* Enable this filter */
CAN_FilterStruct.BankNumber = 14; /* Start slave bank filter (?) */
HAL_CAN_ConfigFilter(&peripheralHandle, &CAN_FilterStruct); /* Initialize filter */
}

Expand Down Expand Up @@ -104,8 +107,8 @@ namespace hal
void CanStm::HandleRxInterrupt()
{
Id id = (peripheralCan[canIndex]->sFIFOMailBox[0].RIR & CAN_RI0R_IDE) == 0
? Id::Create11BitId(peripheralCan[canIndex]->sFIFOMailBox[0].RIR >> 21)
: Id::Create29BitId(peripheralCan[canIndex]->sFIFOMailBox[0].RIR >> 3);
? Id::Create11BitId(peripheralCan[canIndex]->sFIFOMailBox[0].RIR >> 21)
: Id::Create29BitId(peripheralCan[canIndex]->sFIFOMailBox[0].RIR >> 3);

Message message(8, uint8_t(0));
reinterpret_cast<uint32_t*>(message.data())[0] = peripheralCan[canIndex]->sFIFOMailBox[0].RDLR;
Expand Down
5 changes: 3 additions & 2 deletions hal_st/stm32fxxx/CanStm.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef HAL_CAN_STM_HPP
#define HAL_CAN_STM_HPP

#include "cmsis_device.h"
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "hal/interfaces/Can.hpp"
#include "hal_st/cortex/InterruptCortex.hpp"
#include "hal_st/stm32fxxx/GpioStm.hpp"
#include "cmsis_device.h"

#if defined(HAS_PERIPHERAL_CAN)

Expand All @@ -17,7 +17,8 @@ namespace hal
public:
struct Config
{
constexpr Config() {}
constexpr Config()
{}

uint32_t prescaler = 1024;
};
Expand Down
2 changes: 1 addition & 1 deletion hal_st/stm32fxxx/DacStm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "hal_st/stm32fxxx/DacStm.hpp"
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "hal_st/stm32fxxx/GpioStm.hpp"
#include <type_traits>

Expand Down
2 changes: 1 addition & 1 deletion hal_st/stm32fxxx/DacStm.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef HAL_DAC_STM_HPP
#define HAL_DAC_STM_HPP

#include "cmsis_device.h"
#include "hal/interfaces/Dac.hpp"
#include "hal_st/stm32fxxx/GpioStm.hpp"
#include "cmsis_device.h"

namespace hal
{
Expand Down
4 changes: 2 additions & 2 deletions hal_st/stm32fxxx/DigitalToAnalogPinStm.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "hal_st/stm32fxxx/DigitalToAnalogPinStm.hpp"
#include "infra/util/BitLogic.hpp"
#include "cmsis_device.h"
#include "generated/stm32fxxx/PeripheralTable.hpp"
#include "infra/util/BitLogic.hpp"

namespace hal
{
Expand Down
1 change: 1 addition & 0 deletions hal_st/stm32fxxx/DigitalToAnalogPinStm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace hal
DigitalToAnalogPinImplStm(hal::GpioPinStm& pin, hal::DacStm& dac);

void Set(uint16_t value) override;

private:
AnalogPinStm pin;
DacStm& dac;
Expand Down
11 changes: 7 additions & 4 deletions hal_st/stm32fxxx/DmaStm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace hal
{ DMA2_Stream0_IRQn, DMA2_Stream1_IRQn, DMA2_Stream2_IRQn, DMA2_Stream3_IRQn, DMA2_Stream4_IRQn, DMA2_Stream5_IRQn, DMA2_Stream6_IRQn, DMA2_Stream7_IRQn }
};

#if defined (STM32F765xx) || defined(STM32F767xx) || defined(STM32F769xx) || defined(STM32F777xx) || defined(STM32F779xx)
#if defined(STM32F765xx) || defined(STM32F767xx) || defined(STM32F769xx) || defined(STM32F777xx) || defined(STM32F779xx)
const uint32_t dmaChannel[16] = {
DMA_CHANNEL_0, DMA_CHANNEL_1, DMA_CHANNEL_2, DMA_CHANNEL_3, DMA_CHANNEL_4, DMA_CHANNEL_5, DMA_CHANNEL_6, DMA_CHANNEL_7,
DMA_CHANNEL_8, DMA_CHANNEL_9, DMA_CHANNEL_10, DMA_CHANNEL_11, DMA_CHANNEL_12, DMA_CHANNEL_13, DMA_CHANNEL_14, DMA_CHANNEL_15
Expand Down Expand Up @@ -71,7 +71,8 @@ namespace hal
, dmaIndex(channelId.dma)
, streamIndex(channelId.stream)
, actionOnTransferComplete(actionOnTransferComplete)
, interruptHandler(hal::dmaIrq[dmaIndex][streamIndex], [this]() { OnInterrupt(); })
, interruptHandler(hal::dmaIrq[dmaIndex][streamIndex], [this]()
{ OnInterrupt(); })
{
dma.ReserveStream(dmaIndex, streamIndex);

Expand Down Expand Up @@ -100,7 +101,8 @@ namespace hal
, dmaIndex(other.dmaIndex)
, streamIndex(other.streamIndex)
, actionOnTransferComplete(other.actionOnTransferComplete)
, interruptHandler(std::move(other.interruptHandler), [this]() { OnInterrupt(); })
, interruptHandler(std::move(other.interruptHandler), [this]()
{ OnInterrupt(); })
{
other.streamIndex = 0xff;
other.actionOnTransferComplete = nullptr;
Expand All @@ -117,7 +119,8 @@ namespace hal
dmaIndex = other.dmaIndex;
streamIndex = other.streamIndex;
actionOnTransferComplete = other.actionOnTransferComplete;
interruptHandler.Assign(std::move(other.interruptHandler), [this]() { OnInterrupt(); });
interruptHandler.Assign(std::move(other.interruptHandler), [this]()
{ OnInterrupt(); });

other.streamIndex = 0xff;
other.actionOnTransferComplete = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions hal_st/stm32fxxx/DmaStm.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef HAL_DMA_STM_HPP
#define HAL_DMA_STM_HPP

#include "cmsis_device.h"
#include "hal_st/cortex/InterruptCortex.hpp"
#include "infra/util/ByteRange.hpp"
#include "infra/util/Function.hpp"
#include "cmsis_device.h"

namespace hal
{
Expand Down Expand Up @@ -66,7 +66,7 @@ namespace hal
void ReleaseStream(uint8_t dmaIndex, uint8_t streamIndex);

private:
std::array<uint32_t, 2> streamAllocation = {{ 0, 0 }};
std::array<uint32_t, 2> streamAllocation = { { 0, 0 } };
};
}

Expand Down
Loading