Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement support for SAMV devices #681

Merged
merged 5 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/compile-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
name: avr-compile-all
path: test/all/log

samd-compile-all:
sam-compile-all:
if: github.event.label.name == 'ci:hal'
runs-on: ubuntu-20.04
container:
Expand All @@ -37,14 +37,14 @@ jobs:
- name: Checkout code and update modm tools
run: |
(git submodule sync && git submodule update --init --jobs 8) & pip3 install --upgrade --upgrade-strategy=eager modm & wait
- name: Compile HAL for all SAMD
- name: Compile HAL for all SAM
run: |
(cd test/all && python3 run_all.py samd --quick-remaining)
(cd test/all && python3 run_all.py sam --quick-remaining)
- name: Upload log artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: samd-compile-all
name: sam-compile-all
path: test/all/log

stm32f0-compile-all:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py samg55_xplained_pro)
- name: Examples SAMV Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py samv)
- name: Execute Python Scripts
if: always()
run: |
Expand Down Expand Up @@ -217,7 +221,7 @@ jobs:
- name: Quick compile HAL for Cortex-M Part 1
if: always()
run: |
(cd test/all && python3 run_all.py stm32 samd --quick --split 4 --part 0)
(cd test/all && python3 run_all.py stm32 sam --quick --split 4 --part 0)
- name: Upload log artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -237,7 +241,7 @@ jobs:
- name: Quick compile HAL for Cortex-M Part 2
if: always()
run: |
(cd test/all && python3 run_all.py stm32 samd --quick --split 4 --part 1)
(cd test/all && python3 run_all.py stm32 sam --quick --split 4 --part 1)
- name: Upload log artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -257,7 +261,7 @@ jobs:
- name: Quick compile HAL for Cortex-M Part 3
if: always()
run: |
(cd test/all && python3 run_all.py stm32 samd --quick --split 4 --part 2)
(cd test/all && python3 run_all.py stm32 sam --quick --split 4 --part 2)
- name: Upload log artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -277,7 +281,7 @@ jobs:
- name: Quick compile HAL for Cortex-M Part 4
if: always()
run: |
(cd test/all && python3 run_all.py stm32 samd --quick --split 4 --part 3)
(cd test/all && python3 run_all.py stm32 sam --quick --split 4 --part 3)
- name: Upload log artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ git clone --recurse-submodules --jobs 8 https://github.com/modm-io/modm.git

## Microcontrollers

modm can create a HAL for <!--allcount-->3175<!--/allcount--> devices of these vendors:
modm can create a HAL for <!--allcount-->3195<!--/allcount--> devices of these vendors:

- STMicroelectronics STM32: <!--stmcount-->2621<!--/stmcount--> devices.
- Microchip SAM: <!--samcount-->166<!--/samcount--> devices.
- Microchip SAM: <!--samcount-->186<!--/samcount--> devices.
- Microchip AVR: <!--avrcount-->388<!--/avrcount--> devices.

Here is a table with all device families and the peripheral drivers they support:
Expand All @@ -96,7 +96,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<tr>
<th align="center"></th>
<th align="center" colspan="12">STM32</th>
<th align="center" colspan="2">SAM</th>
<th align="center" colspan="3">SAM</th>
<th align="center" colspan="3">AT</th>
</tr><tr>
<th align="left">Peripheral</th>
Expand All @@ -113,7 +113,8 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<th align="center">L1</th>
<th align="center">L4</th>
<th align="center">D21</th>
<th align="center">G</th>
<th align="center">G55</th>
<th align="center">V70</th>
<th align="center">90</th>
<th align="center">Mega</th>
<th align="center">Tiny</th>
Expand All @@ -134,6 +135,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">✅</td>
</tr><tr>
Expand All @@ -154,6 +156,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✗</td>
</tr><tr>
<td align="left">Comparator</td>
Expand All @@ -174,6 +177,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
</tr><tr>
<td align="left">DAC</td>
<td align="center">✅</td>
Expand All @@ -190,6 +194,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">✗</td>
Expand All @@ -209,6 +214,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
Expand All @@ -231,6 +237,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
twasilczyk marked this conversation as resolved.
Show resolved Hide resolved
</tr><tr>
<td align="left">External Interrupt</td>
<td align="center">✅</td>
Expand All @@ -246,7 +253,8 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand All @@ -266,6 +274,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
Expand All @@ -288,6 +297,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
</tr><tr>
<td align="left">I<sup>2</sup>C</td>
<td align="center">✅</td>
Expand All @@ -304,6 +314,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand All @@ -322,7 +333,8 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
Expand All @@ -342,6 +354,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
Expand All @@ -361,6 +374,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand All @@ -383,6 +397,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
twasilczyk marked this conversation as resolved.
Show resolved Hide resolved
</tr><tr>
<td align="left">Timer</td>
<td align="center">✅</td>
Expand All @@ -402,6 +417,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
</tr><tr>
<td align="left">UART</td>
<td align="center">✅</td>
Expand All @@ -418,6 +434,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
Expand All @@ -440,6 +457,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
twasilczyk marked this conversation as resolved.
Show resolved Hide resolved
</tr><tr>
<td align="left">USB</td>
<td align="center">✅</td>
Expand All @@ -456,6 +474,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✗</td>
<td align="center">✗</td>
<td align="center">✗</td>
Expand Down
61 changes: 61 additions & 0 deletions examples/samv/blink/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2021, Tomasz Wasilczyk
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include <modm/architecture/interface/clock.hpp>
#include <modm/platform.hpp>

using namespace std::chrono_literals;
using namespace modm::platform;

struct SystemClock
{
// Chosen to achieve 300MHz system clock
static constexpr uint32_t PllAMult = 25;
static constexpr uint32_t Frequency = 300'000'000; // PllAMult * Osc 12MHz

static bool inline
enable()
{
ClockGen::setFlashLatency<Frequency / 2>(); // Flash runs off MCK

ClockGen::enableMainInternal(MainInternalFreq::Rc12Mhz);
ClockGen::selectMainClockSource(MainClockSource::Internal);
ClockGen::enablePllA<PllAMult>();
ClockGen::selectMasterClk<MasterClkSource::PLLA_CLK, MasterClkPrescaler::CLK_1, MasterClkDivider::Div2>();
ClockGen::updateCoreFrequency<Frequency>();

return true;
}
};

using Led0 = GpioD17;
using Led1 = GpioD16;
using Led2 = GpioD15;

int
main()
{
WDT->WDT_MR = (WDT_MR_WDDIS_Msk); // turn off Watchdog

SystemClock::enable();
SysTickTimer::initialize<SystemClock>();

Led0::setOutput(false);
Led1::setOutput(true);
Led2::setOutput(false);

while (1)
{
Led0::toggle();
modm::delay(500ms);
}

return 0;
}
9 changes: 9 additions & 0 deletions examples/samv/blink/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source [find interface/jlink.cfg]
transport select swd

source [find target/atsamv.cfg]

# Set boot mode selection to Flash (instead of SAM-BA on ROM)
init
halt
atsamv gpnvm set 1
15 changes: 15 additions & 0 deletions examples/samv/blink/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<library>
<options>
<option name="modm:target">samv70n20b-aabt</option>
<option name="modm:build:build.path">../../../build/samv/blink</option>
<option name="modm:build:openocd.cfg">openocd.cfg</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:platform:core</module>
<module>modm:platform:clock</module>
<module>modm:platform:gpio</module>
<module>modm:architecture:delay</module>
<module>modm:platform:clockgen</module>
</modules>
</library>
2 changes: 1 addition & 1 deletion ext/microchip/sam
Submodule sam updated 216 files
3 changes: 1 addition & 2 deletions repo.lb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ class DevicesCache(dict):
"stm32h7",
"stm32l0", "stm32l1", "stm32l4",
"at90", "attiny", "atmega",
"samd21",
"samg55",
"samd21", "samg55", "samv70",
"hosted"]
device_file_names = [dfn for dfn in device_file_names if any(s in dfn for s in supported)]
# These files are ignored due to various issues
Expand Down
4 changes: 3 additions & 1 deletion src/modm/platform/clock/sam/gclk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ ClockGenerator : uint32_t
Internal8M = 3,
};

enum class ClockPeripheral : uint32_t {
enum class
ClockPeripheral : uint32_t
{
Dfll48 = GCLK_CLKCTRL_ID_DFLL48_Val,
Fdpll = GCLK_CLKCTRL_ID_FDPLL_Val,
Fdpll32K = GCLK_CLKCTRL_ID_FDPLL32K_Val,
Expand Down
Loading