Skip to content

Commit

Permalink
[gpio] Add .clang-format with modm style and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikssn committed Sep 25, 2020
1 parent f0a2521 commit c9de7d1
Show file tree
Hide file tree
Showing 9 changed files with 584 additions and 370 deletions.
163 changes: 163 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: ForContinuationAndIndentation
40 changes: 22 additions & 18 deletions examples/samd/interrupt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ using namespace std::chrono_literals;

static volatile bool blink = true;

void isr() {
blink = !blink;
// Kids, please don't do serial logging in ISRs...
MODM_LOG_DEBUG << "blink: " << (blink ? "true" : "false") << modm::endl;
void
isr()
{
blink = !blink;
// Kids, please don't do serial logging in ISRs...
MODM_LOG_DEBUG << "blink: " << (blink ? "true" : "false") << modm::endl;
}

int main() {
Board::initialize();
ExternalInterrupt::initialize();
ExtInt<3>::initialize(&isr);
ExtInt<3>::connect<D12>();
while (1) {
if (blink) {
Led::toggle();
} else {
Led::set(0);
}
modm::delay(100ms);
}
return 0;
int
main()
{
Board::initialize();
ExternalInterrupt::initialize();
ExtInt<3>::initialize(&isr);
ExtInt<3>::connect<D12>();
while (1) {
if (blink) {
Led::toggle();
} else {
Led::set(0);
}
modm::delay(100ms);
}
return 0;
}
2 changes: 1 addition & 1 deletion ext/modm-devices
82 changes: 43 additions & 39 deletions src/modm/board/feather_m0/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
using namespace modm::platform;

/// @ingroup modm_board_feather_m0
namespace Board {
namespace Board
{

using namespace modm::literals;

Expand Down Expand Up @@ -61,50 +62,53 @@ using Led = D13;

/// samd21g18a running at 48MHz generated from the external 32.768 KHz crystal
struct SystemClock {
static constexpr uint32_t Frequency = 48_MHz;
// static constexpr uint32_t Ahb = Frequency;
// static constexpr uint32_t Apba = Frequency;
// static constexpr uint32_t Apbb = Frequency;
// static constexpr uint32_t Apbc = Frequency;

// static constexpr uint32_t Adc = Apb2;

// static constexpr uint32_t SercomSlow = Apb2;
// static constexpr uint32_t Sercom0 = Apb2;
// static constexpr uint32_t Sercom1 = Apb2;
// static constexpr uint32_t Sercom2 = Apb2;
// static constexpr uint32_t Sercom3 = Apb2;
// static constexpr uint32_t Sercom4 = Apb2;
// static constexpr uint32_t Sercom5 = Apb2;

// static constexpr uint32_t Apb1Timer = Apb1 * 2;
// static constexpr uint32_t Apb2Timer = Apb2 * 1;
// static constexpr uint32_t Timer1 = Apb2Timer;
// static constexpr uint32_t Timer2 = Apb1Timer;
// static constexpr uint32_t Timer3 = Apb1Timer;
// static constexpr uint32_t Timer4 = Apb1Timer;

static bool inline enable() {
GenericClockController::setFlashLatency<Frequency>();
GenericClockController::initExternalCrystal();
GenericClockController::initDFLL48MHz();
GenericClockController::initOsc8MHz();
GenericClockController::setSystemClock(ClockSource::DFLL48M);
GenericClockController::updateCoreFrequency<Frequency>();
return true;
}
static constexpr uint32_t Frequency = 48_MHz;
// static constexpr uint32_t Ahb = Frequency;
// static constexpr uint32_t Apba = Frequency;
// static constexpr uint32_t Apbb = Frequency;
// static constexpr uint32_t Apbc = Frequency;

// static constexpr uint32_t Adc = Apb2;

// static constexpr uint32_t SercomSlow = Apb2;
// static constexpr uint32_t Sercom0 = Apb2;
// static constexpr uint32_t Sercom1 = Apb2;
// static constexpr uint32_t Sercom2 = Apb2;
// static constexpr uint32_t Sercom3 = Apb2;
// static constexpr uint32_t Sercom4 = Apb2;
// static constexpr uint32_t Sercom5 = Apb2;

// static constexpr uint32_t Apb1Timer = Apb1 * 2;
// static constexpr uint32_t Apb2Timer = Apb2 * 1;
// static constexpr uint32_t Timer1 = Apb2Timer;
// static constexpr uint32_t Timer2 = Apb1Timer;
// static constexpr uint32_t Timer3 = Apb1Timer;
// static constexpr uint32_t Timer4 = Apb1Timer;

static bool inline enable()
{
GenericClockController::setFlashLatency<Frequency>();
GenericClockController::initExternalCrystal();
GenericClockController::initDFLL48MHz();
GenericClockController::initOsc8MHz();
GenericClockController::setSystemClock(ClockSource::DFLL48M);
GenericClockController::updateCoreFrequency<Frequency>();
return true;
}
};

using LoggerDevice = modm::IODeviceWrapper<Uart0, modm::IOBuffer::BlockIfFull>;
using Leds = Led;

inline void initialize() {
SystemClock::enable();
SysTickTimer::initialize<SystemClock>();
Uart0::connect<Rx, Tx>();
Uart0::initialize<SystemClock, 115'200_Bd>();
inline void
initialize()
{
SystemClock::enable();
SysTickTimer::initialize<SystemClock>();
Uart0::connect<Rx, Tx>();
Uart0::initialize<SystemClock, 115'200_Bd>();

Led::setOutput(modm::Gpio::Low);
Led::setOutput(modm::Gpio::Low);
}

} // namespace Board
Loading

0 comments on commit c9de7d1

Please sign in to comment.