gerrit-log
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
January 2025
- 1 participants
- 1491 discussions
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39439?usp=email )
Change subject: tame the linter
......................................................................
tame the linter
Change-Id: I745b741dedf2c2ed5679c289e70adcb01c750e4d
---
A .checkpatch.conf
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/39/39439/1
diff --git a/.checkpatch.conf b/.checkpatch.conf
new file mode 100644
index 0000000..5b21bdc
--- /dev/null
+++ b/.checkpatch.conf
@@ -0,0 +1 @@
+--exclude gcc/gcc/.*ld
\ No newline at end of file
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39439?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I745b741dedf2c2ed5679c289e70adcb01c750e4d
Gerrit-Change-Number: 39439
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
1
0
Jenkins Builder has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435?usp=email )
Change subject: errata 2.6.10
......................................................................
Patch Set 1:
(17 comments)
File gcc/gcc/startup_same54.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/c5813e67_567c6bd… :
PS1, Line 671: __attribute__((naked,noreturn)) void Reset_Handler(void)
space required after that ',' (ctx:VxV)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/93dff4cd_4177237… :
PS1, Line 675: __asm volatile (
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/9373fc81_8e64a37… :
PS1, Line 676: "movs r0, #0\n"
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/2b7d17c3_0779c8e… :
PS1, Line 676: "movs r0, #0\n"
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/6816a398_4f7c417… :
PS1, Line 677: "ldr r1, =0x40002000\n"
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/8a9b5a11_e37c0aa… :
PS1, Line 677: "ldr r1, =0x40002000\n"
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/40b45f7c_3d22779… :
PS1, Line 678: "strb r0, [r1]\n"
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/0574c5d5_fc5a4fb… :
PS1, Line 678: "strb r0, [r1]\n"
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/f55a6fab_770c558… :
PS1, Line 679: "bl _Reset_Handler\n"
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/2365f18b_5a863eb… :
PS1, Line 679: "bl _Reset_Handler\n"
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/d710b350_a601a77… :
PS1, Line 680: ::: "r0", "r1", "memory"
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/248d2c37_893c0f1… :
PS1, Line 680: ::: "r0", "r1", "memory"
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/5fa96671_e7967db… :
PS1, Line 681: );
please, no spaces at the start of a line
File usb_flash_main.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/af46e7a9_7fd8228… :
PS1, Line 136: bool startup_wdt_inactive = _user_area_read_bits((void*)NVMCTRL_USER, 62, 1) != 1;
"(foo*)" should be "(foo *)"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/eeb8c7f1_f3a8924… :
PS1, Line 137: if (chiprev_lower_revG && startup_wdt_inactive)
that open brace { should be on the previous line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/b6f308b1_a172260… :
PS1, Line 139: _user_area_write_bits((void*)NVMCTRL_USER, 50, 0, 4);
"(foo*)" should be "(foo *)"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21260):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435/comment/3d45facf_e307e61… :
PS1, Line 140: _user_area_write_bits((void*)NVMCTRL_USER, 62, 1, 1);
"(foo*)" should be "(foo *)"
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39435?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: Ifbc6a3dfe91462029fce50ed42f20440debaa552
Gerrit-Change-Number: 39435
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 29 Jan 2025 18:24:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
1
0
Jenkins Builder has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434?usp=email )
Change subject: bl updater app
......................................................................
Patch Set 1:
(313 comments)
File CMSIS/Include/cmsis_version.h:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dc8d7d20_e7f2395… :
PS1, Line 1: /**************************************************************************//**
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/57d95251_13b61c4… :
PS1, Line 2: * @file cmsis_version.h
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b7b06e43_13679a1… :
PS1, Line 3: * @brief CMSIS Core(M) Version definitions
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d87c2e7a_5b77466… :
PS1, Line 4: * @version V5.0.2
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dc9fd457_8ba7e03… :
PS1, Line 5: * @date 19. April 2017
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e24dc3d9_1fde6b7… :
PS1, Line 6: ******************************************************************************/
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/834c219d_44937c3… :
PS1, Line 7: /*
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a5b779ac_082d557… :
PS1, Line 8: * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/25c16838_36e8085… :
PS1, Line 9: *
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c704e890_e8b9107… :
PS1, Line 10: * SPDX-License-Identifier: Apache-2.0
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/896313a6_dd42b1b… :
PS1, Line 11: *
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dfd14ed1_f5cc616… :
PS1, Line 12: * Licensed under the Apache License, Version 2.0 (the License); you may
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/fcb301fa_925ce17… :
PS1, Line 13: * not use this file except in compliance with the License.
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a1b8137f_5725791… :
PS1, Line 14: * You may obtain a copy of the License at
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5d89ebf0_6426c2b… :
PS1, Line 15: *
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/906c5fc4_b94f267… :
PS1, Line 16: * www.apache.org/licenses/LICENSE-2.0
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1dcb3b76_383098f… :
PS1, Line 17: *
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a3bde681_57383a1… :
PS1, Line 18: * Unless required by applicable law or agreed to in writing, software
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/06b4ca23_20cf4ec… :
PS1, Line 19: * distributed under the License is distributed on an AS IS BASIS, WITHOUT
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/60fd758b_203bdd7… :
PS1, Line 20: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f8df66f1_238d3aa… :
PS1, Line 21: * See the License for the specific language governing permissions and
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b30c9ea4_cf49c56… :
PS1, Line 22: * limitations under the License.
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f337fcb8_045c187… :
PS1, Line 23: */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c55e2751_5f6b579… :
PS1, Line 24:
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/662df76c_1434046… :
PS1, Line 25: #if defined ( __ICCARM__ )
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b8e67712_1f249a0… :
PS1, Line 25: #if defined ( __ICCARM__ )
space prohibited between function name and open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ca136436_75c3874… :
PS1, Line 25: #if defined ( __ICCARM__ )
space prohibited after that open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/cb812cd2_364a87e… :
PS1, Line 25: #if defined ( __ICCARM__ )
space prohibited before that close parenthesis ')'
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2d8fb0b8_742fde6… :
PS1, Line 26: #pragma system_include /* treat file as system include file for MISRA check */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3a9ca61c_93fa4cf… :
PS1, Line 27: #elif defined (__clang__)
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/596f2626_3fc4f14… :
PS1, Line 27: #elif defined (__clang__)
space prohibited between function name and open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1c3e44ff_556bc9e… :
PS1, Line 28: #pragma clang system_header /* treat file as system include file */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/faa2a21b_69f41fa… :
PS1, Line 29: #endif
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/605a0ad6_b878bc0… :
PS1, Line 30:
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d61e858b_82634b4… :
PS1, Line 31: #ifndef __CMSIS_VERSION_H
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/67ebf04b_1feacf4… :
PS1, Line 32: #define __CMSIS_VERSION_H
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b9bbe78d_780177a… :
PS1, Line 33:
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ba58dbdd_70da143… :
PS1, Line 34: /* CMSIS Version definitions */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bf70ccec_69a229b… :
PS1, Line 35: #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/547bbf25_dad0b32… :
PS1, Line 35: #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
space prohibited after that open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/86739ecb_04b8a98… :
PS1, Line 36: #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/85d007bd_1064452… :
PS1, Line 36: #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
space prohibited after that open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/11e60669_36c7183… :
PS1, Line 37: #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7d1c1b25_dbaf103… :
PS1, Line 37: #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
Whitespace after \ makes next lines useless
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/85eeee22_bd08cd0… :
PS1, Line 38: __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
DOS line endings
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/6be2487c_2d8aa62… :
PS1, Line 38: __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/90d4b090_e06fc68… :
PS1, Line 38: __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/4e5d75c9_4d6a42d… :
PS1, Line 38: __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
space prohibited before that close parenthesis ')'
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/909d134e_0583bee… :
PS1, Line 39: #endif
DOS line endings
File hpl/core/hpl_core_m4.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/858f8e2a_f4878c5… :
PS1, Line 220: __asm(".align 3 \n"
unnecessary whitespace before a quoted newline
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3685f85b_2aadbd4… :
PS1, Line 226: ".align 3 \n"
unnecessary whitespace before a quoted newline
File hpl/sercom/hpl_sercom.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bd062de9_1008f06… :
PS1, Line 89: | (CONF_SERCOM_##n##_USART_RUNSTDBY << SERCOM_USART_CTRLA_RUNSTDBY_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/05fb2f25_21074a1… :
PS1, Line 90: | (CONF_SERCOM_##n##_USART_IBON << SERCOM_USART_CTRLA_IBON_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dad2a895_065d258… :
PS1, Line 91: | (CONF_SERCOM_##n##_USART_TXINV << SERCOM_USART_CTRLA_TXINV_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e1499b28_9fdb39f… :
PS1, Line 92: | (CONF_SERCOM_##n##_USART_RXINV << SERCOM_USART_CTRLA_RXINV_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2ba99a37_1027c70… :
PS1, Line 93: | SERCOM_USART_CTRLA_SAMPR(CONF_SERCOM_##n##_USART_SAMPR) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7afb04b3_61ba7a9… :
PS1, Line 94: | SERCOM_USART_CTRLA_TXPO(CONF_SERCOM_##n##_USART_TXPO) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9584f5d9_9f450ce… :
PS1, Line 95: | SERCOM_USART_CTRLA_RXPO(CONF_SERCOM_##n##_USART_RXPO) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/defd3361_c7b1e7e… :
PS1, Line 96: | SERCOM_USART_CTRLA_SAMPA(CONF_SERCOM_##n##_USART_SAMPA) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/cb63c638_d0159ff… :
PS1, Line 97: | SERCOM_USART_CTRLA_FORM(CONF_SERCOM_##n##_USART_FORM) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/376bb85a_396f86f… :
PS1, Line 98: | (CONF_SERCOM_##n##_USART_CMODE << SERCOM_USART_CTRLA_CMODE_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/34720b71_8441524… :
PS1, Line 99: | (CONF_SERCOM_##n##_USART_CPOL << SERCOM_USART_CTRLA_CPOL_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1e7bc09c_c9b5412… :
PS1, Line 100: | (CONF_SERCOM_##n##_USART_DORD << SERCOM_USART_CTRLA_DORD_Pos), \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d4272ee8_54cdc46… :
PS1, Line 102: | (CONF_SERCOM_##n##_USART_SBMODE << SERCOM_USART_CTRLB_SBMODE_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/501f5a4c_9dca777… :
PS1, Line 103: | (CONF_SERCOM_##n##_USART_CLODEN << SERCOM_USART_CTRLB_COLDEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7254da6c_b60fa1a… :
PS1, Line 104: | (CONF_SERCOM_##n##_USART_SFDE << SERCOM_USART_CTRLB_SFDE_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bdc1eb49_9b21812… :
PS1, Line 105: | (CONF_SERCOM_##n##_USART_ENC << SERCOM_USART_CTRLB_ENC_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c89547ec_65938ed… :
PS1, Line 106: | (CONF_SERCOM_##n##_USART_PMODE << SERCOM_USART_CTRLB_PMODE_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bf0e28b7_6620ceb… :
PS1, Line 107: | (CONF_SERCOM_##n##_USART_TXEN << SERCOM_USART_CTRLB_TXEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e7a6f2a9_e22c077… :
PS1, Line 108: | (CONF_SERCOM_##n##_USART_RXEN << SERCOM_USART_CTRLB_RXEN_Pos), \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d0c1930d_1b8824a… :
PS1, Line 110: | (CONF_SERCOM_##n##_USART_DSNACK << SERCOM_USART_CTRLC_DSNACK_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2c3778bd_63f9a26… :
PS1, Line 111: | (CONF_SERCOM_##n##_USART_INACK << SERCOM_USART_CTRLC_INACK_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b6bd71bb_06a7faa… :
PS1, Line 112: | SERCOM_USART_CTRLC_MAXITER(CONF_SERCOM_##n##_USART_MAXITER), \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/972623e0_a381409… :
PS1, Line 140: SERCOM_CONFIGURATION(0),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3f16fabf_e3b4b2a… :
PS1, Line 143: SERCOM_CONFIGURATION(1),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/65b68a7e_a29d295… :
PS1, Line 146: SERCOM_CONFIGURATION(2),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/420b6ef0_3da9572… :
PS1, Line 149: SERCOM_CONFIGURATION(3),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d4d44c67_1837076… :
PS1, Line 152: SERCOM_CONFIGURATION(4),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2bd32ea2_32f5423… :
PS1, Line 155: SERCOM_CONFIGURATION(5),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/43424672_117daa2… :
PS1, Line 158: SERCOM_CONFIGURATION(6),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/516354ce_b556afb… :
PS1, Line 161: SERCOM_CONFIGURATION(7),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/4f83313a_a606c08… :
PS1, Line 188: const enum usart_baud_rate_mode mode, const uint8_t fraction);
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e6018a24_8244f86… :
PS1, Line 188: const enum usart_baud_rate_mode mode, const uint8_t fraction);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/4783ab40_30a41c4… :
PS1, Line 218: if (init_status) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c3e1c63b_9657787… :
PS1, Line 254: const enum usart_baud_rate_mode mode, const uint8_t fraction)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/eb51cf4f_b118225… :
PS1, Line 254: const enum usart_baud_rate_mode mode, const uint8_t fraction)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d24224cb_8068c33… :
PS1, Line 263: const enum usart_baud_rate_mode mode, const uint8_t fraction)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f28540c6_9a9d081… :
PS1, Line 263: const enum usart_baud_rate_mode mode, const uint8_t fraction)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9da445f2_7716550… :
PS1, Line 471: void _usart_sync_set_flow_control_state(struct _usart_sync_device *const device,
"foo *const bar" should be "foo *const bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2ef0741b_6e9350c… :
PS1, Line 472: const union usart_flow_control_state state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0aa8a5c0_b5883e3… :
PS1, Line 472: const union usart_flow_control_state state)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1fbf81a4_3fec36e… :
PS1, Line 481: void _usart_async_set_flow_control_state(struct _usart_async_device *const device,
"foo *const bar" should be "foo *const bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e7a54a79_e1892de… :
PS1, Line 482: const union usart_flow_control_state state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/78d0d99b_2ffa4de… :
PS1, Line 482: const union usart_flow_control_state state)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dd786b35_5a0758e… :
PS1, Line 535: Sercom *const sercom_modules[] = SERCOM_INSTS;
need consistent spacing around '*' (ctx:WxV) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/713da56c_6a82e57… :
PS1, Line 538: if ((uint32_t)hw == (uint32_t)sercom_modules[i]) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9094cf91_6e4f0be… :
PS1, Line 565: const bool state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b64c2146_fbf3f04… :
PS1, Line 565: const bool state)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/21f4d8ac_3698a9c… :
PS1, Line 626: if (_usarts[i].number == sercom_offset) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/daa8349d_066c040… :
PS1, Line 641: if (hw == SERCOM0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/81222ebd_be6d5e4… :
PS1, Line 645: if (hw == SERCOM1) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/687675b3_206e591… :
PS1, Line 649: if (hw == SERCOM2) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ded46887_2d08927… :
PS1, Line 653: if (hw == SERCOM3) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d6de9e71_2fb15a9… :
PS1, Line 657: if (hw == SERCOM4) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/50e1b410_1d3ad78… :
PS1, Line 661: if (hw == SERCOM5) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c99b4fdd_e51fff3… :
PS1, Line 665: if (hw == SERCOM6) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1508327c_ea9b35a… :
PS1, Line 730: const enum usart_baud_rate_mode mode, const uint8_t fraction)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c82f099d_caa2f3e… :
PS1, Line 730: const enum usart_baud_rate_mode mode, const uint8_t fraction)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/860865bd_b1b415b… :
PS1, Line 732: if (USART_BAUDRATE_ASYNCH_ARITHMETIC == mode) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5b0962fd_29e9df5… :
PS1, Line 736: if (USART_BAUDRATE_ASYNCH_FRACTIONAL == mode) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/76245435_6a8061a… :
PS1, Line 740: if (USART_BAUDRATE_SYNCH == mode) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/141c3fd2_4f3e303… :
PS1, Line 822: if (USART_PARITY_NONE != parity) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f707edbb_dbdbc42… :
PS1, Line 871: if (enabled) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f58bb482_fb00323… :
PS1, Line 918: | (CONF_SERCOM_##n##_I2CM_SPEED << SERCOM_I2CM_CTRLA_SPEED_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1c02f3d8_272ed8b… :
PS1, Line 919: | (CONF_SERCOM_##n##_I2CM_MEXTTOEN << SERCOM_I2CM_CTRLA_MEXTTOEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bb30cf4c_3df6741… :
PS1, Line 920: | (CONF_SERCOM_##n##_I2CM_SEXTTOEN << SERCOM_I2CM_CTRLA_SEXTTOEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/4478509b_ef57ca3… :
PS1, Line 921: | (CONF_SERCOM_##n##_I2CM_INACTOUT << SERCOM_I2CM_CTRLA_INACTOUT_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dc966ccf_dd9f3f5… :
PS1, Line 922: | (CONF_SERCOM_##n##_I2CM_LOWTOUT << SERCOM_I2CM_CTRLA_LOWTOUTEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/afd65868_66c51ef… :
PS1, Line 923: | (CONF_SERCOM_##n##_I2CM_SDAHOLD << SERCOM_I2CM_CTRLA_SDAHOLD_Pos), \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a29cb2df_9a91d95… :
PS1, Line 966: I2CM_CONFIGURATION(0),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c685d94a_0123f8b… :
PS1, Line 969: I2CM_CONFIGURATION(1),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0d8fdf27_0873e77… :
PS1, Line 972: I2CM_CONFIGURATION(2),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/937d5a5d_9e01f45… :
PS1, Line 975: I2CM_CONFIGURATION(3),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8d38a64f_658379b… :
PS1, Line 978: I2CM_CONFIGURATION(4),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d9606db1_d6295be… :
PS1, Line 981: I2CM_CONFIGURATION(5),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/17048124_6ea7925… :
PS1, Line 984: I2CM_CONFIGURATION(6),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/51c702b4_027d2d6… :
PS1, Line 987: I2CM_CONFIGURATION(7),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/37ba619c_ed22e3f… :
PS1, Line 1005: if (_i2cms[i].number == sercom_offset) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5cf0a2b0_6dc8376… :
PS1, Line 1034: if (status & SERCOM_I2CM_STATUS_BUSERR) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/cfca7e39_411480b… :
PS1, Line 1039: } else {
else is not generally useful after a break or return
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ca7145af_510bdd0… :
PS1, Line 1043: if (msg->len > 0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3b3ce917_5e085b5… :
PS1, Line 1047: if (msg->flags & I2C_M_STOP) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5c03178f_6a74e76… :
PS1, Line 1058: ((((msg->addr & TEN_ADDR_MASK) >> 8) | TEN_ADDR_FRAME) << 1) | I2C_M_RD
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1589e6ae_28540d4… :
PS1, Line 1059: | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1257ff4d_4efd817… :
PS1, Line 1066: if (msg->flags & I2C_M_STOP) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/602b612b_6fae5f5… :
PS1, Line 1084: if ((msg->len == 0 && !sclsm) || (msg->len == 1 && sclsm)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3cce8471_68842e6… :
PS1, Line 1153: void * hw = i2c_dev->hw;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f044f73e_dd8b005… :
PS1, Line 1155: if (hri_sercomi2cm_get_CTRLA_ENABLE_bit(hw)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3faff101_46c8ba7… :
PS1, Line 1164: / (2 * baudrate));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/467e12d2_bcff1e1… :
PS1, Line 1168: / (2 * baudrate));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/51419a61_659a408… :
PS1, Line 1203: if (init_status) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/1228c268_115ec85… :
PS1, Line 1240: void * hw = i2c_dev->hw;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0e5edd4f_cc2d76a… :
PS1, Line 1246: if (msg->len == 1 && sclsm) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2ea42631_6ba7f6c… :
PS1, Line 1254: if (msg->flags & I2C_M_RD) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0bdb90e0_9a8cc6e… :
PS1, Line 1259: ((msg->addr & TEN_ADDR_MASK) << 1) | SERCOM_I2CM_ADDR_TENBITEN
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a16aaf87_cd06899… :
PS1, Line 1260: | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/df791200_9e1e934… :
PS1, Line 1263: ((msg->addr & SEVEN_ADDR_MASK) << 1) | (msg->flags & I2C_M_RD ? I2C_M_RD : 0x0)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d6861c38_6d41a09… :
PS1, Line 1264: | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ab724f35_76519b3… :
PS1, Line 1288: if (msg->len == 0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bdf44712_7aa7233… :
PS1, Line 1292: if (i2c_dev->service.msg.flags & I2C_M_BUSY) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/cd7a639f_24a1669… :
PS1, Line 1319: FUNC_PTR func)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/fdc0dd11_88a50ab… :
PS1, Line 1319: FUNC_PTR func)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a8e89204_acf890a… :
PS1, Line 1345: * \retval I2C_OK Operation was successfull
'successfull' may be misspelled - perhaps 'successful'?
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a2973e9a_6f33743… :
PS1, Line 1366: if (i2c_dev->service.msg.flags & I2C_M_BUSY) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/12be16cf_fc4edd8… :
PS1, Line 1441: void * hw = i2c_dev->hw;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a3fbf9eb_96bf910… :
PS1, Line 1443: if (hri_sercomi2cm_get_CTRLA_ENABLE_bit(hw)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/03e10e32_a329824… :
PS1, Line 1452: / (2 * baudrate));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e635ffab_51437c2… :
PS1, Line 1456: / (2 * baudrate));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2375227e_93301b9… :
PS1, Line 1473: const bool state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/392a83c7_72d7040… :
PS1, Line 1473: const bool state)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2d974c1e_836e355… :
PS1, Line 1493: inline static int32_t _sercom_i2c_sync_wait_bus(struct _i2c_m_sync_device *const i2c_dev, uint32_t *flags)
inline keyword should sit between storage class and type
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a9cec127_005c65f… :
PS1, Line 1496: void * hw = i2c_dev->hw;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2a164d72_102d499… :
PS1, Line 1501: if (timeout-- == 0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d32d13cc_180383b… :
PS1, Line 1516: void * hw = i2c_dev->hw;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/fbeff6b4_23b5aa4… :
PS1, Line 1523: if (msg->len == 1 && sclsm) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a04e2d5d_a63ad19… :
PS1, Line 1531: if (msg->flags & I2C_M_RD) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7c794a44_b3d5866… :
PS1, Line 1536: ((msg->addr & TEN_ADDR_MASK) << 1) | SERCOM_I2CM_ADDR_TENBITEN
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/19768d48_df14b5b… :
PS1, Line 1537: | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d38a507f_b704886… :
PS1, Line 1540: ((msg->addr & SEVEN_ADDR_MASK) << 1) | (msg->flags & I2C_M_RD ? I2C_M_RD : 0x0)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/58278a66_b6a5c58… :
PS1, Line 1541: | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c500b3da_901f600… :
PS1, Line 1562: void * hw = i2c_dev->hw;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/4cd31404_10db6cb… :
PS1, Line 1568: if (i2c_dev->service.msg.flags & I2C_M_BUSY) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/10985f91_579b293… :
PS1, Line 1588: if (msg->flags & I2C_M_STOP) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e8a25c9d_3b03c78… :
PS1, Line 1704: | SERCOM_I2CS_CTRLA_SDAHOLD(CONF_SERCOM_##n##_I2CS_SDAHOLD) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ab88d0cc_40ee10e… :
PS1, Line 1705: | (CONF_SERCOM_##n##_I2CS_SEXTTOEN << SERCOM_I2CS_CTRLA_SEXTTOEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a2eb59f9_27fc661… :
PS1, Line 1706: | (CONF_SERCOM_##n##_I2CS_SPEED << SERCOM_I2CS_CTRLA_SPEED_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/68ca04b2_8efb2c8… :
PS1, Line 1707: | (CONF_SERCOM_##n##_I2CS_SCLSM << SERCOM_I2CS_CTRLA_SCLSM_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3cefb6f2_8d98050… :
PS1, Line 1708: | (CONF_SERCOM_##n##_I2CS_LOWTOUT << SERCOM_I2CS_CTRLA_LOWTOUTEN_Pos), \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/10389ce3_3987430… :
PS1, Line 1711: | SERCOM_I2CS_ADDR_ADDR(CONF_SERCOM_##n##_I2CS_ADDRESS) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e1d13611_f59eb5c… :
PS1, Line 1712: | (CONF_SERCOM_##n##_I2CS_TENBITEN << SERCOM_I2CS_ADDR_TENBITEN_Pos) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7c1ee3e7_a472b27… :
PS1, Line 1713: | SERCOM_I2CS_ADDR_ADDRMASK(CONF_SERCOM_##n##_I2CS_ADDRESS_MASK) \
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/df8f3390_71aaa29… :
PS1, Line 1745: I2CS_CONFIGURATION(0),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a6511d51_49d4643… :
PS1, Line 1748: I2CS_CONFIGURATION(1),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3fe7451b_cc2a2fa… :
PS1, Line 1751: I2CS_CONFIGURATION(2),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dbd53c79_d2ea6c5… :
PS1, Line 1754: I2CS_CONFIGURATION(3),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ceed4d33_0285693… :
PS1, Line 1757: I2CS_CONFIGURATION(4),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/44fbaf6a_884d08d… :
PS1, Line 1760: I2CS_CONFIGURATION(5),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/963bf907_b0bddba… :
PS1, Line 1763: I2CS_CONFIGURATION(6),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8fb4e86e_317bbe5… :
PS1, Line 1766: I2CS_CONFIGURATION(7),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9f0d2665_77a6662… :
PS1, Line 1781: if (status) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f3d5658e_1cc1b3e… :
PS1, Line 1799: if (init_status) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/77659999_e91c185… :
PS1, Line 1992: const bool state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b98ec985_1505a6c… :
PS1, Line 1992: const bool state)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/453cd986_5da83dd… :
PS1, Line 1996: if (I2C_S_DEVICE_TX == type || I2C_S_DEVICE_RX_COMPLETE == type) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d7b2a3ab_b474170… :
PS1, Line 2006: * \internal Initalize i2c slave hardware
'Initalize' may be misspelled - perhaps 'Initialize'?
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/304f652b_f7f04d0… :
PS1, Line 2015: if (i == -1) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f26dfdf0_7de0e9e… :
PS1, Line 2049: if (_i2css[i].number == sercom_offset) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/38f920f7_d73c64b… :
PS1, Line 2086: if (enabled) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/26ab9956_405559f… :
PS1, Line 2179: SERCOMSPI_REGS(0),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/4fcf202c_f6a4b34… :
PS1, Line 2182: SERCOMSPI_REGS(1),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/471077ae_955bfdb… :
PS1, Line 2185: SERCOMSPI_REGS(2),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a835130b_2783c8e… :
PS1, Line 2188: SERCOMSPI_REGS(3),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/088ba129_2b397d6… :
PS1, Line 2191: SERCOMSPI_REGS(4),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/433e3fb8_2e416ca… :
PS1, Line 2194: SERCOMSPI_REGS(5),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7e909084_94b88d3… :
PS1, Line 2197: SERCOMSPI_REGS(6),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/795dbb30_e17cb71… :
PS1, Line 2200: SERCOMSPI_REGS(7),
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/58b376c9_7e58ab9… :
PS1, Line 2227: if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/520b84ed_0f05a77… :
PS1, Line 2246: for (uint32_t i = 0; i < 4; i++) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a6311866_679ee6e… :
PS1, Line 2261: if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/34078dbf_995815d… :
PS1, Line 2281: for (uint32_t i = 0; i < 4; i++) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/923a33b9_d982e7e… :
PS1, Line 2299: if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST | SERCOM_SPI_SYNCBUSY_ENABLE)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/358f3139_171e3b8… :
PS1, Line 2320: if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/834d4316_01de3d0… :
PS1, Line 2340: if (!(char_size == SPI_CHAR_SIZE_8 || char_size == SPI_CHAR_SIZE_9)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/14bd4dab_9152c0b… :
PS1, Line 2344: if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST | SERCOM_SPI_SYNCBUSY_CTRLB)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7e174b07_0e8cbd7… :
PS1, Line 2365: if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/af678bb2_c768563… :
PS1, Line 2371: if (dord == SPI_DATA_ORDER_LSB_1ST) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/6971a87b_9acc4ff… :
PS1, Line 2396: | (SERCOM_SPI_CTRLB_RXEN));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2d39c787_5cd0bd2… :
PS1, Line 2413: (regs->ctrlb & ~(SERCOM_SPI_CTRLB_MSSEN))
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3d9584ca_d6b7aaf… :
PS1, Line 2414: | (SERCOM_SPI_CTRLB_RXEN | SERCOM_SPI_CTRLB_SSDE | SERCOM_SPI_CTRLB_PLOADEN));
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ead0c44e_63ea56b… :
PS1, Line 2431: if (sercomspi_regs[i].n == n) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bcea847a_3a385b9… :
PS1, Line 2648: if (regs == NULL) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/404f5b87_7354ef3… :
PS1, Line 2664: if ((regs->ctrla & SERCOM_SPI_CTRLA_MODE_Msk) == SERCOM_USART_CTRLA_MODE_SPI_SLAVE) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/740cb449_a95042f… :
PS1, Line 2689: if (rc < 0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5a0aebd6_483fb8c… :
PS1, Line 2829: if (clk == 0 || baud == 0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0b38588f_f1ff7ff… :
PS1, Line 2834: if (!(baud <= (clk >> 1) && baud >= (clk >> 8))) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/6c8c1130_4e1f581… :
PS1, Line 2915: while (!(hri_sercomspi_get_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_TXC | SERCOM_SPI_INTFLAG_DRE))) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/09ea8ea5_e964fb7… :
PS1, Line 2940: if (!(iflag & SERCOM_SPI_INTFLAG_RXC)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e88b1559_cfc7479… :
PS1, Line 2949: if (ctrl->char_size > 1) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/612eb2a0_36a9cfc… :
PS1, Line 2961: uint16_t dummy)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b7718d12_b4ae26a… :
PS1, Line 2961: uint16_t dummy)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9984b1bf_7445a81… :
PS1, Line 2965: if (!(SERCOM_SPI_INTFLAG_DRE & iflag)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f0e8a50a_5565745… :
PS1, Line 2998: void * hw = dev->prvt;
"foo * bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/059b0d7d_063d106… :
PS1, Line 3006: hw, (SERCOM_SPI_SYNCBUSY_SWRST | SERCOM_SPI_SYNCBUSY_ENABLE | SERCOM_SPI_SYNCBUSY_CTRLB))) {
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c65e2d51_9fb44c2… :
PS1, Line 3011: if (!hri_sercomspi_get_CTRLA_ENABLE_bit(hw)) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/95fc70b2_8642004… :
PS1, Line 3021: if (ctrl.rxcnt >= ctrl.txcnt) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3d11b4d5_9081496… :
PS1, Line 3028: if (rc < 0) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e1ef830d_e3b8ddd… :
PS1, Line 3048: if (state) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7608f58e_66fb180… :
PS1, Line 3069: if (state) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b5ed3a88_b26b6c0… :
PS1, Line 3087: if (state) {
braces {} are not necessary for any arm of this statement
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/2f34d313_a1afc7b… :
PS1, Line 3150: const FUNC_PTR func)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ba4bf77f_ab56b0a… :
PS1, Line 3150: const FUNC_PTR func)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/815cbd2b_5c659cd… :
PS1, Line 3164: const FUNC_PTR func)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8964a924_453c5f5… :
PS1, Line 3164: const FUNC_PTR func)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/36d99748_b15141a… :
PS1, Line 3218: const bool state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3a1cdf04_f72024f… :
PS1, Line 3218: const bool state)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ef05b9ed_0eba6e6… :
PS1, Line 3222: if (SPI_DEV_CB_ERROR == type) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a0e17c46_ed5a639… :
PS1, Line 3235: const bool state)
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/01754421_8f916b4… :
PS1, Line 3235: const bool state)
please, no spaces at the start of a line
File usb_dfu_main.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5014665a_b7b052a… :
PS1, Line 18: * License along with this library; if not, write to the Free Software
Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. This Osmocom project should already include a copy of the (A)GPL.
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8c05715d_0334789… :
PS1, Line 19: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. This Osmocom project should already include a copy of the (A)GPL.
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e3195035_eb906e9… :
PS1, Line 36: static volatile const uint32_t bl_update_data[BLSZ_BYTE / sizeof(uint32_t)] __attribute__((section(".fwupdate"),used,retain)) = { 0xFF };
space required after that ',' (ctx:VxV)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/05f1b111_3d67115… :
PS1, Line 36: static volatile const uint32_t bl_update_data[BLSZ_BYTE / sizeof(uint32_t)] __attribute__((section(".fwupdate"),used,retain)) = { 0xFF };
space required after that ',' (ctx:VxV)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d260d354_4077f41… :
PS1, Line 38: _Static_assert (BLSZ_BYTE % NVMCTRL_PAGE_SIZE == 0, "invalid bl size");
space prohibited between function name and open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/cd836065_e0f0ec7… :
PS1, Line 42: void same54_flash_write_page(uint32_t address, uint8_t *data) {
open brace '{' following function definitions go on the next line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b5d5ab18_abec5ff… :
PS1, Line 44: while (!NVMCTRL->STATUS.bit.READY) {}
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/291e7801_d7d8099… :
PS1, Line 44: while (!NVMCTRL->STATUS.bit.READY) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3faba46c_d8fba7b… :
PS1, Line 48: while (!NVMCTRL->STATUS.bit.READY) {}
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d8de5bcd_61d486c… :
PS1, Line 48: while (!NVMCTRL->STATUS.bit.READY) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ad90a3bb_fb50852… :
PS1, Line 51: volatile uint32_t *src = (uint32_t *)data;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f2b64e01_9123177… :
PS1, Line 53: for (uint32_t i = 0; i < (NVMCTRL_PAGE_SIZE / sizeof(uint32_t)); i++) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a5f26aac_18286e1… :
PS1, Line 53: for (uint32_t i = 0; i < (NVMCTRL_PAGE_SIZE / sizeof(uint32_t)); i++) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/6806be89_447846d… :
PS1, Line 54: dst[i] = src[i];
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/fabda757_83ac824… :
PS1, Line 54: dst[i] = src[i];
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7ec25a38_fb20185… :
PS1, Line 55: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/6d7f9f68_29d0809… :
PS1, Line 57: NVMCTRL->ADDR.reg = address;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/130b1452_0f45d1e… :
PS1, Line 58: NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMD_WP | NVMCTRL_CTRLB_CMDEX_KEY;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5dc3e56d_054ce51… :
PS1, Line 59: while (!NVMCTRL->INTFLAG.bit.DONE) {}
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/da0fc0b4_a1ed909… :
PS1, Line 59: while (!NVMCTRL->INTFLAG.bit.DONE) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/43737ebf_ca2917b… :
PS1, Line 60: while (!NVMCTRL->STATUS.bit.READY) {}
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/28423f09_6b13aae… :
PS1, Line 60: while (!NVMCTRL->STATUS.bit.READY) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/dc68b0a8_749ff6d… :
PS1, Line 63: __attribute__((section(".ramfunc"),OPTNONE))
space required after that ',' (ctx:VxV)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/f3871626_c03556d… :
PS1, Line 64: void do_update() {
Bad function definition - void do_update() should probably be void do_update(void)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/eb187ab6_810c95c… :
PS1, Line 64: void do_update() {
open brace '{' following function definitions go on the next line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ee6ab79e_33a472f… :
PS1, Line 65: uint16_t mask = NVMCTRL_CTRLA_AHBNS0 |NVMCTRL_CTRLA_AHBNS1|NVMCTRL_CTRLA_RWS_Msk;
need consistent spacing around '|' (ctx:WxV) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a5a05ab6_0dbb724… :
PS1, Line 66: uint16_t _nvm = (NVMCTRL_CTRLA_CACHEDIS0 | NVMCTRL_CTRLA_CACHEDIS1 | NVMCTRL_CTRLA_PRM(3) | NVMCTRL_CTRLA_RWS(0x7) | NVMCTRL_CTRLA_WMODE(0) |NVMCTRL_CTRLA_AUTOWS );
need consistent spacing around '|' (ctx:WxV) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ba24263d_9eec6c7… :
PS1, Line 66: uint16_t _nvm = (NVMCTRL_CTRLA_CACHEDIS0 | NVMCTRL_CTRLA_CACHEDIS1 | NVMCTRL_CTRLA_PRM(3) | NVMCTRL_CTRLA_RWS(0x7) | NVMCTRL_CTRLA_WMODE(0) |NVMCTRL_CTRLA_AUTOWS );
space prohibited before that close parenthesis ')'
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d301e5d3_002fbba… :
PS1, Line 83: _Static_assert (BL_IN_REGIONS > 0, "bootprot regions must be at least 1");
space prohibited between function name and open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/6c9eb733_67adf78… :
PS1, Line 86: for(int i = 0; i< NVMCTRL_REGIONS_NUM; i++){
spaces required around that '<' (ctx:VxW)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/bca1da35_6f98a46… :
PS1, Line 86: for(int i = 0; i< NVMCTRL_REGIONS_NUM; i++){
space required before the open brace '{'
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/c29ed889_3b2b17d… :
PS1, Line 86: for(int i = 0; i< NVMCTRL_REGIONS_NUM; i++){
space required before the open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5b81bc91_a818569… :
PS1, Line 87: while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/02279bf4_98f4d2f… :
PS1, Line 88: hri_nvmctrl_write_ADDR_reg(NVMCTRL, REGION_SZ* i);
need consistent spacing around '*' (ctx:VxW) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e0ed2bd0_42b05ce… :
PS1, Line 94: while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/cc30cd29_5576355… :
PS1, Line 96: for(int i = 0; i< bootloader_regions; i++){
spaces required around that '<' (ctx:VxW)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/680ec4dd_450405b… :
PS1, Line 96: for(int i = 0; i< bootloader_regions; i++){
space required before the open brace '{'
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a574067c_f5e9ce6… :
PS1, Line 96: for(int i = 0; i< bootloader_regions; i++){
space required before the open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e3b5df21_06d1846… :
PS1, Line 97: while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d8d97686_74003b6… :
PS1, Line 102: while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/02d1daf0_1b06363… :
PS1, Line 105: uint32_t address = 0;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a046891e_0d8e2ee… :
PS1, Line 106: uint8_t *data_ptr = (uint8_t *)bl_update_data;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8456c8fd_628382f… :
PS1, Line 107: uint32_t remaining = BLSZ_BYTE;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0a578c49_a009aa3… :
PS1, Line 109: while (remaining >= NVMCTRL_PAGE_SIZE) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ca2a8cf2_69b7ec9… :
PS1, Line 110: same54_flash_write_page(address, data_ptr);
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a77d3dcb_c52286a… :
PS1, Line 110: same54_flash_write_page(address, data_ptr);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7d513c01_0f2cb26… :
PS1, Line 111: address += NVMCTRL_PAGE_SIZE;
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3a2c3f41_08e5b40… :
PS1, Line 111: address += NVMCTRL_PAGE_SIZE;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9b260038_94e6fee… :
PS1, Line 112: data_ptr += NVMCTRL_PAGE_SIZE;
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b30a8e2a_3c83251… :
PS1, Line 112: data_ptr += NVMCTRL_PAGE_SIZE;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/9dfe59d4_471bf2d… :
PS1, Line 113: remaining -= NVMCTRL_PAGE_SIZE;
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8df69d61_5f86853… :
PS1, Line 113: remaining -= NVMCTRL_PAGE_SIZE;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/3159109a_8b3d118… :
PS1, Line 114: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/734ea392_c446595… :
PS1, Line 117: for(int i = bootloader_regions; i < bootloader_regions+1; i++){
space required before the open brace '{'
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/e6b6264a_8d07de8… :
PS1, Line 117: for(int i = bootloader_regions; i < bootloader_regions+1; i++){
space required before the open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/960cf0e2_71dc052… :
PS1, Line 118: while (!(((Nvmctrl *)NVMCTRL)->STATUS.reg & NVMCTRL_STATUS_READY) >> NVMCTRL_STATUS_READY_Pos) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/5675937c_07b03fb… :
PS1, Line 122: while (!(((Nvmctrl *)NVMCTRL)->STATUS.reg & NVMCTRL_STATUS_READY) >> NVMCTRL_STATUS_READY_Pos) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/d3c09f95_3bc1bf5… :
PS1, Line 123:
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/7df5738a_6111fc2… :
PS1, Line 125: SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |SCB_AIRCR_SYSRESETREQ_Msk );
need consistent spacing around '|' (ctx:WxV) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/a323b388_b8a48f2… :
PS1, Line 125: SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |SCB_AIRCR_SYSRESETREQ_Msk );
need consistent spacing around '|' (ctx:WxV) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/b331119f_39b89b8… :
PS1, Line 125: SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |SCB_AIRCR_SYSRESETREQ_Msk );
space prohibited before that close parenthesis ')'
File usb_flash_main.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/ff01529a_91fdaf8… :
PS1, Line 30: static uint32_t* application_start_address = (uint32_t*)(BL_SIZE_BYTE);
"(foo*)" should be "(foo *)"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/0c106751_a65ab14… :
PS1, Line 30: static uint32_t* application_start_address = (uint32_t*)(BL_SIZE_BYTE);
"foo* bar" should be "foo *bar"
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/8f4de57d_6c2141d… :
PS1, Line 137: while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21258):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434/comment/36b69465_a56eb5c… :
PS1, Line 139: _user_area_write_bits((void*)NVMCTRL_FUSES_BOOTPROT_ADDR, NVMCTRL_FUSES_BOOTPROT_Pos, 13, 4);
"(foo*)" should be "(foo *)"
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I1403d35497cdea41ea5bed2c94b9e729ca352772
Gerrit-Change-Number: 39434
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 29 Jan 2025 18:24:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
1
0
[M] Change in osmo-asf4-dfu[master]: linker scripts: add bl size, fix ram size to 19a part
by Jenkins Builder 29 Jan '25
by Jenkins Builder 29 Jan '25
29 Jan '25
Jenkins Builder has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39433?usp=email )
Change subject: linker scripts: add bl size, fix ram size to 19a part
......................................................................
Patch Set 1:
(2 comments)
File gcc/gcc/same54p20a_dfu.ld:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21256):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39433/comment/d53230e0_2bccfd6… :
PS1, Line 17: *
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21256):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39433/comment/afcc9e1d_409c0cf… :
PS1, Line 19: *
trailing whitespace
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39433?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: Ic2da201b8f95855d05e15ac6ac8461e434593760
Gerrit-Change-Number: 39433
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 29 Jan 2025 18:24:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
1
0
Jenkins Builder has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437?usp=email )
Change subject: add fw update crcstub
......................................................................
Patch Set 1:
(82 comments)
File crc_code.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/0d7a59c9_71bed15… :
PS1, Line 15: static uint32_t
open brace '{' following function definitions go on the next line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/98db7872_ec0ee97… :
PS1, Line 17: uint32_t crc = 0xFFFFFFFF;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/322ee23d_e08ce6f… :
PS1, Line 18: for (uint32_t i = 0; i < length; i++) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/2beede5e_94ca49d… :
PS1, Line 18: for (uint32_t i = 0; i < length; i++) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/8feddccf_1e0c8d3… :
PS1, Line 19: crc ^= data[i];
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/7562e1bd_f42d7f5… :
PS1, Line 20: for (uint8_t j = 0; j < 8; j++) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/093433aa_6d4c028… :
PS1, Line 20: for (uint8_t j = 0; j < 8; j++) {
suspect code indent for conditional statements (4, 6)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/c4a9779f_94e1f04… :
PS1, Line 20: for (uint8_t j = 0; j < 8; j++) {
braces {} are not necessary for single statement blocks
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/1ce4972f_5a92741… :
PS1, Line 22: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/2ea0e8eb_d8bb91e… :
PS1, Line 23: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/c14137ec_62f8055… :
PS1, Line 24: return ~crc;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/8e7d89b5_082a03f… :
PS1, Line 28: __attribute__((used, section(".crc_code"), OPTNONE)) void Reset_Handler(void) {
open brace '{' following function definitions go on the next line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/c620301f_5197096… :
PS1, Line 29: extern uint32_t __CRC_Checksum;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/ce9613bd_3eb6659… :
PS1, Line 30: extern uint32_t __CRC_Start;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/983be7cb_dc57583… :
PS1, Line 31: extern uint32_t __CRC_End;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/afd6cc2f_c6374cb… :
PS1, Line 32: extern int main(void);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/883fffa9_6425167… :
PS1, Line 39: USB->DEVICE.CTRLA.reg = 0x1;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/10dfe21d_db274d0… :
PS1, Line 41: uint32_t length = (uint32_t)&__CRC_End - (uint32_t)&__CRC_Start;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/d03cdb20_5ff4597… :
PS1, Line 42: uint32_t calculated_crc = calculate_crc((uint8_t *)&__CRC_Start, length);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/f16c53ea_e9b2881… :
PS1, Line 43: uint32_t expected_crc = *(uint32_t *)&__CRC_Checksum;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/b192caf8_2226ade… :
PS1, Line 45: if (calculated_crc != expected_crc) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/10e84163_c7cb727… :
PS1, Line 45: if (calculated_crc != expected_crc) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/22300aa0_46567a2… :
PS1, Line 46: static volatile uint32_t *dfu_magic = (uint32_t *)HSRAM_ADDR;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/9de263a0_9f08cbf… :
PS1, Line 47: *dfu_magic = 0x44465521;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/a9fdfa4c_48e028b… :
PS1, Line 50: __DSB();
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/abacff17_447b3b5… :
PS1, Line 51: SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/5b92642b_5745c74… :
PS1, Line 53: __DSB();
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/11c07246_a54395b… :
PS1, Line 54: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/9ed8981b_cff27f3… :
PS1, Line 58: _Reset_Handler();
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/f537a8be_5fb4e6c… :
PS1, Line 61: while (1)
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/89d67972_1a3d5cc… :
PS1, Line 61: while (1)
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/873d179b_6637d69… :
PS1, Line 62: ;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/c5629ec9_6079e1a… :
PS1, Line 73: int main(int argc, char *argv[]) {
open brace '{' following function definitions go on the next line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/13deb765_15e17d7… :
PS1, Line 74: if (argc != 4) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/6d649ebf_73eaf1d… :
PS1, Line 74: if (argc != 4) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/c66c120c_6b9d188… :
PS1, Line 75: fprintf(stderr, "Usage: %s <binary_file> <start_offset_hex> <length_hex>\n", argv[0]);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/798536bf_6f5a9d3… :
PS1, Line 76: return 1;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/bcf65973_0abb4aa… :
PS1, Line 77: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/4811eb84_28853c0… :
PS1, Line 79: const char *filename = argv[1];
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/25d0e87c_9a626dd… :
PS1, Line 82: uint32_t start_offset = strtoul(argv[2], NULL, 10);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/ea6becca_bb12e4a… :
PS1, Line 83: uint32_t length = strtoul(argv[3], NULL, 10);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/89dd8722_e0949ac… :
PS1, Line 85: FILE *f = fopen(filename, "rb");
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/e237bbe7_5114d2d… :
PS1, Line 86: if (!f) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/6745bcbc_d6ea7de… :
PS1, Line 86: if (!f) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/0d628629_01850b5… :
PS1, Line 87: perror("fopen");
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/38dbb4d6_316e8ad… :
PS1, Line 88: return 1;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/7f2362ee_5c61d76… :
PS1, Line 89: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/9370e12c_3d9a824… :
PS1, Line 92: if (fseek(f, (long)start_offset, SEEK_SET) != 0) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/4a748eee_e6e5202… :
PS1, Line 92: if (fseek(f, (long)start_offset, SEEK_SET) != 0) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/cfcdb09e_4be807f… :
PS1, Line 93: perror("fseek");
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/0a293239_0cec1bd… :
PS1, Line 94: fclose(f);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/d73999e4_4e60ddb… :
PS1, Line 95: return 1;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/5948b14c_53893b4… :
PS1, Line 96: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/dc055464_4fef4f1… :
PS1, Line 98: uint8_t *buf = (uint8_t *)malloc(length);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/4f0a4f5b_3a68a1b… :
PS1, Line 99: if (!buf) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/7e91416d_3fa3a97… :
PS1, Line 99: if (!buf) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/4bda3868_0875a16… :
PS1, Line 100: fprintf(stderr, "Memory allocation error\n");
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/db1160e2_e7ef640… :
PS1, Line 101: fclose(f);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/73e7def0_3c7561d… :
PS1, Line 102: return 1;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/84ef37fe_d62c142… :
PS1, Line 103: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/d5682c8f_8c3e08c… :
PS1, Line 105: size_t read_bytes = fread(buf, 1, length, f);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/1aa6a051_6a34913… :
PS1, Line 106: fclose(f);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/ccb0f9db_1098d5b… :
PS1, Line 108: if (read_bytes != length) {
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/2f1871de_ef75804… :
PS1, Line 108: if (read_bytes != length) {
suspect code indent for conditional statements (2, 4)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/a170fd94_240d276… :
PS1, Line 109: fprintf(stderr, "Error reading file or not enough data\n");
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/467b7204_e555e3a… :
PS1, Line 110: free(buf);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/45b71d19_4e2938a… :
PS1, Line 111: return 1;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/3a888fd5_b42253f… :
PS1, Line 112: }
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/f38e9c86_0ca572a… :
PS1, Line 114: uint32_t crc = calculate_crc(buf, length);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/907d0b13_0e91e7c… :
PS1, Line 115: free(buf);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/0cd9a1ea_251ae30… :
PS1, Line 117: printf("%08X\n", crc);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/2f0d8632_0c3c3a7… :
PS1, Line 118: return 0;
please, no spaces at the start of a line
File gcc/Makefile:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/c56456aa_bf5e1a0… :
PS1, Line 2: SHELL := /bin/bash
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/ad568a56_8a9aab9… :
PS1, Line 52: SRC_dfu = usb_dfu_main.c crc_code.c crc_params.c
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/2fb59e51_f568ba7… :
PS1, Line 81: all: $(SUB_DIRS) hosttools dfu-merge
trailing whitespace
File gcc/gcc/same54p20a_dfu.ld:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/9300529a_9533905… :
PS1, Line 103: } > rom = 0xff
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/9fa485a3_1d18393… :
PS1, Line 110: } > rom = 0xff
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/63ee2215_af72195… :
PS1, Line 119: } > rom = 0xff
trailing whitespace
File gcc/gcc/same54p20a_flash.ld:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/653f125f_2cf4e5c… :
PS1, Line 99: } > rom = 0xff
trailing whitespace
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/683aac7a_465a290… :
PS1, Line 106: } > rom = 0xff
trailing whitespace
File gcc/gcc/startup_same54.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/e1b47600_b52e2d2… :
PS1, Line 671: __attribute__((naked,noreturn,weak)) void Reset_Handler(void)
space required after that ',' (ctx:VxV)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21255):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437/comment/ad721c7d_1659334… :
PS1, Line 671: __attribute__((naked,noreturn,weak)) void Reset_Handler(void)
space required after that ',' (ctx:VxV)
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39437?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I39eae7aaafd5531db6ce48837c9499432caadbed
Gerrit-Change-Number: 39437
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 29 Jan 2025 18:24:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
1
0
Jenkins Builder has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39438?usp=email )
Change subject: ver in usb prod desc
......................................................................
Patch Set 1:
(2 comments)
File usb_flash_main.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21254):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39438/comment/be8d2ccc_c8fd33c… :
PS1, Line 124: uint8_t __attribute__ ((aligned (16))) sernr_buf_descr[1+1+16*2*2];
space prohibited between function name and open parenthesis '('
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-21254):
https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39438/comment/1a6ed71c_cf886ff… :
PS1, Line 125: uint8_t __attribute__ ((aligned (16))) product_buf_descr[1+1+(sizeof(product_buf)-1)*2];
space prohibited between function name and open parenthesis '('
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39438?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I1f183695a3e458db2668e9950f859c936a821dc8
Gerrit-Change-Number: 39438
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 29 Jan 2025 18:24:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
1
0
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434?usp=email )
Change subject: bl updater app
......................................................................
bl updater app
This builds a second binary that will be flashed like the main firmware
and will then update the bootloader, just like the st2. It additionaly
aligns the cmsis + config with the main app, and ensures the hw is
mostly completely initalized before the main app starts, which allows
skipping the init in the main fw.
Main changes:
* bl freq 12/48Mhz -> 120Mhz
* ext 32khz disabled
* "proper" init time for xosc
* no usb init unless DFU mode is actually used
* errata 2.13.1 clock init/lock fixups
* no guessing according to f++&%! bootprog flags where the main app is
Change-Id: I1403d35497cdea41ea5bed2c94b9e729ca352772
---
A CMSIS/Include/cmsis_version.h
M atmel_start.c
M atmel_start_pins.h
M config/hpl_cmcc_config.h
M config/hpl_gclk_config.h
M config/hpl_osc32kctrl_config.h
M config/hpl_oscctrl_config.h
A config/hpl_rtc_config.h
A config/hpl_sercom_config.h
M config/peripheral_clk_config.h
M gcc/Makefile
M gcc/system_same54.c
M hpl/core/hpl_core_m4.c
M hpl/oscctrl/hpl_oscctrl.c
A hpl/sercom/hpl_sercom.c
A usb_dfu_main.c
M usb_flash_main.c
M usb_start.c
18 files changed, 6,118 insertions(+), 196 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/34/39434/1
diff --git a/CMSIS/Include/cmsis_version.h b/CMSIS/Include/cmsis_version.h
new file mode 100644
index 0000000..ae3f2e3
--- /dev/null
+++ b/CMSIS/Include/cmsis_version.h
@@ -0,0 +1,39 @@
+/**************************************************************************//**
+ * @file cmsis_version.h
+ * @brief CMSIS Core(M) Version definitions
+ * @version V5.0.2
+ * @date 19. April 2017
+ ******************************************************************************/
+/*
+ * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if defined ( __ICCARM__ )
+ #pragma system_include /* treat file as system include file for MISRA check */
+#elif defined (__clang__)
+ #pragma clang system_header /* treat file as system include file */
+#endif
+
+#ifndef __CMSIS_VERSION_H
+#define __CMSIS_VERSION_H
+
+/* CMSIS Version definitions */
+#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
+#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
+#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
+ __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
+#endif
diff --git a/atmel_start.c b/atmel_start.c
index 9a5f36c..b788d5a 100644
--- a/atmel_start.c
+++ b/atmel_start.c
@@ -6,5 +6,5 @@
void atmel_start_init(void)
{
system_init();
- usb_init();
+ // do not init usb here: might not be needed.
}
diff --git a/atmel_start_pins.h b/atmel_start_pins.h
index 220a7b5..e51dd83 100644
--- a/atmel_start_pins.h
+++ b/atmel_start_pins.h
@@ -45,4 +45,41 @@
#define PA24 GPIO(GPIO_PORTA, 24)
#define PA25 GPIO(GPIO_PORTA, 25)
+#define SIM4_INT GPIO(GPIO_PORTA, 2)
+#define SIM5_INT GPIO(GPIO_PORTA, 3)
+#define SIM0_IO GPIO(GPIO_PORTA, 4)
+#define SIM2_IO GPIO(GPIO_PORTA, 9)
+#define RMII_CLOCK GPIO(GPIO_PORTA, 10)
+#define SIMCLK_20MHZ GPIO(GPIO_PORTA, 11)
+#define SIM1_IO GPIO(GPIO_PORTA, 16)
+#define VB0 GPIO(GPIO_PORTA, 20)
+#define VB1 GPIO(GPIO_PORTA, 21)
+#define VB2 GPIO(GPIO_PORTA, 22)
+#define VB3 GPIO(GPIO_PORTA, 23)
+#define USBUP_D_N GPIO(GPIO_PORTA, 24)
+#define USBUP_D_P GPIO(GPIO_PORTA, 25)
+#define SCL2 GPIO(GPIO_PORTB, 2)
+#define SDA2 GPIO(GPIO_PORTB, 3)
+#define SIM6_INT GPIO(GPIO_PORTB, 4)
+#define SIM7_INT GPIO(GPIO_PORTB, 5)
+#define SCL3 GPIO(GPIO_PORTB, 6)
+#define SDA3 GPIO(GPIO_PORTB, 7)
+#define SIM4_IO GPIO(GPIO_PORTB, 8)
+#define SCL1 GPIO(GPIO_PORTB, 14)
+#define SDA1 GPIO(GPIO_PORTB, 15)
+#define SIM5_IO GPIO(GPIO_PORTB, 16)
+#define SIM3_IO GPIO(GPIO_PORTB, 20)
+#define UART_TX GPIO(GPIO_PORTB, 30)
+#define UART_RX GPIO(GPIO_PORTB, 31)
+#define SIM0_INT GPIO(GPIO_PORTC, 0)
+#define SIM1_INT GPIO(GPIO_PORTC, 1)
+#define SIM2_INT GPIO(GPIO_PORTC, 2)
+#define SIM3_INT GPIO(GPIO_PORTC, 3)
+#define SWITCH GPIO(GPIO_PORTC, 14)
+#define MUX_STAT GPIO(GPIO_PORTC, 15)
+#define SIM6_IO GPIO(GPIO_PORTC, 16)
+#define USER_LED GPIO(GPIO_PORTC, 26)
+#define SCL4 GPIO(GPIO_PORTC, 27)
+#define SDA4 GPIO(GPIO_PORTC, 28)
+
#endif // ATMEL_START_PINS_H_INCLUDED
diff --git a/config/hpl_cmcc_config.h b/config/hpl_cmcc_config.h
index 8590736..d69c21a 100644
--- a/config/hpl_cmcc_config.h
+++ b/config/hpl_cmcc_config.h
@@ -10,7 +10,7 @@
//<i> Defines the cache should be enabled or not.
// <id> cmcc_enable
#ifndef CONF_CMCC_ENABLE
-#define CONF_CMCC_ENABLE 0x0
+#define CONF_CMCC_ENABLE 0x1
#endif
// <o> Cache Size
@@ -29,7 +29,7 @@
//<i> Defines the data cache should be disabled or not.
// <id> cmcc_data_cache_disable
#ifndef CONF_CMCC_DATA_CACHE_DISABLE
-#define CONF_CMCC_DATA_CACHE_DISABLE 0x0
+#define CONF_CMCC_DATA_CACHE_DISABLE 0x1
#endif
// <q> Instruction cache disable
diff --git a/config/hpl_gclk_config.h b/config/hpl_gclk_config.h
index 306d90e..f2b75bf 100644
--- a/config/hpl_gclk_config.h
+++ b/config/hpl_gclk_config.h
@@ -25,7 +25,7 @@
// <i> This defines the clock source for generic clock generator 0
// <id> gclk_gen_0_oscillator
#ifndef CONF_GCLK_GEN_0_SOURCE
-#define CONF_GCLK_GEN_0_SOURCE GCLK_GENCTRL_SRC_XOSC1
+#define CONF_GCLK_GEN_0_SOURCE GCLK_GENCTRL_SRC_DPLL0
#endif
// <q> Run in Standby
@@ -159,7 +159,7 @@
// <i> Indicates whether generic clock 2 configuration is enabled or not
// <id> enable_gclk_gen_2
#ifndef CONF_GCLK_GENERATOR_2_CONFIG
-#define CONF_GCLK_GENERATOR_2_CONFIG 0
+#define CONF_GCLK_GENERATOR_2_CONFIG 1
#endif
// <h> Generic Clock Generator Control
@@ -176,7 +176,7 @@
// <i> This defines the clock source for generic clock generator 2
// <id> gclk_gen_2_oscillator
#ifndef CONF_GCLK_GEN_2_SOURCE
-#define CONF_GCLK_GEN_2_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_2_SOURCE GCLK_GENCTRL_SRC_DPLL1
#endif
// <q> Run in Standby
@@ -190,7 +190,7 @@
// <i> Indicates whether Divide Selection is enabled or not
//<id> gclk_gen_2_div_sel
#ifndef CONF_GCLK_GEN_2_DIVSEL
-#define CONF_GCLK_GEN_2_DIVSEL 1
+#define CONF_GCLK_GEN_2_DIVSEL 0
#endif
// <q> Output Enable
@@ -218,7 +218,7 @@
// <i> Indicates whether Generic Clock Generator Enable is enabled or not
// <id> gclk_arch_gen_2_enable
#ifndef CONF_GCLK_GEN_2_GENEN
-#define CONF_GCLK_GEN_2_GENEN 0
+#define CONF_GCLK_GEN_2_GENEN 1
#endif
// </h>
@@ -226,7 +226,7 @@
//<o> Generic clock generator 2 division <0x0000-0xFFFF>
// <id> gclk_gen_2_div
#ifndef CONF_GCLK_GEN_2_DIV
-#define CONF_GCLK_GEN_2_DIV 1
+#define CONF_GCLK_GEN_2_DIV 200
#endif
// </h>
// </e>
@@ -252,7 +252,7 @@
// <i> This defines the clock source for generic clock generator 3
// <id> gclk_gen_3_oscillator
#ifndef CONF_GCLK_GEN_3_SOURCE
-#define CONF_GCLK_GEN_3_SOURCE GCLK_GENCTRL_SRC_XOSC32K
+#define CONF_GCLK_GEN_3_SOURCE GCLK_GENCTRL_SRC_OSCULP32K
#endif
// <q> Run in Standby
@@ -311,7 +311,7 @@
// <i> Indicates whether generic clock 4 configuration is enabled or not
// <id> enable_gclk_gen_4
#ifndef CONF_GCLK_GENERATOR_4_CONFIG
-#define CONF_GCLK_GENERATOR_4_CONFIG 0
+#define CONF_GCLK_GENERATOR_4_CONFIG 1
#endif
// <h> Generic Clock Generator Control
@@ -328,7 +328,7 @@
// <i> This defines the clock source for generic clock generator 4
// <id> gclk_gen_4_oscillator
#ifndef CONF_GCLK_GEN_4_SOURCE
-#define CONF_GCLK_GEN_4_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_4_SOURCE GCLK_GENCTRL_SRC_DPLL1
#endif
// <q> Run in Standby
@@ -349,7 +349,7 @@
// <i> Indicates whether Output Enable is enabled or not
// <id> gclk_arch_gen_4_oe
#ifndef CONF_GCLK_GEN_4_OE
-#define CONF_GCLK_GEN_4_OE 0
+#define CONF_GCLK_GEN_4_OE 1
#endif
// <q> Output Off Value
@@ -370,7 +370,7 @@
// <i> Indicates whether Generic Clock Generator Enable is enabled or not
// <id> gclk_arch_gen_4_enable
#ifndef CONF_GCLK_GEN_4_GENEN
-#define CONF_GCLK_GEN_4_GENEN 0
+#define CONF_GCLK_GEN_4_GENEN 1
#endif
// </h>
@@ -378,7 +378,7 @@
//<o> Generic clock generator 4 division <0x0000-0xFFFF>
// <id> gclk_gen_4_div
#ifndef CONF_GCLK_GEN_4_DIV
-#define CONF_GCLK_GEN_4_DIV 1
+#define CONF_GCLK_GEN_4_DIV 2
#endif
// </h>
// </e>
@@ -387,7 +387,7 @@
// <i> Indicates whether generic clock 5 configuration is enabled or not
// <id> enable_gclk_gen_5
#ifndef CONF_GCLK_GENERATOR_5_CONFIG
-#define CONF_GCLK_GENERATOR_5_CONFIG 0
+#define CONF_GCLK_GENERATOR_5_CONFIG 1
#endif
// <h> Generic Clock Generator Control
@@ -404,7 +404,7 @@
// <i> This defines the clock source for generic clock generator 5
// <id> gclk_gen_5_oscillator
#ifndef CONF_GCLK_GEN_5_SOURCE
-#define CONF_GCLK_GEN_5_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_5_SOURCE GCLK_GENCTRL_SRC_DPLL1
#endif
// <q> Run in Standby
@@ -425,7 +425,7 @@
// <i> Indicates whether Output Enable is enabled or not
// <id> gclk_arch_gen_5_oe
#ifndef CONF_GCLK_GEN_5_OE
-#define CONF_GCLK_GEN_5_OE 0
+#define CONF_GCLK_GEN_5_OE 1
#endif
// <q> Output Off Value
@@ -446,7 +446,7 @@
// <i> Indicates whether Generic Clock Generator Enable is enabled or not
// <id> gclk_arch_gen_5_enable
#ifndef CONF_GCLK_GEN_5_GENEN
-#define CONF_GCLK_GEN_5_GENEN 0
+#define CONF_GCLK_GEN_5_GENEN 1
#endif
// </h>
@@ -454,7 +454,7 @@
//<o> Generic clock generator 5 division <0x0000-0xFFFF>
// <id> gclk_gen_5_div
#ifndef CONF_GCLK_GEN_5_DIV
-#define CONF_GCLK_GEN_5_DIV 1
+#define CONF_GCLK_GEN_5_DIV 5
#endif
// </h>
// </e>
@@ -463,7 +463,7 @@
// <i> Indicates whether generic clock 6 configuration is enabled or not
// <id> enable_gclk_gen_6
#ifndef CONF_GCLK_GENERATOR_6_CONFIG
-#define CONF_GCLK_GENERATOR_6_CONFIG 0
+#define CONF_GCLK_GENERATOR_6_CONFIG 1
#endif
// <h> Generic Clock Generator Control
@@ -480,7 +480,7 @@
// <i> This defines the clock source for generic clock generator 6
// <id> gclk_gen_6_oscillator
#ifndef CONF_GCLK_GEN_6_SOURCE
-#define CONF_GCLK_GEN_6_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_6_SOURCE GCLK_GENCTRL_SRC_DPLL0
#endif
// <q> Run in Standby
@@ -522,7 +522,7 @@
// <i> Indicates whether Generic Clock Generator Enable is enabled or not
// <id> gclk_arch_gen_6_enable
#ifndef CONF_GCLK_GEN_6_GENEN
-#define CONF_GCLK_GEN_6_GENEN 0
+#define CONF_GCLK_GEN_6_GENEN 1
#endif
// </h>
@@ -530,7 +530,7 @@
//<o> Generic clock generator 6 division <0x0000-0xFFFF>
// <id> gclk_gen_6_div
#ifndef CONF_GCLK_GEN_6_DIV
-#define CONF_GCLK_GEN_6_DIV 1
+#define CONF_GCLK_GEN_6_DIV 17
#endif
// </h>
// </e>
@@ -556,7 +556,7 @@
// <i> This defines the clock source for generic clock generator 7
// <id> gclk_gen_7_oscillator
#ifndef CONF_GCLK_GEN_7_SOURCE
-#define CONF_GCLK_GEN_7_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_7_SOURCE GCLK_GENCTRL_SRC_XOSC1
#endif
// <q> Run in Standby
@@ -632,7 +632,7 @@
// <i> This defines the clock source for generic clock generator 8
// <id> gclk_gen_8_oscillator
#ifndef CONF_GCLK_GEN_8_SOURCE
-#define CONF_GCLK_GEN_8_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_8_SOURCE GCLK_GENCTRL_SRC_XOSC1
#endif
// <q> Run in Standby
@@ -708,7 +708,7 @@
// <i> This defines the clock source for generic clock generator 9
// <id> gclk_gen_9_oscillator
#ifndef CONF_GCLK_GEN_9_SOURCE
-#define CONF_GCLK_GEN_9_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_9_SOURCE GCLK_GENCTRL_SRC_XOSC1
#endif
// <q> Run in Standby
@@ -784,7 +784,7 @@
// <i> This defines the clock source for generic clock generator 10
// <id> gclk_gen_10_oscillator
#ifndef CONF_GCLK_GEN_10_SOURCE
-#define CONF_GCLK_GEN_10_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_10_SOURCE GCLK_GENCTRL_SRC_XOSC1
#endif
// <q> Run in Standby
@@ -860,7 +860,7 @@
// <i> This defines the clock source for generic clock generator 11
// <id> gclk_gen_11_oscillator
#ifndef CONF_GCLK_GEN_11_SOURCE
-#define CONF_GCLK_GEN_11_SOURCE GCLK_GENCTRL_SRC_XOSC0
+#define CONF_GCLK_GEN_11_SOURCE GCLK_GENCTRL_SRC_XOSC1
#endif
// <q> Run in Standby
@@ -910,7 +910,7 @@
//<o> Generic clock generator 11 division <0x0000-0xFFFF>
// <id> gclk_gen_11_div
#ifndef CONF_GCLK_GEN_11_DIV
-#define CONF_GCLK_GEN_11_DIV 1
+#define CONF_GCLK_GEN_11_DIV 6
#endif
// </h>
// </e>
diff --git a/config/hpl_osc32kctrl_config.h b/config/hpl_osc32kctrl_config.h
index d0b0d34..7bcb41b 100644
--- a/config/hpl_osc32kctrl_config.h
+++ b/config/hpl_osc32kctrl_config.h
@@ -43,7 +43,7 @@
// <i> Indicates whether configuration for External 32K Osc is enabled or not
// <id> enable_xosc32k
#ifndef CONF_XOSC32K_CONFIG
-#define CONF_XOSC32K_CONFIG 1
+#define CONF_XOSC32K_CONFIG 0
#endif
// <h> 32kHz External Crystal Oscillator Control
@@ -51,7 +51,7 @@
// <i> Indicates whether 32kHz External Crystal Oscillator is enabled or not
// <id> xosc32k_arch_enable
#ifndef CONF_XOSC32K_ENABLE
-#define CONF_XOSC32K_ENABLE 1
+#define CONF_XOSC32K_ENABLE 0
#endif
// <o> Start-Up Time
@@ -71,21 +71,21 @@
// <i> Indicates whether On Demand Control is enabled or not
// <id> xosc32k_arch_ondemand
#ifndef CONF_XOSC32K_ONDEMAND
-#define CONF_XOSC32K_ONDEMAND 1
+#define CONF_XOSC32K_ONDEMAND 0
#endif
// <q> Run in Standby
// <i> Indicates whether Run in Standby is enabled or not
// <id> xosc32k_arch_runstdby
#ifndef CONF_XOSC32K_RUNSTDBY
-#define CONF_XOSC32K_RUNSTDBY 0
+#define CONF_XOSC32K_RUNSTDBY 1
#endif
// <q> 1kHz Output Enable
// <i> Indicates whether 1kHz Output is enabled or not
// <id> xosc32k_arch_en1k
#ifndef CONF_XOSC32K_EN1K
-#define CONF_XOSC32K_EN1K 0
+#define CONF_XOSC32K_EN1K 1
#endif
// <q> 32kHz Output Enable
diff --git a/config/hpl_oscctrl_config.h b/config/hpl_oscctrl_config.h
index 11e4a24..db34009 100644
--- a/config/hpl_oscctrl_config.h
+++ b/config/hpl_oscctrl_config.h
@@ -158,7 +158,7 @@
// <0xF=>1000000us
// <id> xosc1_arch_startup
#ifndef CONF_XOSC1_STARTUP
-#define CONF_XOSC1_STARTUP 0
+#define CONF_XOSC1_STARTUP 0xE
#endif
// <q> Clock Switch Back
@@ -179,7 +179,7 @@
// <i> Indicates whether Automatic Loop Control is enabled or not
// <id> xosc1_arch_enalc
#ifndef CONF_XOSC1_ENALC
-#define CONF_XOSC1_ENALC 0
+#define CONF_XOSC1_ENALC 1
#endif
// <q> Low Buffer Gain Enable
@@ -296,7 +296,7 @@
// <i> Indicates whether Bypass Coarse Lock is enabled or not
// <id> dfll_arch_bplckc
#ifndef CONF_DFLL_BPLCKC
-#define CONF_DFLL_BPLCKC 0
+#define CONF_DFLL_BPLCKC 1
#endif
// <q> Quick Lock Disable
@@ -324,7 +324,7 @@
// <i> Indicates whether Stable DFLL Frequency is enabled or not
// <id> dfll_arch_stable
#ifndef CONF_DFLL_STABLE
-#define CONF_DFLL_STABLE 0
+#define CONF_DFLL_STABLE 1
#endif
// <o> Operating Mode Selection
@@ -332,7 +332,7 @@
// <1=>Closed Loop Mode
// <id> dfll_mode
#ifndef CONF_DFLL_MODE
-#define CONF_DFLL_MODE 0x1
+#define CONF_DFLL_MODE 0x0
#endif
// <o> Coarse Maximum Step <0x0-0x1F>
@@ -344,7 +344,7 @@
// <o> Fine Maximum Step <0x0-0xFF>
// <id> dfll_arch_fstep
#ifndef CONF_DFLL_FSTEP
-#define CONF_DFLL_FSTEP 0x1
+#define CONF_DFLL_FSTEP 0xa
#endif
// <o> DFLL Multiply Factor <0x0-0xFFFF>
@@ -382,7 +382,7 @@
// <i> Indicates whether configuration for FDPLL0 is enabled or not
// <id> enable_fdpll0
#ifndef CONF_FDPLL0_CONFIG
-#define CONF_FDPLL0_CONFIG 0
+#define CONF_FDPLL0_CONFIG 1
#endif
// <y> Reference Clock Source
@@ -404,7 +404,7 @@
// <i> Select the clock source.
// <id> fdpll0_ref_clock
#ifndef CONF_FDPLL0_GCLK
-#define CONF_FDPLL0_GCLK GCLK_GENCTRL_SRC_XOSC32K
+#define CONF_FDPLL0_GCLK GCLK_GENCTRL_SRC_XOSC1
#endif
// <h> Digital Phase Locked Loop Control
@@ -412,7 +412,7 @@
// <i> Indicates whether Digital Phase Locked Loop is enabled or not
// <id> fdpll0_arch_enable
#ifndef CONF_FDPLL0_ENABLE
-#define CONF_FDPLL0_ENABLE 0
+#define CONF_FDPLL0_ENABLE 1
#endif
// <q> On Demand Control
@@ -430,21 +430,24 @@
#endif
// <o> Loop Divider Ratio Fractional Part <0x0-0x1F>
+// <i> Value of LDRFRAC is calculated using Fclk_dpll=Fckr*(LDR+1+LDRFRAC/32) formula as given in datasheet. This value is directly written in to DPLLRATIO register
// <id> fdpll0_ldrfrac
#ifndef CONF_FDPLL0_LDRFRAC
-#define CONF_FDPLL0_LDRFRAC 0xd
+#define CONF_FDPLL0_LDRFRAC 0x0
#endif
// <o> Loop Divider Ratio Integer Part <0x0-0x1FFF>
+// <i> Value of LDR is calculated using Fclk_dpll=Fckr*(LDR+1+LDRFRAC/32) formula as given in datasheet. This value is directly written in to DPLLRATIO register
// <id> fdpll0_ldr
#ifndef CONF_FDPLL0_LDR
-#define CONF_FDPLL0_LDR 0x5b7
+#define CONF_FDPLL0_LDR 0x3b
#endif
// <o> Clock Divider <0x0-0x7FF>
+// <i> This Clock divider is only for XOSC clock input to DPLL
// <id> fdpll0_clock_div
#ifndef CONF_FDPLL0_DIV
-#define CONF_FDPLL0_DIV 0x0
+#define CONF_FDPLL0_DIV 0x2
#endif
// <q> DCO Filter Enable
@@ -464,7 +467,7 @@
// <i> Indicates whether Lock Bypass is enabled or not
// <id> fdpll0_arch_lbypass
#ifndef CONF_FDPLL0_LBYPASS
-#define CONF_FDPLL0_LBYPASS 0
+#define CONF_FDPLL0_LBYPASS 1
#endif
// <o> Lock Time
@@ -485,14 +488,14 @@
// <0x3=>XOSC1 clock reference
// <id> fdpll0_arch_refclk
#ifndef CONF_FDPLL0_REFCLK
-#define CONF_FDPLL0_REFCLK 0x1
+#define CONF_FDPLL0_REFCLK 0x3
#endif
// <q> Wake Up Fast
// <i> Indicates whether Wake Up Fast is enabled or not
// <id> fdpll0_arch_wuf
#ifndef CONF_FDPLL0_WUF
-#define CONF_FDPLL0_WUF 0
+#define CONF_FDPLL0_WUF 1
#endif
// <o> Proportional Integral Filter Selection <0x0-0xF>
@@ -507,7 +510,7 @@
// <i> Indicates whether configuration for FDPLL1 is enabled or not
// <id> enable_fdpll1
#ifndef CONF_FDPLL1_CONFIG
-#define CONF_FDPLL1_CONFIG 0
+#define CONF_FDPLL1_CONFIG 1
#endif
// <y> Reference Clock Source
@@ -529,7 +532,7 @@
// <i> Select the clock source.
// <id> fdpll1_ref_clock
#ifndef CONF_FDPLL1_GCLK
-#define CONF_FDPLL1_GCLK GCLK_GENCTRL_SRC_XOSC32K
+#define CONF_FDPLL1_GCLK GCLK_GENCTRL_SRC_XOSC1
#endif
// <h> Digital Phase Locked Loop Control
@@ -537,7 +540,7 @@
// <i> Indicates whether Digital Phase Locked Loop is enabled or not
// <id> fdpll1_arch_enable
#ifndef CONF_FDPLL1_ENABLE
-#define CONF_FDPLL1_ENABLE 0
+#define CONF_FDPLL1_ENABLE 1
#endif
// <q> On Demand Control
@@ -555,21 +558,24 @@
#endif
// <o> Loop Divider Ratio Fractional Part <0x0-0x1F>
+// <i> Value of LDRFRAC is calculated using Fclk_dpll=Fckr*(LDR+1+LDRFRAC/32) formula as given in datasheet. This value is directly written in to DPLLRATIO register
// <id> fdpll1_ldrfrac
#ifndef CONF_FDPLL1_LDRFRAC
-#define CONF_FDPLL1_LDRFRAC 0xd
+#define CONF_FDPLL1_LDRFRAC 0x0
#endif
// <o> Loop Divider Ratio Integer Part <0x0-0x1FFF>
+// <i> Value of LDR is calculated using Fclk_dpll=Fckr*(LDR+1+LDRFRAC/32) formula as given in datasheet. This value is directly written in to DPLLRATIO register
// <id> fdpll1_ldr
#ifndef CONF_FDPLL1_LDR
-#define CONF_FDPLL1_LDR 0x5b7
+#define CONF_FDPLL1_LDR 0x31
#endif
// <o> Clock Divider <0x0-0x7FF>
+// <i> This Clock divider is only for XOSC clock input to DPLL
// <id> fdpll1_clock_div
#ifndef CONF_FDPLL1_DIV
-#define CONF_FDPLL1_DIV 0x0
+#define CONF_FDPLL1_DIV 0x2
#endif
// <q> DCO Filter Enable
@@ -589,7 +595,7 @@
// <i> Indicates whether Lock Bypass is enabled or not
// <id> fdpll1_arch_lbypass
#ifndef CONF_FDPLL1_LBYPASS
-#define CONF_FDPLL1_LBYPASS 0
+#define CONF_FDPLL1_LBYPASS 1
#endif
// <o> Lock Time
@@ -610,14 +616,14 @@
// <0x3=>XOSC1 clock reference
// <id> fdpll1_arch_refclk
#ifndef CONF_FDPLL1_REFCLK
-#define CONF_FDPLL1_REFCLK 0x1
+#define CONF_FDPLL1_REFCLK 0x3
#endif
// <q> Wake Up Fast
// <i> Indicates whether Wake Up Fast is enabled or not
// <id> fdpll1_arch_wuf
#ifndef CONF_FDPLL1_WUF
-#define CONF_FDPLL1_WUF 0
+#define CONF_FDPLL1_WUF 1
#endif
// <o> Proportional Integral Filter Selection <0x0-0xF>
diff --git a/config/hpl_rtc_config.h b/config/hpl_rtc_config.h
new file mode 100644
index 0000000..0e795ba
--- /dev/null
+++ b/config/hpl_rtc_config.h
@@ -0,0 +1,337 @@
+/* Auto-generated config file hpl_rtc_config.h */
+#ifndef HPL_RTC_CONFIG_H
+#define HPL_RTC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// <h> Basic settings
+
+#ifndef CONF_RTC_ENABLE
+#define CONF_RTC_ENABLE 1
+#endif
+
+// <q> Force reset RTC on initialization
+// <i> Force RTC to reset on initialization.
+// <i> Note that the previous power down data in RTC is lost if it's enabled.
+// <id> rtc_arch_init_reset
+#ifndef CONF_RTC_INIT_RESET
+#define CONF_RTC_INIT_RESET 1
+#endif
+
+// <o> Prescaler configuration
+// <0x0=>OFF(Peripheral clock divided by 1)
+// <0x1=>Peripheral clock divided by 1
+// <0x2=>Peripheral clock divided by 2
+// <0x3=>Peripheral clock divided by 4
+// <0x4=>Peripheral clock divided by 8
+// <0x5=>Peripheral clock divided by 16
+// <0x6=>Peripheral clock divided by 32
+// <0x7=>Peripheral clock divided by 64
+// <0x8=>Peripheral clock divided by 128
+// <0x9=>Peripheral clock divided by 256
+// <0xA=>Peripheral clock divided by 512
+// <0xB=>Peripheral clock divided by 1024
+// <i> These bits define the RTC clock relative to the peripheral clock
+// <id> rtc_arch_prescaler
+#ifndef CONF_RTC_PRESCALER
+
+#define CONF_RTC_PRESCALER 0xb
+
+#endif
+
+#ifndef CONF_RTC_COMP_VAL
+
+#define CONF_RTC_COMP_VAL 0
+
+#endif
+
+// <e> RTC Tamper Input 0 settings
+// <id> tamper_input_0_settings
+#ifndef CONF_TAMPER_INPUT_0_SETTINGS
+#define CONF_TAMPER_INPUT_0_SETTINGS 0
+#endif
+
+// <q> Tamper Level Settings
+// <i> Indicates Tamper input 0 level
+// <id> tamper_level_0
+#ifndef CONF_RTC_TAMP_LVL_0
+#define CONF_RTC_TAMP_LVL_0 0
+#endif
+
+// <o> RTC Tamper Input Action
+// <0x0=>OFF(Disabled)
+// <0x1=>Wake and Set Tamper Flag
+// <0x2=>Capture Timestamp and Set Tamper Flag
+// <0x3=>Active Layer Mode.IN and OUT pin is used.Timestamp is also captured.
+// <i> These bits define the RTC Tamper Input Action to be performed
+// <id> rtc_tamper_input_action_0
+#ifndef CONF_RTC_TAMPER_INACT_0
+#define CONF_RTC_TAMPER_INACT_0 0
+#endif
+
+// <q> Debounce Enable for Tamper Input
+// <i> Indicates Debounce should be enabled for Tamper input 0
+// <id> tamper_debounce_enable_0
+#ifndef CONF_RTC_TAMP_DEBNC_0
+#define CONF_RTC_TAMP_DEBNC_0 0
+#endif
+
+// </e>
+
+// <e> RTC Tamper Input 1 settings
+// <id> tamper_input_1_settings
+#ifndef CONF_TAMPER_INPUT_1_SETTINGS
+#define CONF_TAMPER_INPUT_1_SETTINGS 0
+#endif
+
+// <q> Tamper Level Settings
+// <i> Indicates Tamper input 1 level
+// <id> tamper_level_1
+#ifndef CONF_RTC_TAMP_LVL_1
+#define CONF_RTC_TAMP_LVL_1 0
+#endif
+
+// <o> RTC Tamper Input Action
+// <0x0=>OFF(Disabled)
+// <0x1=>Wake and Set Tamper Flag
+// <0x2=>Capture Timestamp and Set Tamper Flag
+// <0x3=>Active Layer Mode.IN and OUT pin is used.Timestamp is also captured.
+// <i> These bits define the RTC Tamper Input Action to be performed
+// <id> rtc_tamper_input_action_1
+#ifndef CONF_RTC_TAMPER_INACT_1
+#define CONF_RTC_TAMPER_INACT_1 0
+#endif
+
+// <q> Debounce Enable for Tamper Input
+// <i> Indicates Debounce should be enabled for Tamper input 1
+// <id> tamper_debounce_enable_1
+#ifndef CONF_RTC_TAMP_DEBNC_1
+#define CONF_RTC_TAMP_DEBNC_1 0
+#endif
+
+// </e>
+
+// <e> RTC Tamper Input 2 settings
+// <id> tamper_input_2_settings
+#ifndef CONF_TAMPER_INPUT_2_SETTINGS
+#define CONF_TAMPER_INPUT_2_SETTINGS 0
+#endif
+
+// <q> Tamper Level Settings
+// <i> Indicates Tamper input 2 level
+// <id> tamper_level_2
+#ifndef CONF_RTC_TAMP_LVL_2
+#define CONF_RTC_TAMP_LVL_2 0
+#endif
+
+// <o> RTC Tamper Input Action
+// <0x0=>OFF(Disabled)
+// <0x1=>Wake and Set Tamper Flag
+// <0x2=>Capture Timestamp and Set Tamper Flag
+// <0x3=>Active Layer Mode.IN and OUT pin is used.Timestamp is also captured.
+// <i> These bits define the RTC Tamper Input Action to be performed
+// <id> rtc_tamper_input_action_2
+#ifndef CONF_RTC_TAMPER_INACT_2
+#define CONF_RTC_TAMPER_INACT_2 0
+#endif
+
+// <q> Debounce Enable for Tamper Input
+// <i> Indicates Debounce should be enabled for Tamper input 2
+// <id> tamper_debounce_enable_2
+#ifndef CONF_RTC_TAMP_DEBNC_2
+#define CONF_RTC_TAMP_DEBNC_2 0
+#endif
+
+// </e>
+
+// <e> RTC Tamper Input 3 settings
+// <id> tamper_input_3_settings
+#ifndef CONF_TAMPER_INPUT_3_SETTINGS
+#define CONF_TAMPER_INPUT_3_SETTINGS 0
+#endif
+
+// <q> Tamper Level Settings
+// <i> Indicates Tamper input 3 level
+// <id> tamper_level_3
+#ifndef CONF_RTC_TAMP_LVL_3
+#define CONF_RTC_TAMP_LVL_3 0
+#endif
+
+// <o> RTC Tamper Input Action
+// <0x0=>OFF(Disabled)
+// <0x1=>Wake and Set Tamper Flag
+// <0x2=>Capture Timestamp and Set Tamper Flag
+// <0x3=>Active Layer Mode.IN and OUT pin is used.Timestamp is also captured.
+// <i> These bits define the RTC Tamper Input Action to be performed
+// <id> rtc_tamper_input_action_3
+#ifndef CONF_RTC_TAMPER_INACT_3
+#define CONF_RTC_TAMPER_INACT_3 0
+#endif
+
+// <q> Debounce Enable for Tamper Input
+// <i> Indicates Debounce should be enabled for Tamper input 3
+// <id> tamper_debounce_enable_3
+#ifndef CONF_RTC_TAMP_DEBNC_3
+#define CONF_RTC_TAMP_DEBNC_3 0
+#endif
+
+// </e>
+
+// <e> RTC Tamper Input 4 settings
+// <id> tamper_input_4_settings
+#ifndef CONF_TAMPER_INPUT_4_SETTINGS
+#define CONF_TAMPER_INPUT_4_SETTINGS 0
+#endif
+
+// <q> Tamper Level Settings
+// <i> Indicates Tamper input 4 level
+// <id> tamper_level_4
+#ifndef CONF_RTC_TAMP_LVL_4
+#define CONF_RTC_TAMP_LVL_4 0
+#endif
+
+// <o> RTC Tamper Input Action
+// <0x0=>OFF(Disabled)
+// <0x1=>Wake and Set Tamper Flag
+// <0x2=>Capture Timestamp and Set Tamper Flag
+// <0x3=>Active Layer Mode.IN and OUT pin is used.Timestamp is also captured.
+// <i> These bits define the RTC Tamper Input Action to be performed
+// <id> rtc_tamper_input_action_4
+#ifndef CONF_RTC_TAMPER_INACT_4
+#define CONF_RTC_TAMPER_INACT_4 0
+#endif
+
+// <q> Debounce Enable for Tamper Input
+// <i> Indicates Debounce should be enabled for Tamper input 4
+// <id> tamper_debounce_enable_4
+#ifndef CONF_RTC_TAMP_DEBNC_4
+#define CONF_RTC_TAMP_DEBNC_4 0
+#endif
+
+// </e>
+
+// <o> RTC Tamper Active Layer Frequency Prescalar
+// <0x0=>DIV2 CLK_RTC_OUT is CLK_RTC /2
+// <0x1=>DIV4 CLK_RTC_OUT is CLK_RTC /4
+// <0x2=>DIV8 CLK_RTC_OUT is CLK_RTC /8
+// <0x3=>DIV16 CLK_RTC_OUT is CLK_RTC /16
+// <0x4=>DIV32 CLK_RTC_OUT is CLK_RTC /32
+// <0x5=>DIV64 CLK_RTC_OUT is CLK_RTC /64
+// <0x6=>DIV128 CLK_RTC_OUT is CLK_RTC /128
+// <0x7=>DIV256 CLK_RTC_OUT is CLK_RTC /256
+// <i> These bits define the RTC Tamper Active Layer Frequecny Prescalar
+// <id> rtc_tamper_active_layer_frequency_prescalar
+#ifndef CONF_RTC_TAMP_ACT_LAYER_FREQ_PRES
+#define CONF_RTC_TAMP_ACT_LAYER_FREQ_PRES 0
+#endif
+
+// <o> RTC Tamper Debounce Frequency Prescalar
+// <0x0=>DIV2 CLK_RTC_DEB is CLK_RTC /2
+// <0x1=>DIV4 CLK_RTC_DEB is CLK_RTC /4
+// <0x2=>DIV8 CLK_RTC_DEB is CLK_RTC /8
+// <0x3=>DIV16 CLK_RTC_DEB is CLK_RTC /16
+// <0x4=>DIV32 CLK_RTC_DEB is CLK_RTC /32
+// <0x5=>DIV64 CLK_RTC_DEB is CLK_RTC /64
+// <0x6=>DIV128 CLK_RTC_DEB is CLK_RTC /128
+// <0x7=>DIV256 CLK_RTC_DEB is CLK_RTC /256
+// <i> These bits define the RTC Debounce Frequency Prescalar
+// <id> rtc_tamper_debounce_frequency_prescalar
+#ifndef CONF_RTC_TAMP_DEBF_PRES
+#define CONF_RTC_TAMP_DEBF_PRES 0
+#endif
+
+// <e> Event control
+// <id> rtc_event_control
+#ifndef CONF_RTC_EVENT_CONTROL_ENABLE
+#define CONF_RTC_EVENT_CONTROL_ENABLE 0
+#endif
+
+// <q> Periodic Interval 0 Event Output
+// <i> This bit indicates whether Periodic interval 0 event is enabled and will be generated
+// <id> rtc_pereo0
+#ifndef CONF_RTC_PEREO0
+#define CONF_RTC_PEREO0 0
+#endif
+// <q> Periodic Interval 1 Event Output
+// <i> This bit indicates whether Periodic interval 1 event is enabled and will be generated
+// <id> rtc_pereo1
+#ifndef CONF_RTC_PEREO1
+#define CONF_RTC_PEREO1 0
+#endif
+// <q> Periodic Interval 2 Event Output
+// <i> This bit indicates whether Periodic interval 2 event is enabled and will be generated
+// <id> rtc_pereo2
+#ifndef CONF_RTC_PEREO2
+#define CONF_RTC_PEREO2 0
+#endif
+// <q> Periodic Interval 3 Event Output
+// <i> This bit indicates whether Periodic interval 3 event is enabled and will be generated
+// <id> rtc_pereo3
+#ifndef CONF_RTC_PEREO3
+#define CONF_RTC_PEREO3 0
+#endif
+// <q> Periodic Interval 4 Event Output
+// <i> This bit indicates whether Periodic interval 4 event is enabled and will be generated
+// <id> rtc_pereo4
+#ifndef CONF_RTC_PEREO4
+#define CONF_RTC_PEREO4 0
+#endif
+// <q> Periodic Interval 5 Event Output
+// <i> This bit indicates whether Periodic interval 5 event is enabled and will be generated
+// <id> rtc_pereo5
+#ifndef CONF_RTC_PEREO5
+#define CONF_RTC_PEREO5 0
+#endif
+// <q> Periodic Interval 6 Event Output
+// <i> This bit indicates whether Periodic interval 6 event is enabled and will be generated
+// <id> rtc_pereo6
+#ifndef CONF_RTC_PEREO6
+#define CONF_RTC_PEREO6 0
+#endif
+// <q> Periodic Interval 7 Event Output
+// <i> This bit indicates whether Periodic interval 7 event is enabled and will be generated
+// <id> rtc_pereo7
+#ifndef CONF_RTC_PEREO7
+#define CONF_RTC_PEREO7 0
+#endif
+
+// <q> Compare 0 Event Output
+// <i> This bit indicates whether Compare O event is enabled and will be generated
+// <id> rtc_cmpeo0
+#ifndef CONF_RTC_COMPE0
+#define CONF_RTC_COMPE0 0
+#endif
+
+// <q> Compare 1 Event Output
+// <i> This bit indicates whether Compare 1 event is enabled and will be generated
+// <id> rtc_cmpeo1
+#ifndef CONF_RTC_COMPE1
+#define CONF_RTC_COMPE1 0
+#endif
+// <q> Overflow Event Output
+// <i> This bit indicates whether Overflow event is enabled and will be generated
+// <id> rtc_ovfeo
+#ifndef CONF_RTC_OVFEO
+#define CONF_RTC_OVFEO 0
+#endif
+
+// <q> Tamper Event Output
+// <i> This bit indicates whether Tamper event output is enabled and will be generated
+// <id> rtc_tampereo
+#ifndef CONF_RTC_TAMPEREO
+#define CONF_RTC_TAMPEREO 0
+#endif
+
+// <q> Tamper Event Input
+// <i> This bit indicates whether Tamper event input is enabled and will be generated
+// <id> rtc_tampevei
+#ifndef CONF_RTC_TAMPEVEI
+#define CONF_RTC_TAMPEVEI 0
+#endif
+// </e>
+
+// </h>
+
+// <<< end of configuration section >>>
+
+#endif // HPL_RTC_CONFIG_H
diff --git a/config/hpl_sercom_config.h b/config/hpl_sercom_config.h
new file mode 100644
index 0000000..bb2bbff
--- /dev/null
+++ b/config/hpl_sercom_config.h
@@ -0,0 +1,2182 @@
+/* Auto-generated config file hpl_sercom_config.h */
+#ifndef HPL_SERCOM_CONFIG_H
+#define HPL_SERCOM_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_0_USART_ENABLE
+#define CONF_SERCOM_0_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_0_USART_RXEN
+#define CONF_SERCOM_0_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_0_USART_TXEN
+#define CONF_SERCOM_0_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_0_USART_PARITY
+#define CONF_SERCOM_0_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_0_USART_CHSIZE
+#define CONF_SERCOM_0_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_0_USART_SBMODE
+#define CONF_SERCOM_0_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_0_USART_BAUD
+#define CONF_SERCOM_0_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_0_USART_INACK
+#define CONF_SERCOM_0_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_0_USART_DSNACK
+#define CONF_SERCOM_0_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_0_USART_MAXITER
+#define CONF_SERCOM_0_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_0_USART_GTIME
+#define CONF_SERCOM_0_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_0_USART_INVERSE_ENABLED
+#define CONF_SERCOM_0_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_0_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_0_USART_RXINV 0x1
+#define CONF_SERCOM_0_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_0_USART_RXINV 0x0
+#define CONF_SERCOM_0_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_0_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_0_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_0_USART_RUNSTDBY
+#define CONF_SERCOM_0_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_0_USART_IBON
+#define CONF_SERCOM_0_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_0_USART_SFDE
+#define CONF_SERCOM_0_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_0_USART_CLODEN
+#define CONF_SERCOM_0_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_0_USART_MODE
+#define CONF_SERCOM_0_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_0_USART_DORD
+#define CONF_SERCOM_0_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_0_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_0_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_0_USART_SAMPR 0x0
+#define CONF_SERCOM_0_USART_SAMPA 0x0
+#define CONF_SERCOM_0_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_0_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_0_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_0_USART_CMODE
+#define CONF_SERCOM_0_USART_CMODE CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PA04 */
+#ifndef CONF_SERCOM_0_USART_RXPO
+#define CONF_SERCOM_0_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_0_USART_TXPO
+#define CONF_SERCOM_0_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_0_USART_PMODE (CONF_SERCOM_0_USART_PARITY - 1)
+#define CONF_SERCOM_0_USART_FORM 7
+
+#if CONF_SERCOM_0_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_0_USART_SAMPR == 0
+#ifndef CONF_SERCOM_0_USART_BAUD_RATE
+#define CONF_SERCOM_0_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_0_USART_BAUD) / CONF_GCLK_SERCOM0_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_0_USART_SAMPR == 1
+#ifndef CONF_SERCOM_0_USART_BAUD_RATE
+#define CONF_SERCOM_0_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM0_CORE_FREQUENCY) / (CONF_SERCOM_0_USART_BAUD * 16)) - (CONF_SERCOM_0_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_0_USART_SAMPR == 2
+#ifndef CONF_SERCOM_0_USART_BAUD_RATE
+#define CONF_SERCOM_0_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_0_USART_BAUD) / CONF_GCLK_SERCOM0_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_0_USART_SAMPR == 3
+#ifndef CONF_SERCOM_0_USART_BAUD_RATE
+#define CONF_SERCOM_0_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM0_CORE_FREQUENCY) / (CONF_SERCOM_0_USART_BAUD * 8)) - (CONF_SERCOM_0_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_0_USART_SAMPR == 4
+#ifndef CONF_SERCOM_0_USART_BAUD_RATE
+#define CONF_SERCOM_0_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_0_USART_BAUD) / CONF_GCLK_SERCOM0_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_0_USART_CMODE == 1
+#ifndef CONF_SERCOM_0_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_0_USART_BAUD_RATE (CONF_GCLK_SERCOM0_CORE_FREQUENCY) / (2 * CONF_SERCOM_0_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 0 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_1_USART_ENABLE
+#define CONF_SERCOM_1_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_1_USART_RXEN
+#define CONF_SERCOM_1_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_1_USART_TXEN
+#define CONF_SERCOM_1_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_1_USART_PARITY
+#define CONF_SERCOM_1_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_1_USART_CHSIZE
+#define CONF_SERCOM_1_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_1_USART_SBMODE
+#define CONF_SERCOM_1_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_1_USART_BAUD
+#define CONF_SERCOM_1_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_1_USART_INACK
+#define CONF_SERCOM_1_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_1_USART_DSNACK
+#define CONF_SERCOM_1_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_1_USART_MAXITER
+#define CONF_SERCOM_1_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_1_USART_GTIME
+#define CONF_SERCOM_1_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_1_USART_INVERSE_ENABLED
+#define CONF_SERCOM_1_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_1_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_1_USART_RXINV 0x1
+#define CONF_SERCOM_1_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_1_USART_RXINV 0x0
+#define CONF_SERCOM_1_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_1_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_1_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_1_USART_RUNSTDBY
+#define CONF_SERCOM_1_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_1_USART_IBON
+#define CONF_SERCOM_1_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_1_USART_SFDE
+#define CONF_SERCOM_1_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_1_USART_CLODEN
+#define CONF_SERCOM_1_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_1_USART_MODE
+#define CONF_SERCOM_1_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_1_USART_DORD
+#define CONF_SERCOM_1_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_1_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_1_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_1_USART_SAMPR 0x0
+#define CONF_SERCOM_1_USART_SAMPA 0x0
+#define CONF_SERCOM_1_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_1_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_1_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_1_USART_CMODE
+#define CONF_SERCOM_1_USART_CMODE CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PA16 */
+#ifndef CONF_SERCOM_1_USART_RXPO
+#define CONF_SERCOM_1_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_1_USART_TXPO
+#define CONF_SERCOM_1_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_1_USART_PMODE (CONF_SERCOM_1_USART_PARITY - 1)
+#define CONF_SERCOM_1_USART_FORM 7
+
+#if CONF_SERCOM_1_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_1_USART_SAMPR == 0
+#ifndef CONF_SERCOM_1_USART_BAUD_RATE
+#define CONF_SERCOM_1_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_1_USART_BAUD) / CONF_GCLK_SERCOM1_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_1_USART_SAMPR == 1
+#ifndef CONF_SERCOM_1_USART_BAUD_RATE
+#define CONF_SERCOM_1_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM1_CORE_FREQUENCY) / (CONF_SERCOM_1_USART_BAUD * 16)) - (CONF_SERCOM_1_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_1_USART_SAMPR == 2
+#ifndef CONF_SERCOM_1_USART_BAUD_RATE
+#define CONF_SERCOM_1_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_1_USART_BAUD) / CONF_GCLK_SERCOM1_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_1_USART_SAMPR == 3
+#ifndef CONF_SERCOM_1_USART_BAUD_RATE
+#define CONF_SERCOM_1_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM1_CORE_FREQUENCY) / (CONF_SERCOM_1_USART_BAUD * 8)) - (CONF_SERCOM_1_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_1_USART_SAMPR == 4
+#ifndef CONF_SERCOM_1_USART_BAUD_RATE
+#define CONF_SERCOM_1_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_1_USART_BAUD) / CONF_GCLK_SERCOM1_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_1_USART_CMODE == 1
+#ifndef CONF_SERCOM_1_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_1_USART_BAUD_RATE (CONF_GCLK_SERCOM1_CORE_FREQUENCY) / (2 * CONF_SERCOM_1_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 1 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_2_USART_ENABLE
+#define CONF_SERCOM_2_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_2_USART_RXEN
+#define CONF_SERCOM_2_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_2_USART_TXEN
+#define CONF_SERCOM_2_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_2_USART_PARITY
+#define CONF_SERCOM_2_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_2_USART_CHSIZE
+#define CONF_SERCOM_2_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_2_USART_SBMODE
+#define CONF_SERCOM_2_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_2_USART_BAUD
+#define CONF_SERCOM_2_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_2_USART_INACK
+#define CONF_SERCOM_2_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_2_USART_DSNACK
+#define CONF_SERCOM_2_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_2_USART_MAXITER
+#define CONF_SERCOM_2_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_2_USART_GTIME
+#define CONF_SERCOM_2_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_2_USART_INVERSE_ENABLED
+#define CONF_SERCOM_2_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_2_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_2_USART_RXINV 0x1
+#define CONF_SERCOM_2_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_2_USART_RXINV 0x0
+#define CONF_SERCOM_2_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_2_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_2_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_2_USART_RUNSTDBY
+#define CONF_SERCOM_2_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_2_USART_IBON
+#define CONF_SERCOM_2_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_2_USART_SFDE
+#define CONF_SERCOM_2_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_2_USART_CLODEN
+#define CONF_SERCOM_2_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_2_USART_MODE
+#define CONF_SERCOM_2_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_2_USART_DORD
+#define CONF_SERCOM_2_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_2_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_2_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_2_USART_SAMPR 0x0
+#define CONF_SERCOM_2_USART_SAMPA 0x0
+#define CONF_SERCOM_2_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_2_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_2_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_2_USART_CMODE
+#define CONF_SERCOM_2_USART_CMODE CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PA09 */
+#ifndef CONF_SERCOM_2_USART_RXPO
+#define CONF_SERCOM_2_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_2_USART_TXPO
+#define CONF_SERCOM_2_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_2_USART_PMODE (CONF_SERCOM_2_USART_PARITY - 1)
+#define CONF_SERCOM_2_USART_FORM 7
+
+#if CONF_SERCOM_2_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_2_USART_SAMPR == 0
+#ifndef CONF_SERCOM_2_USART_BAUD_RATE
+#define CONF_SERCOM_2_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_2_USART_BAUD) / CONF_GCLK_SERCOM2_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_2_USART_SAMPR == 1
+#ifndef CONF_SERCOM_2_USART_BAUD_RATE
+#define CONF_SERCOM_2_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM2_CORE_FREQUENCY) / (CONF_SERCOM_2_USART_BAUD * 16)) - (CONF_SERCOM_2_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_2_USART_SAMPR == 2
+#ifndef CONF_SERCOM_2_USART_BAUD_RATE
+#define CONF_SERCOM_2_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_2_USART_BAUD) / CONF_GCLK_SERCOM2_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_2_USART_SAMPR == 3
+#ifndef CONF_SERCOM_2_USART_BAUD_RATE
+#define CONF_SERCOM_2_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM2_CORE_FREQUENCY) / (CONF_SERCOM_2_USART_BAUD * 8)) - (CONF_SERCOM_2_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_2_USART_SAMPR == 4
+#ifndef CONF_SERCOM_2_USART_BAUD_RATE
+#define CONF_SERCOM_2_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_2_USART_BAUD) / CONF_GCLK_SERCOM2_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_2_USART_CMODE == 1
+#ifndef CONF_SERCOM_2_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_2_USART_BAUD_RATE (CONF_GCLK_SERCOM2_CORE_FREQUENCY) / (2 * CONF_SERCOM_2_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 2 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_3_USART_ENABLE
+#define CONF_SERCOM_3_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_3_USART_RXEN
+#define CONF_SERCOM_3_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_3_USART_TXEN
+#define CONF_SERCOM_3_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_3_USART_PARITY
+#define CONF_SERCOM_3_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_3_USART_CHSIZE
+#define CONF_SERCOM_3_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_3_USART_SBMODE
+#define CONF_SERCOM_3_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_3_USART_BAUD
+#define CONF_SERCOM_3_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_3_USART_INACK
+#define CONF_SERCOM_3_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_3_USART_DSNACK
+#define CONF_SERCOM_3_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_3_USART_MAXITER
+#define CONF_SERCOM_3_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_3_USART_GTIME
+#define CONF_SERCOM_3_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_3_USART_INVERSE_ENABLED
+#define CONF_SERCOM_3_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_3_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_3_USART_RXINV 0x1
+#define CONF_SERCOM_3_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_3_USART_RXINV 0x0
+#define CONF_SERCOM_3_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_3_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_3_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_3_USART_RUNSTDBY
+#define CONF_SERCOM_3_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_3_USART_IBON
+#define CONF_SERCOM_3_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_3_USART_SFDE
+#define CONF_SERCOM_3_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_3_USART_CLODEN
+#define CONF_SERCOM_3_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_3_USART_MODE
+#define CONF_SERCOM_3_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_3_USART_DORD
+#define CONF_SERCOM_3_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_3_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_3_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_3_USART_SAMPR 0x0
+#define CONF_SERCOM_3_USART_SAMPA 0x0
+#define CONF_SERCOM_3_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_3_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_3_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_3_USART_CMODE
+#define CONF_SERCOM_3_USART_CMODE CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PB20 */
+#ifndef CONF_SERCOM_3_USART_RXPO
+#define CONF_SERCOM_3_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_3_USART_TXPO
+#define CONF_SERCOM_3_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_3_USART_PMODE (CONF_SERCOM_3_USART_PARITY - 1)
+#define CONF_SERCOM_3_USART_FORM 7
+
+#if CONF_SERCOM_3_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_3_USART_SAMPR == 0
+#ifndef CONF_SERCOM_3_USART_BAUD_RATE
+#define CONF_SERCOM_3_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_3_USART_BAUD) / CONF_GCLK_SERCOM3_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_3_USART_SAMPR == 1
+#ifndef CONF_SERCOM_3_USART_BAUD_RATE
+#define CONF_SERCOM_3_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM3_CORE_FREQUENCY) / (CONF_SERCOM_3_USART_BAUD * 16)) - (CONF_SERCOM_3_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_3_USART_SAMPR == 2
+#ifndef CONF_SERCOM_3_USART_BAUD_RATE
+#define CONF_SERCOM_3_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_3_USART_BAUD) / CONF_GCLK_SERCOM3_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_3_USART_SAMPR == 3
+#ifndef CONF_SERCOM_3_USART_BAUD_RATE
+#define CONF_SERCOM_3_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM3_CORE_FREQUENCY) / (CONF_SERCOM_3_USART_BAUD * 8)) - (CONF_SERCOM_3_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_3_USART_SAMPR == 4
+#ifndef CONF_SERCOM_3_USART_BAUD_RATE
+#define CONF_SERCOM_3_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_3_USART_BAUD) / CONF_GCLK_SERCOM3_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_3_USART_CMODE == 1
+#ifndef CONF_SERCOM_3_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_3_USART_BAUD_RATE (CONF_GCLK_SERCOM3_CORE_FREQUENCY) / (2 * CONF_SERCOM_3_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 3 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_4_USART_ENABLE
+#define CONF_SERCOM_4_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_4_USART_RXEN
+#define CONF_SERCOM_4_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_4_USART_TXEN
+#define CONF_SERCOM_4_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_4_USART_PARITY
+#define CONF_SERCOM_4_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_4_USART_CHSIZE
+#define CONF_SERCOM_4_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_4_USART_SBMODE
+#define CONF_SERCOM_4_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_4_USART_BAUD
+#define CONF_SERCOM_4_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_4_USART_INACK
+#define CONF_SERCOM_4_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_4_USART_DSNACK
+#define CONF_SERCOM_4_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_4_USART_MAXITER
+#define CONF_SERCOM_4_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_4_USART_GTIME
+#define CONF_SERCOM_4_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_4_USART_INVERSE_ENABLED
+#define CONF_SERCOM_4_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_4_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_4_USART_RXINV 0x1
+#define CONF_SERCOM_4_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_4_USART_RXINV 0x0
+#define CONF_SERCOM_4_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_4_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_4_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_4_USART_RUNSTDBY
+#define CONF_SERCOM_4_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_4_USART_IBON
+#define CONF_SERCOM_4_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_4_USART_SFDE
+#define CONF_SERCOM_4_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_4_USART_CLODEN
+#define CONF_SERCOM_4_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_4_USART_MODE
+#define CONF_SERCOM_4_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_4_USART_DORD
+#define CONF_SERCOM_4_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_4_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_4_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_4_USART_SAMPR 0x0
+#define CONF_SERCOM_4_USART_SAMPA 0x0
+#define CONF_SERCOM_4_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_4_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_4_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_4_USART_CMODE
+#define CONF_SERCOM_4_USART_CMODE CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PB08 */
+#ifndef CONF_SERCOM_4_USART_RXPO
+#define CONF_SERCOM_4_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_4_USART_TXPO
+#define CONF_SERCOM_4_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_4_USART_PMODE (CONF_SERCOM_4_USART_PARITY - 1)
+#define CONF_SERCOM_4_USART_FORM 7
+
+#if CONF_SERCOM_4_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_4_USART_SAMPR == 0
+#ifndef CONF_SERCOM_4_USART_BAUD_RATE
+#define CONF_SERCOM_4_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_4_USART_BAUD) / CONF_GCLK_SERCOM4_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_4_USART_SAMPR == 1
+#ifndef CONF_SERCOM_4_USART_BAUD_RATE
+#define CONF_SERCOM_4_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM4_CORE_FREQUENCY) / (CONF_SERCOM_4_USART_BAUD * 16)) - (CONF_SERCOM_4_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_4_USART_SAMPR == 2
+#ifndef CONF_SERCOM_4_USART_BAUD_RATE
+#define CONF_SERCOM_4_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_4_USART_BAUD) / CONF_GCLK_SERCOM4_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_4_USART_SAMPR == 3
+#ifndef CONF_SERCOM_4_USART_BAUD_RATE
+#define CONF_SERCOM_4_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM4_CORE_FREQUENCY) / (CONF_SERCOM_4_USART_BAUD * 8)) - (CONF_SERCOM_4_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_4_USART_SAMPR == 4
+#ifndef CONF_SERCOM_4_USART_BAUD_RATE
+#define CONF_SERCOM_4_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_4_USART_BAUD) / CONF_GCLK_SERCOM4_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_4_USART_CMODE == 1
+#ifndef CONF_SERCOM_4_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_4_USART_BAUD_RATE (CONF_GCLK_SERCOM4_CORE_FREQUENCY) / (2 * CONF_SERCOM_4_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 4 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_5_USART_ENABLE
+#define CONF_SERCOM_5_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_5_USART_RXEN
+#define CONF_SERCOM_5_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_5_USART_TXEN
+#define CONF_SERCOM_5_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_5_USART_PARITY
+#define CONF_SERCOM_5_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_5_USART_CHSIZE
+#define CONF_SERCOM_5_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_5_USART_SBMODE
+#define CONF_SERCOM_5_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_5_USART_BAUD
+#define CONF_SERCOM_5_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_5_USART_INACK
+#define CONF_SERCOM_5_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_5_USART_DSNACK
+#define CONF_SERCOM_5_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_5_USART_MAXITER
+#define CONF_SERCOM_5_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_5_USART_GTIME
+#define CONF_SERCOM_5_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_5_USART_INVERSE_ENABLED
+#define CONF_SERCOM_5_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_5_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_5_USART_RXINV 0x1
+#define CONF_SERCOM_5_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_5_USART_RXINV 0x0
+#define CONF_SERCOM_5_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_5_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_5_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_5_USART_RUNSTDBY
+#define CONF_SERCOM_5_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_5_USART_IBON
+#define CONF_SERCOM_5_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_5_USART_SFDE
+#define CONF_SERCOM_5_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_5_USART_CLODEN
+#define CONF_SERCOM_5_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_5_USART_MODE
+#define CONF_SERCOM_5_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_5_USART_DORD
+#define CONF_SERCOM_5_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_5_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_5_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_5_USART_SAMPR 0x0
+#define CONF_SERCOM_5_USART_SAMPA 0x0
+#define CONF_SERCOM_5_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_5_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_5_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_5_USART_CMODE
+#define CONF_SERCOM_5_USART_CMODE CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PB16 */
+#ifndef CONF_SERCOM_5_USART_RXPO
+#define CONF_SERCOM_5_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_5_USART_TXPO
+#define CONF_SERCOM_5_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_5_USART_PMODE (CONF_SERCOM_5_USART_PARITY - 1)
+#define CONF_SERCOM_5_USART_FORM 7
+
+#if CONF_SERCOM_5_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_5_USART_SAMPR == 0
+#ifndef CONF_SERCOM_5_USART_BAUD_RATE
+#define CONF_SERCOM_5_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_5_USART_BAUD) / CONF_GCLK_SERCOM5_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_5_USART_SAMPR == 1
+#ifndef CONF_SERCOM_5_USART_BAUD_RATE
+#define CONF_SERCOM_5_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM5_CORE_FREQUENCY) / (CONF_SERCOM_5_USART_BAUD * 16)) - (CONF_SERCOM_5_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_5_USART_SAMPR == 2
+#ifndef CONF_SERCOM_5_USART_BAUD_RATE
+#define CONF_SERCOM_5_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_5_USART_BAUD) / CONF_GCLK_SERCOM5_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_5_USART_SAMPR == 3
+#ifndef CONF_SERCOM_5_USART_BAUD_RATE
+#define CONF_SERCOM_5_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM5_CORE_FREQUENCY) / (CONF_SERCOM_5_USART_BAUD * 8)) - (CONF_SERCOM_5_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_5_USART_SAMPR == 4
+#ifndef CONF_SERCOM_5_USART_BAUD_RATE
+#define CONF_SERCOM_5_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_5_USART_BAUD) / CONF_GCLK_SERCOM5_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_5_USART_CMODE == 1
+#ifndef CONF_SERCOM_5_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_5_USART_BAUD_RATE (CONF_GCLK_SERCOM5_CORE_FREQUENCY) / (2 * CONF_SERCOM_5_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 5 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_6_USART_ENABLE
+#define CONF_SERCOM_6_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_6_USART_RXEN
+#define CONF_SERCOM_6_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_6_USART_TXEN
+#define CONF_SERCOM_6_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x1=>Even parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_6_USART_PARITY
+#define CONF_SERCOM_6_USART_PARITY 1
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_6_USART_CHSIZE
+#define CONF_SERCOM_6_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_6_USART_SBMODE
+#define CONF_SERCOM_6_USART_SBMODE 1
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_6_USART_BAUD
+#define CONF_SERCOM_6_USART_BAUD 6720
+#endif
+// </h>
+
+// <h> ISO7816 configuration
+// <o> ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+// <i> Define ISO7816 protocol type as 0.
+// <id> usart_iso7816_type
+#ifndef CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+// <o> ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+// <i> Define whether a NACK is transmitted when a parity error is received.
+// <id> usart_inack
+#ifndef CONF_SERCOM_6_USART_INACK
+#define CONF_SERCOM_6_USART_INACK 0x0
+#endif
+
+// <o> ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+// <i> Define whether NACK will be sent on parity error reception.
+// <id> usart_dsnack
+#ifndef CONF_SERCOM_6_USART_DSNACK
+#define CONF_SERCOM_6_USART_DSNACK 0x0
+#endif
+
+// <o> ISO7816 Maximum Iterations<0-7>
+// <i> Define the maximum number of retransmit iterations.
+// <id> usart_maxiter
+#ifndef CONF_SERCOM_6_USART_MAXITER
+#define CONF_SERCOM_6_USART_MAXITER 0x7
+#endif
+
+// <o> ISO7816 Guard Time
+// <0x2=> 2-bit times
+// <0x3=> 3-bit times
+// <0x4=> 4-bit times
+// <0x5=> 5-bit times
+// <0x6=> 6-bit times
+// <0x7=> 7-bit times
+// <i> Define the guard time.
+// <id> usart_gtime
+#ifndef CONF_SERCOM_6_USART_GTIME
+#define CONF_SERCOM_6_USART_GTIME 0x2
+#endif
+
+// <q> Inverse transmission and reception enabled
+// <i> Define inverse transmission and reception enabled.
+// <id> usart_inverse_enabled
+#ifndef CONF_SERCOM_6_USART_INVERSE_ENABLED
+#define CONF_SERCOM_6_USART_INVERSE_ENABLED 0x0
+#endif
+
+#if (CONF_SERCOM_6_USART_INVERSE_ENABLED == 1)
+#define CONF_SERCOM_6_USART_RXINV 0x1
+#define CONF_SERCOM_6_USART_TXINV 0x1
+#else
+#define CONF_SERCOM_6_USART_RXINV 0x0
+#define CONF_SERCOM_6_USART_TXINV 0x0
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_6_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_6_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_6_USART_RUNSTDBY
+#define CONF_SERCOM_6_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_6_USART_IBON
+#define CONF_SERCOM_6_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_6_USART_SFDE
+#define CONF_SERCOM_6_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_6_USART_CLODEN
+#define CONF_SERCOM_6_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_6_USART_MODE
+#define CONF_SERCOM_6_USART_MODE 0x1
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_6_USART_DORD
+#define CONF_SERCOM_6_USART_DORD 1
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_6_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_6_USART_DEBUG_STOP_MODE 0
+#endif
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_6_USART_SAMPR 0x0
+#define CONF_SERCOM_6_USART_SAMPA 0x0
+#define CONF_SERCOM_6_USART_FRACTIONAL 0x0
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_6_USART_CPOL 0
+
+// Does not do anything in USRT mode
+#define CONF_SERCOM_6_USART_ENC 0
+
+// </e>
+
+#ifndef CONF_SERCOM_6_USART_CMODE
+#define CONF_SERCOM_6_USART_CMODE CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T
+#endif
+
+/* RX is on PIN_PC16 */
+#ifndef CONF_SERCOM_6_USART_RXPO
+#define CONF_SERCOM_6_USART_RXPO 0
+#endif
+
+/* TX uses the same pin with RX */
+#ifndef CONF_SERCOM_6_USART_TXPO
+#define CONF_SERCOM_6_USART_TXPO 2
+#endif
+
+/* Set iso7816 mode */
+#define CONF_SERCOM_6_USART_PMODE (CONF_SERCOM_6_USART_PARITY - 1)
+#define CONF_SERCOM_6_USART_FORM 7
+
+#if CONF_SERCOM_6_USART_CMODE == 0
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_6_USART_SAMPR == 0
+#ifndef CONF_SERCOM_6_USART_BAUD_RATE
+#define CONF_SERCOM_6_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_6_USART_BAUD) / CONF_GCLK_SERCOM6_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_6_USART_SAMPR == 1
+#ifndef CONF_SERCOM_6_USART_BAUD_RATE
+#define CONF_SERCOM_6_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM6_CORE_FREQUENCY) / (CONF_SERCOM_6_USART_BAUD * 16)) - (CONF_SERCOM_6_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_6_USART_SAMPR == 2
+#ifndef CONF_SERCOM_6_USART_BAUD_RATE
+#define CONF_SERCOM_6_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_6_USART_BAUD) / CONF_GCLK_SERCOM6_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_6_USART_SAMPR == 3
+#ifndef CONF_SERCOM_6_USART_BAUD_RATE
+#define CONF_SERCOM_6_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM6_CORE_FREQUENCY) / (CONF_SERCOM_6_USART_BAUD * 8)) - (CONF_SERCOM_6_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_6_USART_SAMPR == 4
+#ifndef CONF_SERCOM_6_USART_BAUD_RATE
+#define CONF_SERCOM_6_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_6_USART_BAUD) / CONF_GCLK_SERCOM6_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+#elif CONF_SERCOM_6_USART_CMODE == 1
+#ifndef CONF_SERCOM_6_USART_BAUD_RATE
+// Calculate BAUD register value in USRT mode
+#define CONF_SERCOM_6_USART_BAUD_RATE (CONF_GCLK_SERCOM6_CORE_FREQUENCY) / (2 * CONF_SERCOM_6_USART_BAUD) - 1
+#endif
+
+#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#else
+#error CMODE value for SERCOM 6 in USART mode not known
+#endif
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_SERCOM_7_USART_ENABLE
+#define CONF_SERCOM_7_USART_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <q> Receive buffer enable
+// <i> Enable input buffer in SERCOM module
+// <id> usart_rx_enable
+#ifndef CONF_SERCOM_7_USART_RXEN
+#define CONF_SERCOM_7_USART_RXEN 1
+#endif
+
+// <q> Transmitt buffer enable
+// <i> Enable output buffer in SERCOM module
+// <id> usart_tx_enable
+#ifndef CONF_SERCOM_7_USART_TXEN
+#define CONF_SERCOM_7_USART_TXEN 1
+#endif
+
+// <o> Frame parity
+// <0x0=>No parity
+// <0x1=>Even parity
+// <0x2=>Odd parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_SERCOM_7_USART_PARITY
+#define CONF_SERCOM_7_USART_PARITY 0x0
+#endif
+
+// <o> Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_SERCOM_7_USART_CHSIZE
+#define CONF_SERCOM_7_USART_CHSIZE 0x0
+#endif
+
+// <o> Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_SERCOM_7_USART_SBMODE
+#define CONF_SERCOM_7_USART_SBMODE 0
+#endif
+
+// <o> Baud rate <1-6250000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_SERCOM_7_USART_BAUD
+#define CONF_SERCOM_7_USART_BAUD 921600
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_SERCOM_7_USART_ADVANCED_CONFIG
+#define CONF_SERCOM_7_USART_ADVANCED_CONFIG 0
+#endif
+
+// <q> Run in stand-by
+// <i> Keep the module running in standby sleep mode
+// <id> usart_arch_runstdby
+#ifndef CONF_SERCOM_7_USART_RUNSTDBY
+#define CONF_SERCOM_7_USART_RUNSTDBY 0
+#endif
+
+// <q> Immediate Buffer Overflow Notification
+// <i> Controls when the BUFOVF status bit is asserted
+// <id> usart_arch_ibon
+#ifndef CONF_SERCOM_7_USART_IBON
+#define CONF_SERCOM_7_USART_IBON 0
+#endif
+
+// <q> Start of Frame Detection Enable
+// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
+// <id> usart_arch_sfde
+#ifndef CONF_SERCOM_7_USART_SFDE
+#define CONF_SERCOM_7_USART_SFDE 0
+#endif
+
+// <q> Collision Detection Enable
+// <i> Collision detection enable
+// <id> usart_arch_cloden
+#ifndef CONF_SERCOM_7_USART_CLODEN
+#define CONF_SERCOM_7_USART_CLODEN 0
+#endif
+
+// <o> Operating Mode
+// <0x0=>USART with external clock
+// <0x1=>USART with internal clock
+// <i> Drive the shift register by an internal clock generated by the baud rate generator or an external clock supplied on the XCK pin.
+// <id> usart_arch_clock_mode
+#ifndef CONF_SERCOM_7_USART_MODE
+#define CONF_SERCOM_7_USART_MODE 0x1
+#endif
+
+// <o> Sample Rate
+// <0x0=>16x arithmetic
+// <0x1=>16x fractional
+// <0x2=>8x arithmetic
+// <0x3=>8x fractional
+// <0x4=>3x arithmetic
+// <i> How many over-sampling bits used when sampling data state
+// <id> usart_arch_sampr
+#ifndef CONF_SERCOM_7_USART_SAMPR
+#define CONF_SERCOM_7_USART_SAMPR 0x0
+#endif
+
+// <o> Sample Adjustment
+// <0x0=>7-8-9 (3-4-5 8-bit over-sampling)
+// <0x1=>9-10-11 (4-5-6 8-bit over-sampling)
+// <0x2=>11-12-13 (5-6-7 8-bit over-sampling)
+// <0x3=>13-14-15 (6-7-8 8-bit over-sampling)
+// <i> Adjust which samples to use for data sampling in asynchronous mode
+// <id> usart_arch_sampa
+#ifndef CONF_SERCOM_7_USART_SAMPA
+#define CONF_SERCOM_7_USART_SAMPA 0x0
+#endif
+
+// <o> Fractional Part <0-7>
+// <i> Fractional part of the baud rate if baud rate generator is in fractional mode
+// <id> usart_arch_fractional
+#ifndef CONF_SERCOM_7_USART_FRACTIONAL
+#define CONF_SERCOM_7_USART_FRACTIONAL 0x0
+#endif
+
+// <o> Data Order
+// <0=>MSB is transmitted first
+// <1=>LSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_dord
+#ifndef CONF_SERCOM_7_USART_DORD
+#define CONF_SERCOM_7_USART_DORD 1
+#endif
+
+// Does not do anything in UART mode
+#define CONF_SERCOM_7_USART_CPOL 0
+
+// <o> Encoding Format
+// <0=>No encoding
+// <1=>IrDA encoded
+// <id> usart_arch_enc
+#ifndef CONF_SERCOM_7_USART_ENC
+#define CONF_SERCOM_7_USART_ENC 0
+#endif
+
+// <o> LIN Slave Enable
+// <i> Break Character Detection and Auto-Baud/LIN Slave Enable.
+// <i> Additional setting needed: 16x sample rate using fractional baud rate generation (CTRLA.SAMPR = 1).
+// <0=>Disable
+// <1=>Enable
+// <id> usart_arch_lin_slave_enable
+#ifndef CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE
+#define CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE 0
+#endif
+
+// <o> Debug Stop Mode
+// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
+// <0=>Keep running
+// <1=>Halt
+// <id> usart_arch_dbgstop
+#ifndef CONF_SERCOM_7_USART_DEBUG_STOP_MODE
+#define CONF_SERCOM_7_USART_DEBUG_STOP_MODE 0
+#endif
+
+// </e>
+
+#ifndef CONF_SERCOM_7_USART_INACK
+#define CONF_SERCOM_7_USART_INACK 0x0
+#endif
+
+#ifndef CONF_SERCOM_7_USART_DSNACK
+#define CONF_SERCOM_7_USART_DSNACK 0x0
+#endif
+
+#ifndef CONF_SERCOM_7_USART_MAXITER
+#define CONF_SERCOM_7_USART_MAXITER 0x7
+#endif
+
+#ifndef CONF_SERCOM_7_USART_GTIME
+#define CONF_SERCOM_7_USART_GTIME 0x2
+#endif
+
+#define CONF_SERCOM_7_USART_RXINV 0x0
+#define CONF_SERCOM_7_USART_TXINV 0x0
+
+#ifndef CONF_SERCOM_7_USART_CMODE
+#define CONF_SERCOM_7_USART_CMODE 0
+#endif
+
+#ifndef CONF_SERCOM_7_USART_RXPO
+#define CONF_SERCOM_7_USART_RXPO 1 /* RX is on PIN_PB31 */
+#endif
+
+#ifndef CONF_SERCOM_7_USART_TXPO
+#define CONF_SERCOM_7_USART_TXPO 0 /* TX is on PIN_PB30 */
+#endif
+
+/* Set correct parity settings in register interface based on PARITY setting */
+#if CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE == 1
+#if CONF_SERCOM_7_USART_PARITY == 0
+#define CONF_SERCOM_7_USART_PMODE 0
+#define CONF_SERCOM_7_USART_FORM 4
+#else
+#define CONF_SERCOM_7_USART_PMODE CONF_SERCOM_7_USART_PARITY - 1
+#define CONF_SERCOM_7_USART_FORM 5
+#endif
+#else /* #if CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE == 0 */
+#if CONF_SERCOM_7_USART_PARITY == 0
+#define CONF_SERCOM_7_USART_PMODE 0
+#define CONF_SERCOM_7_USART_FORM 0
+#else
+#define CONF_SERCOM_7_USART_PMODE CONF_SERCOM_7_USART_PARITY - 1
+#define CONF_SERCOM_7_USART_FORM 1
+#endif
+#endif
+
+// Calculate BAUD register value in UART mode
+#if CONF_SERCOM_7_USART_SAMPR == 0
+#ifndef CONF_SERCOM_7_USART_BAUD_RATE
+#define CONF_SERCOM_7_USART_BAUD_RATE \
+ 65536 - ((65536 * 16.0f * CONF_SERCOM_7_USART_BAUD) / CONF_GCLK_SERCOM7_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_7_USART_SAMPR == 1
+#ifndef CONF_SERCOM_7_USART_BAUD_RATE
+#define CONF_SERCOM_7_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM7_CORE_FREQUENCY) / (CONF_SERCOM_7_USART_BAUD * 16)) - (CONF_SERCOM_7_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_7_USART_SAMPR == 2
+#ifndef CONF_SERCOM_7_USART_BAUD_RATE
+#define CONF_SERCOM_7_USART_BAUD_RATE \
+ 65536 - ((65536 * 8.0f * CONF_SERCOM_7_USART_BAUD) / CONF_GCLK_SERCOM7_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_7_USART_SAMPR == 3
+#ifndef CONF_SERCOM_7_USART_BAUD_RATE
+#define CONF_SERCOM_7_USART_BAUD_RATE \
+ ((CONF_GCLK_SERCOM7_CORE_FREQUENCY) / (CONF_SERCOM_7_USART_BAUD * 8)) - (CONF_SERCOM_7_USART_FRACTIONAL / 8)
+#endif
+#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#elif CONF_SERCOM_7_USART_SAMPR == 4
+#ifndef CONF_SERCOM_7_USART_BAUD_RATE
+#define CONF_SERCOM_7_USART_BAUD_RATE \
+ 65536 - ((65536 * 3.0f * CONF_SERCOM_7_USART_BAUD) / CONF_GCLK_SERCOM7_CORE_FREQUENCY)
+#endif
+#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
+#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
+#endif
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // HPL_SERCOM_CONFIG_H
diff --git a/config/peripheral_clk_config.h b/config/peripheral_clk_config.h
index 9a9c30f..8078e4b 100644
--- a/config/peripheral_clk_config.h
+++ b/config/peripheral_clk_config.h
@@ -9,7 +9,7 @@
* \brief CPU's Clock frequency
*/
#ifndef CONF_CPU_FREQUENCY
-#define CONF_CPU_FREQUENCY 12000000
+#define CONF_CPU_FREQUENCY 120000000
#endif
// <y> USB Clock Source
diff --git a/gcc/Makefile b/gcc/Makefile
index 3493102..2df931e 100644
--- a/gcc/Makefile
+++ b/gcc/Makefile
@@ -5,7 +5,7 @@
# Set for which board the bootloader should be compiled
# run `make clean` for the change to be effective
# possible values: SAME54_XPLAINED_PRO, SYSMOOCTSIM
-BOARD ?= SAME54_XPLAINED_PRO
+BOARD ?= SYSMOOCTSIM
GIT_VERSION=$(shell ../git-version-gen $(TOP)/.tarvers)
@@ -89,124 +89,64 @@
hal/src/hal_cache.o \
hpl/cmcc/hpl_cmcc.o \
atmel_start.o \
-usb_dfu_main.o \
usb/device/usbdc.o \
hal/src/hal_atomic.o
-
-OBJS_AS_ARGS += \
-"hal/src/hal_io.o" \
-"hpl/core/hpl_core_m4.o" \
-"usb/class/dfu/device/dfudf.o" \
-"hal/utils/src/utils_syscalls.o" \
-"hpl/dmac/hpl_dmac.o" \
-"hpl/nvmctrl/hpl_nvmctrl.o" \
-"gcc/system_same54.o" \
-"hpl/usb/hpl_usb.o" \
-"hal/src/hal_delay.o" \
-"hpl/pm/hpl_pm.o" \
-"hpl/core/hpl_init.o" \
-"hpl/gclk/hpl_gclk.o" \
-"hal/utils/src/utils_list.o" \
-"hal/utils/src/utils_assert.o" \
-"usb_start.o" \
-"hpl/oscctrl/hpl_oscctrl.o" \
-"hpl/mclk/hpl_mclk.o" \
-"hpl/ramecc/hpl_ramecc.o" \
-"usb/usb_protocol.o" \
-"hal/src/hal_flash.o" \
-"hal/src/hal_init.o" \
-"gcc/gcc/startup_same54.o" \
-"hal/src/hal_usb_device.o" \
-"hpl/osc32kctrl/hpl_osc32kctrl.o" \
-"driver_init.o" \
-"hal/src/hal_gpio.o" \
-"hal/utils/src/utils_event.o" \
-"hal/src/hal_sleep.o" \
-"hal/src/hal_cache.o" \
-"hpl/cmcc/hpl_cmcc.o" \
-"atmel_start.o" \
-"usb_dfu_main.o" \
-"usb/device/usbdc.o" \
-"hal/src/hal_atomic.o"
-
-# List the dependency files
DEPS := $(OBJS:%.o=%.d)
-
-DEPS_AS_ARGS += \
-"hal/utils/src/utils_event.d" \
-"hal/src/hal_io.d" \
-"hpl/ramecc/hpl_ramecc.d" \
-"hpl/core/hpl_core_m4.d" \
-"hal/utils/src/utils_syscalls.d" \
-"hpl/nvmctrl/hpl_nvmctrl.d" \
-"usb/class/dfu/device/dfudf.d" \
-"gcc/gcc/startup_same54.d" \
-"hpl/usb/hpl_usb.d" \
-"hal/utils/src/utils_list.d" \
-"hpl/cmcc/hpl_cmcc.d" \
-"usb_start.d" \
-"hal/utils/src/utils_assert.d" \
-"hal/src/hal_delay.d" \
-"hpl/core/hpl_init.d" \
-"hpl/pm/hpl_pm.d" \
-"usb/usb_protocol.d" \
-"hal/src/hal_flash.d" \
-"hpl/gclk/hpl_gclk.d" \
-"hal/src/hal_usb_device.d" \
-"hpl/dmac/hpl_dmac.d" \
-"hal/src/hal_init.d" \
-"usb_dfu_main.d" \
-"hpl/mclk/hpl_mclk.d" \
-"driver_init.d" \
-"hpl/osc32kctrl/hpl_osc32kctrl.d" \
-"hal/src/hal_cache.d" \
-"hal/src/hal_sleep.d" \
-"hal/src/hal_gpio.d" \
-"hal/src/hal_atomic.d" \
-"usb/device/usbdc.d" \
-"hpl/oscctrl/hpl_oscctrl.d" \
-"gcc/system_same54.d" \
-"atmel_start.d"
+OBJS_AS_ARGS = $(patsubst %,"%",$(OBJS))
+DEPS_AS_ARGS = $(patsubst %,"%",$(DEPS))
BOARD_LC := $(shell echo $(BOARD) | tr A-Z a-z)
OUTPUT_FILE_NAME := bootloader-$(BOARD_LC)-$(GIT_VERSION)
QUOTE := "
-OUTPUT_FILE_PATH +=$(OUTPUT_FILE_NAME).elf
-OUTPUT_FILE_PATH_AS_ARGS +=$(OUTPUT_FILE_NAME).elf
+# OUTPUT_FILE_PATH +=$(OUTPUT_FILE_NAME).elf
+#OUTPUT_FILE_PATH_AS_ARGS +=$(OUTPUT_FILE_NAME).elf
+BLSIZE_DEF := -D$(QUOTE)$(shell sed 's/;//g' gcc/blsize.ld | tr -d ' ')$(QUOTE)
+
+# .PHONY MAIN_dfu MAIN_flash
+# MAIN_%:
+# = usb_dfu_main.o
vpath %.c ../
vpath %.s ../
vpath %.S ../
-# All Target
-all: $(SUB_DIRS) $(OUTPUT_FILE_PATH) symlink
+.PHONY: clean-dfu clean-flash
+
+all: $(SUB_DIRS) dfu-merge
+
+dfu-merge: $(OUTPUT_FILE_NAME)-dfu
+
+$(OUTPUT_FILE_NAME)-dfu: $(OUTPUT_FILE_NAME)-flash
# Linker target
-$(OUTPUT_FILE_PATH): $(OBJS)
+$(OUTPUT_FILE_NAME)-%: $(OBJS) usb_%_main.o
@echo Building target: $@
@echo Invoking: ARM/GNU Linker
- $(QUOTE)arm-none-eabi-gcc$(QUOTE) -o $(OUTPUT_FILE_NAME).elf $(OBJS_AS_ARGS) -Wl,--start-group -lm -Wl,--end-group -mthumb \
--Wl,-Map="$(OUTPUT_FILE_NAME).map" --specs=nano.specs -Wl,--gc-sections -mcpu=cortex-m4 \
- \
--T"../gcc/gcc/same54p20a_flash.ld" \
--L"../gcc/gcc"
+ $(QUOTE)arm-none-eabi-gcc$(QUOTE) -o $(OUTPUT_FILE_NAME)-$*.elf $(OBJS_AS_ARGS) "usb_$*_main.o" \
+ -Wl,--no-undefined -Wl,--print-memory-usage -Wl,--strip-discarded -Wl,--start-group -lm -Wl,--end-group -mthumb \
+ -Wl,-Map="$(OUTPUT_FILE_NAME)-$*.map" --specs=nano.specs -Wl,--gc-sections -mcpu=cortex-m4 \
+ -T"../gcc/gcc/same54p20a_$*.ld" \
+ -L"../gcc/gcc"
@echo Finished building target: $@
- "arm-none-eabi-objcopy" -O binary "$(OUTPUT_FILE_NAME).elf" "$(OUTPUT_FILE_NAME).bin"
- "arm-none-eabi-objcopy" -O ihex -R .eeprom -R .fuse -R .lock -R .signature \
- "$(OUTPUT_FILE_NAME).elf" "$(OUTPUT_FILE_NAME).hex"
- "arm-none-eabi-objcopy" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma \
- .eeprom=0 --no-change-warnings -O binary "$(OUTPUT_FILE_NAME).elf" \
- "$(OUTPUT_FILE_NAME).eep" || exit 0
- "arm-none-eabi-objdump" -h -S "$(OUTPUT_FILE_NAME).elf" > "$(OUTPUT_FILE_NAME).lss"
- "arm-none-eabi-size" "$(OUTPUT_FILE_NAME).elf"
+ "arm-none-eabi-objcopy" -O binary "$(OUTPUT_FILE_NAME)-$*.elf" "$(OUTPUT_FILE_NAME)-$*.bin"
+# "arm-none-eabi-objcopy" -O ihex -R .eeprom -R .fuse -R .lock -R .signature "$(OUTPUT_FILE_NAME)-$*.elf" "$(OUTPUT_FILE_NAME)-$*.hex"
+# "arm-none-eabi-objcopy" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O binary "$(OUTPUT_FILE_NAME)-$*.elf" "$(OUTPUT_FILE_NAME)-$*.eep" || exit 0
+ "arm-none-eabi-objdump" -h -S "$(OUTPUT_FILE_NAME)-$*.elf" > "$(OUTPUT_FILE_NAME)-$*.lss"
+ "arm-none-eabi-size" "$(OUTPUT_FILE_NAME)-$*.elf"
+ ln -sf $(OUTPUT_FILE_NAME)-$*.bin bootloader-$(BOARD_LC)-$*.bin
+ ln -sf $(OUTPUT_FILE_NAME)-$*.elf bootloader-$(BOARD_LC)-$*.elf
-.PHONY: symlink
-symlink: $(OUTPUT_FILE_PATH)
- ln -sf $(OUTPUT_FILE_NAME).bin bootloader-$(BOARD_LC).bin
- ln -sf $(OUTPUT_FILE_NAME).elf bootloader-$(BOARD_LC).elf
+.PHONY: dfu-merge
+dfu-merge:
+ $(info updating updater section with padded bootloader file..)
+ $(SILENT)dd if=/dev/zero bs=16384 count=1 of=dfu-flash-padded.bin
+ $(SILENT)dd if=$(OUTPUT_FILE_NAME)-flash.bin conv=notrunc of=dfu-flash-padded.bin
+ $(SILENT)"arm-none-eabi-objcopy" --update-section .blupdate=dfu-flash-padded.bin $(OUTPUT_FILE_NAME)-dfu.elf
+ $(SILENT)"arm-none-eabi-objcopy" -O binary $(OUTPUT_FILE_NAME)-dfu.elf $(OUTPUT_FILE_NAME)-dfu.bin
+ rm dfu-flash-padded.bin
# Compiler targets
@@ -217,7 +157,7 @@
@echo Building file: $<
@echo ARM/GNU C Compiler
$(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \
--D__SAME54P20A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \
+$(BLSIZE_DEF) -D__SAME54P19A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \
-I"../" -I"../config" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/nvmctrl" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include" \
-MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
@@ -226,7 +166,7 @@
@echo Building file: $<
@echo ARM/GNU Assembler
$(QUOTE)arm-none-eabi-as$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \
--D__SAME54P20A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \
+$(BLSIZE_DEF) -D__SAME54P19A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \
-I"../" -I"../config" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/nvmctrl" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include" \
-MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
@@ -235,7 +175,7 @@
@echo Building file: $<
@echo ARM/GNU Preprocessing Assembler
$(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \
--D__SAME54P20A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \
+$(BLSIZE_DEF) -D__SAME54P19A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \
-I"../" -I"../config" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/nvmctrl" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include" \
-MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
@@ -244,19 +184,28 @@
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
+-include usb_flash_main.d usb_dfu_main.d
endif
endif
$(SUB_DIRS):
$(MK_DIR) "$@"
-clean:
+clean-%:
rm -f $(OBJS_AS_ARGS)
- rm -f $(OUTPUT_FILE_PATH)
+ # rm -f $(OUTPUT_FILE_PATH)
rm -f $(DEPS_AS_ARGS)
- rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \
- $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \
- $(OUTPUT_FILE_NAME).srec bootloader-$(BOARD_LC).bin bootloader-$(BOARD_LC).elf
+ rm -f $(OUTPUT_FILE_NAME)-$*.a $(OUTPUT_FILE_NAME)-$*.hex $(OUTPUT_FILE_NAME)-$*.bin \
+ $(OUTPUT_FILE_NAME)-$*.lss $(OUTPUT_FILE_NAME)-$*.eep $(OUTPUT_FILE_NAME)-$*.map \
+ $(OUTPUT_FILE_NAME)-$*.srec bootloader-$(BOARD_LC)-$*.bin bootloader-$(BOARD_LC)-$*.elf
+
+clean: clean-dfu clean-flash
+ rm -f $(OBJS_AS_ARGS)
+ # rm -f $(OUTPUT_FILE_PATH)
+ rm -f $(DEPS_AS_ARGS)
+ # rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \
+ # $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \
+ # $(OUTPUT_FILE_NAME).srec bootloader-$(BOARD_LC).bin bootloader-$(BOARD_LC).elf
mrproper: clean
- rm -f *.o *.d *.a *.elf *.bin *.ihex *.eep *.lss *.map *.srec
+ rm -f *.o *.d *.a *.elf *.bin *.hex *.ihex *.eep *.lss *.map *.srec
diff --git a/gcc/system_same54.c b/gcc/system_same54.c
index 55a5fd2..9d17c8d 100644
--- a/gcc/system_same54.c
+++ b/gcc/system_same54.c
@@ -28,12 +28,13 @@
*/
#include "same54.h"
+#include "peripheral_clk_config.h"
/**
* Initial system clock frequency. The System RC Oscillator (RCSYS) provides
* the source for the main clock at chip startup.
*/
-#define __SYSTEM_CLOCK (48000000)
+#define __SYSTEM_CLOCK CONF_CPU_FREQUENCY
uint32_t SystemCoreClock = __SYSTEM_CLOCK; /*!< System Clock Frequency (Core Clock)*/
diff --git a/hpl/core/hpl_core_m4.c b/hpl/core/hpl_core_m4.c
index acb75bc..4680ec3 100644
--- a/hpl/core/hpl_core_m4.c
+++ b/hpl/core/hpl_core_m4.c
@@ -216,8 +216,14 @@
#ifndef _UNIT_TEST_
(void)hw;
(void)cycles;
-#if defined __GNUC__
+#if defined(__GNUC__) && (__ARMCOMPILER_VERSION > 6000000) /* Keil MDK with ARM Compiler 6 */
+ __asm(".align 3 \n"
+ "__delay:\n"
+ "subs r1, r1, #1\n"
+ "bhi __delay\n");
+#elif defined __GNUC__
__asm(".syntax unified\n"
+ ".align 3 \n"
"__delay:\n"
"subs r1, r1, #1\n"
"bhi __delay\n"
diff --git a/hpl/oscctrl/hpl_oscctrl.c b/hpl/oscctrl/hpl_oscctrl.c
index 9f55076..1fc04bd 100644
--- a/hpl/oscctrl/hpl_oscctrl.c
+++ b/hpl/oscctrl/hpl_oscctrl.c
@@ -35,6 +35,7 @@
#include <hpl_init.h>
#include <hpl_oscctrl_config.h>
#include <hpl_gclk_config.h>
+#include <hpl_delay.h>
/**
* \brief Initialize clock sources
@@ -219,6 +220,11 @@
#endif
#endif
+ // startup default is internal osck32k -> pll @48M -> gclk0 -> cpu
+ // but this code sets it to osc32k while being reconfigured
+ // errata 2.13.1 delay
+ _delay_cycles(0, (32768U/1000) * 10 /* 10 ms*/);
+
#if CONF_DFLL_CONFIG == 1
while (hri_gclk_read_SYNCBUSY_reg(GCLK))
;
diff --git a/hpl/sercom/hpl_sercom.c b/hpl/sercom/hpl_sercom.c
new file mode 100644
index 0000000..bda6655
--- /dev/null
+++ b/hpl/sercom/hpl_sercom.c
@@ -0,0 +1,3238 @@
+
+/**
+ * \file
+ *
+ * \brief SAM Serial Communication Interface
+ *
+ * Copyright (c) 2014-2019 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+#include <hpl_dma.h>
+#include <hpl_i2c_m_async.h>
+#include <hpl_i2c_m_sync.h>
+#include <hpl_i2c_s_async.h>
+#include <hpl_sercom_config.h>
+#include <hpl_spi_m_async.h>
+#include <hpl_spi_m_sync.h>
+#include <hpl_spi_s_async.h>
+#include <hpl_spi_s_sync.h>
+#include <hpl_usart_async.h>
+#include <hpl_usart_sync.h>
+#include <utils.h>
+#include <utils_assert.h>
+
+#ifndef CONF_SERCOM_0_USART_ENABLE
+#define CONF_SERCOM_0_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_1_USART_ENABLE
+#define CONF_SERCOM_1_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_2_USART_ENABLE
+#define CONF_SERCOM_2_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_3_USART_ENABLE
+#define CONF_SERCOM_3_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_4_USART_ENABLE
+#define CONF_SERCOM_4_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_5_USART_ENABLE
+#define CONF_SERCOM_5_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_6_USART_ENABLE
+#define CONF_SERCOM_6_USART_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_7_USART_ENABLE
+#define CONF_SERCOM_7_USART_ENABLE 0
+#endif
+
+/** Amount of SERCOM that is used as USART. */
+#define SERCOM_USART_AMOUNT \
+ (CONF_SERCOM_0_USART_ENABLE + CONF_SERCOM_1_USART_ENABLE + CONF_SERCOM_2_USART_ENABLE + CONF_SERCOM_3_USART_ENABLE \
+ + CONF_SERCOM_4_USART_ENABLE + CONF_SERCOM_5_USART_ENABLE + CONF_SERCOM_6_USART_ENABLE \
+ + CONF_SERCOM_7_USART_ENABLE)
+
+/**
+ * \brief Macro is used to fill usart configuration structure based on
+ * its number
+ *
+ * \param[in] n The number of structures
+ */
+#define SERCOM_CONFIGURATION(n) \
+ { \
+ n, \
+ SERCOM_USART_CTRLA_MODE(CONF_SERCOM_##n##_USART_MODE) \
+ | (CONF_SERCOM_##n##_USART_RUNSTDBY << SERCOM_USART_CTRLA_RUNSTDBY_Pos) \
+ | (CONF_SERCOM_##n##_USART_IBON << SERCOM_USART_CTRLA_IBON_Pos) \
+ | (CONF_SERCOM_##n##_USART_TXINV << SERCOM_USART_CTRLA_TXINV_Pos) \
+ | (CONF_SERCOM_##n##_USART_RXINV << SERCOM_USART_CTRLA_RXINV_Pos) \
+ | SERCOM_USART_CTRLA_SAMPR(CONF_SERCOM_##n##_USART_SAMPR) \
+ | SERCOM_USART_CTRLA_TXPO(CONF_SERCOM_##n##_USART_TXPO) \
+ | SERCOM_USART_CTRLA_RXPO(CONF_SERCOM_##n##_USART_RXPO) \
+ | SERCOM_USART_CTRLA_SAMPA(CONF_SERCOM_##n##_USART_SAMPA) \
+ | SERCOM_USART_CTRLA_FORM(CONF_SERCOM_##n##_USART_FORM) \
+ | (CONF_SERCOM_##n##_USART_CMODE << SERCOM_USART_CTRLA_CMODE_Pos) \
+ | (CONF_SERCOM_##n##_USART_CPOL << SERCOM_USART_CTRLA_CPOL_Pos) \
+ | (CONF_SERCOM_##n##_USART_DORD << SERCOM_USART_CTRLA_DORD_Pos), \
+ SERCOM_USART_CTRLB_CHSIZE(CONF_SERCOM_##n##_USART_CHSIZE) \
+ | (CONF_SERCOM_##n##_USART_SBMODE << SERCOM_USART_CTRLB_SBMODE_Pos) \
+ | (CONF_SERCOM_##n##_USART_CLODEN << SERCOM_USART_CTRLB_COLDEN_Pos) \
+ | (CONF_SERCOM_##n##_USART_SFDE << SERCOM_USART_CTRLB_SFDE_Pos) \
+ | (CONF_SERCOM_##n##_USART_ENC << SERCOM_USART_CTRLB_ENC_Pos) \
+ | (CONF_SERCOM_##n##_USART_PMODE << SERCOM_USART_CTRLB_PMODE_Pos) \
+ | (CONF_SERCOM_##n##_USART_TXEN << SERCOM_USART_CTRLB_TXEN_Pos) \
+ | (CONF_SERCOM_##n##_USART_RXEN << SERCOM_USART_CTRLB_RXEN_Pos), \
+ SERCOM_USART_CTRLC_GTIME(CONF_SERCOM_##n##_USART_GTIME) \
+ | (CONF_SERCOM_##n##_USART_DSNACK << SERCOM_USART_CTRLC_DSNACK_Pos) \
+ | (CONF_SERCOM_##n##_USART_INACK << SERCOM_USART_CTRLC_INACK_Pos) \
+ | SERCOM_USART_CTRLC_MAXITER(CONF_SERCOM_##n##_USART_MAXITER), \
+ (uint16_t)(CONF_SERCOM_##n##_USART_BAUD_RATE), CONF_SERCOM_##n##_USART_FRACTIONAL, \
+ CONF_SERCOM_##n##_USART_RECEIVE_PULSE_LENGTH, CONF_SERCOM_##n##_USART_DEBUG_STOP_MODE, \
+ }
+
+/**
+ * \brief SERCOM USART configuration type
+ */
+struct usart_configuration {
+ uint8_t number;
+ hri_sercomusart_ctrla_reg_t ctrl_a;
+ hri_sercomusart_ctrlb_reg_t ctrl_b;
+ hri_sercomusart_ctrlc_reg_t ctrl_c;
+ hri_sercomusart_baud_reg_t baud;
+ uint8_t fractional;
+ hri_sercomusart_rxpl_reg_t rxpl;
+ hri_sercomusart_dbgctrl_reg_t debug_ctrl;
+};
+
+#if SERCOM_USART_AMOUNT < 1
+/** Dummy array to pass compiling. */
+static struct usart_configuration _usarts[1] = {{0}};
+#else
+/**
+ * \brief Array of SERCOM USART configurations
+ */
+static struct usart_configuration _usarts[] = {
+#if CONF_SERCOM_0_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(0),
+#endif
+#if CONF_SERCOM_1_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(1),
+#endif
+#if CONF_SERCOM_2_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(2),
+#endif
+#if CONF_SERCOM_3_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(3),
+#endif
+#if CONF_SERCOM_4_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(4),
+#endif
+#if CONF_SERCOM_5_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(5),
+#endif
+#if CONF_SERCOM_6_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(6),
+#endif
+#if CONF_SERCOM_7_USART_ENABLE == 1
+ SERCOM_CONFIGURATION(7),
+#endif
+};
+#endif
+
+static struct _usart_async_device *_sercom0_dev = NULL;
+
+static struct _usart_async_device *_sercom1_dev = NULL;
+
+static struct _usart_async_device *_sercom2_dev = NULL;
+
+static struct _usart_async_device *_sercom3_dev = NULL;
+
+static struct _usart_async_device *_sercom4_dev = NULL;
+
+static struct _usart_async_device *_sercom5_dev = NULL;
+
+static struct _usart_async_device *_sercom6_dev = NULL;
+
+static uint8_t _get_sercom_index(const void *const hw);
+static uint8_t _sercom_get_irq_num(const void *const hw);
+static void _sercom_init_irq_param(const void *const hw, void *dev);
+static uint8_t _sercom_get_hardware_index(const void *const hw);
+
+static int32_t _usart_init(void *const hw);
+static inline void _usart_deinit(void *const hw);
+static uint16_t _usart_calculate_baud_rate(const uint32_t baud, const uint32_t clock_rate, const uint8_t samples,
+ const enum usart_baud_rate_mode mode, const uint8_t fraction);
+static void _usart_set_baud_rate(void *const hw, const uint32_t baud_rate);
+static void _usart_set_data_order(void *const hw, const enum usart_data_order order);
+static void _usart_set_mode(void *const hw, const enum usart_mode mode);
+static void _usart_set_parity(void *const hw, const enum usart_parity parity);
+static void _usart_set_stop_bits(void *const hw, const enum usart_stop_bits stop_bits);
+static void _usart_set_character_size(void *const hw, const enum usart_character_size size);
+
+/**
+ * \brief Initialize synchronous SERCOM USART
+ */
+int32_t _usart_sync_init(struct _usart_sync_device *const device, void *const hw)
+{
+ ASSERT(device);
+
+ device->hw = hw;
+
+ return _usart_init(hw);
+}
+
+/**
+ * \brief Initialize asynchronous SERCOM USART
+ */
+int32_t _usart_async_init(struct _usart_async_device *const device, void *const hw)
+{
+ int32_t init_status;
+
+ ASSERT(device);
+
+ init_status = _usart_init(hw);
+ if (init_status) {
+ return init_status;
+ }
+ device->hw = hw;
+ _sercom_init_irq_param(hw, (void *)device);
+ uint8_t irq = _sercom_get_irq_num(hw);
+ for (uint32_t i = 0; i < 4; i++) {
+ NVIC_DisableIRQ((IRQn_Type)irq);
+ NVIC_ClearPendingIRQ((IRQn_Type)irq);
+ NVIC_EnableIRQ((IRQn_Type)irq);
+ irq++;
+ }
+ return ERR_NONE;
+}
+
+/**
+ * \brief De-initialize SERCOM USART
+ */
+void _usart_sync_deinit(struct _usart_sync_device *const device)
+{
+ _usart_deinit(device->hw);
+}
+
+/**
+ * \brief De-initialize SERCOM USART
+ */
+void _usart_async_deinit(struct _usart_async_device *const device)
+{
+ NVIC_DisableIRQ((IRQn_Type)_sercom_get_irq_num(device->hw));
+ _usart_deinit(device->hw);
+}
+
+/**
+ * \brief Calculate baud rate register value
+ */
+uint16_t _usart_sync_calculate_baud_rate(const uint32_t baud, const uint32_t clock_rate, const uint8_t samples,
+ const enum usart_baud_rate_mode mode, const uint8_t fraction)
+{
+ return _usart_calculate_baud_rate(baud, clock_rate, samples, mode, fraction);
+}
+
+/**
+ * \brief Calculate baud rate register value
+ */
+uint16_t _usart_async_calculate_baud_rate(const uint32_t baud, const uint32_t clock_rate, const uint8_t samples,
+ const enum usart_baud_rate_mode mode, const uint8_t fraction)
+{
+ return _usart_calculate_baud_rate(baud, clock_rate, samples, mode, fraction);
+}
+
+/**
+ * \brief Enable SERCOM module
+ */
+void _usart_sync_enable(struct _usart_sync_device *const device)
+{
+ hri_sercomusart_set_CTRLA_ENABLE_bit(device->hw);
+}
+
+/**
+ * \brief Enable SERCOM module
+ */
+void _usart_async_enable(struct _usart_async_device *const device)
+{
+ hri_sercomusart_set_CTRLA_ENABLE_bit(device->hw);
+}
+
+/**
+ * \brief Disable SERCOM module
+ */
+void _usart_sync_disable(struct _usart_sync_device *const device)
+{
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(device->hw);
+}
+
+/**
+ * \brief Disable SERCOM module
+ */
+void _usart_async_disable(struct _usart_async_device *const device)
+{
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(device->hw);
+}
+
+/**
+ * \brief Set baud rate
+ */
+void _usart_sync_set_baud_rate(struct _usart_sync_device *const device, const uint32_t baud_rate)
+{
+ _usart_set_baud_rate(device->hw, baud_rate);
+}
+
+/**
+ * \brief Set baud rate
+ */
+void _usart_async_set_baud_rate(struct _usart_async_device *const device, const uint32_t baud_rate)
+{
+ _usart_set_baud_rate(device->hw, baud_rate);
+}
+
+/**
+ * \brief Set data order
+ */
+void _usart_sync_set_data_order(struct _usart_sync_device *const device, const enum usart_data_order order)
+{
+ _usart_set_data_order(device->hw, order);
+}
+
+/**
+ * \brief Set data order
+ */
+void _usart_async_set_data_order(struct _usart_async_device *const device, const enum usart_data_order order)
+{
+ _usart_set_data_order(device->hw, order);
+}
+
+/**
+ * \brief Set mode
+ */
+void _usart_sync_set_mode(struct _usart_sync_device *const device, const enum usart_mode mode)
+{
+ _usart_set_mode(device->hw, mode);
+}
+
+/**
+ * \brief Set mode
+ */
+void _usart_async_set_mode(struct _usart_async_device *const device, const enum usart_mode mode)
+{
+ _usart_set_mode(device->hw, mode);
+}
+
+/**
+ * \brief Set parity
+ */
+void _usart_sync_set_parity(struct _usart_sync_device *const device, const enum usart_parity parity)
+{
+ _usart_set_parity(device->hw, parity);
+}
+
+/**
+ * \brief Set parity
+ */
+void _usart_async_set_parity(struct _usart_async_device *const device, const enum usart_parity parity)
+{
+ _usart_set_parity(device->hw, parity);
+}
+
+/**
+ * \brief Set stop bits mode
+ */
+void _usart_sync_set_stop_bits(struct _usart_sync_device *const device, const enum usart_stop_bits stop_bits)
+{
+ _usart_set_stop_bits(device->hw, stop_bits);
+}
+
+/**
+ * \brief Set stop bits mode
+ */
+void _usart_async_set_stop_bits(struct _usart_async_device *const device, const enum usart_stop_bits stop_bits)
+{
+ _usart_set_stop_bits(device->hw, stop_bits);
+}
+
+/**
+ * \brief Set character size
+ */
+void _usart_sync_set_character_size(struct _usart_sync_device *const device, const enum usart_character_size size)
+{
+ _usart_set_character_size(device->hw, size);
+}
+
+/**
+ * \brief Set character size
+ */
+void _usart_async_set_character_size(struct _usart_async_device *const device, const enum usart_character_size size)
+{
+ _usart_set_character_size(device->hw, size);
+}
+
+/**
+ * \brief Retrieve SERCOM usart status
+ */
+uint32_t _usart_sync_get_status(const struct _usart_sync_device *const device)
+{
+ return hri_sercomusart_read_STATUS_reg(device->hw);
+}
+
+/**
+ * \brief Retrieve SERCOM usart status
+ */
+uint32_t _usart_async_get_status(const struct _usart_async_device *const device)
+{
+ return hri_sercomusart_read_STATUS_reg(device->hw);
+}
+
+/**
+ * \brief Write a byte to the given SERCOM USART instance
+ */
+void _usart_sync_write_byte(struct _usart_sync_device *const device, uint8_t data)
+{
+ hri_sercomusart_write_DATA_reg(device->hw, data);
+}
+
+/**
+ * \brief Write a byte to the given SERCOM USART instance
+ */
+void _usart_async_write_byte(struct _usart_async_device *const device, uint8_t data)
+{
+ hri_sercomusart_write_DATA_reg(device->hw, data);
+}
+
+/**
+ * \brief Read a byte from the given SERCOM USART instance
+ */
+uint8_t _usart_sync_read_byte(const struct _usart_sync_device *const device)
+{
+ return hri_sercomusart_read_DATA_reg(device->hw);
+}
+
+/**
+ * \brief Check if USART is ready to send next byte
+ */
+bool _usart_sync_is_ready_to_send(const struct _usart_sync_device *const device)
+{
+ return hri_sercomusart_get_interrupt_DRE_bit(device->hw);
+}
+
+/**
+ * \brief Check if USART transmission complete
+ */
+bool _usart_sync_is_transmit_done(const struct _usart_sync_device *const device)
+{
+ return hri_sercomusart_get_interrupt_TXC_bit(device->hw);
+}
+
+/**
+ * \brief Check if USART is ready to send next byte
+ */
+bool _usart_async_is_byte_sent(const struct _usart_async_device *const device)
+{
+ return hri_sercomusart_get_interrupt_DRE_bit(device->hw);
+}
+
+/**
+ * \brief Check if there is data received by USART
+ */
+bool _usart_sync_is_byte_received(const struct _usart_sync_device *const device)
+{
+ return hri_sercomusart_get_interrupt_RXC_bit(device->hw);
+}
+
+/**
+ * \brief Set the state of flow control pins
+ */
+void _usart_sync_set_flow_control_state(struct _usart_sync_device *const device,
+ const union usart_flow_control_state state)
+{
+ (void)device;
+ (void)state;
+}
+
+/**
+ * \brief Set the state of flow control pins
+ */
+void _usart_async_set_flow_control_state(struct _usart_async_device *const device,
+ const union usart_flow_control_state state)
+{
+ (void)device;
+ (void)state;
+}
+
+/**
+ * \brief Retrieve the state of flow control pins
+ */
+union usart_flow_control_state _usart_sync_get_flow_control_state(const struct _usart_sync_device *const device)
+{
+ (void)device;
+ union usart_flow_control_state state;
+
+ state.value = 0;
+ state.bit.unavailable = 1;
+ return state;
+}
+
+/**
+ * \brief Retrieve the state of flow control pins
+ */
+union usart_flow_control_state _usart_async_get_flow_control_state(const struct _usart_async_device *const device)
+{
+ (void)device;
+ union usart_flow_control_state state;
+
+ state.value = 0;
+ state.bit.unavailable = 1;
+ return state;
+}
+
+/**
+ * \brief Enable data register empty interrupt
+ */
+void _usart_async_enable_byte_sent_irq(struct _usart_async_device *const device)
+{
+ hri_sercomusart_set_INTEN_DRE_bit(device->hw);
+}
+
+/**
+ * \brief Enable transmission complete interrupt
+ */
+void _usart_async_enable_tx_done_irq(struct _usart_async_device *const device)
+{
+ hri_sercomusart_set_INTEN_TXC_bit(device->hw);
+}
+
+/**
+ * \brief Retrieve ordinal number of the given sercom hardware instance
+ */
+static uint8_t _sercom_get_hardware_index(const void *const hw)
+{
+ Sercom *const sercom_modules[] = SERCOM_INSTS;
+ /* Find index for SERCOM instance. */
+ for (uint32_t i = 0; i < SERCOM_INST_NUM; i++) {
+ if ((uint32_t)hw == (uint32_t)sercom_modules[i]) {
+ return i;
+ }
+ }
+ return 0;
+}
+
+/**
+ * \brief Retrieve ordinal number of the given SERCOM USART hardware instance
+ */
+uint8_t _usart_sync_get_hardware_index(const struct _usart_sync_device *const device)
+{
+ return _sercom_get_hardware_index(device->hw);
+}
+
+/**
+ * \brief Retrieve ordinal number of the given SERCOM USART hardware instance
+ */
+uint8_t _usart_async_get_hardware_index(const struct _usart_async_device *const device)
+{
+ return _sercom_get_hardware_index(device->hw);
+}
+
+/**
+ * \brief Enable/disable USART interrupt
+ */
+void _usart_async_set_irq_state(struct _usart_async_device *const device, const enum _usart_async_callback_type type,
+ const bool state)
+{
+ ASSERT(device);
+
+ if (USART_ASYNC_BYTE_SENT == type || USART_ASYNC_TX_DONE == type) {
+ hri_sercomusart_write_INTEN_DRE_bit(device->hw, state);
+ hri_sercomusart_write_INTEN_TXC_bit(device->hw, state);
+ } else if (USART_ASYNC_RX_DONE == type) {
+ hri_sercomusart_write_INTEN_RXC_bit(device->hw, state);
+ } else if (USART_ASYNC_ERROR == type) {
+ hri_sercomusart_write_INTEN_ERROR_bit(device->hw, state);
+ }
+}
+
+/**
+ * \internal Sercom interrupt handler
+ *
+ * \param[in] p The pointer to interrupt parameter
+ */
+static void _sercom_usart_interrupt_handler(struct _usart_async_device *device)
+{
+ void *hw = device->hw;
+
+ if (hri_sercomusart_get_interrupt_DRE_bit(hw) && hri_sercomusart_get_INTEN_DRE_bit(hw)) {
+ hri_sercomusart_clear_INTEN_DRE_bit(hw);
+ device->usart_cb.tx_byte_sent(device);
+ } else if (hri_sercomusart_get_interrupt_TXC_bit(hw) && hri_sercomusart_get_INTEN_TXC_bit(hw)) {
+ hri_sercomusart_clear_INTEN_TXC_bit(hw);
+ device->usart_cb.tx_done_cb(device);
+ } else if (hri_sercomusart_get_interrupt_RXC_bit(hw)) {
+ if (hri_sercomusart_read_STATUS_reg(hw)
+ & (SERCOM_USART_STATUS_PERR | SERCOM_USART_STATUS_FERR | SERCOM_USART_STATUS_BUFOVF
+ | SERCOM_USART_STATUS_ISF | SERCOM_USART_STATUS_COLL)) {
+ hri_sercomusart_clear_STATUS_reg(hw, SERCOM_USART_STATUS_MASK);
+ return;
+ }
+
+ device->usart_cb.rx_done_cb(device, hri_sercomusart_read_DATA_reg(hw));
+ } else if (hri_sercomusart_get_interrupt_ERROR_bit(hw)) {
+ uint32_t status;
+
+ hri_sercomusart_clear_interrupt_ERROR_bit(hw);
+ device->usart_cb.error_cb(device);
+ status = hri_sercomusart_read_STATUS_reg(hw);
+ hri_sercomusart_clear_STATUS_reg(hw, status);
+ }
+}
+
+/**
+ * \internal Retrieve ordinal number of the given sercom hardware instance
+ *
+ * \param[in] hw The pointer to hardware instance
+
+ * \return The ordinal number of the given sercom hardware instance
+ */
+static uint8_t _get_sercom_index(const void *const hw)
+{
+ uint8_t sercom_offset = _sercom_get_hardware_index(hw);
+ uint8_t i;
+
+ for (i = 0; i < ARRAY_SIZE(_usarts); i++) {
+ if (_usarts[i].number == sercom_offset) {
+ return i;
+ }
+ }
+
+ ASSERT(false);
+ return 0;
+}
+
+/**
+ * \brief Init irq param with the given sercom hardware instance
+ */
+static void _sercom_init_irq_param(const void *const hw, void *dev)
+{
+
+ if (hw == SERCOM0) {
+ _sercom0_dev = (struct _usart_async_device *)dev;
+ }
+
+ if (hw == SERCOM1) {
+ _sercom1_dev = (struct _usart_async_device *)dev;
+ }
+
+ if (hw == SERCOM2) {
+ _sercom2_dev = (struct _usart_async_device *)dev;
+ }
+
+ if (hw == SERCOM3) {
+ _sercom3_dev = (struct _usart_async_device *)dev;
+ }
+
+ if (hw == SERCOM4) {
+ _sercom4_dev = (struct _usart_async_device *)dev;
+ }
+
+ if (hw == SERCOM5) {
+ _sercom5_dev = (struct _usart_async_device *)dev;
+ }
+
+ if (hw == SERCOM6) {
+ _sercom6_dev = (struct _usart_async_device *)dev;
+ }
+}
+
+/**
+ * \internal Initialize SERCOM USART
+ *
+ * \param[in] hw The pointer to hardware instance
+ *
+ * \return The status of initialization
+ */
+static int32_t _usart_init(void *const hw)
+{
+ uint8_t i = _get_sercom_index(hw);
+
+ if (!hri_sercomusart_is_syncing(hw, SERCOM_USART_SYNCBUSY_SWRST)) {
+ uint32_t mode = _usarts[i].ctrl_a & SERCOM_USART_CTRLA_MODE_Msk;
+ if (hri_sercomusart_get_CTRLA_reg(hw, SERCOM_USART_CTRLA_ENABLE)) {
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+ }
+ hri_sercomusart_write_CTRLA_reg(hw, SERCOM_USART_CTRLA_SWRST | mode);
+ }
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_SWRST);
+
+ hri_sercomusart_write_CTRLA_reg(hw, _usarts[i].ctrl_a);
+ hri_sercomusart_write_CTRLB_reg(hw, _usarts[i].ctrl_b);
+ hri_sercomusart_write_CTRLC_reg(hw, _usarts[i].ctrl_c);
+ if ((_usarts[i].ctrl_a & SERCOM_USART_CTRLA_SAMPR(0x1)) || (_usarts[i].ctrl_a & SERCOM_USART_CTRLA_SAMPR(0x3))) {
+ ((Sercom *)hw)->USART.BAUD.FRAC.BAUD = _usarts[i].baud;
+ ((Sercom *)hw)->USART.BAUD.FRAC.FP = _usarts[i].fractional;
+ } else {
+ hri_sercomusart_write_BAUD_reg(hw, _usarts[i].baud);
+ }
+
+ hri_sercomusart_write_RXPL_reg(hw, _usarts[i].rxpl);
+ hri_sercomusart_write_DBGCTRL_reg(hw, _usarts[i].debug_ctrl);
+
+ return ERR_NONE;
+}
+
+/**
+ * \internal De-initialize SERCOM USART
+ *
+ * \param[in] hw The pointer to hardware instance
+ */
+static inline void _usart_deinit(void *const hw)
+{
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomusart_set_CTRLA_SWRST_bit(hw);
+}
+
+/**
+ * \internal Calculate baud rate register value
+ *
+ * \param[in] baud Required baud rate
+ * \param[in] clock_rate SERCOM clock frequency
+ * \param[in] samples The number of samples
+ * \param[in] mode USART mode
+ * \param[in] fraction A fraction value
+ *
+ * \return Calculated baud rate register value
+ */
+static uint16_t _usart_calculate_baud_rate(const uint32_t baud, const uint32_t clock_rate, const uint8_t samples,
+ const enum usart_baud_rate_mode mode, const uint8_t fraction)
+{
+ if (USART_BAUDRATE_ASYNCH_ARITHMETIC == mode) {
+ return 65536 - ((uint64_t)65536 * samples * baud) / clock_rate;
+ }
+
+ if (USART_BAUDRATE_ASYNCH_FRACTIONAL == mode) {
+ return clock_rate / baud / samples + SERCOM_USART_BAUD_FRACFP_FP(fraction);
+ }
+
+ if (USART_BAUDRATE_SYNCH == mode) {
+ return clock_rate / baud / 2 - 1;
+ }
+
+ return 0;
+}
+
+/**
+ * \internal Set baud rate
+ *
+ * \param[in] device The pointer to USART device instance
+ * \param[in] baud_rate A baud rate to set
+ */
+static void _usart_set_baud_rate(void *const hw, const uint32_t baud_rate)
+{
+ bool enabled = hri_sercomusart_get_CTRLA_ENABLE_bit(hw);
+
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+ hri_sercomusart_write_BAUD_reg(hw, baud_rate);
+ CRITICAL_SECTION_LEAVE()
+
+ hri_sercomusart_write_CTRLA_ENABLE_bit(hw, enabled);
+}
+
+/**
+ * \internal Set data order
+ *
+ * \param[in] device The pointer to USART device instance
+ * \param[in] order A data order to set
+ */
+static void _usart_set_data_order(void *const hw, const enum usart_data_order order)
+{
+ bool enabled = hri_sercomusart_get_CTRLA_ENABLE_bit(hw);
+
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+ hri_sercomusart_write_CTRLA_DORD_bit(hw, order);
+ CRITICAL_SECTION_LEAVE()
+
+ hri_sercomusart_write_CTRLA_ENABLE_bit(hw, enabled);
+}
+
+/**
+ * \internal Set mode
+ *
+ * \param[in] device The pointer to USART device instance
+ * \param[in] mode A mode to set
+ */
+static void _usart_set_mode(void *const hw, const enum usart_mode mode)
+{
+ bool enabled = hri_sercomusart_get_CTRLA_ENABLE_bit(hw);
+
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+ hri_sercomusart_write_CTRLA_CMODE_bit(hw, mode);
+ CRITICAL_SECTION_LEAVE()
+
+ hri_sercomusart_write_CTRLA_ENABLE_bit(hw, enabled);
+}
+
+/**
+ * \internal Set parity
+ *
+ * \param[in] device The pointer to USART device instance
+ * \param[in] parity A parity to set
+ */
+static void _usart_set_parity(void *const hw, const enum usart_parity parity)
+{
+ bool enabled = hri_sercomusart_get_CTRLA_ENABLE_bit(hw);
+
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+
+ if (USART_PARITY_NONE != parity) {
+ hri_sercomusart_set_CTRLA_FORM_bf(hw, 1);
+ } else {
+ hri_sercomusart_clear_CTRLA_FORM_bf(hw, 1);
+ }
+
+ hri_sercomusart_write_CTRLB_PMODE_bit(hw, parity);
+ CRITICAL_SECTION_LEAVE()
+
+ hri_sercomusart_write_CTRLA_ENABLE_bit(hw, enabled);
+}
+
+/**
+ * \internal Set stop bits mode
+ *
+ * \param[in] device The pointer to USART device instance
+ * \param[in] stop_bits A stop bits mode to set
+ */
+static void _usart_set_stop_bits(void *const hw, const enum usart_stop_bits stop_bits)
+{
+ bool enabled = hri_sercomusart_get_CTRLA_ENABLE_bit(hw);
+
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+ hri_sercomusart_write_CTRLB_SBMODE_bit(hw, stop_bits);
+ CRITICAL_SECTION_LEAVE()
+
+ hri_sercomusart_write_CTRLA_ENABLE_bit(hw, enabled);
+}
+
+/**
+ * \internal Set character size
+ *
+ * \param[in] device The pointer to USART device instance
+ * \param[in] size A character size to set
+ */
+static void _usart_set_character_size(void *const hw, const enum usart_character_size size)
+{
+ bool enabled = hri_sercomusart_get_CTRLA_ENABLE_bit(hw);
+
+ hri_sercomusart_clear_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomusart_wait_for_sync(hw, SERCOM_USART_SYNCBUSY_ENABLE);
+ hri_sercomusart_write_CTRLB_CHSIZE_bf(hw, size);
+ CRITICAL_SECTION_LEAVE()
+
+ if (enabled) {
+ hri_sercomusart_set_CTRLA_ENABLE_bit(hw);
+ }
+}
+
+ /* Sercom I2C implementation */
+
+#ifndef CONF_SERCOM_0_I2CM_ENABLE
+#define CONF_SERCOM_0_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_1_I2CM_ENABLE
+#define CONF_SERCOM_1_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_2_I2CM_ENABLE
+#define CONF_SERCOM_2_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_3_I2CM_ENABLE
+#define CONF_SERCOM_3_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_4_I2CM_ENABLE
+#define CONF_SERCOM_4_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_5_I2CM_ENABLE
+#define CONF_SERCOM_5_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_6_I2CM_ENABLE
+#define CONF_SERCOM_6_I2CM_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_7_I2CM_ENABLE
+#define CONF_SERCOM_7_I2CM_ENABLE 0
+#endif
+
+/** Amount of SERCOM that is used as I2C Master. */
+#define SERCOM_I2CM_AMOUNT \
+ (CONF_SERCOM_0_I2CM_ENABLE + CONF_SERCOM_1_I2CM_ENABLE + CONF_SERCOM_2_I2CM_ENABLE + CONF_SERCOM_3_I2CM_ENABLE \
+ + CONF_SERCOM_4_I2CM_ENABLE + CONF_SERCOM_5_I2CM_ENABLE + CONF_SERCOM_6_I2CM_ENABLE + CONF_SERCOM_7_I2CM_ENABLE)
+
+/**
+ * \brief Macro is used to fill i2cm configuration structure based on
+ * its number
+ *
+ * \param[in] n The number of structures
+ */
+#define I2CM_CONFIGURATION(n) \
+ { \
+ (n), \
+ (SERCOM_I2CM_CTRLA_MODE_I2C_MASTER) | (CONF_SERCOM_##n##_I2CM_RUNSTDBY << SERCOM_I2CM_CTRLA_RUNSTDBY_Pos) \
+ | (CONF_SERCOM_##n##_I2CM_SPEED << SERCOM_I2CM_CTRLA_SPEED_Pos) \
+ | (CONF_SERCOM_##n##_I2CM_MEXTTOEN << SERCOM_I2CM_CTRLA_MEXTTOEN_Pos) \
+ | (CONF_SERCOM_##n##_I2CM_SEXTTOEN << SERCOM_I2CM_CTRLA_SEXTTOEN_Pos) \
+ | (CONF_SERCOM_##n##_I2CM_INACTOUT << SERCOM_I2CM_CTRLA_INACTOUT_Pos) \
+ | (CONF_SERCOM_##n##_I2CM_LOWTOUT << SERCOM_I2CM_CTRLA_LOWTOUTEN_Pos) \
+ | (CONF_SERCOM_##n##_I2CM_SDAHOLD << SERCOM_I2CM_CTRLA_SDAHOLD_Pos), \
+ SERCOM_I2CM_CTRLB_SMEN, (uint32_t)(CONF_SERCOM_##n##_I2CM_BAUD_RATE), \
+ CONF_SERCOM_##n##_I2CM_DEBUG_STOP_MODE, CONF_SERCOM_##n##_I2CM_TRISE, CONF_GCLK_SERCOM##n##_CORE_FREQUENCY \
+ }
+
+#define ERROR_FLAG (1 << 7)
+#define SB_FLAG (1 << 1)
+#define MB_FLAG (1 << 0)
+
+#define CMD_STOP 0x3
+#define I2C_IDLE 0x1
+#define I2C_SM 0x0
+#define I2C_FM 0x1
+#define I2C_HS 0x2
+#define TEN_ADDR_FRAME 0x78
+#define TEN_ADDR_MASK 0x3ff
+#define SEVEN_ADDR_MASK 0x7f
+
+/**
+ * \brief SERCOM I2CM configuration type
+ */
+struct i2cm_configuration {
+ uint8_t number;
+ hri_sercomi2cm_ctrla_reg_t ctrl_a;
+ hri_sercomi2cm_ctrlb_reg_t ctrl_b;
+ hri_sercomi2cm_baud_reg_t baud;
+ hri_sercomi2cm_dbgctrl_reg_t dbgctrl;
+ uint16_t trise;
+ uint32_t clk; /* SERCOM peripheral clock frequency */
+};
+
+static inline int32_t _i2c_m_enable_implementation(void *hw);
+static int32_t _i2c_m_sync_init_impl(struct _i2c_m_service *const service, void *const hw);
+
+#if SERCOM_I2CM_AMOUNT < 1
+/** Dummy array to pass compiling. */
+static struct i2cm_configuration _i2cms[1] = {{0}};
+#else
+/**
+ * \brief Array of SERCOM I2CM configurations
+ */
+static struct i2cm_configuration _i2cms[] = {
+#if CONF_SERCOM_0_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(0),
+#endif
+#if CONF_SERCOM_1_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(1),
+#endif
+#if CONF_SERCOM_2_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(2),
+#endif
+#if CONF_SERCOM_3_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(3),
+#endif
+#if CONF_SERCOM_4_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(4),
+#endif
+#if CONF_SERCOM_5_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(5),
+#endif
+#if CONF_SERCOM_6_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(6),
+#endif
+#if CONF_SERCOM_7_I2CM_ENABLE == 1
+ I2CM_CONFIGURATION(7),
+#endif
+};
+#endif
+
+/**
+ * \internal Retrieve ordinal number of the given sercom hardware instance
+ *
+ * \param[in] hw The pointer to hardware instance
+
+ * \return The ordinal number of the given sercom hardware instance
+ */
+static int8_t _get_i2cm_index(const void *const hw)
+{
+ uint8_t sercom_offset = _sercom_get_hardware_index(hw);
+ uint8_t i;
+
+ for (i = 0; i < ARRAY_SIZE(_i2cms); i++) {
+ if (_i2cms[i].number == sercom_offset) {
+ return i;
+ }
+ }
+
+ ASSERT(false);
+ return -1;
+}
+
+static inline void _sercom_i2c_send_stop(void *const hw)
+{
+ hri_sercomi2cm_set_CTRLB_CMD_bf(hw, CMD_STOP);
+}
+
+/**
+ * \brief SERCOM I2CM analyze hardware status and transfer next byte
+ */
+static inline int32_t _sercom_i2c_sync_analyse_flags(void *const hw, uint32_t flags, struct _i2c_m_msg *const msg)
+{
+ int sclsm = hri_sercomi2cm_get_CTRLA_SCLSM_bit(hw);
+ uint16_t status = hri_sercomi2cm_read_STATUS_reg(hw);
+
+ if (flags & MB_FLAG) {
+ /* tx error */
+ if (status & SERCOM_I2CM_STATUS_ARBLOST) {
+ hri_sercomi2cm_clear_interrupt_MB_bit(hw);
+ msg->flags |= I2C_M_FAIL;
+ msg->flags &= ~I2C_M_BUSY;
+
+ if (status & SERCOM_I2CM_STATUS_BUSERR) {
+ return I2C_ERR_BUS;
+ }
+
+ return I2C_ERR_BAD_ADDRESS;
+ } else {
+ if (status & SERCOM_I2CM_STATUS_RXNACK) {
+
+ /* Slave rejects to receive more data */
+ if (msg->len > 0) {
+ msg->flags |= I2C_M_FAIL;
+ }
+
+ if (msg->flags & I2C_M_STOP) {
+ _sercom_i2c_send_stop(hw);
+ }
+
+ msg->flags &= ~I2C_M_BUSY;
+
+ return I2C_NACK;
+ }
+
+ if (msg->flags & I2C_M_TEN) {
+ hri_sercomi2cm_write_ADDR_reg(hw,
+ ((((msg->addr & TEN_ADDR_MASK) >> 8) | TEN_ADDR_FRAME) << 1) | I2C_M_RD
+ | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
+ msg->flags &= ~I2C_M_TEN;
+
+ return I2C_OK;
+ }
+
+ if (msg->len == 0) {
+ if (msg->flags & I2C_M_STOP) {
+ _sercom_i2c_send_stop(hw);
+ }
+
+ msg->flags &= ~I2C_M_BUSY;
+ } else {
+ hri_sercomi2cm_write_DATA_reg(hw, *msg->buffer);
+ msg->buffer++;
+ msg->len--;
+ }
+
+ return I2C_OK;
+ }
+ } else if (flags & SB_FLAG) {
+ if ((msg->len) && !(status & SERCOM_I2CM_STATUS_RXNACK)) {
+ msg->len--;
+
+ /* last byte, send nack */
+ if ((msg->len == 0 && !sclsm) || (msg->len == 1 && sclsm)) {
+ hri_sercomi2cm_set_CTRLB_ACKACT_bit(hw);
+ }
+
+ if (msg->len == 0) {
+ if (msg->flags & I2C_M_STOP) {
+ hri_sercomi2cm_clear_CTRLB_SMEN_bit(hw);
+ _sercom_i2c_send_stop(hw);
+ }
+
+ msg->flags &= ~I2C_M_BUSY;
+ }
+
+ /* Accessing DATA.DATA auto-triggers I2C bus operations.
+ * The operation performed depends on the state of
+ * CTRLB.ACKACT, CTRLB.SMEN
+ **/
+ *msg->buffer++ = hri_sercomi2cm_read_DATA_reg(hw);
+ } else {
+ hri_sercomi2cm_clear_interrupt_SB_bit(hw);
+ return I2C_NACK;
+ }
+
+ hri_sercomi2cm_clear_interrupt_SB_bit(hw);
+ }
+
+ return I2C_OK;
+}
+
+/**
+ * \brief Enable the i2c master module
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_async_enable(struct _i2c_m_async_device *const i2c_dev)
+{
+ ASSERT(i2c_dev);
+
+ return _i2c_m_enable_implementation(i2c_dev->hw);
+}
+
+/**
+ * \brief Disable the i2c master module
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_async_disable(struct _i2c_m_async_device *const i2c_dev)
+{
+ void *hw = i2c_dev->hw;
+
+ ASSERT(i2c_dev);
+ ASSERT(i2c_dev->hw);
+
+ NVIC_DisableIRQ((IRQn_Type)_sercom_get_irq_num(hw));
+ hri_sercomi2cm_clear_CTRLA_ENABLE_bit(hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Set baudrate of master
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ * \param[in] clkrate The clock rate of i2c master, in KHz
+ * \param[in] baudrate The baud rate desired for i2c master, in KHz
+ */
+int32_t _i2c_m_async_set_baudrate(struct _i2c_m_async_device *const i2c_dev, uint32_t clkrate, uint32_t baudrate)
+{
+ uint32_t tmp;
+ void * hw = i2c_dev->hw;
+
+ if (hri_sercomi2cm_get_CTRLA_ENABLE_bit(hw)) {
+ return ERR_DENIED;
+ }
+
+ tmp = _get_i2cm_index(hw);
+ clkrate = _i2cms[tmp].clk / 1000;
+
+ if (i2c_dev->service.mode == I2C_STANDARD_MODE) {
+ tmp = (uint32_t)((clkrate - 10 * baudrate - baudrate * clkrate * (i2c_dev->service.trise * 0.000000001))
+ / (2 * baudrate));
+ hri_sercomi2cm_write_BAUD_BAUD_bf(hw, tmp);
+ } else if (i2c_dev->service.mode == I2C_FASTMODE) {
+ tmp = (uint32_t)((clkrate - 10 * baudrate - baudrate * clkrate * (i2c_dev->service.trise * 0.000000001))
+ / (2 * baudrate));
+ hri_sercomi2cm_write_BAUD_BAUD_bf(hw, tmp);
+ } else if (i2c_dev->service.mode == I2C_HIGHSPEED_MODE) {
+ tmp = (clkrate - 2 * baudrate) / (2 * baudrate);
+ hri_sercomi2cm_write_BAUD_HSBAUD_bf(hw, tmp);
+ } else {
+ /* error baudrate */
+ return ERR_INVALID_ARG;
+ }
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Retrieve IRQ number for the given hardware instance
+ */
+static uint8_t _sercom_get_irq_num(const void *const hw)
+{
+ return SERCOM0_0_IRQn + (_sercom_get_hardware_index(hw) << 2);
+}
+
+/**
+ * \brief Initialize sercom i2c module to use in async mode
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_async_init(struct _i2c_m_async_device *const i2c_dev, void *const hw)
+{
+ int32_t init_status;
+
+ ASSERT(i2c_dev);
+
+ i2c_dev->hw = hw;
+
+ init_status = _i2c_m_sync_init_impl(&i2c_dev->service, hw);
+ if (init_status) {
+ return init_status;
+ }
+
+ _sercom_init_irq_param(hw, (void *)i2c_dev);
+ uint8_t irq = _sercom_get_irq_num(hw);
+ for (uint32_t i = 0; i < 4; i++) {
+ NVIC_DisableIRQ((IRQn_Type)irq);
+ NVIC_ClearPendingIRQ((IRQn_Type)irq);
+ NVIC_EnableIRQ((IRQn_Type)irq);
+ irq++;
+ }
+ return ERR_NONE;
+}
+
+/**
+ * \brief Deinitialize sercom i2c module
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_async_deinit(struct _i2c_m_async_device *const i2c_dev)
+{
+ ASSERT(i2c_dev);
+
+ hri_sercomi2cm_clear_CTRLA_ENABLE_bit(i2c_dev->hw);
+ hri_sercomi2cm_set_CTRLA_SWRST_bit(i2c_dev->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Transfer the slave address to bus, which will start the transfer
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+static int32_t _sercom_i2c_send_address(struct _i2c_m_async_device *const i2c_dev)
+{
+ void * hw = i2c_dev->hw;
+ struct _i2c_m_msg *msg = &i2c_dev->service.msg;
+ int sclsm = hri_sercomi2cm_get_CTRLA_SCLSM_bit(hw);
+
+ ASSERT(i2c_dev);
+
+ if (msg->len == 1 && sclsm) {
+ hri_sercomi2cm_set_CTRLB_ACKACT_bit(hw);
+ } else {
+ hri_sercomi2cm_clear_CTRLB_ACKACT_bit(hw);
+ }
+
+ /* ten bit address */
+ if (msg->addr & I2C_M_TEN) {
+ if (msg->flags & I2C_M_RD) {
+ msg->flags |= I2C_M_TEN;
+ }
+
+ hri_sercomi2cm_write_ADDR_reg(hw,
+ ((msg->addr & TEN_ADDR_MASK) << 1) | SERCOM_I2CM_ADDR_TENBITEN
+ | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
+ } else {
+ hri_sercomi2cm_write_ADDR_reg(hw,
+ ((msg->addr & SEVEN_ADDR_MASK) << 1) | (msg->flags & I2C_M_RD ? I2C_M_RD : 0x0)
+ | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
+ }
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Transfer data specified by msg
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ * \param[in] msg The pointer to i2c message
+ *
+ * \return Transfer status.
+ * \retval 0 Transfer success
+ * \retval <0 Transfer fail, return the error code
+ */
+int32_t _i2c_m_async_transfer(struct _i2c_m_async_device *i2c_dev, struct _i2c_m_msg *msg)
+{
+ int ret;
+
+ ASSERT(i2c_dev);
+ ASSERT(i2c_dev->hw);
+ ASSERT(msg);
+
+ if (msg->len == 0) {
+ return ERR_NONE;
+ }
+
+ if (i2c_dev->service.msg.flags & I2C_M_BUSY) {
+ return ERR_BUSY;
+ }
+
+ msg->flags |= I2C_M_BUSY;
+ i2c_dev->service.msg = *msg;
+ hri_sercomi2cm_set_CTRLB_SMEN_bit(i2c_dev->hw);
+
+ ret = _sercom_i2c_send_address(i2c_dev);
+
+ if (ret) {
+ i2c_dev->service.msg.flags &= ~I2C_M_BUSY;
+
+ return ret;
+ }
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Set callback to be called in interrupt handler
+ *
+ * \param[in] i2c_dev The pointer to master i2c device
+ * \param[in] type The callback type
+ * \param[in] func The callback function pointer
+ */
+int32_t _i2c_m_async_register_callback(struct _i2c_m_async_device *const i2c_dev, enum _i2c_m_async_callback_type type,
+ FUNC_PTR func)
+{
+ switch (type) {
+ case I2C_M_ASYNC_DEVICE_ERROR:
+ i2c_dev->cb.error = (_i2c_error_cb_t)func;
+ break;
+ case I2C_M_ASYNC_DEVICE_TX_COMPLETE:
+ i2c_dev->cb.tx_complete = (_i2c_complete_cb_t)func;
+ break;
+ case I2C_M_ASYNC_DEVICE_RX_COMPLETE:
+ i2c_dev->cb.rx_complete = (_i2c_complete_cb_t)func;
+ break;
+ default:
+ /* error */
+ break;
+ }
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Set stop condition on I2C
+ *
+ * \param i2c_dev Pointer to master i2c device
+ *
+ * \return Operation status
+ * \retval I2C_OK Operation was successfull
+ */
+int32_t _i2c_m_async_send_stop(struct _i2c_m_async_device *const i2c_dev)
+{
+ void *hw = i2c_dev->hw;
+
+ _sercom_i2c_send_stop(hw);
+
+ return I2C_OK;
+}
+
+/**
+ * \brief Get number of bytes left in transfer buffer
+ *
+ * \param i2c_dev Pointer to i2c master device
+ *
+ * \return Bytes left in buffer
+ * \retval =>0 Bytes left in buffer
+ */
+int32_t _i2c_m_async_get_bytes_left(struct _i2c_m_async_device *const i2c_dev)
+{
+ if (i2c_dev->service.msg.flags & I2C_M_BUSY) {
+ return i2c_dev->service.msg.len;
+ }
+
+ return 0;
+}
+
+/**
+ * \brief Initialize sercom i2c module to use in sync mode
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_sync_init(struct _i2c_m_sync_device *const i2c_dev, void *const hw)
+{
+ ASSERT(i2c_dev);
+
+ i2c_dev->hw = hw;
+
+ return _i2c_m_sync_init_impl(&i2c_dev->service, hw);
+}
+
+/**
+ * \brief Deinitialize sercom i2c module
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_sync_deinit(struct _i2c_m_sync_device *const i2c_dev)
+{
+ ASSERT(i2c_dev);
+
+ hri_sercomi2cm_clear_CTRLA_ENABLE_bit(i2c_dev->hw);
+ hri_sercomi2cm_set_CTRLA_SWRST_bit(i2c_dev->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Enable the i2c master module
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_sync_enable(struct _i2c_m_sync_device *const i2c_dev)
+{
+ ASSERT(i2c_dev);
+
+ return _i2c_m_enable_implementation(i2c_dev->hw);
+}
+
+/**
+ * \brief Disable the i2c master module
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+int32_t _i2c_m_sync_disable(struct _i2c_m_sync_device *const i2c_dev)
+{
+ void *hw = i2c_dev->hw;
+
+ ASSERT(i2c_dev);
+ ASSERT(i2c_dev->hw);
+
+ hri_sercomi2cm_clear_CTRLA_ENABLE_bit(hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Set baudrate of master
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ * \param[in] clkrate The clock rate of i2c master, in KHz
+ * \param[in] baudrate The baud rate desired for i2c master, in KHz
+ */
+int32_t _i2c_m_sync_set_baudrate(struct _i2c_m_sync_device *const i2c_dev, uint32_t clkrate, uint32_t baudrate)
+{
+ uint32_t tmp;
+ void * hw = i2c_dev->hw;
+
+ if (hri_sercomi2cm_get_CTRLA_ENABLE_bit(hw)) {
+ return ERR_DENIED;
+ }
+
+ tmp = _get_i2cm_index(hw);
+ clkrate = _i2cms[tmp].clk / 1000;
+
+ if (i2c_dev->service.mode == I2C_STANDARD_MODE) {
+ tmp = (uint32_t)((clkrate - 10 * baudrate - baudrate * clkrate * (i2c_dev->service.trise * 0.000000001))
+ / (2 * baudrate));
+ hri_sercomi2cm_write_BAUD_BAUD_bf(hw, tmp);
+ } else if (i2c_dev->service.mode == I2C_FASTMODE) {
+ tmp = (uint32_t)((clkrate - 10 * baudrate - baudrate * clkrate * (i2c_dev->service.trise * 0.000000001))
+ / (2 * baudrate));
+ hri_sercomi2cm_write_BAUD_BAUD_bf(hw, tmp);
+ } else if (i2c_dev->service.mode == I2C_HIGHSPEED_MODE) {
+ tmp = (clkrate - 2 * baudrate) / (2 * baudrate);
+ hri_sercomi2cm_write_BAUD_HSBAUD_bf(hw, tmp);
+ } else {
+ /* error baudrate */
+ return ERR_INVALID_ARG;
+ }
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Enable/disable I2C master interrupt
+ */
+void _i2c_m_async_set_irq_state(struct _i2c_m_async_device *const device, const enum _i2c_m_async_callback_type type,
+ const bool state)
+{
+ if (I2C_M_ASYNC_DEVICE_TX_COMPLETE == type || I2C_M_ASYNC_DEVICE_RX_COMPLETE == type) {
+ hri_sercomi2cm_write_INTEN_SB_bit(device->hw, state);
+ hri_sercomi2cm_write_INTEN_MB_bit(device->hw, state);
+ } else if (I2C_M_ASYNC_DEVICE_ERROR == type) {
+ hri_sercomi2cm_write_INTEN_ERROR_bit(device->hw, state);
+ }
+}
+
+/**
+ * \brief Wait for bus response
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ * \param[in] flags Store the hardware response
+ *
+ * \return Bus response status.
+ * \retval 0 Bus response status OK
+ * \retval <0 Bus response fail
+ */
+inline static int32_t _sercom_i2c_sync_wait_bus(struct _i2c_m_sync_device *const i2c_dev, uint32_t *flags)
+{
+ uint32_t timeout = 65535;
+ void * hw = i2c_dev->hw;
+
+ do {
+ *flags = hri_sercomi2cm_read_INTFLAG_reg(hw);
+
+ if (timeout-- == 0) {
+ return I2C_ERR_BUS;
+ }
+ } while (!(*flags & MB_FLAG) && !(*flags & SB_FLAG));
+
+ return I2C_OK;
+}
+
+/**
+ * \brief Send the slave address to bus, which will start the transfer
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ */
+static int32_t _sercom_i2c_sync_send_address(struct _i2c_m_sync_device *const i2c_dev)
+{
+ void * hw = i2c_dev->hw;
+ struct _i2c_m_msg *msg = &i2c_dev->service.msg;
+ int sclsm = hri_sercomi2cm_get_CTRLA_SCLSM_bit(hw);
+ uint32_t flags;
+
+ ASSERT(i2c_dev);
+
+ if (msg->len == 1 && sclsm) {
+ hri_sercomi2cm_set_CTRLB_ACKACT_bit(hw);
+ } else {
+ hri_sercomi2cm_clear_CTRLB_ACKACT_bit(hw);
+ }
+
+ /* ten bit address */
+ if (msg->addr & I2C_M_TEN) {
+ if (msg->flags & I2C_M_RD) {
+ msg->flags |= I2C_M_TEN;
+ }
+
+ hri_sercomi2cm_write_ADDR_reg(hw,
+ ((msg->addr & TEN_ADDR_MASK) << 1) | SERCOM_I2CM_ADDR_TENBITEN
+ | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
+ } else {
+ hri_sercomi2cm_write_ADDR_reg(hw,
+ ((msg->addr & SEVEN_ADDR_MASK) << 1) | (msg->flags & I2C_M_RD ? I2C_M_RD : 0x0)
+ | (hri_sercomi2cm_read_ADDR_reg(hw) & SERCOM_I2CM_ADDR_HS));
+ }
+
+ _sercom_i2c_sync_wait_bus(i2c_dev, &flags);
+ return _sercom_i2c_sync_analyse_flags(hw, flags, msg);
+}
+
+/**
+ * \brief Transfer data specified by msg
+ *
+ * \param[in] i2c_dev The pointer to i2c device
+ * \param[in] msg The pointer to i2c message
+ *
+ * \return Transfer status.
+ * \retval 0 Transfer success
+ * \retval <0 Transfer fail or partial fail, return the error code
+ */
+int32_t _i2c_m_sync_transfer(struct _i2c_m_sync_device *const i2c_dev, struct _i2c_m_msg *msg)
+{
+ uint32_t flags;
+ int ret;
+ void * hw = i2c_dev->hw;
+
+ ASSERT(i2c_dev);
+ ASSERT(i2c_dev->hw);
+ ASSERT(msg);
+
+ if (i2c_dev->service.msg.flags & I2C_M_BUSY) {
+ return I2C_ERR_BUSY;
+ }
+
+ msg->flags |= I2C_M_BUSY;
+ i2c_dev->service.msg = *msg;
+ hri_sercomi2cm_set_CTRLB_SMEN_bit(hw);
+
+ ret = _sercom_i2c_sync_send_address(i2c_dev);
+
+ if (ret) {
+ i2c_dev->service.msg.flags &= ~I2C_M_BUSY;
+
+ return ret;
+ }
+
+ while (i2c_dev->service.msg.flags & I2C_M_BUSY) {
+ ret = _sercom_i2c_sync_wait_bus(i2c_dev, &flags);
+
+ if (ret) {
+ if (msg->flags & I2C_M_STOP) {
+ _sercom_i2c_send_stop(hw);
+ }
+
+ i2c_dev->service.msg.flags &= ~I2C_M_BUSY;
+
+ return ret;
+ }
+
+ ret = _sercom_i2c_sync_analyse_flags(hw, flags, &i2c_dev->service.msg);
+ }
+
+ return ret;
+}
+
+int32_t _i2c_m_sync_send_stop(struct _i2c_m_sync_device *const i2c_dev)
+{
+ void *hw = i2c_dev->hw;
+
+ _sercom_i2c_send_stop(hw);
+
+ return I2C_OK;
+}
+
+static inline int32_t _i2c_m_enable_implementation(void *const hw)
+{
+ int timeout = 65535;
+ int timeout_attempt = 4;
+
+ ASSERT(hw);
+
+ /* Enable interrupts */
+ hri_sercomi2cm_set_CTRLA_ENABLE_bit(hw);
+
+ while (hri_sercomi2cm_read_STATUS_BUSSTATE_bf(hw) != I2C_IDLE) {
+ timeout--;
+
+ if (timeout <= 0) {
+ if (--timeout_attempt)
+ timeout = 65535;
+ else
+ return I2C_ERR_BUSY;
+ hri_sercomi2cm_clear_STATUS_reg(hw, SERCOM_I2CM_STATUS_BUSSTATE(I2C_IDLE));
+ }
+ }
+ return ERR_NONE;
+}
+
+static int32_t _i2c_m_sync_init_impl(struct _i2c_m_service *const service, void *const hw)
+{
+ uint8_t i = _get_i2cm_index(hw);
+
+ if (!hri_sercomi2cm_is_syncing(hw, SERCOM_I2CM_SYNCBUSY_SWRST)) {
+ uint32_t mode = _i2cms[i].ctrl_a & SERCOM_I2CM_CTRLA_MODE_Msk;
+ if (hri_sercomi2cm_get_CTRLA_reg(hw, SERCOM_I2CM_CTRLA_ENABLE)) {
+ hri_sercomi2cm_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomi2cm_wait_for_sync(hw, SERCOM_I2CM_SYNCBUSY_ENABLE);
+ }
+ hri_sercomi2cm_write_CTRLA_reg(hw, SERCOM_I2CM_CTRLA_SWRST | mode);
+ }
+ hri_sercomi2cm_wait_for_sync(hw, SERCOM_I2CM_SYNCBUSY_SWRST);
+
+ hri_sercomi2cm_write_CTRLA_reg(hw, _i2cms[i].ctrl_a);
+ hri_sercomi2cm_write_CTRLB_reg(hw, _i2cms[i].ctrl_b);
+ hri_sercomi2cm_write_BAUD_reg(hw, _i2cms[i].baud);
+
+ service->mode = (_i2cms[i].ctrl_a & SERCOM_I2CM_CTRLA_SPEED_Msk) >> SERCOM_I2CM_CTRLA_SPEED_Pos;
+ hri_sercomi2cm_write_ADDR_HS_bit(hw, service->mode < I2C_HS ? 0 : 1);
+
+ service->trise = _i2cms[i].trise;
+
+ return ERR_NONE;
+}
+
+ /* SERCOM I2C slave */
+
+#ifndef CONF_SERCOM_0_I2CS_ENABLE
+#define CONF_SERCOM_0_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_1_I2CS_ENABLE
+#define CONF_SERCOM_1_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_2_I2CS_ENABLE
+#define CONF_SERCOM_2_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_3_I2CS_ENABLE
+#define CONF_SERCOM_3_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_4_I2CS_ENABLE
+#define CONF_SERCOM_4_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_5_I2CS_ENABLE
+#define CONF_SERCOM_5_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_6_I2CS_ENABLE
+#define CONF_SERCOM_6_I2CS_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_7_I2CS_ENABLE
+#define CONF_SERCOM_7_I2CS_ENABLE 0
+#endif
+
+/** Amount of SERCOM that is used as I2C Slave. */
+#define SERCOM_I2CS_AMOUNT \
+ (CONF_SERCOM_0_I2CS_ENABLE + CONF_SERCOM_1_I2CS_ENABLE + CONF_SERCOM_2_I2CS_ENABLE + CONF_SERCOM_3_I2CS_ENABLE \
+ + CONF_SERCOM_4_I2CS_ENABLE + CONF_SERCOM_5_I2CS_ENABLE + CONF_SERCOM_6_I2CS_ENABLE + CONF_SERCOM_7_I2CS_ENABLE)
+
+/**
+ * \brief Macro is used to fill I2C slave configuration structure based on
+ * its number
+ *
+ * \param[in] n The number of structures
+ */
+#define I2CS_CONFIGURATION(n) \
+ { \
+ n, \
+ SERCOM_I2CM_CTRLA_MODE_I2C_SLAVE | (CONF_SERCOM_##n##_I2CS_RUNSTDBY << SERCOM_I2CS_CTRLA_RUNSTDBY_Pos) \
+ | SERCOM_I2CS_CTRLA_SDAHOLD(CONF_SERCOM_##n##_I2CS_SDAHOLD) \
+ | (CONF_SERCOM_##n##_I2CS_SEXTTOEN << SERCOM_I2CS_CTRLA_SEXTTOEN_Pos) \
+ | (CONF_SERCOM_##n##_I2CS_SPEED << SERCOM_I2CS_CTRLA_SPEED_Pos) \
+ | (CONF_SERCOM_##n##_I2CS_SCLSM << SERCOM_I2CS_CTRLA_SCLSM_Pos) \
+ | (CONF_SERCOM_##n##_I2CS_LOWTOUT << SERCOM_I2CS_CTRLA_LOWTOUTEN_Pos), \
+ SERCOM_I2CS_CTRLB_SMEN | SERCOM_I2CS_CTRLB_AACKEN | SERCOM_I2CS_CTRLB_AMODE(CONF_SERCOM_##n##_I2CS_AMODE), \
+ (CONF_SERCOM_##n##_I2CS_GENCEN << SERCOM_I2CS_ADDR_GENCEN_Pos) \
+ | SERCOM_I2CS_ADDR_ADDR(CONF_SERCOM_##n##_I2CS_ADDRESS) \
+ | (CONF_SERCOM_##n##_I2CS_TENBITEN << SERCOM_I2CS_ADDR_TENBITEN_Pos) \
+ | SERCOM_I2CS_ADDR_ADDRMASK(CONF_SERCOM_##n##_I2CS_ADDRESS_MASK) \
+ }
+
+/**
+ * \brief Macro to check 10-bit addressing
+ */
+#define I2CS_7BIT_ADDRESSING_MASK 0x7F
+
+static int32_t _i2c_s_init(void *const hw);
+static int8_t _get_i2c_s_index(const void *const hw);
+static inline void _i2c_s_deinit(void *const hw);
+static int32_t _i2c_s_set_address(void *const hw, const uint16_t address);
+
+/**
+ * \brief SERCOM I2C slave configuration type
+ */
+struct i2cs_configuration {
+ uint8_t number;
+ hri_sercomi2cs_ctrla_reg_t ctrl_a;
+ hri_sercomi2cs_ctrlb_reg_t ctrl_b;
+ hri_sercomi2cs_addr_reg_t address;
+};
+
+#if SERCOM_I2CS_AMOUNT < 1
+/** Dummy array for compiling. */
+static struct i2cs_configuration _i2css[1] = {{0}};
+#else
+/**
+ * \brief Array of SERCOM I2C slave configurations
+ */
+static struct i2cs_configuration _i2css[] = {
+#if CONF_SERCOM_0_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(0),
+#endif
+#if CONF_SERCOM_1_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(1),
+#endif
+#if CONF_SERCOM_2_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(2),
+#endif
+#if CONF_SERCOM_3_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(3),
+#endif
+#if CONF_SERCOM_4_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(4),
+#endif
+#if CONF_SERCOM_5_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(5),
+#endif
+#if CONF_SERCOM_6_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(6),
+#endif
+#if CONF_SERCOM_7_I2CS_ENABLE == 1
+ I2CS_CONFIGURATION(7),
+#endif
+};
+#endif
+
+/**
+ * \brief Initialize synchronous I2C slave
+ */
+int32_t _i2c_s_sync_init(struct _i2c_s_sync_device *const device, void *const hw)
+{
+ int32_t status;
+
+ ASSERT(device);
+
+ status = _i2c_s_init(hw);
+ if (status) {
+ return status;
+ }
+ device->hw = hw;
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Initialize asynchronous I2C slave
+ */
+int32_t _i2c_s_async_init(struct _i2c_s_async_device *const device, void *const hw)
+{
+ int32_t init_status;
+
+ ASSERT(device);
+
+ init_status = _i2c_s_init(hw);
+ if (init_status) {
+ return init_status;
+ }
+
+ device->hw = hw;
+ _sercom_init_irq_param(hw, (void *)device);
+ uint8_t irq = _sercom_get_irq_num(hw);
+ for (uint32_t i = 0; i < 4; i++) {
+ NVIC_DisableIRQ((IRQn_Type)irq);
+ NVIC_ClearPendingIRQ((IRQn_Type)irq);
+ NVIC_EnableIRQ((IRQn_Type)irq);
+ irq++;
+ }
+ // Enable Address Match and PREC interrupt by default.
+ hri_sercomi2cs_set_INTEN_AMATCH_bit(hw);
+ hri_sercomi2cs_set_INTEN_PREC_bit(hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Deinitialize synchronous I2C
+ */
+int32_t _i2c_s_sync_deinit(struct _i2c_s_sync_device *const device)
+{
+ _i2c_s_deinit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Deinitialize asynchronous I2C
+ */
+int32_t _i2c_s_async_deinit(struct _i2c_s_async_device *const device)
+{
+ NVIC_DisableIRQ((IRQn_Type)_sercom_get_irq_num(device->hw));
+ _i2c_s_deinit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Enable I2C module
+ */
+int32_t _i2c_s_sync_enable(struct _i2c_s_sync_device *const device)
+{
+ hri_sercomi2cs_set_CTRLA_ENABLE_bit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Enable I2C module
+ */
+int32_t _i2c_s_async_enable(struct _i2c_s_async_device *const device)
+{
+ hri_sercomi2cs_set_CTRLA_ENABLE_bit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Disable I2C module
+ */
+int32_t _i2c_s_sync_disable(struct _i2c_s_sync_device *const device)
+{
+ hri_sercomi2cs_clear_CTRLA_ENABLE_bit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Disable I2C module
+ */
+int32_t _i2c_s_async_disable(struct _i2c_s_async_device *const device)
+{
+ hri_sercomi2cs_clear_CTRLA_ENABLE_bit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Check if 10-bit addressing mode is on
+ */
+int32_t _i2c_s_sync_is_10bit_addressing_on(const struct _i2c_s_sync_device *const device)
+{
+ return hri_sercomi2cs_get_ADDR_TENBITEN_bit(device->hw);
+}
+
+/**
+ * \brief Check if 10-bit addressing mode is on
+ */
+int32_t _i2c_s_async_is_10bit_addressing_on(const struct _i2c_s_async_device *const device)
+{
+ return hri_sercomi2cs_get_ADDR_TENBITEN_bit(device->hw);
+}
+
+/**
+ * \brief Set I2C slave address
+ */
+int32_t _i2c_s_sync_set_address(struct _i2c_s_sync_device *const device, const uint16_t address)
+{
+ return _i2c_s_set_address(device->hw, address);
+}
+
+/**
+ * \brief Set I2C slave address
+ */
+int32_t _i2c_s_async_set_address(struct _i2c_s_async_device *const device, const uint16_t address)
+{
+ return _i2c_s_set_address(device->hw, address);
+}
+
+/**
+ * \brief Write a byte to the given I2C instance
+ */
+void _i2c_s_sync_write_byte(struct _i2c_s_sync_device *const device, const uint8_t data)
+{
+ hri_sercomi2cs_write_DATA_reg(device->hw, data);
+}
+
+/**
+ * \brief Write a byte to the given I2C instance
+ */
+void _i2c_s_async_write_byte(struct _i2c_s_async_device *const device, const uint8_t data)
+{
+ hri_sercomi2cs_write_DATA_reg(device->hw, data);
+}
+
+/**
+ * \brief Read a byte from the given I2C instance
+ */
+uint8_t _i2c_s_sync_read_byte(const struct _i2c_s_sync_device *const device)
+{
+ return hri_sercomi2cs_read_DATA_reg(device->hw);
+}
+
+/**
+ * \brief Check if I2C is ready to send next byt
+ */
+bool _i2c_s_sync_is_byte_sent(const struct _i2c_s_sync_device *const device)
+{
+ return hri_sercomi2cs_get_interrupt_DRDY_bit(device->hw);
+}
+
+/**
+ * \brief Check if there is data received by I2C
+ */
+bool _i2c_s_sync_is_byte_received(const struct _i2c_s_sync_device *const device)
+{
+ return hri_sercomi2cs_get_interrupt_DRDY_bit(device->hw);
+}
+
+/**
+ * \brief Retrieve I2C slave status
+ */
+i2c_s_status_t _i2c_s_sync_get_status(const struct _i2c_s_sync_device *const device)
+{
+ return hri_sercomi2cs_read_STATUS_reg(device->hw);
+}
+
+/**
+ * \brief Clear the Data Ready interrupt flag
+ */
+int32_t _i2c_s_sync_clear_data_ready_flag(const struct _i2c_s_sync_device *const device)
+{
+ hri_sercomi2cs_clear_INTFLAG_DRDY_bit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Retrieve I2C slave status
+ */
+i2c_s_status_t _i2c_s_async_get_status(const struct _i2c_s_async_device *const device)
+{
+ return hri_sercomi2cs_read_STATUS_reg(device->hw);
+}
+
+/**
+ * \brief Abort data transmission
+ */
+int32_t _i2c_s_async_abort_transmission(const struct _i2c_s_async_device *const device)
+{
+ hri_sercomi2cs_clear_INTEN_DRDY_bit(device->hw);
+
+ return ERR_NONE;
+}
+
+/**
+ * \brief Enable/disable I2C slave interrupt
+ */
+int32_t _i2c_s_async_set_irq_state(struct _i2c_s_async_device *const device, const enum _i2c_s_async_callback_type type,
+ const bool state)
+{
+ ASSERT(device);
+
+ if (I2C_S_DEVICE_TX == type || I2C_S_DEVICE_RX_COMPLETE == type) {
+ hri_sercomi2cs_write_INTEN_DRDY_bit(device->hw, state);
+ } else if (I2C_S_DEVICE_ERROR == type) {
+ hri_sercomi2cs_write_INTEN_ERROR_bit(device->hw, state);
+ }
+
+ return ERR_NONE;
+}
+
+/**
+ * \internal Initalize i2c slave hardware
+ *
+ * \param[in] p The pointer to hardware instance
+ *
+ *\ return status of initialization
+ */
+static int32_t _i2c_s_init(void *const hw)
+{
+ int8_t i = _get_i2c_s_index(hw);
+ if (i == -1) {
+ return ERR_INVALID_ARG;
+ }
+
+ if (!hri_sercomi2cs_is_syncing(hw, SERCOM_I2CS_CTRLA_SWRST)) {
+ uint32_t mode = _i2css[i].ctrl_a & SERCOM_I2CS_CTRLA_MODE_Msk;
+ if (hri_sercomi2cs_get_CTRLA_reg(hw, SERCOM_I2CS_CTRLA_ENABLE)) {
+ hri_sercomi2cs_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomi2cs_wait_for_sync(hw, SERCOM_I2CS_SYNCBUSY_ENABLE);
+ }
+ hri_sercomi2cs_write_CTRLA_reg(hw, SERCOM_I2CS_CTRLA_SWRST | mode);
+ }
+ hri_sercomi2cs_wait_for_sync(hw, SERCOM_I2CS_SYNCBUSY_SWRST);
+
+ hri_sercomi2cs_write_CTRLA_reg(hw, _i2css[i].ctrl_a);
+ hri_sercomi2cs_write_CTRLB_reg(hw, _i2css[i].ctrl_b);
+ hri_sercomi2cs_write_ADDR_reg(hw, _i2css[i].address);
+
+ return ERR_NONE;
+}
+
+/**
+ * \internal Retrieve ordinal number of the given sercom hardware instance
+ *
+ * \param[in] hw The pointer to hardware instance
+ *
+ * \return The ordinal number of the given sercom hardware instance
+ */
+static int8_t _get_i2c_s_index(const void *const hw)
+{
+ uint8_t sercom_offset = _sercom_get_hardware_index(hw);
+ uint8_t i;
+
+ for (i = 0; i < ARRAY_SIZE(_i2css); i++) {
+ if (_i2css[i].number == sercom_offset) {
+ return i;
+ }
+ }
+
+ ASSERT(false);
+ return -1;
+}
+
+/**
+ * \internal De-initialize i2c slave
+ *
+ * \param[in] hw The pointer to hardware instance
+ */
+static inline void _i2c_s_deinit(void *const hw)
+{
+ hri_sercomi2cs_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomi2cs_set_CTRLA_SWRST_bit(hw);
+}
+
+/**
+ * \internal De-initialize i2c slave
+ *
+ * \param[in] hw The pointer to hardware instance
+ * \param[in] address Address to set
+ */
+static int32_t _i2c_s_set_address(void *const hw, const uint16_t address)
+{
+ bool enabled;
+
+ enabled = hri_sercomi2cs_get_CTRLA_ENABLE_bit(hw);
+
+ CRITICAL_SECTION_ENTER()
+ hri_sercomi2cs_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomi2cs_write_ADDR_ADDR_bf(hw, address);
+ CRITICAL_SECTION_LEAVE()
+
+ if (enabled) {
+ hri_sercomi2cs_set_CTRLA_ENABLE_bit(hw);
+ }
+
+ return ERR_NONE;
+}
+
+ /* Sercom SPI implementation */
+
+#ifndef SERCOM_USART_CTRLA_MODE_SPI_SLAVE
+#define SERCOM_USART_CTRLA_MODE_SPI_SLAVE (2 << 2)
+#endif
+
+#define SPI_DEV_IRQ_MODE 0x8000
+
+#define _SPI_CS_PORT_EXTRACT(cs) (((cs) >> 0) & 0xFF)
+#define _SPI_CS_PIN_EXTRACT(cs) (((cs) >> 8) & 0xFF)
+
+COMPILER_PACK_SET(1)
+/** Initialization configuration of registers. */
+struct sercomspi_regs_cfg {
+ uint32_t ctrla;
+ uint32_t ctrlb;
+ uint32_t addr;
+ uint8_t baud;
+ uint8_t dbgctrl;
+ uint16_t dummy_byte;
+ uint8_t n;
+};
+COMPILER_PACK_RESET()
+
+/** Build configuration from header macros. */
+#define SERCOMSPI_REGS(n) \
+ { \
+ (((CONF_SERCOM_##n##_SPI_DORD) << SERCOM_SPI_CTRLA_DORD_Pos) \
+ | (CONF_SERCOM_##n##_SPI_CPOL << SERCOM_SPI_CTRLA_CPOL_Pos) \
+ | (CONF_SERCOM_##n##_SPI_CPHA << SERCOM_SPI_CTRLA_CPHA_Pos) \
+ | (CONF_SERCOM_##n##_SPI_AMODE_EN ? SERCOM_SPI_CTRLA_FORM(2) : SERCOM_SPI_CTRLA_FORM(0)) \
+ | SERCOM_SPI_CTRLA_DOPO(CONF_SERCOM_##n##_SPI_TXPO) | SERCOM_SPI_CTRLA_DIPO(CONF_SERCOM_##n##_SPI_RXPO) \
+ | (CONF_SERCOM_##n##_SPI_IBON << SERCOM_SPI_CTRLA_IBON_Pos) \
+ | (CONF_SERCOM_##n##_SPI_RUNSTDBY << SERCOM_SPI_CTRLA_RUNSTDBY_Pos) \
+ | SERCOM_SPI_CTRLA_MODE(CONF_SERCOM_##n##_SPI_MODE)), /* ctrla */ \
+ ((CONF_SERCOM_##n##_SPI_RXEN << SERCOM_SPI_CTRLB_RXEN_Pos) \
+ | (CONF_SERCOM_##n##_SPI_MSSEN << SERCOM_SPI_CTRLB_MSSEN_Pos) \
+ | (CONF_SERCOM_##n##_SPI_SSDE << SERCOM_SPI_CTRLB_SSDE_Pos) \
+ | (CONF_SERCOM_##n##_SPI_PLOADEN << SERCOM_SPI_CTRLB_PLOADEN_Pos) \
+ | SERCOM_SPI_CTRLB_AMODE(CONF_SERCOM_##n##_SPI_AMODE) \
+ | SERCOM_SPI_CTRLB_CHSIZE(CONF_SERCOM_##n##_SPI_CHSIZE)), /* ctrlb */ \
+ (SERCOM_SPI_ADDR_ADDR(CONF_SERCOM_##n##_SPI_ADDR) \
+ | SERCOM_SPI_ADDR_ADDRMASK(CONF_SERCOM_##n##_SPI_ADDRMASK)), /* addr */ \
+ ((uint8_t)CONF_SERCOM_##n##_SPI_BAUD_RATE), /* baud */ \
+ (CONF_SERCOM_##n##_SPI_DBGSTOP << SERCOM_SPI_DBGCTRL_DBGSTOP_Pos), /* dbgctrl */ \
+ CONF_SERCOM_##n##_SPI_DUMMYBYTE, /* Dummy byte for SPI master mode */ \
+ n /* sercom number */ \
+ }
+
+#ifndef CONF_SERCOM_0_SPI_ENABLE
+#define CONF_SERCOM_0_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_1_SPI_ENABLE
+#define CONF_SERCOM_1_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_2_SPI_ENABLE
+#define CONF_SERCOM_2_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_3_SPI_ENABLE
+#define CONF_SERCOM_3_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_4_SPI_ENABLE
+#define CONF_SERCOM_4_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_5_SPI_ENABLE
+#define CONF_SERCOM_5_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_6_SPI_ENABLE
+#define CONF_SERCOM_6_SPI_ENABLE 0
+#endif
+#ifndef CONF_SERCOM_7_SPI_ENABLE
+#define CONF_SERCOM_7_SPI_ENABLE 0
+#endif
+
+/** Amount of SERCOM that is used as SPI */
+#define SERCOM_SPI_AMOUNT \
+ (CONF_SERCOM_0_SPI_ENABLE + CONF_SERCOM_1_SPI_ENABLE + CONF_SERCOM_2_SPI_ENABLE + CONF_SERCOM_3_SPI_ENABLE \
+ + CONF_SERCOM_4_SPI_ENABLE + CONF_SERCOM_5_SPI_ENABLE + CONF_SERCOM_6_SPI_ENABLE + CONF_SERCOM_7_SPI_ENABLE)
+
+#if SERCOM_SPI_AMOUNT < 1
+/** Dummy array for compiling. */
+static const struct sercomspi_regs_cfg sercomspi_regs[1] = {{0}};
+#else
+/** The SERCOM SPI configurations of SERCOM that is used as SPI. */
+static const struct sercomspi_regs_cfg sercomspi_regs[] = {
+#if CONF_SERCOM_0_SPI_ENABLE
+ SERCOMSPI_REGS(0),
+#endif
+#if CONF_SERCOM_1_SPI_ENABLE
+ SERCOMSPI_REGS(1),
+#endif
+#if CONF_SERCOM_2_SPI_ENABLE
+ SERCOMSPI_REGS(2),
+#endif
+#if CONF_SERCOM_3_SPI_ENABLE
+ SERCOMSPI_REGS(3),
+#endif
+#if CONF_SERCOM_4_SPI_ENABLE
+ SERCOMSPI_REGS(4),
+#endif
+#if CONF_SERCOM_5_SPI_ENABLE
+ SERCOMSPI_REGS(5),
+#endif
+#if CONF_SERCOM_6_SPI_ENABLE
+ SERCOMSPI_REGS(6),
+#endif
+#if CONF_SERCOM_7_SPI_ENABLE
+ SERCOMSPI_REGS(7),
+#endif
+};
+#endif
+
+/** \internal De-initialize SERCOM SPI
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ *
+ * \return De-initialization status
+ */
+static int32_t _spi_deinit(void *const hw)
+{
+ hri_sercomspi_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomspi_set_CTRLA_SWRST_bit(hw);
+
+ return ERR_NONE;
+}
+
+/** \internal Enable SERCOM SPI
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ *
+ * \return Enabling status
+ */
+static int32_t _spi_sync_enable(void *const hw)
+{
+ if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
+ return ERR_BUSY;
+ }
+
+ hri_sercomspi_set_CTRLA_ENABLE_bit(hw);
+
+ return ERR_NONE;
+}
+
+/** \internal Enable SERCOM SPI
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ *
+ * \return Enabling status
+ */
+static int32_t _spi_async_enable(void *const hw)
+{
+ _spi_sync_enable(hw);
+ uint8_t irq = _sercom_get_irq_num(hw);
+ for (uint32_t i = 0; i < 4; i++) {
+ NVIC_EnableIRQ((IRQn_Type)irq++);
+ }
+
+ return ERR_NONE;
+}
+
+/** \internal Disable SERCOM SPI
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ *
+ * \return Disabling status
+ */
+static int32_t _spi_sync_disable(void *const hw)
+{
+ if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
+ return ERR_BUSY;
+ }
+ hri_sercomspi_clear_CTRLA_ENABLE_bit(hw);
+
+ return ERR_NONE;
+}
+
+/** \internal Disable SERCOM SPI
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ *
+ * \return Disabling status
+ */
+static int32_t _spi_async_disable(void *const hw)
+{
+ _spi_sync_disable(hw);
+ hri_sercomspi_clear_INTEN_reg(
+ hw, SERCOM_SPI_INTFLAG_ERROR | SERCOM_SPI_INTFLAG_RXC | SERCOM_SPI_INTFLAG_TXC | SERCOM_SPI_INTFLAG_DRE);
+ uint8_t irq = _sercom_get_irq_num(hw);
+ for (uint32_t i = 0; i < 4; i++) {
+ NVIC_DisableIRQ((IRQn_Type)irq++);
+ }
+
+ return ERR_NONE;
+}
+
+/** \internal Set SERCOM SPI mode
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ * \param[in] mode The mode to set
+ *
+ * \return Setting mode status
+ */
+static int32_t _spi_set_mode(void *const hw, const enum spi_transfer_mode mode)
+{
+ uint32_t ctrla;
+
+ if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST | SERCOM_SPI_SYNCBUSY_ENABLE)) {
+ return ERR_BUSY;
+ }
+
+ ctrla = hri_sercomspi_read_CTRLA_reg(hw);
+ ctrla &= ~(SERCOM_SPI_CTRLA_CPOL | SERCOM_SPI_CTRLA_CPHA);
+ ctrla |= (mode & 0x3u) << SERCOM_SPI_CTRLA_CPHA_Pos;
+ hri_sercomspi_write_CTRLA_reg(hw, ctrla);
+
+ return ERR_NONE;
+}
+
+/** \internal Set SERCOM SPI baudrate
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ * \param[in] baud_val The baudrate to set
+ *
+ * \return Setting baudrate status
+ */
+static int32_t _spi_set_baudrate(void *const hw, const uint32_t baud_val)
+{
+ if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
+ return ERR_BUSY;
+ }
+
+ hri_sercomspi_write_BAUD_reg(hw, baud_val);
+
+ return ERR_NONE;
+}
+
+/** \internal Set SERCOM SPI char size
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ * \param[in] baud_val The baudrate to set
+ * \param[out] size Stored char size
+ *
+ * \return Setting char size status
+ */
+static int32_t _spi_set_char_size(void *const hw, const enum spi_char_size char_size, uint8_t *const size)
+{
+ /* Only 8-bit or 9-bit accepted */
+ if (!(char_size == SPI_CHAR_SIZE_8 || char_size == SPI_CHAR_SIZE_9)) {
+ return ERR_INVALID_ARG;
+ }
+
+ if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST | SERCOM_SPI_SYNCBUSY_CTRLB)) {
+ return ERR_BUSY;
+ }
+
+ hri_sercomspi_write_CTRLB_CHSIZE_bf(hw, char_size);
+ *size = (char_size == SPI_CHAR_SIZE_8) ? 1 : 2;
+
+ return ERR_NONE;
+}
+
+/** \internal Set SERCOM SPI data order
+ *
+ * \param[in] hw Pointer to the hardware register base.
+ * \param[in] baud_val The baudrate to set
+ *
+ * \return Setting data order status
+ */
+static int32_t _spi_set_data_order(void *const hw, const enum spi_data_order dord)
+{
+ uint32_t ctrla;
+
+ if (hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
+ return ERR_BUSY;
+ }
+
+ ctrla = hri_sercomspi_read_CTRLA_reg(hw);
+
+ if (dord == SPI_DATA_ORDER_LSB_1ST) {
+ ctrla |= SERCOM_SPI_CTRLA_DORD;
+ } else {
+ ctrla &= ~SERCOM_SPI_CTRLA_DORD;
+ }
+ hri_sercomspi_write_CTRLA_reg(hw, ctrla);
+
+ return ERR_NONE;
+}
+
+/** \brief Load SERCOM registers to init for SPI master mode
+ * The settings will be applied with default master mode, unsupported things
+ * are ignored.
+ * \param[in, out] hw Pointer to the hardware register base.
+ * \param[in] regs Pointer to register configuration values.
+ */
+static inline void _spi_load_regs_master(void *const hw, const struct sercomspi_regs_cfg *regs)
+{
+ ASSERT(hw && regs);
+ hri_sercomspi_write_CTRLA_reg(
+ hw, regs->ctrla & ~(SERCOM_SPI_CTRLA_IBON | SERCOM_SPI_CTRLA_ENABLE | SERCOM_SPI_CTRLA_SWRST));
+ hri_sercomspi_write_CTRLB_reg(
+ hw,
+ (regs->ctrlb
+ & ~(SERCOM_SPI_CTRLB_MSSEN | SERCOM_SPI_CTRLB_AMODE_Msk | SERCOM_SPI_CTRLB_SSDE | SERCOM_SPI_CTRLB_PLOADEN))
+ | (SERCOM_SPI_CTRLB_RXEN));
+ hri_sercomspi_write_BAUD_reg(hw, regs->baud);
+ hri_sercomspi_write_DBGCTRL_reg(hw, regs->dbgctrl);
+}
+
+/** \brief Load SERCOM registers to init for SPI slave mode
+ * The settings will be applied with default slave mode, unsupported things
+ * are ignored.
+ * \param[in, out] hw Pointer to the hardware register base.
+ * \param[in] regs Pointer to register configuration values.
+ */
+static inline void _spi_load_regs_slave(void *const hw, const struct sercomspi_regs_cfg *regs)
+{
+ ASSERT(hw && regs);
+ hri_sercomspi_write_CTRLA_reg(
+ hw, regs->ctrla & ~(SERCOM_SPI_CTRLA_IBON | SERCOM_SPI_CTRLA_ENABLE | SERCOM_SPI_CTRLA_SWRST));
+ hri_sercomspi_write_CTRLB_reg(hw,
+ (regs->ctrlb & ~(SERCOM_SPI_CTRLB_MSSEN))
+ | (SERCOM_SPI_CTRLB_RXEN | SERCOM_SPI_CTRLB_SSDE | SERCOM_SPI_CTRLB_PLOADEN));
+ hri_sercomspi_write_ADDR_reg(hw, regs->addr);
+ hri_sercomspi_write_DBGCTRL_reg(hw, regs->dbgctrl);
+ while (hri_sercomspi_is_syncing(hw, 0xFFFFFFFF))
+ ;
+}
+
+/** \brief Return the pointer to register settings of specific SERCOM
+ * \param[in] hw_addr The hardware register base address.
+ * \return Pointer to register settings of specific SERCOM.
+ */
+static inline const struct sercomspi_regs_cfg *_spi_get_regs(const uint32_t hw_addr)
+{
+ uint8_t n = _sercom_get_hardware_index((const void *)hw_addr);
+ uint8_t i;
+
+ for (i = 0; i < sizeof(sercomspi_regs) / sizeof(struct sercomspi_regs_cfg); i++) {
+ if (sercomspi_regs[i].n == n) {
+ return &sercomspi_regs[i];
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM0_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom0_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM0_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom0_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM0_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom0_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM0_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom0_dev);
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM1_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom1_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM1_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom1_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM1_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom1_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM1_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom1_dev);
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM2_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom2_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM2_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom2_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM2_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom2_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM2_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom2_dev);
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM3_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom3_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM3_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom3_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM3_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom3_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM3_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom3_dev);
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM4_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom4_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM4_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom4_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM4_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom4_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM4_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom4_dev);
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM5_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom5_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM5_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom5_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM5_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom5_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM5_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom5_dev);
+}
+
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM6_0_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom6_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM6_1_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom6_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM6_2_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom6_dev);
+}
+/**
+ * \internal Sercom interrupt handler
+ */
+void SERCOM6_3_Handler(void)
+{
+ _sercom_usart_interrupt_handler(_sercom6_dev);
+}
+
+int32_t _spi_m_sync_init(struct _spi_m_sync_dev *dev, void *const hw)
+{
+ const struct sercomspi_regs_cfg *regs = _spi_get_regs((uint32_t)hw);
+
+ ASSERT(dev && hw);
+
+ if (regs == NULL) {
+ return ERR_INVALID_ARG;
+ }
+
+ if (!hri_sercomspi_is_syncing(hw, SERCOM_SPI_SYNCBUSY_SWRST)) {
+ uint32_t mode = regs->ctrla & SERCOM_SPI_CTRLA_MODE_Msk;
+ if (hri_sercomspi_get_CTRLA_reg(hw, SERCOM_SPI_CTRLA_ENABLE)) {
+ hri_sercomspi_clear_CTRLA_ENABLE_bit(hw);
+ hri_sercomspi_wait_for_sync(hw, SERCOM_SPI_SYNCBUSY_ENABLE);
+ }
+ hri_sercomspi_write_CTRLA_reg(hw, SERCOM_SPI_CTRLA_SWRST | mode);
+ }
+ hri_sercomspi_wait_for_sync(hw, SERCOM_SPI_SYNCBUSY_SWRST);
+
+ dev->prvt = hw;
+
+ if ((regs->ctrla & SERCOM_SPI_CTRLA_MODE_Msk) == SERCOM_USART_CTRLA_MODE_SPI_SLAVE) {
+ _spi_load_regs_slave(hw, regs);
+ } else {
+ _spi_load_regs_master(hw, regs);
+ }
+
+ /* Load character size from default hardware configuration */
+ dev->char_size = ((regs->ctrlb & SERCOM_SPI_CTRLB_CHSIZE_Msk) == 0) ? 1 : 2;
+
+ dev->dummy_byte = regs->dummy_byte;
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_sync_init(struct _spi_s_sync_dev *dev, void *const hw)
+{
+ return _spi_m_sync_init(dev, hw);
+}
+
+int32_t _spi_m_async_init(struct _spi_async_dev *dev, void *const hw)
+{
+ struct _spi_async_dev *spid = dev;
+ /* Do hardware initialize. */
+ int32_t rc = _spi_m_sync_init((struct _spi_m_sync_dev *)dev, hw);
+
+ if (rc < 0) {
+ return rc;
+ }
+
+ _sercom_init_irq_param(hw, (void *)dev);
+ /* Initialize callbacks: must use them */
+ spid->callbacks.complete = NULL;
+ spid->callbacks.rx = NULL;
+ spid->callbacks.tx = NULL;
+ uint8_t irq = _sercom_get_irq_num(hw);
+ for (uint32_t i = 0; i < 4; i++) {
+ NVIC_DisableIRQ((IRQn_Type)irq);
+ NVIC_ClearPendingIRQ((IRQn_Type)irq);
+ irq++;
+ }
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_async_init(struct _spi_s_async_dev *dev, void *const hw)
+{
+ return _spi_m_async_init(dev, hw);
+}
+
+int32_t _spi_m_async_deinit(struct _spi_async_dev *dev)
+{
+ NVIC_DisableIRQ((IRQn_Type)_sercom_get_irq_num(dev->prvt));
+ NVIC_ClearPendingIRQ((IRQn_Type)_sercom_get_irq_num(dev->prvt));
+
+ return _spi_deinit(dev->prvt);
+}
+
+int32_t _spi_s_async_deinit(struct _spi_s_async_dev *dev)
+{
+ NVIC_DisableIRQ((IRQn_Type)_sercom_get_irq_num(dev->prvt));
+ NVIC_ClearPendingIRQ((IRQn_Type)_sercom_get_irq_num(dev->prvt));
+
+ return _spi_deinit(dev->prvt);
+}
+
+int32_t _spi_m_sync_deinit(struct _spi_m_sync_dev *dev)
+{
+ return _spi_deinit(dev->prvt);
+}
+
+int32_t _spi_s_sync_deinit(struct _spi_s_sync_dev *dev)
+{
+ return _spi_deinit(dev->prvt);
+}
+
+int32_t _spi_m_sync_enable(struct _spi_m_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_sync_enable(dev->prvt);
+}
+
+int32_t _spi_s_sync_enable(struct _spi_s_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_sync_enable(dev->prvt);
+}
+
+int32_t _spi_m_async_enable(struct _spi_async_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_async_enable(dev->prvt);
+}
+
+int32_t _spi_s_async_enable(struct _spi_s_async_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_async_enable(dev->prvt);
+}
+
+int32_t _spi_m_sync_disable(struct _spi_m_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_sync_disable(dev->prvt);
+}
+
+int32_t _spi_s_sync_disable(struct _spi_s_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_sync_disable(dev->prvt);
+}
+
+int32_t _spi_m_async_disable(struct _spi_async_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_async_disable(dev->prvt);
+}
+
+int32_t _spi_s_async_disable(struct _spi_s_async_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_async_disable(dev->prvt);
+}
+
+int32_t _spi_m_sync_set_mode(struct _spi_m_sync_dev *dev, const enum spi_transfer_mode mode)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_mode(dev->prvt, mode);
+}
+
+int32_t _spi_m_async_set_mode(struct _spi_async_dev *dev, const enum spi_transfer_mode mode)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_mode(dev->prvt, mode);
+}
+
+int32_t _spi_s_async_set_mode(struct _spi_s_async_dev *dev, const enum spi_transfer_mode mode)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_mode(dev->prvt, mode);
+}
+
+int32_t _spi_s_sync_set_mode(struct _spi_s_sync_dev *dev, const enum spi_transfer_mode mode)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_mode(dev->prvt, mode);
+}
+
+int32_t _spi_calc_baud_val(struct spi_dev *dev, const uint32_t clk, const uint32_t baud)
+{
+ int32_t rc;
+ ASSERT(dev);
+
+ /* Not accept 0es */
+ if (clk == 0 || baud == 0) {
+ return ERR_INVALID_ARG;
+ }
+
+ /* Check baudrate range of current assigned clock */
+ if (!(baud <= (clk >> 1) && baud >= (clk >> 8))) {
+ return ERR_INVALID_ARG;
+ }
+
+ rc = ((clk >> 1) / baud) - 1;
+ return rc;
+}
+
+int32_t _spi_m_sync_set_baudrate(struct _spi_m_sync_dev *dev, const uint32_t baud_val)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_baudrate(dev->prvt, baud_val);
+}
+
+int32_t _spi_m_async_set_baudrate(struct _spi_async_dev *dev, const uint32_t baud_val)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_baudrate(dev->prvt, baud_val);
+}
+
+int32_t _spi_m_sync_set_char_size(struct _spi_m_sync_dev *dev, const enum spi_char_size char_size)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_char_size(dev->prvt, char_size, &dev->char_size);
+}
+
+int32_t _spi_m_async_set_char_size(struct _spi_async_dev *dev, const enum spi_char_size char_size)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_char_size(dev->prvt, char_size, &dev->char_size);
+}
+
+int32_t _spi_s_async_set_char_size(struct _spi_s_async_dev *dev, const enum spi_char_size char_size)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_char_size(dev->prvt, char_size, &dev->char_size);
+}
+
+int32_t _spi_s_sync_set_char_size(struct _spi_s_sync_dev *dev, const enum spi_char_size char_size)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_char_size(dev->prvt, char_size, &dev->char_size);
+}
+
+int32_t _spi_m_sync_set_data_order(struct _spi_m_sync_dev *dev, const enum spi_data_order dord)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_data_order(dev->prvt, dord);
+}
+
+int32_t _spi_m_async_set_data_order(struct _spi_async_dev *dev, const enum spi_data_order dord)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_data_order(dev->prvt, dord);
+}
+
+int32_t _spi_s_async_set_data_order(struct _spi_s_async_dev *dev, const enum spi_data_order dord)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_data_order(dev->prvt, dord);
+}
+
+int32_t _spi_s_sync_set_data_order(struct _spi_s_sync_dev *dev, const enum spi_data_order dord)
+{
+ ASSERT(dev && dev->prvt);
+
+ return _spi_set_data_order(dev->prvt, dord);
+}
+
+/** Wait until SPI bus idle. */
+static inline void _spi_wait_bus_idle(void *const hw)
+{
+ while (!(hri_sercomspi_get_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_TXC | SERCOM_SPI_INTFLAG_DRE))) {
+ ;
+ }
+ hri_sercomspi_clear_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_TXC | SERCOM_SPI_INTFLAG_DRE);
+}
+
+/** Holds run time information for message sync transaction. */
+struct _spi_trans_ctrl {
+ /** Pointer to transmitting data buffer. */
+ uint8_t *txbuf;
+ /** Pointer to receiving data buffer. */
+ uint8_t *rxbuf;
+ /** Count number of data transmitted. */
+ uint32_t txcnt;
+ /** Count number of data received. */
+ uint32_t rxcnt;
+ /** Data character size. */
+ uint8_t char_size;
+};
+
+/** Check interrupt flag of RXC and update transaction runtime information. */
+static inline bool _spi_rx_check_and_receive(void *const hw, const uint32_t iflag, struct _spi_trans_ctrl *ctrl)
+{
+ uint32_t data;
+
+ if (!(iflag & SERCOM_SPI_INTFLAG_RXC)) {
+ return false;
+ }
+
+ data = hri_sercomspi_read_DATA_reg(hw);
+
+ if (ctrl->rxbuf) {
+ *ctrl->rxbuf++ = (uint8_t)data;
+
+ if (ctrl->char_size > 1) {
+ *ctrl->rxbuf++ = (uint8_t)(data >> 8);
+ }
+ }
+
+ ctrl->rxcnt++;
+
+ return true;
+}
+
+/** Check interrupt flag of DRE and update transaction runtime information. */
+static inline void _spi_tx_check_and_send(void *const hw, const uint32_t iflag, struct _spi_trans_ctrl *ctrl,
+ uint16_t dummy)
+{
+ uint32_t data;
+
+ if (!(SERCOM_SPI_INTFLAG_DRE & iflag)) {
+ return;
+ }
+
+ if (ctrl->txbuf) {
+ data = *ctrl->txbuf++;
+
+ if (ctrl->char_size > 1) {
+ data |= (*ctrl->txbuf) << 8;
+ ctrl->txbuf++;
+ }
+ } else {
+ data = dummy;
+ }
+
+ ctrl->txcnt++;
+ hri_sercomspi_write_DATA_reg(hw, data);
+}
+
+/** Check interrupt flag of ERROR and update transaction runtime information. */
+static inline int32_t _spi_err_check(const uint32_t iflag, void *const hw)
+{
+ if (SERCOM_SPI_INTFLAG_ERROR & iflag) {
+ hri_sercomspi_clear_STATUS_reg(hw, ~0);
+ hri_sercomspi_clear_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_ERROR);
+ return ERR_OVERFLOW;
+ }
+
+ return ERR_NONE;
+}
+
+int32_t _spi_m_sync_trans(struct _spi_m_sync_dev *dev, const struct spi_msg *msg)
+{
+ void * hw = dev->prvt;
+ int32_t rc = 0;
+ struct _spi_trans_ctrl ctrl = {msg->txbuf, msg->rxbuf, 0, 0, dev->char_size};
+
+ ASSERT(dev && hw);
+
+ /* If settings are not applied (pending), we can not go on */
+ if (hri_sercomspi_is_syncing(
+ hw, (SERCOM_SPI_SYNCBUSY_SWRST | SERCOM_SPI_SYNCBUSY_ENABLE | SERCOM_SPI_SYNCBUSY_CTRLB))) {
+ return ERR_BUSY;
+ }
+
+ /* SPI must be enabled to start synchronous transfer */
+ if (!hri_sercomspi_get_CTRLA_ENABLE_bit(hw)) {
+ return ERR_NOT_INITIALIZED;
+ }
+
+ for (;;) {
+ uint32_t iflag = hri_sercomspi_read_INTFLAG_reg(hw);
+
+ if (!_spi_rx_check_and_receive(hw, iflag, &ctrl)) {
+ /* In master mode, do not start next byte before previous byte received
+ * to make better output waveform */
+ if (ctrl.rxcnt >= ctrl.txcnt) {
+ _spi_tx_check_and_send(hw, iflag, &ctrl, dev->dummy_byte);
+ }
+ }
+
+ rc = _spi_err_check(iflag, hw);
+
+ if (rc < 0) {
+ break;
+ }
+ if (ctrl.txcnt >= msg->size && ctrl.rxcnt >= msg->size) {
+ rc = ctrl.txcnt;
+ break;
+ }
+ }
+ /* Wait until SPI bus idle */
+ _spi_wait_bus_idle(hw);
+
+ return rc;
+}
+
+int32_t _spi_m_async_enable_tx(struct _spi_async_dev *dev, bool state)
+{
+ void *hw = dev->prvt;
+
+ ASSERT(dev && hw);
+
+ if (state) {
+ hri_sercomspi_set_INTEN_DRE_bit(hw);
+ } else {
+ hri_sercomspi_clear_INTEN_DRE_bit(hw);
+ }
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_async_enable_tx(struct _spi_s_async_dev *dev, bool state)
+{
+ return _spi_m_async_enable_tx(dev, state);
+}
+
+int32_t _spi_m_async_enable_rx(struct _spi_async_dev *dev, bool state)
+{
+ void *hw = dev->prvt;
+
+ ASSERT(dev);
+ ASSERT(hw);
+
+ if (state) {
+ hri_sercomspi_set_INTEN_RXC_bit(hw);
+ } else {
+ hri_sercomspi_clear_INTEN_RXC_bit(hw);
+ }
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_async_enable_rx(struct _spi_s_async_dev *dev, bool state)
+{
+ return _spi_m_async_enable_rx(dev, state);
+}
+
+int32_t _spi_m_async_enable_tx_complete(struct _spi_async_dev *dev, bool state)
+{
+ ASSERT(dev && dev->prvt);
+
+ if (state) {
+ hri_sercomspi_set_INTEN_TXC_bit(dev->prvt);
+ } else {
+ hri_sercomspi_clear_INTEN_TXC_bit(dev->prvt);
+ }
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_async_enable_ss_detect(struct _spi_s_async_dev *dev, bool state)
+{
+ return _spi_m_async_enable_tx_complete(dev, state);
+}
+
+int32_t _spi_m_async_write_one(struct _spi_async_dev *dev, uint16_t data)
+{
+ ASSERT(dev && dev->prvt);
+
+ hri_sercomspi_write_DATA_reg(dev->prvt, data);
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_async_write_one(struct _spi_s_async_dev *dev, uint16_t data)
+{
+ ASSERT(dev && dev->prvt);
+
+ hri_sercomspi_write_DATA_reg(dev->prvt, data);
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_sync_write_one(struct _spi_s_sync_dev *dev, uint16_t data)
+{
+ ASSERT(dev && dev->prvt);
+
+ hri_sercomspi_write_DATA_reg(dev->prvt, data);
+
+ return ERR_NONE;
+}
+
+uint16_t _spi_m_async_read_one(struct _spi_async_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return hri_sercomspi_read_DATA_reg(dev->prvt);
+}
+
+uint16_t _spi_s_async_read_one(struct _spi_s_async_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return hri_sercomspi_read_DATA_reg(dev->prvt);
+}
+
+uint16_t _spi_s_sync_read_one(struct _spi_s_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return hri_sercomspi_read_DATA_reg(dev->prvt);
+}
+
+int32_t _spi_m_async_register_callback(struct _spi_async_dev *dev, const enum _spi_async_dev_cb_type cb_type,
+ const FUNC_PTR func)
+{
+ typedef void (*func_t)(void);
+ struct _spi_async_dev *spid = dev;
+
+ ASSERT(dev && (cb_type < SPI_DEV_CB_N));
+
+ func_t *p_ls = (func_t *)&spid->callbacks;
+ p_ls[cb_type] = (func_t)func;
+
+ return ERR_NONE;
+}
+
+int32_t _spi_s_async_register_callback(struct _spi_s_async_dev *dev, const enum _spi_s_async_dev_cb_type cb_type,
+ const FUNC_PTR func)
+{
+ return _spi_m_async_register_callback(dev, cb_type, func);
+}
+
+bool _spi_s_sync_is_tx_ready(struct _spi_s_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return hri_sercomi2cm_get_INTFLAG_reg(dev->prvt, SERCOM_SPI_INTFLAG_DRE);
+}
+
+bool _spi_s_sync_is_rx_ready(struct _spi_s_sync_dev *dev)
+{
+ ASSERT(dev && dev->prvt);
+
+ return hri_sercomi2cm_get_INTFLAG_reg(dev->prvt, SERCOM_SPI_INTFLAG_RXC);
+}
+
+bool _spi_s_sync_is_ss_deactivated(struct _spi_s_sync_dev *dev)
+{
+ void *hw = dev->prvt;
+
+ ASSERT(dev && hw);
+
+ if (hri_sercomi2cm_get_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_TXC)) {
+ hri_sercomspi_clear_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_TXC);
+ return true;
+ }
+ return false;
+}
+
+bool _spi_s_sync_is_error(struct _spi_s_sync_dev *dev)
+{
+ void *hw = dev->prvt;
+
+ ASSERT(dev && hw);
+
+ if (hri_sercomi2cm_get_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_ERROR)) {
+ hri_sercomspi_clear_STATUS_reg(hw, SERCOM_SPI_STATUS_BUFOVF);
+ hri_sercomspi_clear_INTFLAG_reg(hw, SERCOM_SPI_INTFLAG_ERROR);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * \brief Enable/disable SPI master interrupt
+ *
+ * param[in] device The pointer to SPI master device instance
+ * param[in] type The type of interrupt to disable/enable if applicable
+ * param[in] state Enable or disable
+ */
+void _spi_m_async_set_irq_state(struct _spi_async_dev *const device, const enum _spi_async_dev_cb_type type,
+ const bool state)
+{
+ ASSERT(device);
+
+ if (SPI_DEV_CB_ERROR == type) {
+ hri_sercomspi_write_INTEN_ERROR_bit(device->prvt, state);
+ }
+}
+
+/**
+ * \brief Enable/disable SPI slave interrupt
+ *
+ * param[in] device The pointer to SPI slave device instance
+ * param[in] type The type of interrupt to disable/enable if applicable
+ * param[in] state Enable or disable
+ */
+void _spi_s_async_set_irq_state(struct _spi_async_dev *const device, const enum _spi_async_dev_cb_type type,
+ const bool state)
+{
+ _spi_m_async_set_irq_state(device, type, state);
+}
diff --git a/usb_dfu_main.c b/usb_dfu_main.c
new file mode 100644
index 0000000..ebecba9
--- /dev/null
+++ b/usb_dfu_main.c
@@ -0,0 +1,133 @@
+/**
+ * \file
+ * \brief USB DFU bootloader implementation (DFU mode)
+ *
+ * Copyright (c) 2018-2019 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon(a)sysmocom.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <errno.h>
+#include <stdint.h>
+#include "atmel_start.h"
+#include "atmel_start_pins.h"
+#include "component/nvmctrl.h"
+
+
+#ifdef __clang__
+#define OPTNONE optnone
+#else
+#define OPTNONE optimize(0)
+#endif
+
+#define BLSZ_BYTE (BL_SIZE_BYTE)
+static volatile const uint32_t bl_update_data[BLSZ_BYTE / sizeof(uint32_t)] __attribute__((section(".fwupdate"),used,retain)) = { 0xFF };
+
+_Static_assert (BLSZ_BYTE % NVMCTRL_PAGE_SIZE == 0, "invalid bl size");
+
+
+__attribute__((section(".ramfunc"), OPTNONE))
+void same54_flash_write_page(uint32_t address, uint8_t *data) {
+ // address &= ~(NVMCTRL_PAGE_SIZE - 1);
+ while (!NVMCTRL->STATUS.bit.READY) {}
+
+ hri_nvmctrl_write_CTRLB_reg(NVMCTRL, NVMCTRL_CTRLB_CMD_PBC | NVMCTRL_CTRLB_CMDEX_KEY);
+
+ while (!NVMCTRL->STATUS.bit.READY) {}
+
+ volatile uint32_t *dst = (uint32_t *)address;
+ volatile uint32_t *src = (uint32_t *)data;
+
+ for (uint32_t i = 0; i < (NVMCTRL_PAGE_SIZE / sizeof(uint32_t)); i++) {
+ dst[i] = src[i];
+ }
+
+ NVMCTRL->ADDR.reg = address;
+ NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMD_WP | NVMCTRL_CTRLB_CMDEX_KEY;
+ while (!NVMCTRL->INTFLAG.bit.DONE) {}
+ while (!NVMCTRL->STATUS.bit.READY) {}
+}
+
+__attribute__((section(".ramfunc"),OPTNONE))
+void do_update() {
+ uint16_t mask = NVMCTRL_CTRLA_AHBNS0 |NVMCTRL_CTRLA_AHBNS1|NVMCTRL_CTRLA_RWS_Msk;
+ uint16_t _nvm = (NVMCTRL_CTRLA_CACHEDIS0 | NVMCTRL_CTRLA_CACHEDIS1 | NVMCTRL_CTRLA_PRM(3) | NVMCTRL_CTRLA_RWS(0x7) | NVMCTRL_CTRLA_WMODE(0) |NVMCTRL_CTRLA_AUTOWS );
+ uint32_t ctrla = NVMCTRL->CTRLA.reg;
+ ctrla &= ~(mask);
+ ctrla |= _nvm;
+ NVMCTRL->CTRLA.reg = ctrla;
+
+ NVIC_DisableIRQ(NVMCTRL_0_IRQn);
+ NVIC_DisableIRQ(NVMCTRL_1_IRQn);
+ NVIC_ClearPendingIRQ(NVMCTRL_0_IRQn);
+ NVIC_ClearPendingIRQ(NVMCTRL_1_IRQn);
+
+ #define NVMCTRL_REGIONS_NUM 32
+ #define REGION_SZ (FLASH_SIZE/NVMCTRL_REGIONS_NUM)
+ #define BL_IN_PAGESZ (BLSZ_BYTE/NVMCTRL_PAGE_SIZE)
+ #define BL_IN_REGIONS (BLSZ_BYTE / REGION_SZ)
+ const uint32_t bootloader_regions = BLSZ_BYTE / NVMCTRL_BLOCK_SIZE;
+
+ _Static_assert (BL_IN_REGIONS > 0, "bootprot regions must be at least 1");
+
+ // unlock everything
+ for(int i = 0; i< NVMCTRL_REGIONS_NUM; i++){
+ while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
+ hri_nvmctrl_write_ADDR_reg(NVMCTRL, REGION_SZ* i);
+ hri_nvmctrl_write_CTRLB_reg(NVMCTRL, NVMCTRL_CTRLB_CMD_UR | NVMCTRL_CTRLB_CMDEX_KEY);
+ }
+
+ // disable bl protection
+ hri_nvmctrl_write_CTRLB_reg(NVMCTRL, NVMCTRL_CTRLB_CMD_SBPDIS | NVMCTRL_CTRLB_CMDEX_KEY);
+ while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
+
+ for(int i = 0; i< bootloader_regions; i++){
+ while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
+ hri_nvmctrl_write_ADDR_reg(NVMCTRL, NVMCTRL_BLOCK_SIZE * i);
+ hri_nvmctrl_write_CTRLB_reg(NVMCTRL, NVMCTRL_CTRLB_CMD_EB | NVMCTRL_CTRLB_CMDEX_KEY);
+ }
+
+ while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
+
+ // Write firmware data to flash
+ uint32_t address = 0;
+ uint8_t *data_ptr = (uint8_t *)bl_update_data;
+ uint32_t remaining = BLSZ_BYTE;
+
+ while (remaining >= NVMCTRL_PAGE_SIZE) {
+ same54_flash_write_page(address, data_ptr);
+ address += NVMCTRL_PAGE_SIZE;
+ data_ptr += NVMCTRL_PAGE_SIZE;
+ remaining -= NVMCTRL_PAGE_SIZE;
+ }
+
+ //erases itself, fns likely not inlined @ -Os.
+ for(int i = bootloader_regions; i < bootloader_regions+1; i++){
+ while (!(((Nvmctrl *)NVMCTRL)->STATUS.reg & NVMCTRL_STATUS_READY) >> NVMCTRL_STATUS_READY_Pos) {}
+ ((Nvmctrl *)NVMCTRL)->ADDR.reg = NVMCTRL_BLOCK_SIZE * i;
+ ((Nvmctrl *)NVMCTRL)->CTRLB.reg = NVMCTRL_CTRLB_CMD_EB | NVMCTRL_CTRLB_CMDEX_KEY;
+ }
+ while (!(((Nvmctrl *)NVMCTRL)->STATUS.reg & NVMCTRL_STATUS_READY) >> NVMCTRL_STATUS_READY_Pos) {}
+
+ __DSB();
+ SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |SCB_AIRCR_SYSRESETREQ_Msk );
+ __DSB();
+}
+int main(void)
+{
+ __disable_irq();
+ MCLK->AHBMASK.reg |= MCLK_AHBMASK_NVMCTRL;
+ do_update();
+}
diff --git a/usb_flash_main.c b/usb_flash_main.c
index 9115bf7..518cf2d 100644
--- a/usb_flash_main.c
+++ b/usb_flash_main.c
@@ -22,31 +22,16 @@
#include <errno.h>
#include "atmel_start.h"
#include "atmel_start_pins.h"
+#include "hpl_user_area.h"
/** Start address of the application in flash
* \remark must be initialized by check_bootloader
*/
-static uint32_t* application_start_address;
+static uint32_t* application_start_address = (uint32_t*)(BL_SIZE_BYTE);
/** Location of the DFU magic value to force starting DFU */
static volatile uint32_t* dfu_magic = (uint32_t*)HSRAM_ADDR; // magic value should be written at start of RAM
-/** Check if the bootloader is valid
- * \return true if the bootloader is valid and can be run
- * \remark initializes application_start_address
- */
-static bool check_bootloader(void)
-{
- if (hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw) > 15) { // ensure BOOTPROT setting is valid
- return false;
- }
- application_start_address = (uint32_t*)((15 - hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw)) * 8192); // calculate bootloader size to know start address of the application (e.g. after the bootloader)
- if (0 == application_start_address) { // no space has been reserved for the bootloader
- return false;
- }
- return true;
-}
-
/** Check if starting the bootloader is forced
* \return true of the DFU bootloader should be started
*/
@@ -84,6 +69,8 @@
{
__set_MSP(*application_start_address); // re-base the Stack Pointer
SCB->VTOR = ((uint32_t) application_start_address & SCB_VTOR_TBLOFF_Msk); // re-base the vector table base address
+ __DSB();
+ __ISB();
asm("bx %0"::"r"(*(application_start_address + 1))); // jump to application Reset Handler in the application */
}
#if defined(SYSMOOCTSIM)
@@ -143,21 +130,23 @@
get_chip_unique_serial_str(sernr_buf, sizeof(sernr_buf));
str_to_usb_desc(sernr_buf, sizeof(sernr_buf), sernr_buf_descr, sizeof(sernr_buf_descr));
#endif
- if (!check_bootloader()) { // check bootloader
- // blink the LED to tell the user we don't know where the application starts
- while (true) {
- gpio_set_pin_level(LED_SYSTEM, false);
- delay_ms(500);
- gpio_set_pin_level(LED_SYSTEM, true);
- delay_ms(500);
- }
+
+
+ // set bootprot bits for (15-13)=2 x8192 byte
+ // hri_nvmctrl_write_CTRLB_reg(NVMCTRL, NVMCTRL_CTRLB_CMD_SBPDIS | NVMCTRL_CTRLB_CMDEX_KEY);
+ while (!hri_nvmctrl_get_STATUS_READY_bit(NVMCTRL)) {}
+ if (hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw) != 13) {
+ _user_area_write_bits((void*)NVMCTRL_FUSES_BOOTPROT_ADDR, NVMCTRL_FUSES_BOOTPROT_Pos, 13, 4);
}
+
+
if (!check_force_dfu() && check_application()) { // application is valid
start_application(); // start application
} else {
if (!check_application()) { // if the application is corrupted the start DFU start should be dfuERROR
dfu_state = USB_DFU_STATE_DFU_ERROR;
}
+ usb_init();
usb_dfu(); // start DFU bootloader
}
}
diff --git a/usb_start.c b/usb_start.c
index 24cde4f..dacd325 100644
--- a/usb_start.c
+++ b/usb_start.c
@@ -151,8 +151,7 @@
while (!dfudf_is_enabled()); // wait for DFU to be installed
LED_SYSTEM_on(); // switch LED on to indicate USB DFU stack is ready
- ASSERT(hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw) <= 15);
- uint32_t application_start_address = (15 - hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw)) * 8192; // calculate bootloader size to know where we should write the application firmware
+ uint32_t application_start_address = BL_SIZE_BYTE; // calculate bootloader size to know where we should write the application firmware
ASSERT(application_start_address > 0);
while (true) { // main DFU infinite loop
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39434?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I1403d35497cdea41ea5bed2c94b9e729ca352772
Gerrit-Change-Number: 39434
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
1
0
[M] Change in osmo-asf4-dfu[master]: linker scripts: add bl size, fix ram size to 19a part
by Hoernchen 29 Jan '25
by Hoernchen 29 Jan '25
29 Jan '25
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39433?usp=email )
Change subject: linker scripts: add bl size, fix ram size to 19a part
......................................................................
linker scripts: add bl size, fix ram size to 19a part
Change-Id: Ic2da201b8f95855d05e15ac6ac8461e434593760
---
A gcc/gcc/blsize.ld
A gcc/gcc/same54p20a_dfu.ld
M gcc/gcc/same54p20a_flash.ld
M gcc/gcc/same54p20a_sram.ld
4 files changed, 178 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/33/39433/1
diff --git a/gcc/gcc/blsize.ld b/gcc/gcc/blsize.ld
new file mode 100644
index 0000000..2ef3633
--- /dev/null
+++ b/gcc/gcc/blsize.ld
@@ -0,0 +1 @@
+BL_SIZE_BYTE = 8192 * 2;
\ No newline at end of file
diff --git a/gcc/gcc/same54p20a_dfu.ld b/gcc/gcc/same54p20a_dfu.ld
new file mode 100644
index 0000000..becba88
--- /dev/null
+++ b/gcc/gcc/same54p20a_dfu.ld
@@ -0,0 +1,173 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAME54P20A
+ *
+ * Copyright (c) 2018 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+INCLUDE blsize.ld
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + BL_SIZE_BYTE, LENGTH = 0x00080000 - BL_SIZE_BYTE
+ /* The first word of the RAM is used for the DFU magic */
+ ram (rwx) : ORIGIN = 0x20000000 + 4, LENGTH = 0x00030000 - 4
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ .blupdate :
+ {
+ . = ALIGN(4);
+ _blupdate_start = .;
+ KEEP(*(.fwupdate .fwupdate.*));
+ _blupdate_end = .;
+ } > rom
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/gcc/gcc/same54p20a_flash.ld b/gcc/gcc/same54p20a_flash.ld
index 6aa3fb1..f2c5124 100644
--- a/gcc/gcc/same54p20a_flash.ld
+++ b/gcc/gcc/same54p20a_flash.ld
@@ -27,6 +27,7 @@
*
*/
+INCLUDE blsize.ld
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
@@ -35,9 +36,9 @@
/* Memory Spaces Definitions */
MEMORY
{
- rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = BL_SIZE_BYTE
/* The first word of the RAM is used for the DFU magic */
- ram (rwx) : ORIGIN = 0x20000000 + 4, LENGTH = 0x00040000 - 4
+ ram (rwx) : ORIGIN = 0x20000000 + 4, LENGTH = 0x00030000 - 4
bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
}
diff --git a/gcc/gcc/same54p20a_sram.ld b/gcc/gcc/same54p20a_sram.ld
index b3be5b3..5cf354c 100644
--- a/gcc/gcc/same54p20a_sram.ld
+++ b/gcc/gcc/same54p20a_sram.ld
@@ -35,7 +35,7 @@
/* Memory Spaces Definitions */
MEMORY
{
- ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39433?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: Ic2da201b8f95855d05e15ac6ac8461e434593760
Gerrit-Change-Number: 39433
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
1
0
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39432?usp=email )
Change subject: rename bl app
......................................................................
rename bl app
Change-Id: I313b2c45017b7c83989d4c61594ce47edb2f2965
---
R usb_flash_main.c
1 file changed, 0 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/32/39432/1
diff --git a/usb_dfu_main.c b/usb_flash_main.c
similarity index 100%
rename from usb_dfu_main.c
rename to usb_flash_main.c
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39432?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I313b2c45017b7c83989d4c61594ce47edb2f2965
Gerrit-Change-Number: 39432
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
1
0
29 Jan '25
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39436?usp=email )
Change subject: contrib: add nvm urow parser ipynb
......................................................................
contrib: add nvm urow parser ipynb
Useful when dealing with the urow bits for wdt, bootprot, ..
Change-Id: I588838d7c33be24636e00cec65c3b485a486f747
---
A contrib/same54_urow.ipynb
1 file changed, 135 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/36/39436/1
diff --git a/contrib/same54_urow.ipynb b/contrib/same54_urow.ipynb
new file mode 100644
index 0000000..3069475
--- /dev/null
+++ b/contrib/same54_urow.ipynb
@@ -0,0 +1,135 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Memory dump from GDB\n",
+ "# (gdb) x/512xb 0x00804000\n",
+ "memory_dump = \"\"\"\n",
+ "0x804000: 0x39 0x92 0x9a 0xfe 0x80 0xff 0xc0 0xee\n",
+ "0x804008: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff\n",
+ "0x804010: 0x10 0x40 0x80 0x00 0xff 0xff 0xff 0xff\n",
+ "0x804018: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff\n",
+ "0x804020: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff\n",
+ "0x804028: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff\n",
+ "0x804030: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff\n",
+ "0x804038: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff\n",
+ "\"\"\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import struct\n",
+ "\n",
+ "DEFAULTS = {\n",
+ "\t'BOD33 Disable': 0x1,\n",
+ "\t'BOD33 Level': 0x1C,\n",
+ "\t'BOD33 Action': 0x1,\n",
+ "\t'BOD33 Hysteresis': 0x2,\n",
+ "\t'NVM BOOTPROT': 0xF,\n",
+ "\t'SBLK': 0x0,\n",
+ "\t'PSZ': 0x0,\n",
+ "\t'RAM ECCDIS': 0x1,\n",
+ "\t'WDT Enable': 0x0,\n",
+ "\t'WDT Always-On': 0x0,\n",
+ "\t'WDT Period': 0xB,\n",
+ "\t'WDT Window': 0xB,\n",
+ "\t'WDT EWOFFSET': 0xB,\n",
+ "\t'WDT WEN': 0x0,\n",
+ "\t'NVM LOCKS': 0xFFFFFFFF\n",
+ "}\n",
+ "\n",
+ "# def extract_bits(value, offset, mask):\n",
+ "# \treturn (value >> offset) & mask\n",
+ "\n",
+ "def extract_bits(value, start, end):\n",
+ "\tmask = (1 << (end - start + 1)) - 1\n",
+ "\treturn (value >> start) & mask\n",
+ "\n",
+ "\n",
+ "def decode_user_row(memory_dump):\n",
+ "\t# Extract only the hexadecimal values from the memory dump\n",
+ "\thex_values = ''.join(line.split(':')[1].strip().replace(' ', '') for line in memory_dump.strip().split('\\n'))\n",
+ "\thex_values = hex_values.replace('0x', '').replace('\\n', '')\n",
+ "\t\n",
+ "\t# Convert the cleaned hex string to bytes\n",
+ "\tmemory_bytes = bytes.fromhex(hex_values)\n",
+ "\t\n",
+ "\t# Convert bytes to 32-bit words\n",
+ "\t# words = struct.unpack('<8I', memory_bytes[:32])\n",
+ "\twords = struct.unpack('<8I', memory_bytes[:32])\n",
+ "\t\n",
+ "\tsettings = {\n",
+ "\t\t'BOD33 Disable': extract_bits(words[0], 0, 0),\n",
+ "\t\t'BOD33 Level': extract_bits(words[0], 1, 8),\n",
+ "\t\t'BOD33 Action': extract_bits(words[0], 9, 10),\n",
+ "\t\t'BOD33 Hysteresis': extract_bits(words[0], 11, 14),\n",
+ "\t\t'BOD12 Calibration': extract_bits(words[0], 15, 25),\n",
+ "\t\t'NVM BOOTPROT': extract_bits(words[0], 26, 29),\n",
+ "\t\t'SBLK': extract_bits(words[1], 0, 3),\n",
+ "\t\t'PSZ': extract_bits(words[1], 4, 6),\n",
+ "\t\t'RAM ECCDIS': extract_bits(words[1], 7, 7),\n",
+ "\t\t'WDT Enable': extract_bits(words[1], 16, 16),\n",
+ "\t\t'WDT Always-On': extract_bits(words[1], 17, 17),\n",
+ "\t\t'WDT Period': extract_bits(words[1], 18, 21),\n",
+ "\t\t'WDT Window': extract_bits(words[1], 22, 25),\n",
+ "\t\t'WDT EWOFFSET': extract_bits(words[1], 26, 29),\n",
+ "\t\t'WDT WEN': extract_bits(words[1], 30, 30),\n",
+ "\t\t'NVM LOCKS': words[2],\n",
+ "\t\t'User Page': words[3]\n",
+ "\t}\n",
+ "\treturn settings\n",
+ "\n",
+ "\n",
+ "\n",
+ "def display_user_row_settings(settings):\n",
+ "\tprint(\"SAME54 User Row Settings (Current vs Default):\")\n",
+ "\tprint(\"-\" * 50)\n",
+ "\tfor key, value in settings.items():\n",
+ "\t\tif key in DEFAULTS:\n",
+ "\t\t\tif value != DEFAULTS[key]:\n",
+ "\t\t\t\tprint(f\"{key:15}: 0x{value:X} (Default: 0x{DEFAULTS[key]:X}) *DIFFERENT*\")\n",
+ "\t\t\telse:\n",
+ "\t\t\t\tprint(f\"{key:15}: 0x{value:X} (Default: 0x{DEFAULTS[key]:X})\")\n",
+ "\t\telse:\n",
+ "\t\t\tprint(f\"{key:15}: 0x{value:X}\")\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Decode the memory dump\n",
+ "decoded_settings = decode_user_row(memory_dump)\n",
+ "\n",
+ "# Display the formatted settings\n",
+ "display_user_row_settings(decoded_settings)\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.12.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
--
To view, visit https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/39436?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-asf4-dfu
Gerrit-Branch: master
Gerrit-Change-Id: I588838d7c33be24636e00cec65c3b485a486f747
Gerrit-Change-Number: 39436
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
1
0