Skip to content

Commit

Permalink
[sam] Adapt to new family naming scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand committed Aug 22, 2022
1 parent 635f226 commit 27b972a
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 81 deletions.
54 changes: 38 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ git clone --recurse-submodules --jobs 8 https://github.com/modm-io/modm.git

## Microcontrollers

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

- STMicroelectronics STM32: <!--stmcount-->2729<!--/stmcount--> devices.
- Microchip SAM: <!--samcount-->186<!--/samcount--> devices.
- Microchip SAM: <!--samcount-->416<!--/samcount--> devices.
- Microchip AVR: <!--avrcount-->388<!--/avrcount--> devices.
- Raspberry Pi: <!--rpicount-->1<!--/rpicount--> device.

Expand All @@ -101,7 +101,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<tr>
<th align="center"></th>
<th align="center" colspan="13">STM32</th>
<th align="center" colspan="3">SAM</th>
<th align="center" colspan="4">SAM</th>
<th align="center" colspan="1">RP</th>
<th align="center" colspan="3">AT</th>
</tr><tr>
Expand All @@ -119,9 +119,10 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<th align="center">L1</th>
<th align="center">L4</th>
<th align="center">L5</th>
<th align="center">D21</th>
<th align="center">G55</th>
<th align="center">V70</th>
<th align="center">D1x/D2x/DAx</th>
<th align="center">D5x/E5x</th>
<th align="center">E7x/S7x/V7x</th>
<th align="center">G5x</th>
<th align="center">20</th>
<th align="center">90</th>
<th align="center">Mega</th>
Expand All @@ -142,8 +143,9 @@ 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>
<td align="center">✅</td>
Expand All @@ -164,9 +166,10 @@ 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>
<td align="center">○</td>
<td align="center">✕</td>
Expand All @@ -186,9 +189,10 @@ 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>
<td align="center">○</td>
<td align="center">○</td>
Expand All @@ -208,8 +212,9 @@ 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>
<td align="center">○</td>
Expand All @@ -230,8 +235,9 @@ 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>
<td align="center">✕</td>
Expand All @@ -252,7 +258,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 @@ -276,6 +283,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 @@ -298,6 +306,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 @@ -324,6 +333,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 @@ -342,6 +352,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 @@ -364,6 +375,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 @@ -384,12 +396,13 @@ 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>
<td align="center">✕</td>
<td align="center">✕</td>
</tr><tr>
<td align="left">SPI</td>
<td align="center">✅</td>
Expand All @@ -406,12 +419,13 @@ 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>
<td align="center">✅</td>
<td align="center">✅</td>
</tr><tr>
<td align="left">System Clock</td>
<td align="center">✅</td>
Expand All @@ -431,6 +445,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 @@ -450,9 +465,10 @@ 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>
<td align="center">○</td>
<td align="center">○</td>
Expand All @@ -477,6 +493,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">Unique ID</td>
Expand All @@ -500,6 +517,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 @@ -519,6 +537,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 Expand Up @@ -611,12 +630,15 @@ We have out-of-box support for many development boards including documentation.
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-same54-xplained-pro">SAME54-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-srxe">Smart Response XE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
</tr><tr>
</tr>
</table>
<!--/bsptable-->
Expand Down
4 changes: 2 additions & 2 deletions ext/microchip/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def validate(env):

# 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"]]),
"".join([device.identifier[f] for f in ["platform", "series", "pin", "flash", "variant"]]),
"".join([device.identifier[f] for f in ["platform", "series", "pin", "flash"]]),
]

device_define = None
Expand Down
10 changes: 5 additions & 5 deletions src/modm/platform/clock/sam_pmc/clockgen.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ ClockGen::masterClkFrequency()
return mainClkFrequency() / div;
case MasterClkSource::PLLA_CLK:
return pllAFrequency() / div;
%% if target.family in ["g"]
%% if target.family == "g5x"
case MasterClkSource::PLLB_CLK:
return pllBFrequency() / div;
%% elif target.series[0] == "7"
%% elif target.family == "e7x/s7x/v7x"
case MasterClkSource::UPLL_CLK:
return 240'000'000; // UPLLDIV2
%% endif
Expand Down Expand Up @@ -112,10 +112,10 @@ uint32_t
ClockGen::pllAFrequency()
{
uint32_t mul = ((PMC->CKGR_PLLAR & CKGR_PLLAR_MULA_Msk) >> CKGR_PLLAR_MULA_Pos) + 1;
%% if target.family in ["g"]
%% if target.family == "g5x"
uint32_t freq = SlowClkFreqHz * mul;
if(PMC->PMC_MCKR & PMC_MCKR_PLLADIV2) freq /= 2;
%% elif target.series[0] == "7"
%% elif target.family == "e7x/s7x/v7x"
uint32_t freq = mainClkFrequency() * mul;
const auto diva = ((PMC->CKGR_PLLAR & CKGR_PLLAR_DIVA_Msk) >> CKGR_PLLAR_DIVA_Pos);
if (diva == 0) return 0; // PLLA is disabled
Expand All @@ -124,7 +124,7 @@ ClockGen::pllAFrequency()
return freq;
}

%% if target.family in ["g"]
%% if target.family == "g5x"
uint32_t
ClockGen::pllBFrequency()
{
Expand Down
18 changes: 9 additions & 9 deletions src/modm/platform/clock/sam_pmc/clockgen.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ MasterClkSource : uint32_t
SLOW_CLK = PMC_MCKR_CSS_SLOW_CLK_Val,
MAIN_CLK = PMC_MCKR_CSS_MAIN_CLK_Val,
PLLA_CLK = PMC_MCKR_CSS_PLLA_CLK_Val,
%% if target.family in ["g"]
%% if target.family == "g5x"
PLLB_CLK = PMC_MCKR_CSS_PLLB_CLK_Val,
%% elif target.series[0] == "7"
%% elif target.family == "e7x/s7x/v7x"
UPLL_CLK = PMC_MCKR_CSS_UPLL_CLK_Val,
%% endif
};
Expand All @@ -60,7 +60,7 @@ enum class
MasterClkDivider : uint8_t
{
Div1 = 0,
%% if target.series[0] == "7"
%% if target.family == "e7x/s7x/v7x"
Div2 = PMC_MCKR_MDIV_PCK_DIV2_Val,
Div4 = PMC_MCKR_MDIV_PCK_DIV4_Val,
Div3 = PMC_MCKR_MDIV_PCK_DIV3_Val,
Expand Down Expand Up @@ -123,7 +123,7 @@ ClockPeripheral : uint32_t
Tc10 = ID_TC3_CHANNEL1,
Tc11 = ID_TC3_CHANNEL2,
#endif
%% if target.family in ["g"]
%% if target.family == "g5x"
Pdmic0 = ID_PDMIC0,
Pdmic1 = ID_PDMIC1,
Mem2Mem = ID_MEM2MEM,
Expand All @@ -139,7 +139,7 @@ ClockPeripheral : uint32_t
Flexcom5 = ID_FLEXCOM5,
Flexcom6 = ID_FLEXCOM6,
Flexcom7 = ID_FLEXCOM7,
%% elif target.series[0] == "7"
%% elif target.family == "e7x/s7x/v7x"
Xdmac = ID_XDMAC,
#ifdef ID_UART0
Uart0 = ID_UART0,
Expand Down Expand Up @@ -216,7 +216,7 @@ ClockPeripheral : uint32_t
%% endif
};

%% if target.series[0] == "7"
%% if target.family == "e7x/s7x/v7x"
enum class
UtmiRefClk : uint32_t
{
Expand Down Expand Up @@ -277,13 +277,13 @@ public:
static void
enablePllA(uint32_t wait_cycles = 50);

%% if target.family in ["g"]
%% if target.family == "g5x"
template<uint32_t multiplier>
static void
enablePllB(uint32_t wait_cycles = 50);
%% endif

%% if target.series[0] == "7"
%% if target.family == "e7x/s7x/v7x"
template<UtmiRefClk refclk>
static void
enableUPll(uint32_t wait_cycles = 50);
Expand Down Expand Up @@ -314,7 +314,7 @@ public:
static uint32_t
pllAFrequency();

%% if target.family in ["g"]
%% if target.family == "g5x"
/** Returns the configured frequency of PLL B output */
static uint32_t
pllBFrequency();
Expand Down
Loading

0 comments on commit 27b972a

Please sign in to comment.