Close

First tests

A project log for Sam DEV

Arduino Nano style board for Atmel's SAM D20 / D21 ARM microcontrollers

ethonEthon 11/16/2015 at 15:060 Comments

After an while we received most of the components and soldered them all together. Now we are testing some of the basic functions and die IO's of the board.

At the picture you can see the first test, to toggle a LED with a button by using ASF.

Code:

#include <asf.h>
#define LED PIN_PA08
#define BUTTON PIN_PA09

void stepup_pins(void)
{
    struct port_config pin_conf; // create struct
    pin_conf.direction = PORT_PIN_DIR_INPUT; // set to input
    pin_conf.input_pull = PORT_PIN_PULL_UP; // set to pullup
    pin_conf.powersave = false; // set not to powersave
    port_pin_set_config(BUTTON, &pin_conf); // configure pin PAxx
    pin_conf.direction = PORT_PIN_DIR_OUTPUT; // set to output
    pin_conf.input_pull = PORT_PIN_PULL_NONE; // set not to pullup
    pin_conf.powersave = false; // set not to powersave
    port_pin_set_config(LED, &pin_conf); // configure pin PAxx
}

void main(void)
{
    system_init();
    stepup_pins();

    while (true) 
    {
        bool pin_state = true;
        pin_state = port_pin_get_input_level(BUTTON);
        port_pin_set_output_level(LED, !pin_state);

    }
}

Discussions