[riot-devel] Working on port to SODAQ Autonomo (SAMD21)

Kees Bakker kees at sodaq.com
Tue Jun 14 20:59:06 CEST 2016


As promissed ...

The final change to make it work was selecting the correct "mux". There
were a few hardcoded things in
* boards/samr21-xpro/include/periph_conf.h
* cpu/samd21/periph/uart.c

SAMR21_XPRO has the first serial connected to:
   RX - PA5
   TX - PA4
static const uart_conf_t uart_config[] = {
     /* device, RX pin, TX pin, mux */
     {&SERCOM0->USART, GPIO_PIN(PA,5), GPIO_PIN(PA,4), GPIO_MUX_D},


My SODAQ Autonomo board has the first serial connected to:
   RX - PA9
   TX - PA10
static const uart_conf_t uart_config[] = {
     /* device, RX pin, TX pin, mux */
     {&SERCOM0->USART, GPIO_PIN(PA,9), GPIO_PIN(PA,10), GPIO_MUX_C},

Is that all? No, welcome to the SERCOM world of ARM Cortex M0.
In cpu/sam???/periph/uart.c some changes are needed too. In the next 
diff, the samr21
is the "old" samd21.

--- cpu/samd21/periph/uart.c    2016-06-13 22:41:15.358773522 +0200
+++ cpu/samr21/periph/uart.c    2016-05-31 19:57:02.788554067 +0200
@@ -86,10 +86,9 @@
      /* reset the UART device */
      dev->CTRLA.reg = SERCOM_USART_CTRLA_SWRST;
      while (dev->SYNCBUSY.reg & SERCOM_USART_SYNCBUSY_SWRST) {}
-    /* set asynchronous mode w/o parity, LSB first, PAD2 to TX, PAD1 to 
RX, sample rate 16x and
+    /* set asynchronous mode w/o parity, LSB first, PAD0 to TX, PAD1 to 
RX and
       * use internal clock */
      dev->CTRLA.reg = (SERCOM_USART_CTRLA_DORD |
-                      SERCOM_USART_CTRLA_TXPO(0x1) |
                        SERCOM_USART_CTRLA_RXPO(0x1) |
                        SERCOM_USART_CTRLA_SAMPR(0x1) |
                        SERCOM_USART_CTRLA_MODE_USART_INT_CLK);


Notice the TXPO and RXPO. These indicate which "pads" the pin can use on 
a certain SERCOM.
So, what we can learn from this is that we need to expand uart_conf_t. 
We need PAD configuration
too. (BTW, Arduino Core is doing similar things.)

Was this a TL;DR? Sorry about it then.
-- Kees


On 13-06-16 23:28, Peter Kietzmann wrote:
> Congrats! Looking forward to hear the trick that did it :-).
>
> Good night
> Peter
>
> Am 13.06.2016 um 23:21 schrieb Kees Bakker:
>> On 13-06-16 20:55, Kees Bakker wrote:
>>>
>>> That is more or less already what I did. I filled in uart_config[]
>>> with two devices
>>> and I have a serial line connect to my PC. This configuration works
>>> with the Arduino
>>> setup. But not yet with RIOT.
>>
>> I almost gave up ..., but then ...
>>
>> �main(): This is RIOT! (Version:
>> 2016.07-devel-191-g42127-rapper-sodaq-autonomo)
>> Hello World!
>> You are running RIOT on a(n) sodaq-autonomo board.
>> This board features a(n) samd21 MCU.
>>
>> Yeah, it's working. Well, hello world is.
>> (( It's getting too late now. I'll explain later this week what was
>> needed to make it work. ))
>>
>


-- 
Kees Bakker
Founder
SODAQ
M. 0031617737165
www.sodaq.com



More information about the devel mailing list