[bsp][mchp][samd51] re-config uart0, remove dma, and fix some error

This commit is contained in:
阿基米东 2023-09-22 18:06:18 +08:00 committed by guo
parent 9795b51b97
commit b1b66dd195
24 changed files with 82 additions and 491 deletions

View File

@ -1054,8 +1054,8 @@ CONFIG_RT_USING_KTIME=y
#
# Hardware Drivers Config
#
CONFIG_SOC_SAMD51J19=y
# CONFIG_SOC_SAMD51P19 is not set
# CONFIG_SOC_SAMD51J19 is not set
CONFIG_SOC_SAMD51P19=y
# CONFIG_SOC_SAME54P20 is not set
# CONFIG_SOC_SAME54N20 is not set
# CONFIG_SOC_SAME53J20 is not set

View File

@ -1,13 +1,15 @@
# SAMD51J19A Adafruit Metro M4 BSP Introduction
# Seeed Wio-Terminal BSP Introduction
[中文](README_zh.md)
[中文](README_zh.md)
- MCU: ATSAMD51J19A @120MHz, 512KB FLASH, 192KB RAM
![](https://static.getiot.tech/WioT-Hardware-Overview.png)
- MCU: ATSAMD51P19A @120MHz, 512KB FLASH, 192KB RAM
- D51: Cortex-M4F + Adavanced Feature Set
- Pin: G=48 pins, J=64 pins, N=100 pins, P=128 pins
- Flash: 18=256KB, 19=512KB, 20=1024KB (size=2^n)
- SRAM : 128KB(Flash 256KB), 192KB(Flash 512KB), 256KB(Flash 1MB)
- Datasheet: <https://www.microchip.com/en-us/product/ATSAMD51J19>
- Datasheet: <https://www.microchip.com/en-us/product/ATSAMD51P19>
#### KEY FEATURES
@ -18,8 +20,9 @@
#### Memories
- 1 MB/512 KB/256 KB in-system self-programmable Flash with:
- Error Correction Code (ECC)
- Dual bank with Read-While-Write (RWW) support
- Error Correction Code (ECC)
- Dual bank with Read-While-Write (RWW) support
- EEPROM hardware emulation
- 128 KB, 192 KB, 256 KB SRAM main memory
- 64 KB, 96 KB, 128 KB of Error Correction Code (ECC) RAM option
@ -114,7 +117,7 @@
#### Board info
- [Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382)
- [Wio Terminal: ATSAMD51 Core with Realtek RTL8720DN BLE 5.0 & Wi-Fi Dev Board](https://www.seeedstudio.com/Wio-Terminal-p-4509.html)
#### Contact Info

View File

@ -1,25 +1,28 @@
# SAMD51J19A Adafruit Metro M4 BSP 介绍
# Seeed Wio-Terminal BSP 介绍
[English](README.md)
- MCU: ATSAMD51J19A @120MHz, 512KB FLASH, 192KB RAM
- D51: Cortex-M4F + Adavanced Feature Set
- 管脚: G系列-48 pins, J系列-64 pins, N系列-100 pins, P系列-128 pins
- Flash: 尾缀18=256KB, 19=512KB, 20=1024KB (size=2^n)
- SRAM : 128KB(Flash 256KB), 192KB(Flash 512KB), 256KB(Flash 1MB)
- 手册: <https://www.microchip.com/en-us/product/ATSAMD51J19>
![](https://static.getiot.tech/WioT-Hardware-Overview.png)
- MCUATSAMD51P19A @120MHz512KB FLASH192KB RAM
- D51Cortex-M4F + Adavanced Feature Set
- 管脚G 系列-48 pinsJ 系列-64 pinsN 系列-100 pinsP 系列-128 pins
- Flash尾缀 18=256KB, 19=512KB, 20=1024KBsize=2^n
- SRAM128KBFlash 256KB192KBFlash 512KB256KBFlash 1MB
- 手册:<https://www.microchip.com/en-us/product/ATSAMD51P19>
#### 关键特性
#### 内核
- 32-bit Arm® Cortex®-M4 内核 + 单精度FPU + 4 KB 复用的指令和数据Cache最大工作主频120 MHz, 带MPU, 403 CoreMark®@120 MHz, 支持 DSP指令集
- 32-bit Arm® Cortex®-M4 内核 + 单精度 FPU + 4 KB 复用的指令和数据 Cache最大工作主频 120 MHz带MPU403 CoreMark®@120 MHz支持 DSP 指令集
#### 内存
- 1 MB/512 KB/256 KB in-system self-programmable Flash with:
- Error Correction Code (ECC)
- Dual bank with Read-While-Write (RWW) support
- Error Correction Code (ECC)
- Dual bank with Read-While-Write (RWW) support
- EEPROM hardware emulation
- 128 KB, 192 KB, 256 KB SRAM main memory
- 64 KB, 96 KB, 128 KB of Error Correction Code (ECC) RAM option
@ -97,7 +100,7 @@
#### I/O管脚
- 最多提供99个用户可编程I/O管脚
- 最多提供 99 个用户可编程 I/O 管脚
#### 汽车应用
@ -114,7 +117,7 @@
#### 开发板信息
- [Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382)
- [Wio Terminal: ATSAMD51 Core with Realtek RTL8720DN BLE 5.0 & Wi-Fi Dev Board](https://www.seeedstudio.com/Wio-Terminal-p-4509.html)
#### 联系方式

View File

@ -21,18 +21,19 @@ extern int rt_hw_uart_init(void);
#endif
static struct io_descriptor* g_stdio;
static uint8_t board_info[48] = "Seeed Wio-Terminal, Microchip SAMD51\n";
static uint8_t board_info[24] = "Seeed Wio-Terminal\r\n"; // Microchip SAMD51
void rt_hw_console_output(const char *str)
{
io_write(g_stdio, (uint8_t *)str, strlen(str));
while (TARGET_IO.stat != 0);
}
RTM_EXPORT(rt_hw_console_output);
static inline void hw_board_init_usart(void)
{
usart_sync_get_io_descriptor(&TARGET_IO, &g_stdio);
usart_sync_enable(&TARGET_IO);
usart_async_get_io_descriptor(&TARGET_IO, &g_stdio);
usart_async_enable(&TARGET_IO);
io_write(g_stdio, board_info, strlen(board_info));
}

View File

@ -75,7 +75,7 @@ extern int __bss_end;
#ifdef RT_USING_SERIAL
#include "hpl_sercom_config.h"
#define DEFAULT_USART_BAUD_RATE CONF_SERCOM_3_USART_BAUD_RATE
#define DEFAULT_USART_BAUD_RATE CONF_SERCOM_2_USART_BAUD_RATE
#endif
void rt_hw_board_init(void);

View File

@ -132,9 +132,6 @@
<file category="header" condition="ARMCC, GCC, IAR" name="hri/hri_trng_d51.h"/>
<file category="header" condition="ARMCC, GCC, IAR" name="hri/hri_usb_d51.h"/>
<file category="header" condition="ARMCC, GCC, IAR" name="hri/hri_wdt_d51.h"/>
<file category="source" condition="ARMCC, GCC, IAR" name="dma_m2m/dma_memory.c"/>
<file category="header" condition="ARMCC, GCC, IAR" name="dma_m2m/dma_memory.h"/>
<file category="doc" condition="ARMCC, GCC, IAR" name="documentation/dma_m2m.rst"/>
<file category="doc" condition="ARMCC, GCC, IAR" name="documentation/usb_device_cdc.rst"/>
<file category="doc" condition="ARMCC, GCC, IAR" name="documentation/usb_device_core.rst"/>
<file category="doc" condition="ARMCC, GCC, IAR" name="documentation/usb_protocol_cdc.rst"/>
@ -186,8 +183,6 @@
<file category="source" condition="ARMCC, GCC, IAR" name="hpl/ramecc/hpl_ramecc.c"/>
<file category="source" condition="ARMCC, GCC, IAR" name="hpl/sercom/hpl_sercom.c"/>
<file category="source" condition="ARMCC, GCC, IAR" name="hpl/usb/hpl_usb.c"/>
<file category="source" condition="ARMCC, GCC, IAR" name="dma_m2m_main.c"/>
<file category="header" condition="ARMCC, GCC, IAR" name="dma_m2m_main.h"/>
<file category="source" condition="ARMCC, GCC, IAR" name="usb_start.c"/>
<file category="header" condition="ARMCC, GCC, IAR" name="usb_start.h"/>
<file category="header" condition="ARMCC, GCC, IAR" name="atmel_start.h"/>
@ -202,7 +197,6 @@
<file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/hpl_sercom_config.h"/>
<file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/hpl_usb_config.h"/>
<file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/peripheral_clk_config.h"/>
<file attr="config" category="header" condition="ARMCC, GCC, IAR" name="dma_m2m/dma_memory_config.h"/>
<file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/usbd_config.h"/>
<file category="include" condition="ARMCC, GCC, IAR" name=""/>
<file category="include" condition="ARMCC, GCC, IAR" name="config"/>
@ -223,8 +217,6 @@
<file category="include" condition="ARMCC, GCC, IAR" name="hpl/usb"/>
<file category="include" condition="ARMCC, GCC, IAR" name="hri"/>
<file category="include" condition="ARMCC, GCC, IAR" name=""/>
<file category="include" condition="ARMCC, GCC, IAR" name="dma_m2m"/>
<file category="include" condition="ARMCC, GCC, IAR" name=""/>
<file category="include" condition="ARMCC, GCC, IAR" name="config"/>
<file category="include" condition="ARMCC, GCC, IAR" name="usb"/>
<file category="include" condition="ARMCC, GCC, IAR" name="usb/class/cdc"/>

View File

@ -16,12 +16,10 @@ src = Glob('hal/src/*.c')
src += Glob('hal/utils/src/*.c')
# src += Glob('hpl/adc/*.c')
# src += Glob('hpl/aes/*.c')
# src += Glob('hpl/can/*.c')
src += Glob('hpl/cmcc/*.c')
src += Glob('hpl/core/*.c')
src += Glob('hpl/dmac/*.c')
src += Glob('hpl/gclk/*.c')
# src += Glob('hpl/gmac/*.c')
src += Glob('hpl/mclk/*.c')
src += Glob('hpl/osc32kctrl/*.c')
src += Glob('hpl/oscctrl/*.c')
@ -30,15 +28,12 @@ src += Glob('hpl/port/*.c')
src += Glob('hpl/ramecc/*.c')
src += Glob('hpl/sercom/*.c')
src += Glob('hpl/usb/*.c')
src += Glob('stdio_redirect/*.c')
# src += Glob('ethernet_phy/*.c')
src += Glob('hpl/usb/*.c')
src += Glob('usb/*.c')
src += Glob('usb/device/*.c')
src += Glob('usb/class/cdc/device/*.c')
src += [cwd + '/atmel_start.c']
src += [cwd + '/driver_init.c']
src += [cwd + '/stdio_start.c']
src += [cwd + '/usb_start.c']
#add for startup script
@ -59,7 +54,6 @@ path = [
cwd + '/hal/include',
cwd + '/hal/utils/include',
# cwd + '/hpl/adc',
# cwd + '/hpl/can',
cwd + '/hpl/core',
cwd + '/hpl/gclk',
cwd + '/hpl/pm',
@ -71,7 +65,6 @@ path = [
cwd + '/usb/class/cdc/device',
cwd + '/usb/device',
cwd + '/samd51a/include',
cwd + '/stdio_redirect',
cwd + '/../board',
cwd + '/../../common/applications'
]

View File

@ -33,7 +33,6 @@ samd51a/armcc/Device/SAMD51/Source \
hpl/ramecc \
hpl/dmac \
usb/class/cdc/device \
dma_m2m \
hal/src \
hpl/mclk \
usb \
@ -52,12 +51,11 @@ hpl/cmcc
OBJS += \
hal/src/hal_io.o \
hpl/core/hpl_core_m4.o \
dma_m2m/dma_memory.o \
usb/class/cdc/device/cdcdf_acm.o \
samd51a/armcc/Device/SAMD51/Source/ARM/startup_samd51.o \
usb_start.o \
hpl/usb/hpl_usb.o \
samd51a/armcc/Device/SAMD51/Source/system_samd51.o \
usb/class/cdc/device/cdcdf_acm.o \
hal/src/hal_delay.o \
hpl/pm/hpl_pm.o \
hpl/core/hpl_init.o \
@ -71,14 +69,13 @@ hpl/ramecc/hpl_ramecc.o \
usb/usb_protocol.o \
hal/src/hal_init.o \
hal/src/hal_usb_device.o \
dma_m2m_main.o \
main.o \
hpl/osc32kctrl/hpl_osc32kctrl.o \
examples/driver_examples.o \
driver_init.o \
hal/src/hal_usart_async.o \
hpl/sercom/hpl_sercom.o \
hal/utils/src/utils_ringbuffer.o \
main.o \
hal/src/hal_gpio.o \
hal/utils/src/utils_event.o \
hal/src/hal_sleep.o \
@ -91,12 +88,11 @@ hal/src/hal_atomic.o
OBJS_AS_ARGS += \
"hal/src/hal_io.o" \
"hpl/core/hpl_core_m4.o" \
"dma_m2m/dma_memory.o" \
"usb/class/cdc/device/cdcdf_acm.o" \
"samd51a/armcc/Device/SAMD51/Source/ARM/startup_samd51.o" \
"usb_start.o" \
"hpl/usb/hpl_usb.o" \
"samd51a/armcc/Device/SAMD51/Source/system_samd51.o" \
"usb/class/cdc/device/cdcdf_acm.o" \
"hal/src/hal_delay.o" \
"hpl/pm/hpl_pm.o" \
"hpl/core/hpl_init.o" \
@ -110,14 +106,13 @@ OBJS_AS_ARGS += \
"usb/usb_protocol.o" \
"hal/src/hal_init.o" \
"hal/src/hal_usb_device.o" \
"dma_m2m_main.o" \
"main.o" \
"hpl/osc32kctrl/hpl_osc32kctrl.o" \
"examples/driver_examples.o" \
"driver_init.o" \
"hal/src/hal_usart_async.o" \
"hpl/sercom/hpl_sercom.o" \
"hal/utils/src/utils_ringbuffer.o" \
"main.o" \
"hal/src/hal_gpio.o" \
"hal/utils/src/utils_event.o" \
"hal/src/hal_sleep.o" \
@ -131,15 +126,13 @@ OBJS_AS_ARGS += \
DEPS := $(OBJS:%.o=%.d)
DEPS_AS_ARGS += \
"usb/class/cdc/device/cdcdf_acm.d" \
"hal/utils/src/utils_event.d" \
"hal/src/hal_io.d" \
"hpl/ramecc/hpl_ramecc.d" \
"hpl/core/hpl_core_m4.d" \
"dma_m2m/dma_memory.d" \
"usb/class/cdc/device/cdcdf_acm.d" \
"samd51a/armcc/Device/SAMD51/Source/system_samd51.d" \
"hpl/usb/hpl_usb.d" \
"main.d" \
"samd51a/armcc/Device/SAMD51/Source/ARM/startup_samd51.d" \
"hal/utils/src/utils_list.d" \
"hpl/cmcc/hpl_cmcc.d" \
@ -157,7 +150,7 @@ DEPS_AS_ARGS += \
"driver_init.d" \
"hal/src/hal_usart_async.d" \
"hpl/osc32kctrl/hpl_osc32kctrl.d" \
"dma_m2m_main.d" \
"main.d" \
"examples/driver_examples.d" \
"hal/src/hal_cache.d" \
"hal/src/hal_sleep.d" \
@ -203,7 +196,7 @@ $(OBJS_AS_ARGS)
@echo Building file: $<
@echo ARMCC Compiler
$(QUOTE)armcc$(QUOTE) --c99 -c -DDEBUG -O1 -g --apcs=interwork --split_sections --cpu Cortex-M4 -D__SAMD51P19A__ \
-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../dma_m2m" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Core/Include" -I"../samd51a/include" \
-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Core/Include" -I"../samd51a/include" \
--depend "$@" -o "$@" "$<"
@echo Finished building: $<
@ -212,7 +205,7 @@ $(OBJS_AS_ARGS)
@echo Building file: $<
@echo ARMCC Assembler
$(QUOTE)armasm$(QUOTE) -g --apcs=interwork --cpu Cortex-M4 --pd "D__SAMD51P19A__ SETA 1" \
-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../dma_m2m" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Core/Include" -I"../samd51a/include" \
-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Core/Include" -I"../samd51a/include" \
--depend "$(@:%.o=%.d)" -o "$@" "$<"
@echo Finished building: $<
@ -221,7 +214,7 @@ $(OBJS_AS_ARGS)
@echo Building file: $<
@echo ARMCC Preprocessing Assembler
$(QUOTE)armcc$(QUOTE) --c99 -c -DDEBUG -O1 -g --apcs=interwork --split_sections --cpu Cortex-M4 -D__SAMD51P19A__ \
-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../dma_m2m" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Core/Include" -I"../samd51a/include" \
-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Core/Include" -I"../samd51a/include" \
--depend "$@" -o "$@" "$<"
@echo Finished building: $<

View File

@ -6,6 +6,5 @@
void atmel_start_init(void)
{
system_init();
dma_memory_init();
usb_init();
}

View File

@ -6,7 +6,6 @@ extern "C" {
#endif
#include "driver_init.h"
#include "dma_m2m_main.h"
#include "usb_start.h"
/**

View File

@ -19,15 +19,6 @@ board:
details: null
application: null
middlewares:
M2M_DMA_0:
user_label: M2M_DMA_0
configuration:
conf_channel: 0
definition: Atmel:MEMORY_DMA:0.0.1::M2M_DMA
functionality: M2M_DMA
api: DMA:M2M:Core
dependencies:
DMAC: DMAC
USB_CHAPTER_9:
user_label: USB_CHAPTER_9
configuration: {}

View File

@ -1,143 +0,0 @@
/**
* \file
*
* \brief Memory with DMA functionality implementation.
*
* Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
*
* \asf_license_start
*
* \page License
*
* Subject to your compliance with these terms, you may use Microchip
* software and any derivatives exclusively with Microchip products.
* It is your responsibility to comply with third party license terms applicable
* to your use of third party software (including open source software) that
* may accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
* INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
* AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
* LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
* LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
* SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
* POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
* ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
* RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* \asf_license_stop
*
*/
#include "dma_memory.h"
#include "dma_memory_config.h"
#include <utils_assert.h>
#include <utils.h>
#include <hal_atomic.h>
/**
* \brief Driver version
*/
#define DRIVER_VERSION 0x00000001u
/**
* \brief memory with dma descriptor instance
*/
static struct dma_memory_descriptor descr;
/**
* \internal Process transfer done interrupts
*
* \param[in] resource The pointer to memory resource
*/
static void dma_transfer_done(struct _dma_resource *resource)
{
(void)resource;
if (descr.memory_cb.complete) {
descr.memory_cb.complete();
}
}
/**
* \internal Process transfer error interrupts
*
* \param[in] resource The pointer to memory resource
*/
static void dma_memory_error(struct _dma_resource *resource)
{
(void)resource;
if (descr.memory_cb.error) {
descr.memory_cb.error();
}
}
/**
* \brief Initialize DMA
*/
int32_t dma_memory_init(void)
{
_dma_get_channel_resource(&descr.resource, CONF_DMA_MEMORY_CHANNEL);
descr.resource->dma_cb.transfer_done = dma_transfer_done;
descr.resource->dma_cb.error = dma_memory_error;
return ERR_NONE;
}
/**
* \brief Register DMA callback
*/
int32_t dma_memory_register_callback(const enum dma_memory_callback_type type, dma_memory_cb_t cb)
{
switch (type) {
case DMA_MEMORY_COMPLETE_CB:
descr.memory_cb.complete = cb;
break;
case DMA_MEMORY_ERROR_CB:
descr.memory_cb.error = cb;
break;
default:
return ERR_INVALID_ARG;
}
_dma_set_irq_state(CONF_DMA_MEMORY_CHANNEL, (enum _dma_callback_type)type, (cb != NULL));
return ERR_NONE;
}
/**
* \brief Memory copy with dma
*/
int32_t dma_memcpy(void *dst, void *src, uint32_t size)
{
_dma_srcinc_enable(CONF_DMA_MEMORY_CHANNEL, true);
_dma_dstinc_enable(CONF_DMA_MEMORY_CHANNEL, true);
_dma_set_destination_address(CONF_DMA_MEMORY_CHANNEL, dst);
_dma_set_source_address(CONF_DMA_MEMORY_CHANNEL, src);
_dma_set_data_amount(CONF_DMA_MEMORY_CHANNEL, size);
_dma_enable_transaction(CONF_DMA_MEMORY_CHANNEL, true);
return ERR_NONE;
}
/**
* \brief Memory set with dma
*/
int32_t dma_memset(void *dst, int32_t ch, uint32_t size)
{
static int32_t tmp_ch;
tmp_ch = ch;
_dma_set_source_address(CONF_DMA_MEMORY_CHANNEL, &tmp_ch);
_dma_srcinc_enable(CONF_DMA_MEMORY_CHANNEL, false);
_dma_dstinc_enable(CONF_DMA_MEMORY_CHANNEL, true);
_dma_set_destination_address(CONF_DMA_MEMORY_CHANNEL, dst);
_dma_set_data_amount(CONF_DMA_MEMORY_CHANNEL, size);
_dma_enable_transaction(CONF_DMA_MEMORY_CHANNEL, true);
return ERR_NONE;
}

View File

@ -1,132 +0,0 @@
/**
* \file
*
* \brief Memory with DMA functionality declaration.
*
* Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
*
* \asf_license_start
*
* \page License
*
* Subject to your compliance with these terms, you may use Microchip
* software and any derivatives exclusively with Microchip products.
* It is your responsibility to comply with third party license terms applicable
* to your use of third party software (including open source software) that
* may accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
* INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
* AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
* LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
* LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
* SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
* POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
* ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
* RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* \asf_license_stop
*
*/
#ifndef DMA_MEMORY_H_INCLUDED
#define DMA_MEMORY_H_INCLUDED
#include <hpl_dma.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup dma_memory
*
* \section dma_rev Revision History
* - v0.0.0.1 Initial Commit
*
*@{
*/
/**
* \brief Memory with DMA descriptor
*
* The Memory with DMA descriptor forward declaration.
*/
struct dma_memory_descriptor;
/**
* \brief memory with dma callback type
*/
typedef void (*dma_memory_cb_t)(void);
/**
* \brief Memory with DMA callback types
*/
enum dma_memory_callback_type { DMA_MEMORY_COMPLETE_CB, DMA_MEMORY_ERROR_CB };
/**
* \brief Memory with DMA callbacks
*/
struct dma_memory_callbacks {
dma_memory_cb_t complete;
dma_memory_cb_t error;
};
/**
* \brief Memory with DMA descriptor
*/
struct dma_memory_descriptor {
struct _dma_resource * resource;
struct dma_memory_callbacks memory_cb;
};
/**
* \brief Initialize Memory with DMA
*
* \return Initialization status.
*/
int32_t dma_memory_init(void);
/**
* \brief Register Memory with DMA callback
*
* \param[in] type Callback type
* \param[in] cb A callback function, passing NULL de-registers callback
*
* \return The status of callback assignment.
* \retval ERR_INVALID_ARG Passed parameters were invalid
* \retval ERR_NONE A callback is registered successfully
*/
int32_t dma_memory_register_callback(const enum dma_memory_callback_type type, dma_memory_cb_t cb);
/**
* \brief dma memory copy
*
* \param[in] dst The pointer to destination address for transfer
* \param[in] src The pointer to source address for transfer
* \param[in] size The transfer size
*
* \return the status of operation`
*/
int32_t dma_memcpy(void *dst, void *src, uint32_t size);
/**
* \brief dma memory set
*
* \param[in] dst The pointer to address to fill
* \param[in] ch The value to be filled
* \param[in] size Number of bytes to set to the value
*
* \return the status of operation
*/
int32_t dma_memset(void *dst, int32_t ch, uint32_t size);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* DMA_MEMORY_H_INCLUDED */

View File

@ -1,16 +0,0 @@
/* Auto-generated config file dma_memory_config.h */
#ifndef DMA_MEMORY_CONFIG_H
#define DMA_MEMORY_CONFIG_H
// <<< Use Configuration Wizard in Context Menu >>>
//<o> Channel <0-15>
//<i> This defines DMA channel to be used
//<id> conf_channel
#ifndef CONF_DMA_MEMORY_CHANNEL
#define CONF_DMA_MEMORY_CHANNEL 0
#endif
// <<< end of configuration section >>>
#endif // DMA_MEMORY_CONFIG_H

View File

@ -1,55 +0,0 @@
/*
* Code generated from Atmel Start.
*
* This file will be overwritten when reconfiguring your Atmel Start project.
* Please copy examples or other code you want to keep to a separate file or main.c
* to avoid loosing it when reconfiguring.
*/
#include "atmel_start.h"
static volatile uint8_t dma_complete_flag;
static void M2M_DMA_0_complete_cb(void)
{
dma_complete_flag = 1;
}
void M2M_DMA_0_example(void)
{
uint8_t src_array[100];
uint8_t dst_array[100];
uint32_t i;
dma_memory_register_callback(DMA_MEMORY_COMPLETE_CB, M2M_DMA_0_complete_cb);
for (i = 0; i < 100; i++) {
src_array[i] = i;
dst_array[i] = 0;
}
/* dma_memset example, set all array data to 0x01 */
dma_complete_flag = 0;
dma_memset(dst_array, 0x01, 100);
while (dma_complete_flag == 0) {
}
/* Check if memory set success */
for (i = 0; i < 100; i++) {
if (dst_array[i] != 0x01) {
while (1) {
};
}
}
/* dma_memcpy example */
dma_complete_flag = 0;
dma_memcpy(dst_array, src_array, 100);
while (dma_complete_flag == 0) {
}
/* Check if dma_memcpy success */
for (i = 0; i < 100; i++) {
if (dst_array[i] != src_array[i]) {
while (1) {
};
}
}
}

View File

@ -1,33 +0,0 @@
/*
* Code generated from Atmel Start.
*
* This file will be overwritten when reconfiguring your Atmel Start project.
* Please copy examples or other code you want to keep to a separate file or main.c
* to avoid loosing it when reconfiguring.
*/
#ifndef DMA_M2M_MAIN_H
#define DMA_M2M_MAIN_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <dma_memory.h>
/**
* \berif Example function for how to use \ref dma_memset and \ref dma_memcpy
* function.
*
* The system driver DMAC must be setup before using DMA M2M example function.
* For ATSAMD51P19A, below configuratino must be set:
* Enable 'DMAC', 'Channel' and associated 'Priority Level'.
* Enable 'Source Address Increment' and 'Destination Address Increment' for
* associate 'Channel'.
*/
void M2M_DMA_0_example(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DMA_M2M_MAIN_H */

View File

@ -1,15 +0,0 @@
Memory DMA
==========
Memory DMA is middleware which provides DMA-based versions of memcpy and memset
functions.
Architecture and provided functionality
---------------------------------------
Memory DMA uses system DMA driver which varies depending on MCU. User must configure
system DMA driver before using Memory DMA middleware.
DMA-based versions of memcpy and memset functions work asynchronously. Application
can be notifications about completion of copy or set operation via callbacks.
A callback can be registered via dma_memory_register_callback function.

View File

@ -36,7 +36,6 @@ hpl/ramecc \
hpl/dmac \
samd51a/gcc \
usb/class/cdc/device \
dma_m2m \
hal/src \
samd51a/gcc/gcc \
hpl/mclk \
@ -56,11 +55,10 @@ OBJS += \
hal/src/hal_io.o \
samd51a/gcc/system_samd51.o \
hpl/core/hpl_core_m4.o \
dma_m2m/dma_memory.o \
usb/class/cdc/device/cdcdf_acm.o \
hal/utils/src/utils_syscalls.o \
usb_start.o \
hpl/usb/hpl_usb.o \
usb/class/cdc/device/cdcdf_acm.o \
hal/src/hal_delay.o \
hpl/pm/hpl_pm.o \
hpl/core/hpl_init.o \
@ -74,14 +72,13 @@ hpl/ramecc/hpl_ramecc.o \
usb/usb_protocol.o \
hal/src/hal_init.o \
hal/src/hal_usb_device.o \
dma_m2m_main.o \
main.o \
hpl/osc32kctrl/hpl_osc32kctrl.o \
examples/driver_examples.o \
driver_init.o \
hal/src/hal_usart_async.o \
hpl/sercom/hpl_sercom.o \
hal/utils/src/utils_ringbuffer.o \
main.o \
hal/src/hal_gpio.o \
hal/utils/src/utils_event.o \
hal/src/hal_sleep.o \
@ -96,11 +93,10 @@ OBJS_AS_ARGS += \
"hal/src/hal_io.o" \
"samd51a/gcc/system_samd51.o" \
"hpl/core/hpl_core_m4.o" \
"dma_m2m/dma_memory.o" \
"usb/class/cdc/device/cdcdf_acm.o" \
"hal/utils/src/utils_syscalls.o" \
"usb_start.o" \
"hpl/usb/hpl_usb.o" \
"usb/class/cdc/device/cdcdf_acm.o" \
"hal/src/hal_delay.o" \
"hpl/pm/hpl_pm.o" \
"hpl/core/hpl_init.o" \
@ -114,14 +110,13 @@ OBJS_AS_ARGS += \
"usb/usb_protocol.o" \
"hal/src/hal_init.o" \
"hal/src/hal_usb_device.o" \
"dma_m2m_main.o" \
"main.o" \
"hpl/osc32kctrl/hpl_osc32kctrl.o" \
"examples/driver_examples.o" \
"driver_init.o" \
"hal/src/hal_usart_async.o" \
"hpl/sercom/hpl_sercom.o" \
"hal/utils/src/utils_ringbuffer.o" \
"main.o" \
"hal/src/hal_gpio.o" \
"hal/utils/src/utils_event.o" \
"hal/src/hal_sleep.o" \
@ -153,8 +148,6 @@ DIR_INCLUDES += \
-I"../hpl/usb" \
-I"../hri" \
-I"../" \
-I"../dma_m2m" \
-I"../" \
-I"../config" \
-I"../usb" \
-I"../usb/class/cdc" \
@ -168,16 +161,14 @@ DIR_INCLUDES += \
DEPS := $(OBJS:%.o=%.d)
DEPS_AS_ARGS += \
"usb/class/cdc/device/cdcdf_acm.d" \
"hal/utils/src/utils_event.d" \
"hal/src/hal_io.d" \
"hpl/ramecc/hpl_ramecc.d" \
"hpl/core/hpl_core_m4.d" \
"hal/utils/src/utils_syscalls.d" \
"dma_m2m/dma_memory.d" \
"usb/class/cdc/device/cdcdf_acm.d" \
"samd51a/gcc/system_samd51.d" \
"hpl/usb/hpl_usb.d" \
"main.d" \
"hal/utils/src/utils_list.d" \
"hpl/cmcc/hpl_cmcc.d" \
"hpl/dmac/hpl_dmac.d" \
@ -194,7 +185,7 @@ DEPS_AS_ARGS += \
"driver_init.d" \
"hal/src/hal_usart_async.d" \
"hpl/osc32kctrl/hpl_osc32kctrl.d" \
"dma_m2m_main.d" \
"main.d" \
"examples/driver_examples.d" \
"hal/src/hal_cache.d" \
"hal/src/hal_sleep.d" \

View File

@ -39,6 +39,7 @@
*/
#define DRIVER_VERSION 0x00000001u
#if 0
/**
* \brief Set the sleep mode of the device and put the MCU to sleep
*
@ -61,6 +62,7 @@ int sleep(const uint8_t mode)
return ERR_NONE;
}
#endif
/**
* \brief Retrieve the current driver version

View File

@ -119,6 +119,7 @@ extern int _lseek(int file, int ptr, int dir)
return 0;
}
#if 0
/**
* \brief Replacement of C library of _exit
*/
@ -129,6 +130,7 @@ extern void _exit(int status)
for (;;)
;
}
#endif
/**
* \brief Replacement of C library of _kill

View File

@ -24,8 +24,6 @@
<path>$PROJ_DIR$\hpl\usb</path>
<path>$PROJ_DIR$\hri</path>
<path>$PROJ_DIR$\</path>
<path>$PROJ_DIR$\dma_m2m</path>
<path>$PROJ_DIR$\</path>
<path>$PROJ_DIR$\config</path>
<path>$PROJ_DIR$\usb</path>
<path>$PROJ_DIR$\usb\class\cdc</path>
@ -56,8 +54,6 @@
<path>$PROJ_DIR$\hpl\usb</path>
<path>$PROJ_DIR$\hri</path>
<path>$PROJ_DIR$\</path>
<path>$PROJ_DIR$\dma_m2m</path>
<path>$PROJ_DIR$\</path>
<path>$PROJ_DIR$\config</path>
<path>$PROJ_DIR$\usb</path>
<path>$PROJ_DIR$\usb\class\cdc</path>
@ -87,8 +83,6 @@
<path>atmel_start.c</path>
<path>atmel_start.h</path>
<path>atmel_start_pins.h</path>
<path>dma_m2m_main.c</path>
<path>dma_m2m_main.h</path>
<path>driver_init.c</path>
<path>driver_init.h</path>
<path>main.c</path>
@ -134,12 +128,6 @@
<path>config/usbd_config.h</path>
</group>
<group name="dma_m2m">
<path>dma_m2m/dma_memory.c</path>
<path>dma_m2m/dma_memory.h</path>
<path>dma_m2m/dma_memory_config.h</path>
</group>
<group name="examples">
<path>examples/driver_examples.c</path>
<path>examples/driver_examples.h</path>

View File

@ -57,6 +57,30 @@ SECTIONS
*(.rodata .rodata* .gnu.linkonce.r.*)
*(.ARM.extab* .gnu.linkonce.armextab.*)
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(4);
/* section information for initial. */
. = ALIGN(4);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
. = ALIGN(4);
/* section information for utest */
. = ALIGN(4);
__rt_utest_tc_tab_start = .;
KEEP(*(UtestTcTab))
__rt_utest_tc_tab_end = .;
/* Support C constructors, and C destructors in both user code
and the C library. This also provides support for C++ code. */
. = ALIGN(4);
@ -160,4 +184,6 @@ SECTIONS
. = ALIGN(4);
_end = . ;
__bss_end = _end;
_ram_end_ = ORIGIN(ram) + LENGTH(ram) - 1 ;
}

View File

@ -623,6 +623,8 @@ __attribute__((section(".vectors"))) const DeviceVectors exception_table
#endif
};
int rtthread_startup(void);
/**
* \brief This is the code that gets called on processor reset.
* To initialize the device, and call the main() routine.
@ -660,8 +662,8 @@ void Reset_Handler(void)
/* Initialize the C library */
__libc_init_array();
/* Branch to main function */
main();
/* Branch to rtthread_startup function */
rtthread_startup();
/* Infinite loop */
while (1)

View File

@ -267,7 +267,7 @@
/* Hardware Drivers Config */
#define SOC_SAMD51J19
#define SOC_SAMD51P19
/* Onboard Peripheral Drivers */