Update to the latest samd platform api.

Also, set additional binary linker output for ctl project.
M .hgsubstate +1 -1
@@ 1,1 1,1 @@ 
-54c6c425a4d04da8e03a0d69e76bb42a4562f71b targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib
+d3ecd938cdf6c8862261f1899f44eaeedd938312 targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib

          
M adafruit-feather-m0-basic-template.hzp +32 -27
@@ 18,36 18,41 @@ 
       <file file_name="targets/Adafruit_Feather_M0_Basic/FeatherM0_MemoryMap.xml" />
     </folder>
     <folder Name="Peripherals">
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_common.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_eic.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_eic.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_gpio.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_gpio.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_rtc.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_rtc.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_wdt.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_wdt.h" />
       <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/LICENSE.txt" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_clocks.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_clocks.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_i2c.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_i2c.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_sercom.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_sercom.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_spi.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_spi.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_uart.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_uart.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_clocks.h" />
       <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/numeric_utils.c" />
       <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/numeric_utils.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tc.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tc.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_adc.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_adc.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tickless_idle.c" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tickless_idle.h" />
-      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_sleep.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_adc.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_adc.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_clocks.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_clocks.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_common.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_devinfo.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_devinfo.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_dma.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_dma.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_eic.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_eic.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_gpio.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_gpio.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_i2c.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_i2c.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_nvm.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_nvm.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_rtc.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_rtc.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_sercom.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_sercom.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_sleep.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_spi.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_spi.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tc.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tc.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tickless_idle.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tickless_idle.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_uart.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_uart.h" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_wdt.c" />
+      <file file_name="targets/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_wdt.h" />
     </folder>
     <folder Name="Other Files">
       <file file_name="README.rst" />

          
M packages/Adafruit_Feather_M0_Basic_package.xml +4 -1
@@ 1,6 1,9 @@ 
 <!DOCTYPE CrossStudio_Package_Description_File>
-<package crossstudio_versions="8:3-" build_version="2015121603.1134011344;crossworks_v3;crossworks_v3" dependencies="SAM_D" board_name="Feather M0 Basic board" cpu_manufacturer="Atmel" version="1.1" author="Tero Koskinen" replaces="" board_manufacturer="Adafruit" cpu_name="ATSAMD21G18A" cpu_family="" name="Adafruit_Feather_M0_Basic" filetype="hzq" >
+<package crossstudio_versions="8:3-" build_version="2015121603.1134011344;crossworks_v3;crossworks_v3" dependencies="SAM_D" board_name="Feather M0 Basic board" cpu_manufacturer="Atmel" version="1.2" author="Tero Koskinen" replaces="" board_manufacturer="Adafruit" cpu_name="ATSAMD21G18A" cpu_family="" name="Adafruit_Feather_M0_Basic" filetype="hzq" >
   <history>
+    <version name="1.2" >
+      <description>SAMD2x CTL peripheral library updated to the new version.</description>
+    </version>
     <version name="1.1" >
       <description>FreeRTOS template. SAMD2x CTL peripheral library updated.</description>
     </version>

          
M targets/Adafruit_Feather_M0_Basic/ctl_board.c +11 -11
@@ 12,11 12,11 @@ 
 #include <debugio.h>
 #include <ctl_api.h>
 
-#include "platform_atmel_d21_i2c.h"
-#include "platform_atmel_d21_spi.h"
-#include "platform_atmel_d21_uart.h"
-#include "d2x_gpio.h"
-#include "d2x_eic.h"
+#include "platform_samd_i2c.h"
+#include "platform_samd_spi.h"
+#include "platform_samd_uart.h"
+#include "platform_samd_gpio.h"
+#include "platform_samd_eic.h"
 #include "pin_mapping.h"
 
 #define SERCOM_MISO_PAD_0 0

          
@@ 142,15 142,15 @@ ctl_board_init(void)
   CTL_UART_t *uart, *uart5;
   CTL_SPI_BUS_t *spi_bus;
 
-  d21_uart_set_pin_config(adafruit_uarts, 6);
-  d21_spi_set_pin_config(adafruit_m0_spis, ADAFRUIT_M0_SPI_AMOUNT);
-  d2x_eic_init();
+  samd_uart_set_pin_config(adafruit_uarts, 6);
+  samd_spi_set_pin_config(adafruit_m0_spis, ADAFRUIT_M0_SPI_AMOUNT);
+  samd_eic_init();
 
   // SCL & SDA pins on the Feather board.
-  d21_configure_i2c_bus(3, 100000);
+  samd_configure_i2c_bus(3, 100000);
 
   // Polled uart0, pins 0 (RX) and 1 (TX) on Feather M0
-  uart = d21_uart(0);
+  uart = samd_uart(0);
   ctl_uart_init(uart, NULL, NULL);
   ctl_uart_set_baud(uart, 9600);
   ctl_uart_puts(uart, "board initialized\r\n");

          
@@ 173,7 173,7 @@ void
 ctl_board_on_button_pressed(CTL_ISR_FN_t isr)
 {
   gpio_set_extint(SAMD_PORT(ARDUINO_D5), SAMD_PIN(ARDUINO_D5), false);
-  d2x_eic_enable_int(15, false, SENSE_EDGE_FALLING, button_press, isr);
+  samd_eic_enable_int(15, false, SENSE_EDGE_FALLING, button_press, isr);
 }
 
 void

          
M targets/Adafruit_Feather_M0_Basic/m0_main_ctl.c +7 -6
@@ 27,8 27,8 @@ 
 #include <ctl_api.h>
 
 #include "libdevice/ctl_uart.h"
-#include "platform_atmel_d21_uart.h"
-#include "d2x_tickless_idle.h"
+#include "platform_samd_uart.h"
+#include "platform_samd_tickless_idle.h"
 
 CTL_TASK_t main_task, led_task;
 

          
@@ 39,7 39,7 @@ void
 led_task_code(void *p)
 {
   unsigned int v=0;
-  CTL_UART_t *uart = d21_uart(0);
+  CTL_UART_t *uart = samd_uart(0);
 
   ctl_uart_puts(uart, "led_task_code started\r\n");
   while (1)

          
@@ 62,7 62,7 @@ int main(void)
   unsigned int v=0;
   ctl_task_init(&main_task, 255, "main"); // create subsequent tasks whilst running at the highest priority.
 
-  d2x_setup_tick();
+  samd_setup_tick(); // Use timer 3 for tick (not systick)
 
   ctl_board_init();
   ctl_board_set_leds(1);

          
@@ 73,8 73,9 @@ int main(void)
   ctl_task_set_priority(&main_task, 0); // drop to lowest priority to start created tasks running.
   while (1)
     {
-      // tickless idle mode
-      d2x_deep_sleep(ctl_get_sleep_delay());
+      // tickless idle mode.
+      // samd_deep_sleep puts mcu into standby mode in Release build and into idle0 mode in Debug build
+      samd_deep_sleep(ctl_get_sleep_delay());
     }
   return 0;
 }

          
M targets/Adafruit_Feather_M0_Basic/pin_mapping.h +1 -1
@@ 1,7 1,7 @@ 
 #ifndef PIN_MAPPING_H
 #define PIN_MAPPING_H
 
-#include "d2x_gpio.h"
+#include "platform_samd_gpio.h"
 
 #define ARDUINO_D0    SAMD_PAD(0, 11)  // sercom 0 rx
 #define ARDUINO_D1    SAMD_PAD(0, 10)  // sercom 0 tx

          
M targets/Adafruit_Feather_M0_Basic/project_templates_Adafruit_Feather_M0_Basic.xml +27 -27
@@ 19,7 19,7 @@ 
     <property name="target_trace_initialize_script" value="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
     <property name="arm_target_interface_type" value="SWD" />
     <property name="gcc_entry_point" value="Reset_Handler" />
-    <property name="linker_output_format" />
+    <property name="linker_output_format" value="bin" />
     <property name="linker_printf_fmt_level" />
     <property name="linker_printf_width_precision_supported" />
     <property name="linker_printf_fp_enabled" />

          
@@ 140,7 140,7 @@ 
     <property name="target_trace_initialize_script" value="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
     <property name="arm_target_interface_type" value="SWD" />
     <property name="gcc_entry_point" value="Reset_Handler" />
-    <property name="linker_output_format" />
+    <property name="linker_output_format" value="bin" />
     <property name="linker_printf_fmt_level" />
     <property name="linker_printf_width_precision_supported" />
     <property name="linker_printf_fp_enabled" />

          
@@ 173,33 173,33 @@ 
       <file name="pin_mapping.h" source="$(TargetsDir)/Adafruit_Feather_M0_Basic/pin_mapping.h"/>
     </folder>
     <folder name="Peripherals">
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_common.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_clocks.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_uart.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_uart.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_spi.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_spi.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_i2c.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_i2c.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_sercom.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_sercom.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_clocks.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_atmel_d21_clocks.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_gpio.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_gpio.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_eic.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_eic.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_adc.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_adc.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_rtc.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_rtc.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tc.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tc.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_common.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_clocks.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_uart.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_uart.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_spi.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_spi.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_i2c.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_i2c.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_sercom.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_sercom.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_clocks.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_clocks.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_gpio.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_gpio.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_eic.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_eic.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_adc.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_adc.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_rtc.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_rtc.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tc.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tc.h" expand="no"/>
       <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/numeric_utils.h" expand="no"/>
       <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/numeric_utils.c" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_sleep.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tickless_idle.h" expand="no"/>
-      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/d2x_tickless_idle.c" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_sleep.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tickless_idle.h" expand="no"/>
+      <file name="$(TargetsDir)/Adafruit_Feather_M0_Basic/samd2x-peripheral-lib/platform_samd_tickless_idle.c" expand="no"/>
     </folder>
     <folder name="System Files">
       <file name="$(StudioDir)/source/thumb_crt0.s" expand="no">