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

Add support for SAMG devices #676

Merged
merged 1 commit into from
Sep 9, 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
6 changes: 5 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ jobs:
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py generic)
- name: Examples SAM Devices
- name: Examples SAMD Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py samd)
- name: Examples SAMG Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py samg55_xplained_pro)
- name: Execute Python Scripts
if: always()
run: |
Expand Down
27 changes: 24 additions & 3 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-->3172<!--/allcount--> devices of these vendors:
modm can create a HAL for <!--allcount-->3175<!--/allcount--> devices of these vendors:

- STMicroelectronics STM32: <!--stmcount-->2621<!--/stmcount--> devices.
- Microchip SAM: <!--samcount-->163<!--/samcount--> devices.
- Microchip SAM: <!--samcount-->166<!--/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="1">SAM</th>
<th align="center" colspan="2">SAM</th>
<th align="center" colspan="3">AT</th>
</tr><tr>
<th align="left">Peripheral</th>
Expand All @@ -113,6 +113,7 @@ 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">90</th>
<th align="center">Mega</th>
<th align="center">Tiny</th>
Expand All @@ -132,6 +133,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 @@ -149,6 +151,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 @@ -167,6 +170,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 @@ -186,6 +190,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 @@ -206,6 +211,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">Ethernet</td>
<td align="center">✗</td>
Expand All @@ -224,6 +230,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">External Interrupt</td>
<td align="center">✅</td>
Expand All @@ -242,6 +249,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">External Memory</td>
<td align="center">✗</td>
Expand All @@ -260,6 +268,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">GPIO</td>
<td align="center">✅</td>
Expand All @@ -278,6 +287,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 @@ -293,6 +303,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 @@ -314,6 +325,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">Random Generator</td>
<td align="center">✗</td>
Expand All @@ -332,6 +344,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">SPI</td>
<td align="center">✅</td>
Expand All @@ -347,6 +360,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 @@ -368,6 +382,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">Timer</td>
<td align="center">✅</td>
Expand All @@ -386,6 +401,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 @@ -401,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>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
Expand All @@ -422,6 +439,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">USB</td>
<td align="center">✅</td>
Expand All @@ -440,6 +458,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>
</table>
<!--/alltable-->
Expand Down Expand Up @@ -523,9 +542,11 @@ We have out-of-box support for many development boards including documentation.
<td align="center"><a href="https://modm.io/reference/module/modm-board-raspberrypi">Raspberry Pi</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-board-samd21-mini">SAMD21-MINI</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/module/modm-board-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32f030_demo">STM32F030-DEMO</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-board-srxe">Smart Response XE</a></td>
</tr><tr>
</tr>
</table>
<!--/bsptable-->
Expand Down
13 changes: 13 additions & 0 deletions examples/samg55_xplained_pro/blink/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "modm/board.hpp"

using namespace modm::platform;

int main() {
Board::initialize();

while(true) {
Board::Led::toggle();
modm::delay_ms(500);
}

}
9 changes: 9 additions & 0 deletions examples/samg55_xplained_pro/blink/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<library>
<extends>modm:samg55-xplained-pro</extends>
<options>
<option name="modm:build:build.path">../../../build/samg/blink</option>
</options>
<modules>
<module>modm:build:scons</module>
</modules>
</library>
21 changes: 15 additions & 6 deletions ext/microchip/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,35 @@ def prepare(module, options):
pp = {}
def validate(env):
device = env[":target"]
name = device.partname.split("-")[0]

# Some families use the variant in header defines, some do not (e.g. SAMG)
names = [
"".join([device.identifier[f] for f in ["platform", "family", "series", "pin", "flash", "variant"]]),
"".join([device.identifier[f] for f in ["platform", "family", "series", "pin", "flash"]]),
]

define = "__{}__".format(name.upper())
device_define = None
family_file = None
device_header = None
for famfile in Path(localpath("sam")).glob("**/sam.h"):
content = famfile.read_text(encoding="utf-8", errors="replace")
match = re.findall(r"defined\((?P<define>__SAM.*?__)\)", content)
if match is not None and define in match:
family_file = famfile.relative_to(localpath("."))
for n in names:
define = "__{}__".format(n.upper())
if match is not None and define in match:
family_file = famfile.relative_to(localpath("."))
device_header = "{}.h".format(n)
device_define = define


if family_file is None:
raise ValidateException("No device define found for '{}'!".format(device.partname))

family_folder = family_file.parent
device_header = "{}.h".format(name)

global pp
pp = {
"define": define,
"define": device_define,
"folder": family_folder,
"device_header": device_header,
}
Expand Down
2 changes: 1 addition & 1 deletion ext/microchip/sam
Submodule sam updated 253 files
1 change: 1 addition & 0 deletions repo.lb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class DevicesCache(dict):
"stm32l0", "stm32l1", "stm32l4",
"at90", "attiny", "atmega",
"samd21",
"samg55",
"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
55 changes: 55 additions & 0 deletions src/modm/board/samg55_xplained_pro/board.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2021, Jeff McBride
*
* 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/.
*/
// ----------------------------------------------------------------------------
#pragma once

#include <modm/platform.hpp>

/// @ingroup modm_board_samg55_xplained_pro
namespace Board
{
using namespace modm::literals;
using namespace modm::platform;

struct SystemClock
{
static constexpr uint32_t PllAMult = 3662;
static constexpr uint32_t Frequency = PllAMult * SlowClkFreqHz;
static bool inline
enable()
{
ClockGen::setFlashLatency<Frequency>();
ClockGen::updateCoreFrequency<Frequency>();
ClockGen::enableExternal32Khz(false);
ClockGen::enablePllA<PllAMult>();
ClockGen::selectMasterClk<MasterClkSource::PLLA_CLK, MasterClkPrescaler::CLK_1>();
return true;
}
};

using Led = GpioA6;
using Button = GpioA2;

inline void
initialize()
{
// Turn off the watchdog
WDT->WDT_MR = (WDT_MR_WDDIS_Msk);
salkinium marked this conversation as resolved.
Show resolved Hide resolved

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

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

Button::setInput();
}

} // namespace Board

14 changes: 14 additions & 0 deletions src/modm/board/samg55_xplained_pro/board.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<library>
<repositories>
<repository>
<path>../../../../repo.lb</path>
</repository>
</repositories>

<options>
<option name="modm:target">samg55j19a-au</option>
</options>
<modules>
<module>modm:board:samg55-xplained-pro</module>
</modules>
</library>
28 changes: 28 additions & 0 deletions src/modm/board/samg55_xplained_pro/module.lb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021, Jeff McBride
#
# 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/.
# -----------------------------------------------------------------------------

def init(module):
module.name = ":board:samg55-xplained-pro"
module.description = "Microchip SAMG55 Xplained Pro"

def prepare(module, options):
if not options[":target"].partname == "samg55j19a-au":
return False

module.depends(":platform:clockgen", ":platform:gpio", ":platform:core");
return True

def build(env):
env.outbasepath = "modm/src/modm/board"
env.copy('board.hpp')

# TODO: openocd config?
Loading