mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-02 14:23:19 +08:00
[bsp][mchp] add ATSAMD51 BSP for Adafruit Metro M4 Express board
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
# files format check exclude path, please follow the instructions below to modify;
|
||||
# If you need to exclude an entire folder, add the folder path in dir_path;
|
||||
# If you need to exclude a file, add the path to the file in file_path.
|
||||
|
||||
dir_path:
|
||||
- bsp
|
||||
@@ -0,0 +1,31 @@
|
||||
mainmenu "RT-Thread Configuration"
|
||||
|
||||
config BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../../.."
|
||||
|
||||
# you can change the RTT_ROOT default: "rt-thread"
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
source "board/Kconfig"
|
||||
|
||||
config SOC_SAMD51
|
||||
bool
|
||||
select ARCH_ARM
|
||||
select ARCH_ARM_CORTEX_M
|
||||
select ARCH_ARM_CORTEX_M4
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
default y
|
||||
@@ -0,0 +1,121 @@
|
||||
# SAMD51J19A Adafruit Metro M4 BSP Introduction
|
||||
|
||||
[中文](README_zh.md)
|
||||
|
||||
- MCU: ATSAMD51J19A @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>
|
||||
|
||||
#### KEY FEATURES
|
||||
|
||||
#### Core
|
||||
|
||||
- 32-bit Arm® Cortex®-M4 core with single-precision FPU and 4 KB combined instruction cache and data cache; frequency up to 120 MHz, MPU, 403 CoreMark® at 120 MHz, and DSP instructions
|
||||
|
||||
#### 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
|
||||
- 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
|
||||
- Up to 4 KB of Tightly Coupled Memory (TCM)
|
||||
- Up to 8 KB additional SRAM
|
||||
- Can be retained in backup mode
|
||||
- Eight 32-bit backup registers
|
||||
|
||||
#### System
|
||||
|
||||
- Power-on Reset (POR) and Brown-out detection (BOD)
|
||||
- Internal and external clock options
|
||||
- External Interrupt Controller (EIC)
|
||||
- 16 external interrupts
|
||||
- One non-maskable interrupt
|
||||
- Two-pin Serial Wire Debug (SWD) programming, test, and debugging interface
|
||||
|
||||
#### High-Performance Peripherals
|
||||
|
||||
- 32-channel Direct Memory Access Controller (DMAC)
|
||||
- Up to two SD/MMC Host Controller (SDHC)
|
||||
- Up to 50 MHz operation
|
||||
- 4-bit or 1-bit interface
|
||||
- Compatibility with SD and SDHC memory card specification version 3.01
|
||||
- Compatibility with SDIO specification version 3.0
|
||||
- Compliant with JDEC specification, MMC memory cards V4.51
|
||||
- One Quad I/O Serial Peripheral Interface (QSPI)
|
||||
- Dedicated AHB memory zone
|
||||
- One Ethernet MAC (SAM E53 and SAM E54)– 10/100 Mbps in MII and RMII with dedicated DMA
|
||||
- IEEE® 1588 Precision Time Protocol (PTP) support
|
||||
- IEEE 1588 Time Stamping Unit (TSU) support
|
||||
- IEEE802.3AZ energy efficiency support
|
||||
- Support for 802.1AS and 1588 precision clock synchronization protocol
|
||||
- Wake on LAN support
|
||||
- Up to two Controller Area Network (CAN) (that is., SAM E51 and SAM E54)
|
||||
- Support for CAN 2.0A/CAN 2.0B and CAN-FD (ISO 11898-1:2016)
|
||||
- One Full-Speed (12 Mbps) Universal Serial Bus (USB) 2.0 interface
|
||||
- Embedded host and device function
|
||||
- Eight endpoints
|
||||
- On-chip transceiver with integrated serial resistor
|
||||
|
||||
#### System Peripherals
|
||||
|
||||
- Up to 114 I/O lines with external interrupt capability (edge- or level-sensitivity), debouncing, glitch filtering and On-die Series Resistor Termination
|
||||
- Five Parallel Input/Output Controllers (PIO)
|
||||
- 32-channel Event System
|
||||
- Up to eight Serial Communication Interfaces (SERCOM), can be configured as USART/I2C/SPI
|
||||
- Up to eight 16-bit Timers/Counters (TC), can be configured as 8/16/32bit TC.
|
||||
- Two 24-bit Timer/Counters for Control (TCC), with extended functions
|
||||
- Up to Three 16-bit Timer/Counters for Control (TCC) with extended functions.
|
||||
- 32-bit Real Time Counter (RTC) with clock/calendar function
|
||||
- Up to 4 wake-up pins with tamper detection and debouncing filter
|
||||
- Watchdog Timer (WDT) with Window mode
|
||||
- CRC-32 generator
|
||||
- One two-channel Inter-IC Sound Interface (I2S)
|
||||
- Position Decoder (PDEC)
|
||||
- Frequency meter (FREQM)
|
||||
- Four Configurable Custom Logic (CCL)
|
||||
- Dual 12-bit, 1 MSPS Analog-to-Digital Converter (ADC) with up to 16 channels each:
|
||||
- Dual 12-bit, 1 MSPS output Digital-to-Analog Converter (DAC)
|
||||
- Two Analog Comparators (AC) with Window Compare function
|
||||
- One temperature sensor
|
||||
- Parallel Capture Controller (PCC)
|
||||
- Peripheral Touch Controller (PTC) - Capacitive Touch buttons, sliders, and wheels
|
||||
|
||||
#### Cryptography
|
||||
|
||||
- One Advanced Encryption System (AES) with 256-bit key length and up to 2 MB/s data rate
|
||||
- Five confidential modes of operation (ECB, CBC, CFB, OFB, CTR)
|
||||
- Supports counter with CBC-MAC mode
|
||||
- Galois Counter Mode (GCM) - True Random Number Generator (TRNG)
|
||||
- Public Key Cryptography Controller (PUKCC) and associated Classical Public Key Cryptography Library (PUKCL)
|
||||
- RSA, DSA : Elliptic Curves Cryptography (ECC) ECC GF(2n), ECC GF(p)
|
||||
- Integrity Check Module (ICM) based on Secure Hash Algorithm (SHA1, SHA224, SHA256), DMA assisted
|
||||
|
||||
#### I/O
|
||||
|
||||
- Up to 99 programmable I/O pins
|
||||
|
||||
#### Qualification
|
||||
|
||||
- AEC-Q100 Grade 1 (-40°C to 125°C)
|
||||
|
||||
#### Package Type
|
||||
|
||||
- VQFN48, 48-lead VQFN, 7x7 mm, pitch 0.5 mm, I/O Pins up to 37
|
||||
- VQFN64, 64-lead VQFN, 9x9 mm, pitch 0.5 mm, I/O Pins up to 51
|
||||
- TQFP64, 64-lead TQFP, 10x10 mm, pitch 0.5 mm, I/O Pins up to 51
|
||||
- TQFP100, 100-lead TQFP, 14x14 mm, pitch 0.5 mm, I/O Pins up to 81
|
||||
- TQFP128, 128-lead TQFP, 14x14 mm, pitch 0.4 mm, I/O Pins up to 99
|
||||
- TFBGA120, 120-ball TFBGA, 8x8 mm, pitch 0.5 mm, I/O Pins up to 90
|
||||
|
||||
#### Board info
|
||||
|
||||
- [Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382)
|
||||
|
||||
#### Contact Info
|
||||
|
||||
- [luhuadong](https://github.com/luhuadong), <luhuadong@163.com>
|
||||
@@ -0,0 +1,121 @@
|
||||
# SAMD51J19A Adafruit Metro M4 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>
|
||||
|
||||
#### 关键特性
|
||||
|
||||
#### 内核
|
||||
|
||||
- 32-bit Arm® Cortex®-M4 内核 + 单精度FPU + 4 KB 复用的指令和数据Cache,最大工作主频120 MHz, 带MPU, 403 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
|
||||
- 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
|
||||
- Up to 4 KB of Tightly Coupled Memory (TCM)
|
||||
- Up to 8 KB additional SRAM
|
||||
- Can be retained in backup mode
|
||||
- Eight 32-bit backup registers
|
||||
|
||||
#### 系统特性
|
||||
|
||||
- Power-on Reset (POR) and Brown-out detection (BOD)
|
||||
- Internal and external clock options
|
||||
- External Interrupt Controller (EIC)
|
||||
- 16 external interrupts
|
||||
- One non-maskable interrupt
|
||||
- Two-pin Serial Wire Debug (SWD) programming, test, and debugging interface
|
||||
|
||||
#### 高性能外设
|
||||
|
||||
- 32-channel Direct Memory Access Controller (DMAC)
|
||||
- Up to two SD/MMC Host Controller (SDHC)
|
||||
- Up to 50 MHz operation
|
||||
- 4-bit or 1-bit interface
|
||||
- Compatibility with SD and SDHC memory card specification version 3.01
|
||||
- Compatibility with SDIO specification version 3.0
|
||||
- Compliant with JDEC specification, MMC memory cards V4.51
|
||||
- One Quad I/O Serial Peripheral Interface (QSPI)
|
||||
- Dedicated AHB memory zone
|
||||
- One Ethernet MAC (SAM E53 and SAM E54)– 10/100 Mbps in MII and RMII with dedicated DMA
|
||||
- IEEE® 1588 Precision Time Protocol (PTP) support
|
||||
- IEEE 1588 Time Stamping Unit (TSU) support
|
||||
- IEEE802.3AZ energy efficiency support
|
||||
- Support for 802.1AS and 1588 precision clock synchronization protocol
|
||||
- Wake on LAN support
|
||||
- Up to two Controller Area Network (CAN) (that is., SAM E51 and SAM E54)
|
||||
- Support for CAN 2.0A/CAN 2.0B and CAN-FD (ISO 11898-1:2016)
|
||||
- One Full-Speed (12 Mbps) Universal Serial Bus (USB) 2.0 interface
|
||||
- Embedded host and device function
|
||||
- Eight endpoints
|
||||
- On-chip transceiver with integrated serial resistor
|
||||
|
||||
#### 系统外设
|
||||
|
||||
- Up to 114 I/O lines with external interrupt capability (edge- or level-sensitivity), debouncing, glitch filtering and On-die Series Resistor Termination
|
||||
- Five Parallel Input/Output Controllers (PIO)
|
||||
- 32-channel Event System
|
||||
- Up to eight Serial Communication Interfaces (SERCOM), can be configured as USART/I2C/SPI
|
||||
- Up to eight 16-bit Timers/Counters (TC), can be configured as 8/16/32bit TC.
|
||||
- Two 24-bit Timer/Counters for Control (TCC), with extended functions
|
||||
- Up to Three 16-bit Timer/Counters for Control (TCC) with extended functions.
|
||||
- 32-bit Real Time Counter (RTC) with clock/calendar function
|
||||
- Up to 4 wake-up pins with tamper detection and debouncing filter
|
||||
- Watchdog Timer (WDT) with Window mode
|
||||
- CRC-32 generator
|
||||
- One two-channel Inter-IC Sound Interface (I2S)
|
||||
- Position Decoder (PDEC)
|
||||
- Frequency meter (FREQM)
|
||||
- Four Configurable Custom Logic (CCL)
|
||||
- Dual 12-bit, 1 MSPS Analog-to-Digital Converter (ADC) with up to 16 channels each:
|
||||
- Dual 12-bit, 1 MSPS output Digital-to-Analog Converter (DAC)
|
||||
- Two Analog Comparators (AC) with Window Compare function
|
||||
- One temperature sensor
|
||||
- Parallel Capture Controller (PCC)
|
||||
- Peripheral Touch Controller (PTC) - Capacitive Touch buttons, sliders, and wheels
|
||||
|
||||
#### 加密功能
|
||||
|
||||
- One Advanced Encryption System (AES) with 256-bit key length and up to 2 MB/s data rate
|
||||
- Five confidential modes of operation (ECB, CBC, CFB, OFB, CTR)
|
||||
- Supports counter with CBC-MAC mode
|
||||
- Galois Counter Mode (GCM) - True Random Number Generator (TRNG)
|
||||
- Public Key Cryptography Controller (PUKCC) and associated Classical Public Key Cryptography Library (PUKCL)
|
||||
- RSA, DSA : Elliptic Curves Cryptography (ECC) ECC GF(2n), ECC GF(p)
|
||||
- Integrity Check Module (ICM) based on Secure Hash Algorithm (SHA1, SHA224, SHA256), DMA assisted
|
||||
|
||||
#### I/O管脚
|
||||
|
||||
- 最多提供99个用户可编程I/O管脚
|
||||
|
||||
#### 汽车应用
|
||||
|
||||
- AEC-Q100 Grade 1 (-40°C to 125°C)
|
||||
|
||||
#### 封装
|
||||
|
||||
- VQFN48, 48-lead VQFN, 7x7 mm, pitch 0.5 mm, I/O Pins up to 37
|
||||
- VQFN64, 64-lead VQFN, 9x9 mm, pitch 0.5 mm, I/O Pins up to 51
|
||||
- TQFP64, 64-lead TQFP, 10x10 mm, pitch 0.5 mm, I/O Pins up to 51
|
||||
- TQFP100, 100-lead TQFP, 14x14 mm, pitch 0.5 mm, I/O Pins up to 81
|
||||
- TQFP128, 128-lead TQFP, 14x14 mm, pitch 0.4 mm, I/O Pins up to 99
|
||||
- TFBGA120, 120-ball TFBGA, 8x8 mm, pitch 0.5 mm, I/O Pins up to 90
|
||||
|
||||
#### 开发板信息
|
||||
|
||||
- [Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382)
|
||||
|
||||
#### 联系方式
|
||||
|
||||
- [luhuadong](https://github.com/luhuadong), <luhuadong@163.com>
|
||||
@@ -0,0 +1,14 @@
|
||||
# for module compiling
|
||||
import os
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
@@ -0,0 +1,60 @@
|
||||
import os
|
||||
import sys
|
||||
import rtconfig
|
||||
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
else:
|
||||
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
try:
|
||||
from building import *
|
||||
except:
|
||||
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
|
||||
print(RTT_ROOT)
|
||||
exit(-1)
|
||||
|
||||
TARGET = 'rt-thread-' + rtconfig.DEVICE_PART + '.' + rtconfig.TARGET_EXT
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
env = Environment(tools = ['mingw'],
|
||||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
|
||||
if rtconfig.PLATFORM in ['iccarm']:
|
||||
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
|
||||
env.Replace(ARFLAGS = [''])
|
||||
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread-'+ rtconfig.DEVICE_PART + '.map')
|
||||
|
||||
Export('RTT_ROOT')
|
||||
Export('rtconfig')
|
||||
|
||||
SDK_ROOT = os.path.abspath('./')
|
||||
|
||||
if os.path.exists(SDK_ROOT + '/common'):
|
||||
common_path_prefix = SDK_ROOT + '/common'
|
||||
else:
|
||||
common_path_prefix = os.path.dirname(SDK_ROOT) + '/common'
|
||||
|
||||
SDK_LIB = common_path_prefix
|
||||
Export('SDK_LIB')
|
||||
|
||||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
|
||||
|
||||
sam_board = 'board'
|
||||
rtconfig.BSP_LIBRARY_TYPE = sam_board
|
||||
|
||||
# include libraries
|
||||
objs.extend(SConscript(os.path.join(common_path_prefix, sam_board, 'SConscript')))
|
||||
|
||||
# include drivers
|
||||
objs.extend(SConscript(os.path.join(common_path_prefix, 'applications', 'SConscript')))
|
||||
|
||||
# make a building
|
||||
DoBuilding(TARGET, objs)
|
||||
@@ -0,0 +1,15 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
list = os.listdir(cwd)
|
||||
for item in list:
|
||||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
|
||||
group = group + SConscript(os.path.join(item, 'SConscript'))
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Email Notes
|
||||
* 2023-09-16 luhuadong luhuadong@163.com First Release
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
#include <shell.h>
|
||||
#endif
|
||||
|
||||
#include "atmel_start.h"
|
||||
#include <hal_gpio.h>
|
||||
|
||||
#ifdef SAM_CAN_EXAMPLE
|
||||
#include "can_demo.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAM_I2C_EXAMPLE
|
||||
#include "i2c_demo.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAM_ADC_EXAMPLE
|
||||
#include "adc_demo.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAM_LWIP_EXAMPLE
|
||||
#include "lwip_demo.h"
|
||||
#endif
|
||||
|
||||
static rt_uint8_t led_stack[512];
|
||||
static struct rt_thread led_thread;
|
||||
|
||||
static void led_thread_entry(void* parameter)
|
||||
{
|
||||
unsigned int count=0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* toggle led */
|
||||
#ifndef RT_USING_FINSH
|
||||
rt_kprintf("led toggle, count : %d\n",count);
|
||||
#endif
|
||||
count++;
|
||||
gpio_toggle_pin_level(LED0);
|
||||
rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rt_err_t result;
|
||||
|
||||
/* initialize led thread */
|
||||
result = rt_thread_init(&led_thread,
|
||||
"led",
|
||||
led_thread_entry,
|
||||
RT_NULL,
|
||||
(rt_uint8_t*)&led_stack[0],
|
||||
sizeof(led_stack),
|
||||
RT_THREAD_PRIORITY_MAX/3,
|
||||
5);
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
rt_thread_startup(&led_thread);
|
||||
}
|
||||
|
||||
#ifdef SAM_I2C_EXAMPLE
|
||||
i2c_demo_run();
|
||||
#endif
|
||||
|
||||
#ifdef SAM_ADC_EXAMPLE
|
||||
adc_demo_run();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
menu "Hardware Drivers Config"
|
||||
|
||||
choice
|
||||
prompt "select chip type"
|
||||
default SOC_SAMD51J19
|
||||
|
||||
config SOC_SAMD51J19
|
||||
bool "SOC_SAMD51J19"
|
||||
help
|
||||
Refer to SAMD51 DataSheet
|
||||
|
||||
config SOC_SAMD51P19
|
||||
bool "SOC_SAMD51P19"
|
||||
help
|
||||
Refer to SAMD51 DataSheet
|
||||
|
||||
config SOC_SAME54P20
|
||||
bool "SOC_SAME54P20"
|
||||
help
|
||||
Refer to SAME54 DataSheet
|
||||
|
||||
config SOC_SAME54N20
|
||||
bool "SOC_SAME54N20"
|
||||
help
|
||||
Refer to SAME54 DataSheet
|
||||
|
||||
config SOC_SAME53J20
|
||||
bool "SOC_SAME53J20"
|
||||
help
|
||||
Refer to SAME54 DataSheet
|
||||
|
||||
endchoice
|
||||
endmenu
|
||||
|
||||
menu "Onboard Peripheral Drivers"
|
||||
depends on SOC_SAMD51J19 || SOC_SAMD51P19
|
||||
|
||||
config SAMD5X_ADC0
|
||||
bool "Enable ADC0"
|
||||
default false
|
||||
|
||||
config SAMD5X_I2C0
|
||||
bool "Enable I2C0"
|
||||
default false
|
||||
endmenu
|
||||
|
||||
menu "Application Demo Config"
|
||||
config SAM_ADC_EXAMPLE
|
||||
bool "Enable SAM ADC Example"
|
||||
depends on SAMD5X_ADC0
|
||||
default false
|
||||
help
|
||||
Add ADC example task to project
|
||||
|
||||
config SAM_I2C_EXAMPLE
|
||||
bool "Enable SAM I2C Example"
|
||||
depends on SAMD5X_I2C0
|
||||
default false
|
||||
help
|
||||
Add I2C example task to project
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,17 @@
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
#remove other no use files
|
||||
#SrcRemove(src, '*.c')
|
||||
|
||||
# You can select chips from the list above
|
||||
CPPDEFINES = ['SAMD51xxx']
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c)
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Email Notes
|
||||
* 2023-09-16 luhuadong luhuadong@163.com First Release
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <atmel_start.h>
|
||||
#include "peripheral_clk_config.h"
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "board.h"
|
||||
|
||||
#ifdef RT_USING_SERIAL
|
||||
extern int rt_hw_uart_init(void);
|
||||
#endif
|
||||
|
||||
static struct io_descriptor* g_stdio;
|
||||
static uint8_t board_info[48] = "Adafruit Metro M4 Express, Microchip SAMD51\n";
|
||||
|
||||
void rt_hw_console_output(const char *str)
|
||||
{
|
||||
io_write(g_stdio, (uint8_t *)str, strlen(str));
|
||||
}
|
||||
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);
|
||||
io_write(g_stdio, board_info, strlen(board_info));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the timer interrupt service routine.
|
||||
*
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
rt_tick_increase();
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will initial SAMD51 board.
|
||||
*/
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
/* Initializes MCU, drivers and middleware */
|
||||
atmel_start_init();
|
||||
|
||||
/* enable USART stdout module */
|
||||
hw_board_init_usart();
|
||||
|
||||
/* UART driver initialization is open by default */
|
||||
#ifdef RT_USING_SERIAL
|
||||
rt_hw_uart_init();
|
||||
#endif
|
||||
|
||||
/* init systick */
|
||||
SysTick_Config(CONF_CPU_FREQUENCY / RT_TICK_PER_SECOND);
|
||||
|
||||
/* set pend exception priority */
|
||||
NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
#if defined(__ARMCC_VERSION)
|
||||
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)HEAP_END);
|
||||
#elif __ICCARM__
|
||||
rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
|
||||
#else
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void*)&__bss_end, (void*)HEAP_END);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Set the shell console output device */
|
||||
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c)
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Email Notes
|
||||
* 2023-09-16 luhuadong luhuadong@163.com First Release
|
||||
*/
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
|
||||
// <o> Internal SRAM memory size[Kbytes] <128-256>
|
||||
// <i>Default: 256
|
||||
#if defined(__SAMD51J18A__) || defined(__ATSAMD51J18A__)
|
||||
#define SAME5x_SRAM_SIZE 128
|
||||
#elif defined(__SAMD51J19A__) || defined(__ATSAMD51J19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAMD51J20A__) || defined(__ATSAMD51J20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAMD51N19A__) || defined(__ATSAMD51N19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAMD51N20A__) || defined(__ATSAMD51N20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAMD51P19A__) || defined(__ATSAMD51P19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAMD51P20A__) || defined(__ATSAMD51P20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAME54N19A__) || defined(__ATSAME54N19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAME54N20A__) || defined(__ATSAME54N20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAME54P19A__) || defined(__ATSAME54P19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAME54P20A__) || defined(__ATSAME54P20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAME53J18A__) || defined(__ATSAME53J18A__)
|
||||
#define SAME5x_SRAM_SIZE 128
|
||||
#elif defined(__SAME53J19A__) || defined(__ATSAME53J19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAME53J20A__) || defined(__ATSAME53J20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAME53N19A__) || defined(__ATSAME53N19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAME53N20A__) || defined(__ATSAME53N20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAME51J18A__) || defined(__ATSAME51J18A__)
|
||||
#define SAME5x_SRAM_SIZE 128
|
||||
#elif defined(__SAME51J19A__) || defined(__ATSAME51J19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAME51J20A__) || defined(__ATSAME51J20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#elif defined(__SAME51N19A__) || defined(__ATSAME51N19A__)
|
||||
#define SAME5x_SRAM_SIZE 192
|
||||
#elif defined(__SAME51N20A__) || defined(__ATSAME51N20A__)
|
||||
#define SAME5x_SRAM_SIZE 256
|
||||
#else
|
||||
#error Board does not support the specified device.
|
||||
#endif
|
||||
|
||||
#define SAME5x_SRAM_END (0x20000000 + SAME5x_SRAM_SIZE * 1024)
|
||||
|
||||
#if defined(__ARMCC_VERSION)
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
#define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
|
||||
#elif __ICCARM__
|
||||
#pragma section="HEAP"
|
||||
#define HEAP_BEGIN (__segment_begin("HEAP"))
|
||||
#define HEAP_END (__segment_end("HEAP"))
|
||||
#else
|
||||
extern int __bss_end;
|
||||
#define HEAP_BEGIN (&__bss_end)
|
||||
#define HEAP_END SAME5x_SRAM_END
|
||||
#endif
|
||||
|
||||
void rt_hw_board_init(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
<environment>
|
||||
<configurations/>
|
||||
<device-packs>
|
||||
<device-pack device="ATSAMD51J19A" name="SAMD51_DFP" vendor="Atmel" version="1.2.139"/>
|
||||
</device-packs>
|
||||
</environment>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.2
|
||||
* @date 19. April 2017
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
/******************************************************************************
|
||||
* @file tz_context.h
|
||||
* @brief Context Management for Armv8-M TrustZone
|
||||
* @version V1.0.1
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef TZ_CONTEXT_H
|
||||
#define TZ_CONTEXT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef TZ_MODULEID_T
|
||||
#define TZ_MODULEID_T
|
||||
/// \details Data type that identifies secure software modules called by a process.
|
||||
typedef uint32_t TZ_ModuleId_t;
|
||||
#endif
|
||||
|
||||
/// \details TZ Memory ID identifies an allocated memory slot.
|
||||
typedef uint32_t TZ_MemoryId_t;
|
||||
|
||||
/// Initialize secure context memory system
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_InitContextSystem_S (void);
|
||||
|
||||
/// Allocate context memory for calling secure software modules in TrustZone
|
||||
/// \param[in] module identifies software modules called from non-secure mode
|
||||
/// \return value != 0 id TrustZone memory slot identifier
|
||||
/// \return value 0 no memory available or internal error
|
||||
TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
|
||||
|
||||
/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
|
||||
/// \param[in] id TrustZone memory slot identifier
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
|
||||
|
||||
/// Load secure context (called on RTOS thread context switch)
|
||||
/// \param[in] id TrustZone memory slot identifier
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
|
||||
|
||||
/// Store secure context (called on RTOS thread context switch)
|
||||
/// \param[in] id TrustZone memory slot identifier
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
|
||||
|
||||
#endif // TZ_CONTEXT_H
|
||||
@@ -0,0 +1,196 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<title>Overview</title>
|
||||
<title>CMSIS-Core (Cortex-M): Overview</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="cmsis.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<script type="text/javascript" src="printComponentTabs.js"></script>
|
||||
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="resize.js"></script>
|
||||
<script type="text/javascript" src="navtree.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(initResizable);
|
||||
$(window).load(resizeHeight);
|
||||
</script>
|
||||
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="search/search.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() { searchBox.OnSelectItem(0); });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 46px;">
|
||||
<td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">CMSIS-Core (Cortex-M)
|
||||
 <span id="projectnumber">Version 5.1.2</span>
|
||||
</div>
|
||||
<div id="projectbrief">CMSIS-Core support for Cortex-M processor-based devices</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<div id="CMSISnav" class="tabs1">
|
||||
<ul class="tablist">
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
writeComponentTabs.call(this);
|
||||
//-->
|
||||
</script>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Generated by Doxygen 1.8.6 -->
|
||||
<script type="text/javascript">
|
||||
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
</script>
|
||||
<div id="navrow1" class="tabs">
|
||||
<ul class="tablist">
|
||||
<li class="current"><a href="index.html"><span>Main Page</span></a></li>
|
||||
<li><a href="pages.html"><span>Usage and Description</span></a></li>
|
||||
<li><a href="modules.html"><span>Reference</span></a></li>
|
||||
<li>
|
||||
<div id="MSearchBox" class="MSearchBoxInactive">
|
||||
<span class="left">
|
||||
<img id="MSearchSelect" src="search/mag_sel.png"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
alt=""/>
|
||||
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
||||
onfocus="searchBox.OnSearchFieldFocus(true)"
|
||||
onblur="searchBox.OnSearchFieldFocus(false)"
|
||||
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
||||
</span><span class="right">
|
||||
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){initNavTree('index.html','');});
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Pages</a></div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<iframe src="javascript:void(0)" frameborder="0"
|
||||
name="MSearchResults" id="MSearchResults">
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Overview </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>CMSIS-Core (Cortex-M) implements the basic run-time system for a Cortex-M device and gives the user access to the processor core and the device peripherals. In detail it defines:</p>
|
||||
<ul>
|
||||
<li><b>Hardware Abstraction Layer (HAL)</b> for Cortex-M processor registers with standardized definitions for the SysTick, NVIC, System Control Block registers, MPU registers, FPU registers, and core access functions.</li>
|
||||
<li><b>System exception names</b> to interface to system exceptions without having compatibility issues.</li>
|
||||
<li><b>Methods to organize header files</b> that makes it easy to learn new Cortex-M microcontroller products and improve software portability. This includes naming conventions for device-specific interrupts.</li>
|
||||
<li><b>Methods for system initialization</b> to be used by each MCU vendor. For example, the standardized <a class="el" href="group__system__init__gr.html#ga93f514700ccf00d08dbdcff7f1224eb2" title="Function to Initialize the system. ">SystemInit()</a> function is essential for configuring the clock system of the device.</li>
|
||||
<li><b>Intrinsic functions</b> used to generate CPU instructions that are not supported by standard C functions.</li>
|
||||
<li>A variable to determine the <b>system clock frequency</b> which simplifies the setup the SysTick timer.</li>
|
||||
</ul>
|
||||
<p>The following sections provide details about the CMSIS-Core (Cortex-M):</p>
|
||||
<ul>
|
||||
<li><a class="el" href="using_pg.html">Using CMSIS in Embedded Applications</a> describes the project setup and shows a simple program example.</li>
|
||||
<li><a class="el" href="using_TrustZone_pg.html">Using TrustZone® for Armv8-M</a> describes how to use the security extensions available in the Armv8-M architecture.</li>
|
||||
<li><a class="el" href="templates_pg.html">CMSIS-Core Device Templates</a> describes the files of the CMSIS-Core (Cortex-M) in detail and explains how to adapt template files provided by Arm to silicon vendor devices.</li>
|
||||
<li><a class="el" href="coreMISRA_Exceptions_pg.html">MISRA-C Deviations</a> describes the violations to the MISRA standard.</li>
|
||||
<li><a href="Modules.html"><b>Reference</b> </a> describe the features and functions of the <a class="el" href="device_h_pg.html">Device Header File <device.h></a> in detail.</li>
|
||||
<li><a href="Annotated.html"><b>Data</b> <b>Structures</b> </a> describe the data structures of the <a class="el" href="device_h_pg.html">Device Header File <device.h></a> in detail.</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<h2>CMSIS-Core (Cortex-M) in ARM::CMSIS Pack </h2>
|
||||
<p>Files relevant to CMSIS-Core (Cortex-M) are present in the following <b>ARM::CMSIS</b> directories: </p>
|
||||
<table class="doxtable">
|
||||
<tr>
|
||||
<th>File/Folder </th><th>Content </th></tr>
|
||||
<tr>
|
||||
<td><b>CMSIS\Documentation\Core</b> </td><td>This documentation </td></tr>
|
||||
<tr>
|
||||
<td><b>CMSIS\Core\Include</b> </td><td>CMSIS-Core (Cortex-M) header files (for example core_cm3.h, core_cmInstr.h, etc.) </td></tr>
|
||||
<tr>
|
||||
<td><b>Device</b> </td><td><a class="el" href="using_ARM_pg.html">Arm reference implementations</a> of Cortex-M devices </td></tr>
|
||||
<tr>
|
||||
<td><b>Device\_Template_Vendor</b> </td><td><a class="el" href="templates_pg.html">CMSIS-Core Device Templates</a> for extension by silicon vendors </td></tr>
|
||||
</table>
|
||||
<hr/>
|
||||
<h1><a class="anchor" id="ref_v6-v8M"></a>
|
||||
Processor Support</h1>
|
||||
<p>CMSIS supports the complete range of <a href="http://www.arm.com/products/processors/cortex-m/index.php" target="_blank"><b>Cortex-M processors</b></a> (with exception of Cortex-M1) and the <a href="http://www.arm.com/products/processors/instruction-set-architectures/armv8-m-architecture.php" target="_blank"><b>Armv8-M architecture</b></a> including security extensions.</p>
|
||||
<h2><a class="anchor" id="ref_man_sec"></a>
|
||||
Cortex-M Reference Manuals</h2>
|
||||
<p>The Cortex-M Device Generic User Guides contain the programmers model and detailed information about the core peripherals and are available for:</p>
|
||||
<ul>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/DUI0497A_cortex_m0_r0p0_generic_ug.pdf" target="_blank"><b>Cortex-M0 Devices Generic User Guide</b></a> (Armv6-M architecture)</li>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0662b/DUI0662B_cortex_m0p_r0p1_dgug.pdf" target="_blank"><b>Cortex-M0+ Devices Generic User Guide</b></a> (Armv6-M architecture)</li>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/DUI0552A_cortex_m3_dgug.pdf" target="_blank"><b>Cortex-M3 Devices Generic User Guide</b></a> (Armv7-M architecture)</li>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/DUI0553A_cortex_m4_dgug.pdf" target="_blank"><b>Cortex-M4 Devices Generic User Guide</b></a> (ARMv7-M architecture)</li>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0646a/DUI0646A_cortex_m7_dgug.pdf" target="_blank"><b>Cortex-M7 Devices Generic User Guide</b></a> (Armv7-M architecture)</li>
|
||||
</ul>
|
||||
<p>The <b>Cortex-M23</b> and <b>Cortex-M33</b> are described with Technical Reference Manuals that are available here:</p>
|
||||
<ul>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.ddi0550c/cortex_m23_r1p0_technical_reference_manual_DDI0550C_en.pdf" target="_blank"><b>Cortex-M23 Technical Reference Manual</b></a> (Armv8-M baseline architecture)</li>
|
||||
<li><a href="http://infocenter.arm.com/help/topic/com.arm.doc.100230_0002_00_en/cortex_m33_trm_100230_0002_00_en.pdf" target="_blank"><b>Cortex-M33 Technical Reference Manual</b></a> (Armv8-M mainline architecture)</li>
|
||||
</ul>
|
||||
<h2><a class="anchor" id="ARMv8M"></a>
|
||||
Armv8-M Architecture</h2>
|
||||
<p>Armv8-M introduces two profiles <b>baseline</b> (for power and area constrained applications) and <b>mainline</b> (full-featured with optional SIMD, floating-point, and co-processor extensions). Both Armv8-M profiles are supported by CMSIS.</p>
|
||||
<p>The Armv8-M Architecture is described in the <a href="http://developer.arm.com/products/architecture/m-profile/docs/ddi0553/latest/armv8-m-architecture-reference-manual" target="_blank"><b>Armv8-M Architecture Reference Manual</b></a>.</p>
|
||||
<hr/>
|
||||
<h1><a class="anchor" id="tested_tools_sec"></a>
|
||||
Tested and Verified Toolchains</h1>
|
||||
<p>The <a class="el" href="templates_pg.html">CMSIS-Core Device Templates</a> supplied by Arm have been tested and verified with the following toolchains:</p>
|
||||
<ul>
|
||||
<li>Arm: Arm Compiler 5.06 update 6 (not for Cortex-M23, Cortex-M33, Armv8-M)</li>
|
||||
<li>Arm: Arm Compiler 6.9</li>
|
||||
<li>Arm: Arm Compiler 6.6.2 (not for Cortex-M0, Cortex-M23, Cortex-M33, Armv8-M)</li>
|
||||
<li>GNU: GNU Tools for Arm Embedded 6.3.1 20170620</li>
|
||||
<li>IAR: IAR ANSI C/C++ Compiler for Arm 8.20.1.14183</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- start footer part -->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="footer">Generated on Wed Aug 1 2018 17:12:09 for CMSIS-Core (Cortex-M) by Arm Ltd. All rights reserved.
|
||||
<!--
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
|
||||
-->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,81 @@
|
||||
import rtconfig
|
||||
from building import *
|
||||
|
||||
# get current directory
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
#var defined
|
||||
CPPDEFINES = []
|
||||
|
||||
#common lib define
|
||||
CPPDEFINES += [rtconfig.DEVICE_TYPE]
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
|
||||
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')
|
||||
src += Glob('hpl/pm/*.c')
|
||||
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
|
||||
if rtconfig.PLATFORM in ['gcc']:
|
||||
src += [cwd + '/samd51a/gcc/system_samd51.c']
|
||||
src += [cwd + '/samd51a/gcc/gcc/startup_samd51.c']
|
||||
elif rtconfig.PLATFORM in ['armcc', 'armclang']:
|
||||
src += [cwd + '/samd51a/armcc/Device/SAMD51/Source/' + 'system_samd51.c']
|
||||
src += [cwd + '/samd51a/armcc/Device/SAMD51/Source/ARM/' + 'startup_samd51.s']
|
||||
elif rtconfig.PLATFORM in ['iccarm']:
|
||||
src += [cwd + '/samd51a/iar/' + 'system_samd51.c']
|
||||
src += [cwd + '/samd51a/iar/iar/' + 'startup_samd51.c']
|
||||
|
||||
path = [
|
||||
cwd,
|
||||
cwd + '/CMSIS/Core/Include',
|
||||
cwd + '/config',
|
||||
cwd + '/hal/include',
|
||||
cwd + '/hal/utils/include',
|
||||
# cwd + '/hpl/adc',
|
||||
# cwd + '/hpl/can',
|
||||
cwd + '/hpl/core',
|
||||
cwd + '/hpl/gclk',
|
||||
cwd + '/hpl/pm',
|
||||
cwd + '/hpl/port',
|
||||
cwd + '/hpl/usb',
|
||||
cwd + '/hri',
|
||||
cwd + '/usb',
|
||||
cwd + '/usb/class/cdc',
|
||||
cwd + '/usb/class/cdc/device',
|
||||
cwd + '/usb/device',
|
||||
cwd + '/samd51a/include',
|
||||
cwd + '/stdio_redirect',
|
||||
cwd + '/../board',
|
||||
cwd + '/../../common/applications'
|
||||
]
|
||||
|
||||
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
#include <atmel_start.h>
|
||||
|
||||
/**
|
||||
* Initializes MCU, drivers and middleware in the project
|
||||
**/
|
||||
void atmel_start_init(void)
|
||||
{
|
||||
system_init();
|
||||
usb_init();
|
||||
stdio_redirect_init();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef ATMEL_START_H_INCLUDED
|
||||
#define ATMEL_START_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver_init.h"
|
||||
#include "usb_start.h"
|
||||
#include "stdio_start.h"
|
||||
|
||||
/**
|
||||
* Initializes MCU, drivers and middleware in the project
|
||||
**/
|
||||
void atmel_start_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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
|
||||
* to avoid losing it when reconfiguring.
|
||||
*/
|
||||
#ifndef ATMEL_START_PINS_H_INCLUDED
|
||||
#define ATMEL_START_PINS_H_INCLUDED
|
||||
|
||||
#include <hal_gpio.h>
|
||||
|
||||
// SAMD51 has 14 pin functions
|
||||
|
||||
#define GPIO_PIN_FUNCTION_A 0
|
||||
#define GPIO_PIN_FUNCTION_B 1
|
||||
#define GPIO_PIN_FUNCTION_C 2
|
||||
#define GPIO_PIN_FUNCTION_D 3
|
||||
#define GPIO_PIN_FUNCTION_E 4
|
||||
#define GPIO_PIN_FUNCTION_F 5
|
||||
#define GPIO_PIN_FUNCTION_G 6
|
||||
#define GPIO_PIN_FUNCTION_H 7
|
||||
#define GPIO_PIN_FUNCTION_I 8
|
||||
#define GPIO_PIN_FUNCTION_J 9
|
||||
#define GPIO_PIN_FUNCTION_K 10
|
||||
#define GPIO_PIN_FUNCTION_L 11
|
||||
#define GPIO_PIN_FUNCTION_M 12
|
||||
#define GPIO_PIN_FUNCTION_N 13
|
||||
|
||||
#define LED0 GPIO(GPIO_PORTA, 16)
|
||||
#define PA22 GPIO(GPIO_PORTA, 22)
|
||||
#define PA23 GPIO(GPIO_PORTA, 23)
|
||||
#define PA24 GPIO(GPIO_PORTA, 24)
|
||||
#define PA25 GPIO(GPIO_PORTA, 25)
|
||||
|
||||
#endif // ATMEL_START_PINS_H_INCLUDED
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Auto-generated config file hpl_cmcc_config.h */
|
||||
#ifndef HPL_CMCC_CONFIG_H
|
||||
#define HPL_CMCC_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Basic Configuration
|
||||
|
||||
// <q> Cache enable
|
||||
//<i> Defines the cache should be enabled or not.
|
||||
// <id> cmcc_enable
|
||||
#ifndef CONF_CMCC_ENABLE
|
||||
#define CONF_CMCC_ENABLE 0x0
|
||||
#endif
|
||||
|
||||
// <o> Cache Size
|
||||
//<i> Defines the cache memory size to be configured.
|
||||
// <0x0=>1 KB
|
||||
// <0x1=>2 KB
|
||||
// <0x2=>4 KB
|
||||
// <id> cache_size
|
||||
#ifndef CONF_CMCC_CACHE_SIZE
|
||||
#define CONF_CMCC_CACHE_SIZE 0x2
|
||||
#endif
|
||||
|
||||
// <e> Advanced Configuration
|
||||
// <id> cmcc_advanced_configuration
|
||||
// <q> Data cache disable
|
||||
//<i> Defines the data cache should be disabled or not.
|
||||
// <id> cmcc_data_cache_disable
|
||||
#ifndef CONF_CMCC_DATA_CACHE_DISABLE
|
||||
#define CONF_CMCC_DATA_CACHE_DISABLE 0x0
|
||||
#endif
|
||||
|
||||
// <q> Instruction cache disable
|
||||
//<i> Defines the Instruction cache should be disabled or not.
|
||||
// <id> cmcc_inst_cache_disable
|
||||
#ifndef CONF_CMCC_INST_CACHE_DISABLE
|
||||
#define CONF_CMCC_INST_CACHE_DISABLE 0x0
|
||||
#endif
|
||||
|
||||
// <q> Clock Gating disable
|
||||
//<i> Defines the clock gating should be disabled or not.
|
||||
// <id> cmcc_clock_gating_disable
|
||||
#ifndef CONF_CMCC_CLK_GATING_DISABLE
|
||||
#define CONF_CMCC_CLK_GATING_DISABLE 0x0
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
#endif // HPL_CMCC_CONFIG_H
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,104 @@
|
||||
/* Auto-generated config file hpl_mclk_config.h */
|
||||
#ifndef HPL_MCLK_CONFIG_H
|
||||
#define HPL_MCLK_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
#include <peripheral_clk_config.h>
|
||||
|
||||
// <e> System Configuration
|
||||
// <i> Indicates whether configuration for system is enabled or not
|
||||
// <id> enable_cpu_clock
|
||||
#ifndef CONF_SYSTEM_CONFIG
|
||||
#define CONF_SYSTEM_CONFIG 1
|
||||
#endif
|
||||
|
||||
// <h> Basic settings
|
||||
// <y> CPU Clock source
|
||||
// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
|
||||
// <i> This defines the clock source for the CPU
|
||||
// <id> cpu_clock_source
|
||||
#ifndef CONF_CPU_SRC
|
||||
#define CONF_CPU_SRC GCLK_PCHCTRL_GEN_GCLK0_Val
|
||||
#endif
|
||||
|
||||
// <y> CPU Clock Division Factor
|
||||
// <MCLK_CPUDIV_DIV_DIV1_Val"> 1
|
||||
// <MCLK_CPUDIV_DIV_DIV2_Val"> 2
|
||||
// <MCLK_CPUDIV_DIV_DIV4_Val"> 4
|
||||
// <MCLK_CPUDIV_DIV_DIV8_Val"> 8
|
||||
// <MCLK_CPUDIV_DIV_DIV16_Val"> 16
|
||||
// <MCLK_CPUDIV_DIV_DIV32_Val"> 32
|
||||
// <MCLK_CPUDIV_DIV_DIV64_Val"> 64
|
||||
// <MCLK_CPUDIV_DIV_DIV128_Val"> 128
|
||||
// <i> Prescalar for CPU clock
|
||||
// <id> cpu_div
|
||||
#ifndef CONF_MCLK_CPUDIV
|
||||
#define CONF_MCLK_CPUDIV MCLK_CPUDIV_DIV_DIV1_Val
|
||||
#endif
|
||||
// <y> Low Power Clock Division
|
||||
// <MCLK_LPDIV_LPDIV_DIV1_Val"> Divide by 1
|
||||
// <MCLK_LPDIV_LPDIV_DIV2_Val"> Divide by 2
|
||||
// <MCLK_LPDIV_LPDIV_DIV4_Val"> Divide by 4
|
||||
// <MCLK_LPDIV_LPDIV_DIV8_Val"> Divide by 8
|
||||
// <MCLK_LPDIV_LPDIV_DIV16_Val"> Divide by 16
|
||||
// <MCLK_LPDIV_LPDIV_DIV32_Val"> Divide by 32
|
||||
// <MCLK_LPDIV_LPDIV_DIV64_Val"> Divide by 64
|
||||
// <MCLK_LPDIV_LPDIV_DIV128_Val"> Divide by 128
|
||||
// <id> mclk_arch_lpdiv
|
||||
#ifndef CONF_MCLK_LPDIV
|
||||
#define CONF_MCLK_LPDIV MCLK_LPDIV_LPDIV_DIV4_Val
|
||||
#endif
|
||||
|
||||
// <y> Backup Clock Division
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV1_Val"> Divide by 1
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV2_Val"> Divide by 2
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV4_Val"> Divide by 4
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV8_Val"> Divide by 8
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV16_Val"> Divide by 16
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV32_Val"> Divide by 32
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV64_Val"> Divide by 64
|
||||
// <MCLK_BUPDIV_BUPDIV_DIV128_Val"> Divide by 128
|
||||
// <id> mclk_arch_bupdiv
|
||||
#ifndef CONF_MCLK_BUPDIV
|
||||
#define CONF_MCLK_BUPDIV MCLK_BUPDIV_BUPDIV_DIV8_Val
|
||||
#endif
|
||||
// <y> High-Speed Clock Division
|
||||
// <MCLK_HSDIV_DIV_DIV1_Val"> Divide by 1
|
||||
// <id> mclk_arch_hsdiv
|
||||
#ifndef CONF_MCLK_HSDIV
|
||||
#define CONF_MCLK_HSDIV MCLK_HSDIV_DIV_DIV1_Val
|
||||
#endif
|
||||
// </h>
|
||||
|
||||
// <h> NVM Settings
|
||||
// <o> NVM Wait States
|
||||
// <i> These bits select the number of wait states for a read operation.
|
||||
// <0=> 0
|
||||
// <1=> 1
|
||||
// <2=> 2
|
||||
// <3=> 3
|
||||
// <4=> 4
|
||||
// <5=> 5
|
||||
// <6=> 6
|
||||
// <7=> 7
|
||||
// <8=> 8
|
||||
// <9=> 9
|
||||
// <10=> 10
|
||||
// <11=> 11
|
||||
// <12=> 12
|
||||
// <13=> 13
|
||||
// <14=> 14
|
||||
// <15=> 15
|
||||
// <id> nvm_wait_states
|
||||
#ifndef CONF_NVM_WAIT_STATE
|
||||
#define CONF_NVM_WAIT_STATE 0
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
|
||||
// </e>
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
#endif // HPL_MCLK_CONFIG_H
|
||||
@@ -0,0 +1,165 @@
|
||||
/* Auto-generated config file hpl_osc32kctrl_config.h */
|
||||
#ifndef HPL_OSC32KCTRL_CONFIG_H
|
||||
#define HPL_OSC32KCTRL_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <e> RTC Source configuration
|
||||
// <id> enable_rtc_source
|
||||
#ifndef CONF_RTCCTRL_CONFIG
|
||||
#define CONF_RTCCTRL_CONFIG 0
|
||||
#endif
|
||||
|
||||
// <h> RTC source control
|
||||
// <y> RTC Clock Source Selection
|
||||
// <GCLK_GENCTRL_SRC_OSCULP32K"> 32kHz Ultra Low Power Internal Oscillator (OSCULP32K)
|
||||
// <GCLK_GENCTRL_SRC_XOSC32K"> 32kHz External Crystal Oscillator (XOSC32K)
|
||||
// <i> This defines the clock source for RTC
|
||||
// <id> rtc_source_oscillator
|
||||
#ifndef CONF_RTCCTRL_SRC
|
||||
#define CONF_RTCCTRL_SRC GCLK_GENCTRL_SRC_OSCULP32K
|
||||
#endif
|
||||
|
||||
// <q> Use 1 kHz output
|
||||
// <id> rtc_1khz_selection
|
||||
#ifndef CONF_RTCCTRL_1KHZ
|
||||
|
||||
#define CONF_RTCCTRL_1KHZ 0
|
||||
|
||||
#endif
|
||||
|
||||
#if CONF_RTCCTRL_SRC == GCLK_GENCTRL_SRC_OSCULP32K
|
||||
#define CONF_RTCCTRL (CONF_RTCCTRL_1KHZ ? OSC32KCTRL_RTCCTRL_RTCSEL_ULP1K_Val : OSC32KCTRL_RTCCTRL_RTCSEL_ULP32K_Val)
|
||||
#elif CONF_RTCCTRL_SRC == GCLK_GENCTRL_SRC_XOSC32K
|
||||
#define CONF_RTCCTRL (CONF_RTCCTRL_1KHZ ? OSC32KCTRL_RTCCTRL_RTCSEL_XOSC1K_Val : OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K_Val)
|
||||
#else
|
||||
#error unexpected CONF_RTCCTRL_SRC
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
// </e>
|
||||
|
||||
// <e> 32kHz External Crystal Oscillator Configuration
|
||||
// <i> Indicates whether configuration for External 32K Osc is enabled or not
|
||||
// <id> enable_xosc32k
|
||||
#ifndef CONF_XOSC32K_CONFIG
|
||||
#define CONF_XOSC32K_CONFIG 0
|
||||
#endif
|
||||
|
||||
// <h> 32kHz External Crystal Oscillator Control
|
||||
// <q> Oscillator enable
|
||||
// <i> Indicates whether 32kHz External Crystal Oscillator is enabled or not
|
||||
// <id> xosc32k_arch_enable
|
||||
#ifndef CONF_XOSC32K_ENABLE
|
||||
#define CONF_XOSC32K_ENABLE 0
|
||||
#endif
|
||||
|
||||
// <o> Start-Up Time
|
||||
// <0x0=>62592us
|
||||
// <0x1=>125092us
|
||||
// <0x2=>500092us
|
||||
// <0x3=>1000092us
|
||||
// <0x4=>2000092us
|
||||
// <0x5=>4000092us
|
||||
// <0x6=>8000092us
|
||||
// <id> xosc32k_arch_startup
|
||||
#ifndef CONF_XOSC32K_STARTUP
|
||||
#define CONF_XOSC32K_STARTUP 0x0
|
||||
#endif
|
||||
|
||||
// <q> On Demand Control
|
||||
// <i> Indicates whether On Demand Control is enabled or not
|
||||
// <id> xosc32k_arch_ondemand
|
||||
#ifndef CONF_XOSC32K_ONDEMAND
|
||||
#define CONF_XOSC32K_ONDEMAND 1
|
||||
#endif
|
||||
|
||||
// <q> Run in Standby
|
||||
// <i> Indicates whether Run in Standby is enabled or not
|
||||
// <id> xosc32k_arch_runstdby
|
||||
#ifndef CONF_XOSC32K_RUNSTDBY
|
||||
#define CONF_XOSC32K_RUNSTDBY 0
|
||||
#endif
|
||||
|
||||
// <q> 1kHz Output Enable
|
||||
// <i> Indicates whether 1kHz Output is enabled or not
|
||||
// <id> xosc32k_arch_en1k
|
||||
#ifndef CONF_XOSC32K_EN1K
|
||||
#define CONF_XOSC32K_EN1K 0
|
||||
#endif
|
||||
|
||||
// <q> 32kHz Output Enable
|
||||
// <i> Indicates whether 32kHz Output is enabled or not
|
||||
// <id> xosc32k_arch_en32k
|
||||
#ifndef CONF_XOSC32K_EN32K
|
||||
#define CONF_XOSC32K_EN32K 0
|
||||
#endif
|
||||
|
||||
// <q> Clock Switch Back
|
||||
// <i> Indicates whether Clock Switch Back is enabled or not
|
||||
// <id> xosc32k_arch_swben
|
||||
#ifndef CONF_XOSC32K_SWBEN
|
||||
#define CONF_XOSC32K_SWBEN 0
|
||||
#endif
|
||||
|
||||
// <q> Clock Failure Detector
|
||||
// <i> Indicates whether Clock Failure Detector is enabled or not
|
||||
// <id> xosc32k_arch_cfden
|
||||
#ifndef CONF_XOSC32K_CFDEN
|
||||
#define CONF_XOSC32K_CFDEN 0
|
||||
#endif
|
||||
|
||||
// <q> Clock Failure Detector Event Out
|
||||
// <i> Indicates whether Clock Failure Detector Event Out is enabled or not
|
||||
// <id> xosc32k_arch_cfdeo
|
||||
#ifndef CONF_XOSC32K_CFDEO
|
||||
#define CONF_XOSC32K_CFDEO 0
|
||||
#endif
|
||||
|
||||
// <q> Crystal connected to XIN32/XOUT32 Enable
|
||||
// <i> Indicates whether the connections between the I/O pads and the external clock or crystal oscillator is enabled or not
|
||||
// <id> xosc32k_arch_xtalen
|
||||
#ifndef CONF_XOSC32K_XTALEN
|
||||
#define CONF_XOSC32K_XTALEN 1
|
||||
#endif
|
||||
|
||||
// <o> Control Gain Mode
|
||||
// <0x0=>Low Power mode
|
||||
// <0x1=>Standard mode
|
||||
// <0x2=>High Speed mode
|
||||
// <id> xosc32k_arch_cgm
|
||||
#ifndef CONF_XOSC32K_CGM
|
||||
#define CONF_XOSC32K_CGM 0x1
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
// </e>
|
||||
|
||||
// <e> 32kHz Ultra Low Power Internal Oscillator Configuration
|
||||
// <i> Indicates whether configuration for OSCULP32K is enabled or not
|
||||
// <id> enable_osculp32k
|
||||
#ifndef CONF_OSCULP32K_CONFIG
|
||||
#define CONF_OSCULP32K_CONFIG 1
|
||||
#endif
|
||||
|
||||
// <h> 32kHz Ultra Low Power Internal Oscillator Control
|
||||
|
||||
// <q> Oscillator Calibration Control
|
||||
// <i> Indicates whether Oscillator Calibration is enabled or not
|
||||
// <id> osculp32k_calib_enable
|
||||
#ifndef CONF_OSCULP32K_CALIB_ENABLE
|
||||
#define CONF_OSCULP32K_CALIB_ENABLE 0
|
||||
#endif
|
||||
|
||||
// <o> Oscillator Calibration <0x0-0x3F>
|
||||
// <id> osculp32k_calib
|
||||
#ifndef CONF_OSCULP32K_CALIB
|
||||
#define CONF_OSCULP32K_CALIB 0x0
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
// </e>
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
#endif // HPL_OSC32KCTRL_CONFIG_H
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
/* Auto-generated config file peripheral_clk_config.h */
|
||||
#ifndef PERIPHERAL_CLK_CONFIG_H
|
||||
#define PERIPHERAL_CLK_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
/**
|
||||
* \def CONF_CPU_FREQUENCY
|
||||
* \brief CPU's Clock frequency
|
||||
*/
|
||||
#ifndef CONF_CPU_FREQUENCY
|
||||
#define CONF_CPU_FREQUENCY 48000000
|
||||
#endif
|
||||
|
||||
// <y> Core Clock Source
|
||||
// <id> core_gclk_selection
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
|
||||
|
||||
// <i> Select the clock source for CORE.
|
||||
#ifndef CONF_GCLK_SERCOM3_CORE_SRC
|
||||
#define CONF_GCLK_SERCOM3_CORE_SRC GCLK_PCHCTRL_GEN_GCLK0_Val
|
||||
#endif
|
||||
|
||||
// <y> Slow Clock Source
|
||||
// <id> slow_gclk_selection
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
|
||||
|
||||
// <i> Select the slow clock source.
|
||||
#ifndef CONF_GCLK_SERCOM3_SLOW_SRC
|
||||
#define CONF_GCLK_SERCOM3_SLOW_SRC GCLK_PCHCTRL_GEN_GCLK3_Val
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def CONF_GCLK_SERCOM3_CORE_FREQUENCY
|
||||
* \brief SERCOM3's Core Clock frequency
|
||||
*/
|
||||
#ifndef CONF_GCLK_SERCOM3_CORE_FREQUENCY
|
||||
#define CONF_GCLK_SERCOM3_CORE_FREQUENCY 48000000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def CONF_GCLK_SERCOM3_SLOW_FREQUENCY
|
||||
* \brief SERCOM3's Slow Clock frequency
|
||||
*/
|
||||
#ifndef CONF_GCLK_SERCOM3_SLOW_FREQUENCY
|
||||
#define CONF_GCLK_SERCOM3_SLOW_FREQUENCY 32768
|
||||
#endif
|
||||
|
||||
// <y> USB Clock Source
|
||||
// <id> usb_gclk_selection
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
|
||||
|
||||
// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
|
||||
|
||||
// <i> Select the clock source for USB.
|
||||
#ifndef CONF_GCLK_USB_SRC
|
||||
#define CONF_GCLK_USB_SRC GCLK_PCHCTRL_GEN_GCLK0_Val
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def CONF_GCLK_USB_FREQUENCY
|
||||
* \brief USB's Clock frequency
|
||||
*/
|
||||
#ifndef CONF_GCLK_USB_FREQUENCY
|
||||
#define CONF_GCLK_USB_FREQUENCY 48000000
|
||||
#endif
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
#endif // PERIPHERAL_CLK_CONFIG_H
|
||||
@@ -0,0 +1,9 @@
|
||||
/* Auto-generated config file stdio_redirect_config.h */
|
||||
#ifndef STDIO_REDIRECT_CONFIG_H
|
||||
#define STDIO_REDIRECT_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
#endif // STDIO_REDIRECT_CONFIG_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
STDIO redirection
|
||||
=================
|
||||
|
||||
The STDIO redirection provides means to redirect standard input/output to HAL
|
||||
IO.
|
||||
|
||||
On initialization, the HAL IO descriptor is assigned so that all input and
|
||||
output is redirected to access it. The IO descriptor can also be changed
|
||||
through stdio_io_set_io(). All stdin or stdout access is redirected to the
|
||||
IO descriptor. When the IO descriptor is set to NULL, all input and output
|
||||
are discarded.
|
||||
|
||||
For GCC redirection, the stdout and stdin buffer are turned off, the
|
||||
standard _read() and _write() are overridden.
|
||||
|
||||
For IAR redirection, the __read() and __write() are overridden.
|
||||
|
||||
For Keil redirection, the Retarget.c are modified to override fputc(), fgetc(),
|
||||
etc.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Standard input/output redirection (e.g., printf to EDBG COM port)
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* HAL IO driver
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
* IO read/write operation should be synchronous
|
||||
@@ -0,0 +1,46 @@
|
||||
==============
|
||||
USB Device CDC
|
||||
==============
|
||||
|
||||
USB Device CDC (Communication Device Class)is a part of the USB Device Stack library.
|
||||
It provides support for Abstract Control Model, which is one of the USB PSTN Device
|
||||
Models. The device uses both a Data Class interface and a Communication Class interface
|
||||
for it. For more detailed definition and description about this model, user can refer to
|
||||
the related chapter in <Universal Serial Bus Communications Class Subclass Specification
|
||||
for PSTN Devices, Revision 1.2>
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Initialization/de-initialization.
|
||||
* Data transfer.
|
||||
* Callbacks management on:
|
||||
|
||||
* Transmission done
|
||||
* Reception done
|
||||
* Setting a new Line coding
|
||||
* Line state changing
|
||||
|
||||
Applications
|
||||
------------
|
||||
|
||||
* Used as a vritual serial.
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* USB Device Driver
|
||||
* USB Device Stack Core
|
||||
* USB Protocol CDC
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
* Only single instance can be supported, not applied for multiple case.
|
||||
* The INF and CAT file would be packed in atzip file. User can extract
|
||||
them from "./usb/class/cdc/device".
|
||||
* If user wants to combine CDC with other classes into one device, USB
|
||||
Device Stack Composite component should be added from the web page
|
||||
rather than USB Device Stack CDC ACM.
|
||||
@@ -0,0 +1,41 @@
|
||||
===============
|
||||
USB Device Core
|
||||
===============
|
||||
|
||||
USB Device Core is a part of the USB Device Stack library. It handles all the requests
|
||||
during USB Enumeration process and helps upper class driver to be installed successfully
|
||||
if only the descriptor configuration is correct. For more detailed description about Bus
|
||||
Enumeration, user can refer to Chapter 9 (USB Device Framework) in Universal Serial Bus
|
||||
Specification.
|
||||
|
||||
Features
|
||||
--------
|
||||
* Initialization/de-initialization
|
||||
* Enabling/disabling USB device class components
|
||||
* Data Transfer
|
||||
* Attaching/detaching control
|
||||
* Waking up by USB host
|
||||
* Callbacks management on:
|
||||
|
||||
* SOF event
|
||||
* USB Device state change
|
||||
* USB Device request handler
|
||||
|
||||
|
||||
Applications
|
||||
------------
|
||||
|
||||
N/A
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* USB Device Driver
|
||||
* USB Protocol Core
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
* It is recommended that at least one device class should run above the USB
|
||||
device core.
|
||||
@@ -0,0 +1,24 @@
|
||||
================
|
||||
USB CDC Protocol
|
||||
================
|
||||
|
||||
USB CDC Protocol is a part of the USB Device Stack library. It provides basic
|
||||
macro definitions and data structures which are compliant with CDC(Communications
|
||||
Device Class) Specification version 1.2.
|
||||
|
||||
|
||||
Applications
|
||||
------------
|
||||
|
||||
N/A
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
N/A
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
N/A
|
||||
@@ -0,0 +1,40 @@
|
||||
=================
|
||||
USB Protocol Core
|
||||
=================
|
||||
|
||||
USB Protocol Core is a part of the USB Device Stack library. It provides basic
|
||||
macro definitions, data structures and API functions which are compliant with
|
||||
USB specification version 2.0.0/2.0.1 for user.
|
||||
|
||||
In addition, it provides interfaces of USB descriptor searching for the upper
|
||||
layer to use, which is especially helpful in the USB enumeration process.
|
||||
|
||||
Features
|
||||
--------
|
||||
* Packaging USB device, configuration, interface, endpoint descriptors.
|
||||
* Getting the descriptor length or type from an assigned USB descriptor.
|
||||
* Getting VID, PID value from an assigned USB descriptor.
|
||||
* Getting the total length of an USB configuration descriptor.
|
||||
* Finding the next valid descriptor in a given USB descriptor.
|
||||
* Finding an endpoint descriptor in a given USB descriptor.
|
||||
* Finding a specific descriptor by an assigned descriptor type.
|
||||
* Finding a configure descriptor by an assigned configure value.
|
||||
* Finding a string descriptor by an assigned string index.
|
||||
|
||||
|
||||
Applications
|
||||
------------
|
||||
|
||||
N/A
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
N/A
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
N/A
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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
|
||||
* to avoid losing it when reconfiguring.
|
||||
*/
|
||||
|
||||
#include "driver_init.h"
|
||||
#include <peripheral_clk_config.h>
|
||||
#include <utils.h>
|
||||
#include <hal_init.h>
|
||||
|
||||
struct usart_sync_descriptor TARGET_IO;
|
||||
|
||||
void TARGET_IO_PORT_init(void)
|
||||
{
|
||||
|
||||
gpio_set_pin_function(PA22, PINMUX_PA22C_SERCOM3_PAD0);
|
||||
|
||||
gpio_set_pin_function(PA23, PINMUX_PA23C_SERCOM3_PAD1);
|
||||
}
|
||||
|
||||
void TARGET_IO_CLOCK_init(void)
|
||||
{
|
||||
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
||||
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
||||
|
||||
hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK);
|
||||
}
|
||||
|
||||
void TARGET_IO_init(void)
|
||||
{
|
||||
TARGET_IO_CLOCK_init();
|
||||
usart_sync_init(&TARGET_IO, SERCOM3, (void *)NULL);
|
||||
TARGET_IO_PORT_init();
|
||||
}
|
||||
|
||||
void USB_DEVICE_INSTANCE_PORT_init(void)
|
||||
{
|
||||
|
||||
gpio_set_pin_direction(PA24,
|
||||
// <y> Pin direction
|
||||
// <id> pad_direction
|
||||
// <GPIO_DIRECTION_OFF"> Off
|
||||
// <GPIO_DIRECTION_IN"> In
|
||||
// <GPIO_DIRECTION_OUT"> Out
|
||||
GPIO_DIRECTION_OUT);
|
||||
|
||||
gpio_set_pin_level(PA24,
|
||||
// <y> Initial level
|
||||
// <id> pad_initial_level
|
||||
// <false"> Low
|
||||
// <true"> High
|
||||
false);
|
||||
|
||||
gpio_set_pin_pull_mode(PA24,
|
||||
// <y> Pull configuration
|
||||
// <id> pad_pull_config
|
||||
// <GPIO_PULL_OFF"> Off
|
||||
// <GPIO_PULL_UP"> Pull-up
|
||||
// <GPIO_PULL_DOWN"> Pull-down
|
||||
GPIO_PULL_OFF);
|
||||
|
||||
gpio_set_pin_function(PA24,
|
||||
// <y> Pin function
|
||||
// <id> pad_function
|
||||
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
||||
// <PINMUX_PA24H_USB_DM"> Auto
|
||||
// <GPIO_PIN_FUNCTION_OFF"> Off
|
||||
// <GPIO_PIN_FUNCTION_A"> A
|
||||
// <GPIO_PIN_FUNCTION_B"> B
|
||||
// <GPIO_PIN_FUNCTION_C"> C
|
||||
// <GPIO_PIN_FUNCTION_D"> D
|
||||
// <GPIO_PIN_FUNCTION_E"> E
|
||||
// <GPIO_PIN_FUNCTION_F"> F
|
||||
// <GPIO_PIN_FUNCTION_G"> G
|
||||
// <GPIO_PIN_FUNCTION_H"> H
|
||||
// <GPIO_PIN_FUNCTION_I"> I
|
||||
// <GPIO_PIN_FUNCTION_J"> J
|
||||
// <GPIO_PIN_FUNCTION_K"> K
|
||||
// <GPIO_PIN_FUNCTION_L"> L
|
||||
// <GPIO_PIN_FUNCTION_M"> M
|
||||
// <GPIO_PIN_FUNCTION_N"> N
|
||||
PINMUX_PA24H_USB_DM);
|
||||
|
||||
gpio_set_pin_direction(PA25,
|
||||
// <y> Pin direction
|
||||
// <id> pad_direction
|
||||
// <GPIO_DIRECTION_OFF"> Off
|
||||
// <GPIO_DIRECTION_IN"> In
|
||||
// <GPIO_DIRECTION_OUT"> Out
|
||||
GPIO_DIRECTION_OUT);
|
||||
|
||||
gpio_set_pin_level(PA25,
|
||||
// <y> Initial level
|
||||
// <id> pad_initial_level
|
||||
// <false"> Low
|
||||
// <true"> High
|
||||
false);
|
||||
|
||||
gpio_set_pin_pull_mode(PA25,
|
||||
// <y> Pull configuration
|
||||
// <id> pad_pull_config
|
||||
// <GPIO_PULL_OFF"> Off
|
||||
// <GPIO_PULL_UP"> Pull-up
|
||||
// <GPIO_PULL_DOWN"> Pull-down
|
||||
GPIO_PULL_OFF);
|
||||
|
||||
gpio_set_pin_function(PA25,
|
||||
// <y> Pin function
|
||||
// <id> pad_function
|
||||
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
||||
// <PINMUX_PA25H_USB_DP"> Auto
|
||||
// <GPIO_PIN_FUNCTION_OFF"> Off
|
||||
// <GPIO_PIN_FUNCTION_A"> A
|
||||
// <GPIO_PIN_FUNCTION_B"> B
|
||||
// <GPIO_PIN_FUNCTION_C"> C
|
||||
// <GPIO_PIN_FUNCTION_D"> D
|
||||
// <GPIO_PIN_FUNCTION_E"> E
|
||||
// <GPIO_PIN_FUNCTION_F"> F
|
||||
// <GPIO_PIN_FUNCTION_G"> G
|
||||
// <GPIO_PIN_FUNCTION_H"> H
|
||||
// <GPIO_PIN_FUNCTION_I"> I
|
||||
// <GPIO_PIN_FUNCTION_J"> J
|
||||
// <GPIO_PIN_FUNCTION_K"> K
|
||||
// <GPIO_PIN_FUNCTION_L"> L
|
||||
// <GPIO_PIN_FUNCTION_M"> M
|
||||
// <GPIO_PIN_FUNCTION_N"> N
|
||||
PINMUX_PA25H_USB_DP);
|
||||
}
|
||||
|
||||
/* The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
|
||||
* for low speed and full speed operation. */
|
||||
#if (CONF_GCLK_USB_FREQUENCY > (48000000 + 48000000 / 400)) || (CONF_GCLK_USB_FREQUENCY < (48000000 - 48000000 / 400))
|
||||
#warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
|
||||
#endif
|
||||
|
||||
void USB_DEVICE_INSTANCE_CLOCK_init(void)
|
||||
{
|
||||
|
||||
hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, CONF_GCLK_USB_SRC | GCLK_PCHCTRL_CHEN);
|
||||
hri_mclk_set_AHBMASK_USB_bit(MCLK);
|
||||
hri_mclk_set_APBBMASK_USB_bit(MCLK);
|
||||
}
|
||||
|
||||
void USB_DEVICE_INSTANCE_init(void)
|
||||
{
|
||||
USB_DEVICE_INSTANCE_CLOCK_init();
|
||||
usb_d_init();
|
||||
USB_DEVICE_INSTANCE_PORT_init();
|
||||
}
|
||||
|
||||
void system_init(void)
|
||||
{
|
||||
init_mcu();
|
||||
|
||||
// GPIO on PA16
|
||||
|
||||
gpio_set_pin_level(LED0,
|
||||
// <y> Initial level
|
||||
// <id> pad_initial_level
|
||||
// <false"> Low
|
||||
// <true"> High
|
||||
false);
|
||||
|
||||
// Set pin direction to output
|
||||
gpio_set_pin_direction(LED0, GPIO_DIRECTION_OUT);
|
||||
|
||||
gpio_set_pin_function(LED0, GPIO_PIN_FUNCTION_OFF);
|
||||
|
||||
TARGET_IO_init();
|
||||
|
||||
USB_DEVICE_INSTANCE_init();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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
|
||||
* to avoid losing it when reconfiguring.
|
||||
*/
|
||||
#ifndef DRIVER_INIT_INCLUDED
|
||||
#define DRIVER_INIT_INCLUDED
|
||||
|
||||
#include "atmel_start_pins.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <hal_atomic.h>
|
||||
#include <hal_delay.h>
|
||||
#include <hal_gpio.h>
|
||||
#include <hal_init.h>
|
||||
#include <hal_io.h>
|
||||
#include <hal_sleep.h>
|
||||
|
||||
#include <hal_usart_sync.h>
|
||||
|
||||
#include "hal_usb_device.h"
|
||||
|
||||
extern struct usart_sync_descriptor TARGET_IO;
|
||||
|
||||
void TARGET_IO_PORT_init(void);
|
||||
void TARGET_IO_CLOCK_init(void);
|
||||
void TARGET_IO_init(void);
|
||||
|
||||
void USB_DEVICE_INSTANCE_CLOCK_init(void);
|
||||
void USB_DEVICE_INSTANCE_init(void);
|
||||
|
||||
/**
|
||||
* \brief Perform system initialization, initialize pins and clocks for
|
||||
* peripherals
|
||||
*/
|
||||
void system_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // DRIVER_INIT_INCLUDED
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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
|
||||
* to avoid losing it when reconfiguring.
|
||||
*/
|
||||
|
||||
#include "driver_examples.h"
|
||||
#include "driver_init.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* Example of using TARGET_IO to write "Hello World" using the IO abstraction.
|
||||
*/
|
||||
void TARGET_IO_example(void)
|
||||
{
|
||||
struct io_descriptor *io;
|
||||
usart_sync_get_io_descriptor(&TARGET_IO, &io);
|
||||
usart_sync_enable(&TARGET_IO);
|
||||
|
||||
io_write(io, (uint8_t *)"Hello World!", 12);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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
|
||||
* to avoid losing it when reconfiguring.
|
||||
*/
|
||||
#ifndef DRIVER_EXAMPLES_H_INCLUDED
|
||||
#define DRIVER_EXAMPLES_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void TARGET_IO_example(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // DRIVER_EXAMPLES_H_INCLUDED
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
The USART Synchronous Driver
|
||||
============================
|
||||
|
||||
The universal synchronous and asynchronous receiver and transmitter
|
||||
(USART) is usually used to transfer data from one device to the other.
|
||||
|
||||
User can set action for flow control pins by function usart_set_flow_control,
|
||||
if the flow control is enabled. All the available states are defined in union
|
||||
usart_flow_control_state.
|
||||
|
||||
Note that user can set state of flow control pins only if automatic support of
|
||||
the flow control is not supported by the hardware.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Initialization/de-initialization
|
||||
* Enabling/disabling
|
||||
* Control of the following settings:
|
||||
|
||||
* Baudrate
|
||||
* UART or USRT communication mode
|
||||
* Character size
|
||||
* Data order
|
||||
* Flow control
|
||||
* Data transfer: transmission, reception
|
||||
|
||||
Applications
|
||||
------------
|
||||
|
||||
They are commonly used in a terminal application or low-speed communication
|
||||
between devices.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
USART capable hardware.
|
||||
|
||||
Concurrency
|
||||
-----------
|
||||
|
||||
Write buffer should not be changed while data is being sent.
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
* The driver does not support 9-bit character size.
|
||||
* The "USART with ISO7816" mode can be only used in ISO7816 capable devices.
|
||||
And the SCK pin can't be set directly. Application can use a GCLK output PIN
|
||||
to generate SCK. For example to communicate with a SMARTCARD with ISO7816
|
||||
(F = 372 ; D = 1), and baudrate=9600, the SCK pin output frequency should be
|
||||
config as 372*9600=3571200Hz. More information can be refer to ISO7816 Specification.
|
||||
|
||||
Known issues and workarounds
|
||||
----------------------------
|
||||
|
||||
N/A
|
||||
@@ -0,0 +1,195 @@
|
||||
The USB Device Asynchronous Driver
|
||||
==================================
|
||||
|
||||
Universal Serial Bus (USB) is an industry standard that defines the cables,
|
||||
connectors and communication protocols used in a bus for connection,
|
||||
communication, and power supply between computers and electronic devices.
|
||||
|
||||
The USB device driver provides necessary APIs to support USB Device states and
|
||||
USB data flow. So that the USB Device enumeration, class and vendor support can
|
||||
be implemented base on it. The driver is asynchronous, which means that all USB
|
||||
data processing is done in callbacks..
|
||||
|
||||
To be recognized by a host, a USB device must handle a subset of the USB events.
|
||||
The USB device should build up control communication to report its descriptors
|
||||
to the host and accept host's requests. An application or upper stack that uses
|
||||
the USB device driver should have its descriptors prepared, catch the callbacks,
|
||||
monitor the control requests and handle them correctly.
|
||||
Usually, a USB device application that can be enumerated may use the following
|
||||
sequence:
|
||||
|
||||
* Initialize
|
||||
* Register callback and handle Reset event, where:
|
||||
|
||||
* Initialize endpoint 0
|
||||
* Register callbacks for endpoint 0, where some of the standard requests
|
||||
defined in Chapter 9, USB specification
|
||||
(see `USB 2.0 Documents <http://www.usb.org/developers/docs/usb20_docs>`_)
|
||||
are handled
|
||||
|
||||
* Setup request handling callback
|
||||
|
||||
* On *GetDeviceDescriptor* request, sends device descriptor
|
||||
* On *GetConfigurationDescriptor* request, sends configuration descriptors
|
||||
* On *SetAddress* request sends no data, just goes to status phase
|
||||
* On *SetConfigure* request initialize and enable other endpoints, sends
|
||||
no data, just goes to status phase
|
||||
* Transfer done handling callback
|
||||
|
||||
* On *SetAddress* request apply the new address
|
||||
* On *SetConfigure* request a global variable can be set to indicates
|
||||
that the host driver is loaded and device is ready to work
|
||||
* Enable endpoint 0
|
||||
* Enable
|
||||
* Attach device
|
||||
|
||||
To support USB transfer on endpoints, endpoints information is stored
|
||||
by the driver internally, including control request data, endpoint status,
|
||||
callbacks and transfer data pointers. The number of endpoints that the driver
|
||||
can support is defined through configuration. To optimize RAM usage, the
|
||||
number of endpoints the driver needs to support should be minimized.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Initialization/de-initialization
|
||||
* Enabling/disabling
|
||||
* USB device attachment/detachment
|
||||
* USB device address control
|
||||
* USB working speed status
|
||||
* USB device frame number and micro frame number status
|
||||
* Sending remote wakeup to host
|
||||
* Callback management for following USB events:
|
||||
|
||||
* Start of Frame (SOF)
|
||||
* Other USB events:
|
||||
|
||||
* VBus change
|
||||
* Reset
|
||||
* Wakeup
|
||||
* Linked Power Management (LPM) Suspend
|
||||
* Suspend
|
||||
* Error
|
||||
* Endpoints management:
|
||||
|
||||
* Endpoint initialization/de-initialization
|
||||
* Endpoint enabling/disabling
|
||||
* Control endpoint setup request packet
|
||||
* Data transfer and abort
|
||||
* Endpoint halt state control
|
||||
* Endpoint status, including:
|
||||
|
||||
* Endpoint address
|
||||
* Last transfer result status code
|
||||
* Last error status code
|
||||
* Current transfer state
|
||||
* Transfer size and done count
|
||||
* Endpoint callback management for endpoint and its transfer events:
|
||||
|
||||
* In case a setup request received on control endpoint
|
||||
* In case transfer finished with/without error
|
||||
|
||||
Applications
|
||||
------------
|
||||
|
||||
USB Device stack, to monitor USB events, handle control requests and process
|
||||
data.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* USB device capable hardware
|
||||
* 48MHz clock for low-speed and full-speed and 480MHz clock for high-speed
|
||||
|
||||
Concurrency
|
||||
-----------
|
||||
|
||||
N/A
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
* When a buffer is used by a USB endpoint to transfer data, it must be kept
|
||||
unchanged while the transfer is in progress.
|
||||
* After receiving a request that has no data expected, the transfer function
|
||||
must be called with data length zero to complete control status phase.
|
||||
|
||||
Known issues and workarounds
|
||||
----------------------------
|
||||
|
||||
N/A
|
||||
|
||||
Considerations for D21 USB
|
||||
--------------------------
|
||||
|
||||
Clocks
|
||||
^^^^^^
|
||||
|
||||
DFLL must be used to generate 48MHz clock for USB device with either of the
|
||||
following mode:
|
||||
|
||||
* USB Clock Recovery Mode
|
||||
|
||||
* Set "DFLL Enable", "Bypass Coarse Lock", "Chill Cycle Disable",
|
||||
"USB Clock Recovery Mode", "Stable DFLL Frequency"
|
||||
* Clear "Wait Lock"
|
||||
* Leave "Operating Mode Selection" to "Closed Loop Mode"
|
||||
|
||||
* Closed Loop Mode
|
||||
|
||||
* Set "DFLL Enable"
|
||||
* Clear "USB Clock Recovery Mode", "Stable DFLL Frequency"
|
||||
* Select "Closed Loop Mode" of "Operating Mode Selection"
|
||||
* Set "DFLL Multiply Factor" to 1464 or 1465 (48000000/32768)
|
||||
* Select "Reference Clock Source" to use 32768Hz source, e.g., use GCLK1 and
|
||||
for GCLK1 settings:
|
||||
|
||||
* Set "Generic Clock Generator Enable"
|
||||
* Select "XOSC32K" of "Generic clock generator 1 source", and for XOSC32K
|
||||
settings:
|
||||
|
||||
* Set "External 32K Oscillator Enable", "Enable 32KHz Output",
|
||||
"Enable XTAL"
|
||||
* Set a right value for "Startup time for the 32K Oscillator", e.g.,
|
||||
1125092 us
|
||||
|
||||
Endpoints
|
||||
^^^^^^^^^
|
||||
|
||||
Each USB device endpoint number supports two endpoint addresses, corresponding
|
||||
to IN and OUT endpoint. E.g., for endpoint 1, the endpoint IN has address 0x81
|
||||
and endpoint OUT has address 0x01. Thus, the possible supported endpoint
|
||||
addresses are almost two times of max endpoint number (endpoint 0 must be used
|
||||
as control endpoint instead of dedicated IN and OUT endpoints).
|
||||
|
||||
Buffering and RAM usage optimization
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When transferring data through USB device endpoints, buffer pointers can be
|
||||
used to let endpoint get access to the buffer, but there are some limits:
|
||||
|
||||
* For control endpoint there must always be a buffer available to put received
|
||||
setup packet.
|
||||
* For IN endpoint (transmit to host) the data must in RAM.
|
||||
* For OUT endpoint (receive from host) the data pointer must be aligned, and
|
||||
the data size must be aligned by max endpoint size and not zero.
|
||||
|
||||
The driver has option for each endpoint to allocate internal static buffer as
|
||||
cache to buffer input/output data, to remove upper limits. The configuration
|
||||
affects the parameter check of transfer functions, and the RAM usage.
|
||||
|
||||
* For control endpoints, cache buffer must be enabled to fill setup packet.
|
||||
In addition, to support unaligned OUT packet and IN packet inside flash, the
|
||||
buffer size must be equal to or larger than max endpoint size.
|
||||
* For OUT endpoints, if the cache is allocated, it's possible to pass unaligned
|
||||
buffer address and buffer size to transfer function. Else the transfer
|
||||
function only accepts aligned buffer with it's size multiple of endpoint
|
||||
packet size.
|
||||
* For IN endpoints, if the cache is allocated, it's possible to pass buffer
|
||||
pointer to internal flash or other memory part other than RAM to the transfer
|
||||
function.
|
||||
|
||||
To optimize the RAM usage, the configuration of max endpoint number, max number
|
||||
of endpoints supported and the buffer usage of used input and/or output
|
||||
endpoints can be adjusted.
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Critical sections related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HAL_ATOMIC_H_INCLUDED
|
||||
#define _HAL_ATOMIC_H_INCLUDED
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup doc_driver_hal_helper_atomic
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Type for the register holding global interrupt enable flag
|
||||
*/
|
||||
typedef uint32_t hal_atomic_t;
|
||||
|
||||
/**
|
||||
* \brief Helper macro for entering critical sections
|
||||
*
|
||||
* This macro is recommended to be used instead of a direct call
|
||||
* hal_enterCritical() function to enter critical
|
||||
* sections. No semicolon is required after the macro.
|
||||
*
|
||||
* \section atomic_usage Usage Example
|
||||
* \code
|
||||
* CRITICAL_SECTION_ENTER()
|
||||
* Critical code
|
||||
* CRITICAL_SECTION_LEAVE()
|
||||
* \endcode
|
||||
*/
|
||||
#define CRITICAL_SECTION_ENTER() \
|
||||
{ \
|
||||
volatile hal_atomic_t __atomic; \
|
||||
atomic_enter_critical(&__atomic);
|
||||
|
||||
/**
|
||||
* \brief Helper macro for leaving critical sections
|
||||
*
|
||||
* This macro is recommended to be used instead of a direct call
|
||||
* hal_leaveCritical() function to leave critical
|
||||
* sections. No semicolon is required after the macro.
|
||||
*/
|
||||
#define CRITICAL_SECTION_LEAVE() \
|
||||
atomic_leave_critical(&__atomic); \
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Disable interrupts, enter critical section
|
||||
*
|
||||
* Disables global interrupts. Supports nested critical sections,
|
||||
* so that global interrupts are only re-enabled
|
||||
* upon leaving the outermost nested critical section.
|
||||
*
|
||||
* \param[out] atomic The pointer to a variable to store the value of global
|
||||
* interrupt enable flag
|
||||
*/
|
||||
void atomic_enter_critical(hal_atomic_t volatile *atomic);
|
||||
|
||||
/**
|
||||
* \brief Exit atomic section
|
||||
*
|
||||
* Enables global interrupts. Supports nested critical sections,
|
||||
* so that global interrupts are only re-enabled
|
||||
* upon leaving the outermost nested critical section.
|
||||
*
|
||||
* \param[in] atomic The pointer to a variable, which stores the latest stored
|
||||
* value of the global interrupt enable flag
|
||||
*/
|
||||
void atomic_leave_critical(hal_atomic_t volatile *atomic);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the current driver version
|
||||
*
|
||||
* \return Current driver version.
|
||||
*/
|
||||
uint32_t atomic_get_version(void);
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HAL_ATOMIC_H_INCLUDED */
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief HAL cache functionality implementation.
|
||||
*
|
||||
* Copyright (c)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
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
|
||||
*/
|
||||
|
||||
#ifndef HAL_CACHE_H_
|
||||
#define HAL_CACHE_H_
|
||||
|
||||
#include <hpl_cmcc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Enable cache module
|
||||
*
|
||||
* \param[in] pointer pointing to the starting address of cache module
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t cache_enable(const void *hw);
|
||||
|
||||
/**
|
||||
* \brief Disable cache module
|
||||
*
|
||||
* \param[in] pointer pointing to the starting address of cache module
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t cache_disable(const void *hw);
|
||||
|
||||
/**
|
||||
* \brief Initialize cache module
|
||||
*
|
||||
* This function initialize cache module configuration.
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t cache_init(void);
|
||||
|
||||
/**
|
||||
* \brief Configure cache module
|
||||
*
|
||||
* \param[in] pointer pointing to the starting address of cache module
|
||||
* \param[in] cache configuration structure pointer
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t cache_configure(const void *hw, struct _cache_cfg *cache);
|
||||
|
||||
/**
|
||||
* \brief Invalidate entire cache entries
|
||||
*
|
||||
* \param[in] pointer pointing to the starting address of cache module
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t cache_invalidate_all(const void *hw);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAL_CACHE_H_ */
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief HAL delay related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 <hpl_irq.h>
|
||||
#include <hpl_reset.h>
|
||||
#include <hpl_sleep.h>
|
||||
|
||||
#ifndef _HAL_DELAY_H_INCLUDED
|
||||
#define _HAL_DELAY_H_INCLUDED
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup doc_driver_hal_delay Delay Driver
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize Delay driver
|
||||
*
|
||||
* \param[in] hw The pointer to hardware instance
|
||||
*/
|
||||
void delay_init(void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Perform delay in us
|
||||
*
|
||||
* This function performs delay for the given amount of microseconds.
|
||||
*
|
||||
* \param[in] us The amount delay in us
|
||||
*/
|
||||
void delay_us(const uint16_t us);
|
||||
|
||||
/**
|
||||
* \brief Perform delay in ms
|
||||
*
|
||||
* This function performs delay for the given amount of milliseconds.
|
||||
*
|
||||
* \param[in] ms The amount delay in ms
|
||||
*/
|
||||
void delay_ms(const uint16_t ms);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the current driver version
|
||||
*
|
||||
* \return Current driver version.
|
||||
*/
|
||||
uint32_t delay_get_version(void);
|
||||
|
||||
/**@}*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _HAL_DELAY_H_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief HAL initialization related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HAL_INIT_H_INCLUDED
|
||||
#define _HAL_INIT_H_INCLUDED
|
||||
|
||||
#include <hpl_init.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup doc_driver_hal_helper_init Init Driver
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize the hardware abstraction layer
|
||||
*
|
||||
* This function calls the various initialization functions.
|
||||
* Currently the following initialization functions are supported:
|
||||
* - System clock initialization
|
||||
*/
|
||||
static inline void init_mcu(void)
|
||||
{
|
||||
_init_chip();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retrieve the current driver version
|
||||
*
|
||||
* \return Current driver version.
|
||||
*/
|
||||
uint32_t init_get_version(void);
|
||||
|
||||
/**@}*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _HAL_INIT_H_INCLUDED */
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief I/O related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HAL_IO_INCLUDED
|
||||
#define _HAL_IO_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup doc_driver_hal_helper_io I/O Driver
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief I/O descriptor
|
||||
*
|
||||
* The I/O descriptor forward declaration.
|
||||
*/
|
||||
struct io_descriptor;
|
||||
|
||||
/**
|
||||
* \brief I/O write function pointer type
|
||||
*/
|
||||
typedef int32_t (*io_write_t)(struct io_descriptor *const io_descr, const uint8_t *const buf, const uint16_t length);
|
||||
|
||||
/**
|
||||
* \brief I/O read function pointer type
|
||||
*/
|
||||
typedef int32_t (*io_read_t)(struct io_descriptor *const io_descr, uint8_t *const buf, const uint16_t length);
|
||||
|
||||
/**
|
||||
* \brief I/O descriptor
|
||||
*/
|
||||
struct io_descriptor {
|
||||
io_write_t write; /*! The write function pointer. */
|
||||
io_read_t read; /*! The read function pointer. */
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief I/O write interface
|
||||
*
|
||||
* This function writes up to \p length of bytes to a given I/O descriptor.
|
||||
* It returns the number of bytes actually write.
|
||||
*
|
||||
* \param[in] descr An I/O descriptor to write
|
||||
* \param[in] buf The buffer pointer to story the write data
|
||||
* \param[in] length The number of bytes to write
|
||||
*
|
||||
* \return The number of bytes written
|
||||
*/
|
||||
int32_t io_write(struct io_descriptor *const io_descr, const uint8_t *const buf, const uint16_t length);
|
||||
|
||||
/**
|
||||
* \brief I/O read interface
|
||||
*
|
||||
* This function reads up to \p length bytes from a given I/O descriptor, and
|
||||
* stores it in the buffer pointed to by \p buf. It returns the number of bytes
|
||||
* actually read.
|
||||
*
|
||||
* \param[in] descr An I/O descriptor to read
|
||||
* \param[in] buf The buffer pointer to story the read data
|
||||
* \param[in] length The number of bytes to read
|
||||
*
|
||||
* \return The number of bytes actually read. This number can be less than the
|
||||
* requested length. E.g., in a driver that uses ring buffer for
|
||||
* reception, it may depend on the availability of data in the
|
||||
* ring buffer.
|
||||
*/
|
||||
int32_t io_read(struct io_descriptor *const io_descr, uint8_t *const buf, const uint16_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HAL_IO_INCLUDED */
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Sleep related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HAL_SLEEP_H_INCLUDED
|
||||
#define _HAL_SLEEP_H_INCLUDED
|
||||
|
||||
#include <hpl_sleep.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup doc_driver_hal_helper_sleep
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Set the sleep mode of the device and put the MCU to sleep
|
||||
*
|
||||
* For an overview of which systems are disabled in sleep for the different
|
||||
* sleep modes, see the data sheet.
|
||||
*
|
||||
* \param[in] mode Sleep mode to use
|
||||
*
|
||||
* \return The status of a sleep request
|
||||
* \retval -1 The requested sleep mode was invalid or not available
|
||||
* \retval 0 The operation completed successfully, returned after leaving the
|
||||
* sleep
|
||||
*/
|
||||
int sleep(const uint8_t mode);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the current driver version
|
||||
*
|
||||
* \return Current driver version.
|
||||
*/
|
||||
uint32_t sleep_get_version(void);
|
||||
/**@}*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _HAL_SLEEP_H_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief CPU core related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_CORE_H_INCLUDED
|
||||
#define _HPL_CORE_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL Core
|
||||
*
|
||||
* \section hpl_core_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include "hpl_core_port.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_CORE_H_INCLUDED */
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Delay related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_DELAY_H_INCLUDED
|
||||
#define _HPL_DELAY_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL Delay
|
||||
*
|
||||
* \section hpl_delay_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifndef _UNIT_TEST_
|
||||
#include <compiler.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* \brief Initialize delay functionality
|
||||
*
|
||||
* \param[in] hw The pointer to hardware instance
|
||||
*/
|
||||
void _delay_init(void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the amount of cycles to delay for the given amount of us
|
||||
*
|
||||
* \param[in] us The amount of us to delay for
|
||||
*
|
||||
* \return The amount of cycles
|
||||
*/
|
||||
uint32_t _get_cycles_for_us(const uint16_t us);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the amount of cycles to delay for the given amount of ms
|
||||
*
|
||||
* \param[in] ms The amount of ms to delay for
|
||||
*
|
||||
* \return The amount of cycles
|
||||
*/
|
||||
uint32_t _get_cycles_for_ms(const uint16_t ms);
|
||||
|
||||
/**
|
||||
* \brief Delay loop to delay n number of cycles
|
||||
*
|
||||
* \param[in] hw The pointer to hardware instance
|
||||
* \param[in] cycles The amount of cycles to delay for
|
||||
*/
|
||||
void _delay_cycles(void *const hw, uint32_t cycles);
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_DELAY_H_INCLUDED */
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief DMA related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_DMA_H_INCLUDED
|
||||
#define _HPL_DMA_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL DMA
|
||||
*
|
||||
* \section hpl_dma_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
#include <hpl_irq.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _dma_resource;
|
||||
|
||||
/**
|
||||
* \brief DMA callback types
|
||||
*/
|
||||
enum _dma_callback_type { DMA_TRANSFER_COMPLETE_CB, DMA_TRANSFER_ERROR_CB };
|
||||
|
||||
/**
|
||||
* \brief DMA interrupt callbacks
|
||||
*/
|
||||
struct _dma_callbacks {
|
||||
void (*transfer_done)(struct _dma_resource *resource);
|
||||
void (*error)(struct _dma_resource *resource);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief DMA resource structure
|
||||
*/
|
||||
struct _dma_resource {
|
||||
struct _dma_callbacks dma_cb;
|
||||
void * back;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Initialize DMA
|
||||
*
|
||||
* This function does low level DMA configuration.
|
||||
*
|
||||
* \return initialize status
|
||||
*/
|
||||
int32_t _dma_init(void);
|
||||
|
||||
/**
|
||||
* \brief Set destination address
|
||||
*
|
||||
* \param[in] channel DMA channel to set destination address for
|
||||
* \param[in] dst Destination address
|
||||
*
|
||||
* \return setting status
|
||||
*/
|
||||
int32_t _dma_set_destination_address(const uint8_t channel, const void *const dst);
|
||||
|
||||
/**
|
||||
* \brief Set source address
|
||||
*
|
||||
* \param[in] channel DMA channel to set source address for
|
||||
* \param[in] src Source address
|
||||
*
|
||||
* \return setting status
|
||||
*/
|
||||
int32_t _dma_set_source_address(const uint8_t channel, const void *const src);
|
||||
|
||||
/**
|
||||
* \brief Set next descriptor address
|
||||
*
|
||||
* \param[in] current_channel Current DMA channel to set next descriptor address
|
||||
* \param[in] next_channel Next DMA channel used as next descriptor
|
||||
*
|
||||
* \return setting status
|
||||
*/
|
||||
int32_t _dma_set_next_descriptor(const uint8_t current_channel, const uint8_t next_channel);
|
||||
|
||||
/**
|
||||
* \brief Enable/disable source address incrementation during DMA transaction
|
||||
*
|
||||
* \param[in] channel DMA channel to set source address for
|
||||
* \param[in] enable True to enable, false to disable
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t _dma_srcinc_enable(const uint8_t channel, const bool enable);
|
||||
|
||||
/**
|
||||
* \brief Enable/disable Destination address incrementation during DMA transaction
|
||||
*
|
||||
* \param[in] channel DMA channel to set destination address for
|
||||
* \param[in] enable True to enable, false to disable
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t _dma_dstinc_enable(const uint8_t channel, const bool enable);
|
||||
/**
|
||||
* \brief Set the amount of data to be transfered per transaction
|
||||
*
|
||||
* \param[in] channel DMA channel to set data amount for
|
||||
* \param[in] amount Data amount
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t _dma_set_data_amount(const uint8_t channel, const uint32_t amount);
|
||||
|
||||
/**
|
||||
* \brief Trigger DMA transaction on the given channel
|
||||
*
|
||||
* \param[in] channel DMA channel to trigger transaction on
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t _dma_enable_transaction(const uint8_t channel, const bool software_trigger);
|
||||
|
||||
/**
|
||||
* \brief Retrieves DMA resource structure
|
||||
*
|
||||
* \param[out] resource The resource to be retrieved
|
||||
* \param[in] channel DMA channel to retrieve structure for
|
||||
*
|
||||
* \return status of operation
|
||||
*/
|
||||
int32_t _dma_get_channel_resource(struct _dma_resource **resource, const uint8_t channel);
|
||||
|
||||
/**
|
||||
* \brief Enable/disable DMA interrupt
|
||||
*
|
||||
* \param[in] channel DMA channel to enable/disable interrupt for
|
||||
* \param[in] type The type of interrupt to disable/enable if applicable
|
||||
* \param[in] state Enable or disable
|
||||
*/
|
||||
void _dma_set_irq_state(const uint8_t channel, const enum _dma_callback_type type, const bool state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HPL_DMA_H_INCLUDED */
|
||||
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Port related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_GPIO_H_INCLUDED
|
||||
#define _HPL_GPIO_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL Port
|
||||
*
|
||||
* \section hpl_port_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* \brief Macros for the pin and port group, lower 5
|
||||
* bits stands for pin number in the group, higher 3
|
||||
* bits stands for port group
|
||||
*/
|
||||
#define GPIO_PIN(n) (((n)&0x1Fu) << 0)
|
||||
#define GPIO_PORT(n) ((n) >> 5)
|
||||
#define GPIO(port, pin) ((((port)&0x7u) << 5) + ((pin)&0x1Fu))
|
||||
#define GPIO_PIN_FUNCTION_OFF 0xffffffff
|
||||
|
||||
/**
|
||||
* \brief PORT pull mode settings
|
||||
*/
|
||||
enum gpio_pull_mode { GPIO_PULL_OFF, GPIO_PULL_UP, GPIO_PULL_DOWN };
|
||||
|
||||
/**
|
||||
* \brief PORT direction settins
|
||||
*/
|
||||
enum gpio_direction { GPIO_DIRECTION_OFF, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT };
|
||||
|
||||
/**
|
||||
* \brief PORT group abstraction
|
||||
*/
|
||||
|
||||
enum gpio_port { GPIO_PORTA, GPIO_PORTB, GPIO_PORTC, GPIO_PORTD, GPIO_PORTE };
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Port initialization function
|
||||
*
|
||||
* Port initialization function should setup the port module based
|
||||
* on a static configuration file, this function should normally
|
||||
* not be called directly, but is a part of hal_init()
|
||||
*/
|
||||
void _gpio_init(void);
|
||||
|
||||
/**
|
||||
* \brief Set direction on port with mask
|
||||
*
|
||||
* Set data direction for each pin, or disable the pin
|
||||
*
|
||||
* \param[in] port Ports are grouped into groups of maximum 32 pins,
|
||||
* GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
|
||||
* \param[in] mask Bit mask where 1 means apply direction setting to the
|
||||
* corresponding pin
|
||||
* \param[in] direction GPIO_DIRECTION_OFF = set pin direction to input
|
||||
* and disable input buffer to disable the pin
|
||||
* GPIO_DIRECTION_IN = set pin direction to input
|
||||
* and enable input buffer to enable the pin
|
||||
* GPIO_DIRECTION_OUT = set pin direction to output
|
||||
* and disable input buffer
|
||||
*/
|
||||
static inline void _gpio_set_direction(const enum gpio_port port, const uint32_t mask,
|
||||
const enum gpio_direction direction);
|
||||
|
||||
/**
|
||||
* \brief Set output level on port with mask
|
||||
*
|
||||
* Sets output state on pin to high or low with pin masking
|
||||
*
|
||||
* \param[in] port Ports are grouped into groups of maximum 32 pins,
|
||||
* GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
|
||||
* \param[in] mask Bit mask where 1 means apply direction setting to
|
||||
* the corresponding pin
|
||||
* \param[in] level true = pin level is set to 1
|
||||
* false = pin level is set to 0
|
||||
*/
|
||||
static inline void _gpio_set_level(const enum gpio_port port, const uint32_t mask, const bool level);
|
||||
|
||||
/**
|
||||
* \brief Change output level to the opposite with mask
|
||||
*
|
||||
* Change pin output level to the opposite with pin masking
|
||||
*
|
||||
* \param[in] port Ports are grouped into groups of maximum 32 pins,
|
||||
* GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
|
||||
* \param[in] mask Bit mask where 1 means apply direction setting to
|
||||
* the corresponding pin
|
||||
*/
|
||||
static inline void _gpio_toggle_level(const enum gpio_port port, const uint32_t mask);
|
||||
|
||||
/**
|
||||
* \brief Get input levels on all port pins
|
||||
*
|
||||
* Get input level on all port pins, will read IN register if configured to
|
||||
* input and OUT register if configured as output
|
||||
*
|
||||
* \param[in] port Ports are grouped into groups of maximum 32 pins,
|
||||
* GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
|
||||
*/
|
||||
static inline uint32_t _gpio_get_level(const enum gpio_port port);
|
||||
|
||||
/**
|
||||
* \brief Set pin pull mode
|
||||
*
|
||||
* Set pull mode on a single pin
|
||||
*
|
||||
* \notice This function will automatically change pin direction to input
|
||||
*
|
||||
* \param[in] port Ports are grouped into groups of maximum 32 pins,
|
||||
* GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
|
||||
* \param[in] pin The pin in the group that pull mode should be selected
|
||||
* for
|
||||
* \param[in] pull_mode GPIO_PULL_OFF = pull resistor on pin is disabled
|
||||
* GPIO_PULL_DOWN = pull resistor on pin will pull pin
|
||||
* level to ground level
|
||||
* GPIO_PULL_UP = pull resistor on pin will pull pin
|
||||
* level to VCC
|
||||
*/
|
||||
static inline void _gpio_set_pin_pull_mode(const enum gpio_port port, const uint8_t pin,
|
||||
const enum gpio_pull_mode pull_mode);
|
||||
|
||||
/**
|
||||
* \brief Set gpio function
|
||||
*
|
||||
* Select which function a gpio is used for
|
||||
*
|
||||
* \param[in] gpio The gpio to set function for
|
||||
* \param[in] function The gpio function is given by a 32-bit wide bitfield
|
||||
* found in the header files for the device
|
||||
*
|
||||
*/
|
||||
static inline void _gpio_set_pin_function(const uint32_t gpio, const uint32_t function);
|
||||
|
||||
#include <hpl_gpio_base.h>
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_GPIO_H_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief I2C Master Hardware Proxy Layer(HPL) declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_I2C_M_SYNC_H_INCLUDED
|
||||
#define _HPL_I2C_M_SYNC_H_INCLUDED
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief i2c flags
|
||||
*/
|
||||
#define I2C_M_RD 0x0001 /* read data, from slave to master */
|
||||
#define I2C_M_BUSY 0x0100
|
||||
#define I2C_M_TEN 0x0400 /* this is a ten bit chip address */
|
||||
#define I2C_M_SEVEN 0x0800 /* this is a seven bit chip address */
|
||||
#define I2C_M_FAIL 0x1000
|
||||
#define I2C_M_STOP 0x8000 /* if I2C_FUNC_PROTOCOL_MANGLING */
|
||||
|
||||
/**
|
||||
* \brief i2c Return codes
|
||||
*/
|
||||
#define I2C_OK 0 /* Operation successful */
|
||||
#define I2C_ACK -1 /* Received ACK from device on I2C bus */
|
||||
#define I2C_NACK -2 /* Received NACK from device on I2C bus */
|
||||
#define I2C_ERR_ARBLOST -3 /* Arbitration lost */
|
||||
#define I2C_ERR_BAD_ADDRESS -4 /* Bad address */
|
||||
#define I2C_ERR_BUS -5 /* Bus error */
|
||||
#define I2C_ERR_BUSY -6 /* Device busy */
|
||||
#define I2c_ERR_PACKAGE_COLLISION -7 /* Package collision */
|
||||
|
||||
/**
|
||||
* \brief i2c I2C Modes
|
||||
*/
|
||||
#define I2C_STANDARD_MODE 0x00
|
||||
#define I2C_FASTMODE 0x01
|
||||
#define I2C_HIGHSPEED_MODE 0x02
|
||||
|
||||
/**
|
||||
* \brief i2c master message structure
|
||||
*/
|
||||
struct _i2c_m_msg {
|
||||
uint16_t addr;
|
||||
volatile uint16_t flags;
|
||||
int32_t len;
|
||||
uint8_t * buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief i2c master service
|
||||
*/
|
||||
struct _i2c_m_service {
|
||||
struct _i2c_m_msg msg;
|
||||
uint16_t mode;
|
||||
uint16_t trise;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief i2c sync master device structure
|
||||
*/
|
||||
struct _i2c_m_sync_device {
|
||||
struct _i2c_m_service service;
|
||||
void * hw;
|
||||
};
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize I2C
|
||||
*
|
||||
* This function does low level I2C configuration.
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device structure
|
||||
* \param[in] hw The pointer to hardware instance
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_init(struct _i2c_m_sync_device *const i2c_dev, void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Deinitialize I2C
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_deinit(struct _i2c_m_sync_device *const i2c_dev);
|
||||
|
||||
/**
|
||||
* \brief Enable I2C module
|
||||
*
|
||||
* This function does low level I2C enable.
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_enable(struct _i2c_m_sync_device *const i2c_dev);
|
||||
|
||||
/**
|
||||
* \brief Disable I2C module
|
||||
*
|
||||
* This function does low level I2C disable.
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_disable(struct _i2c_m_sync_device *const i2c_dev);
|
||||
|
||||
/**
|
||||
* \brief Transfer data by I2C
|
||||
*
|
||||
* This function does low level I2C data transfer.
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device structure
|
||||
* \param[in] msg The pointer to i2c msg structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_transfer(struct _i2c_m_sync_device *const i2c_dev, struct _i2c_m_msg *msg);
|
||||
|
||||
/**
|
||||
* \brief Set baud rate of I2C
|
||||
*
|
||||
* This function does low level I2C set baud rate.
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device structure
|
||||
* \param[in] clkrate The clock rate(KHz) input to i2c module
|
||||
* \param[in] baudrate The demand baud rate(KHz) of i2c module
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_set_baudrate(struct _i2c_m_sync_device *const i2c_dev, uint32_t clkrate, uint32_t baudrate);
|
||||
|
||||
/**
|
||||
* \brief Send send condition on the I2C bus
|
||||
*
|
||||
* This function will generate a stop condition on the I2C bus
|
||||
*
|
||||
* \param[in] i2c_dev The pointer to i2c device struct
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_m_sync_send_stop(struct _i2c_m_sync_device *const i2c_dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief I2C Slave Hardware Proxy Layer(HPL) declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_I2C_S_ASYNC_H_INCLUDED
|
||||
#define _HPL_I2C_S_ASYNC_H_INCLUDED
|
||||
|
||||
#include "hpl_i2c_s_sync.h"
|
||||
#include "hpl_irq.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief i2c callback types
|
||||
*/
|
||||
enum _i2c_s_async_callback_type { I2C_S_DEVICE_ERROR, I2C_S_DEVICE_TX, I2C_S_DEVICE_RX_COMPLETE };
|
||||
|
||||
/**
|
||||
* \brief Forward declaration of I2C Slave device
|
||||
*/
|
||||
struct _i2c_s_async_device;
|
||||
|
||||
/**
|
||||
* \brief i2c slave callback function type
|
||||
*/
|
||||
typedef void (*_i2c_s_async_cb_t)(struct _i2c_s_async_device *device);
|
||||
|
||||
/**
|
||||
* \brief i2c slave callback pointers structure
|
||||
*/
|
||||
struct _i2c_s_async_callback {
|
||||
void (*error)(struct _i2c_s_async_device *const device);
|
||||
void (*tx)(struct _i2c_s_async_device *const device);
|
||||
void (*rx_done)(struct _i2c_s_async_device *const device, const uint8_t data);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief i2c slave device structure
|
||||
*/
|
||||
struct _i2c_s_async_device {
|
||||
void * hw;
|
||||
struct _i2c_s_async_callback cb;
|
||||
struct _irq_descriptor irq;
|
||||
};
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize asynchronous I2C slave
|
||||
*
|
||||
* This function does low level I2C configuration.
|
||||
*
|
||||
* \param[in] device The pointer to i2c interrupt device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_async_init(struct _i2c_s_async_device *const device, void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Deinitialize asynchronous I2C in interrupt mode
|
||||
*
|
||||
* \param[in] device The pointer to i2c device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_async_deinit(struct _i2c_s_async_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Enable I2C module
|
||||
*
|
||||
* This function does low level I2C enable.
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_async_enable(struct _i2c_s_async_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Disable I2C module
|
||||
*
|
||||
* This function does low level I2C disable.
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_async_disable(struct _i2c_s_async_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Check if 10-bit addressing mode is on
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Cheking status
|
||||
* \retval 1 10-bit addressing mode is on
|
||||
* \retval 0 10-bit addressing mode is off
|
||||
*/
|
||||
int32_t _i2c_s_async_is_10bit_addressing_on(const struct _i2c_s_async_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Set I2C slave address
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
* \param[in] address Address to set
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_async_set_address(struct _i2c_s_async_device *const device, const uint16_t address);
|
||||
|
||||
/**
|
||||
* \brief Write a byte to the given I2C instance
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
* \param[in] data Data to write
|
||||
*/
|
||||
void _i2c_s_async_write_byte(struct _i2c_s_async_device *const device, const uint8_t data);
|
||||
|
||||
/**
|
||||
* \brief Retrieve I2C slave status
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
*\return I2C slave status
|
||||
*/
|
||||
i2c_s_status_t _i2c_s_async_get_status(const struct _i2c_s_async_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Abort data transmission
|
||||
*
|
||||
* \param[in] device The pointer to i2c device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_async_abort_transmission(const struct _i2c_s_async_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Enable/disable I2C slave interrupt
|
||||
*
|
||||
* param[in] device The pointer to I2C slave device instance
|
||||
* param[in] type The type of interrupt to disable/enable if applicable
|
||||
* param[in] disable Enable or disable
|
||||
*/
|
||||
int32_t _i2c_s_async_set_irq_state(struct _i2c_s_async_device *const device, const enum _i2c_s_async_callback_type type,
|
||||
const bool disable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HPL_I2C_S_ASYNC_H_INCLUDED */
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief I2C Slave Hardware Proxy Layer(HPL) declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_I2C_S_SYNC_H_INCLUDED
|
||||
#define _HPL_I2C_S_SYNC_H_INCLUDED
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief I2C Slave status type
|
||||
*/
|
||||
typedef uint32_t i2c_s_status_t;
|
||||
|
||||
/**
|
||||
* \brief i2c slave device structure
|
||||
*/
|
||||
struct _i2c_s_sync_device {
|
||||
void *hw;
|
||||
};
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Initialize synchronous I2C slave
|
||||
*
|
||||
* This function does low level I2C configuration.
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_sync_init(struct _i2c_s_sync_device *const device, void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Deinitialize synchronous I2C slave
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_sync_deinit(struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Enable I2C module
|
||||
*
|
||||
* This function does low level I2C enable.
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_sync_enable(struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Disable I2C module
|
||||
*
|
||||
* This function does low level I2C disable.
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_sync_disable(struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Check if 10-bit addressing mode is on
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Cheking status
|
||||
* \retval 1 10-bit addressing mode is on
|
||||
* \retval 0 10-bit addressing mode is off
|
||||
*/
|
||||
int32_t _i2c_s_sync_is_10bit_addressing_on(const struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Set I2C slave address
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
* \param[in] address Address to set
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_sync_set_address(struct _i2c_s_sync_device *const device, const uint16_t address);
|
||||
|
||||
/**
|
||||
* \brief Write a byte to the given I2C instance
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
* \param[in] data Data to write
|
||||
*/
|
||||
void _i2c_s_sync_write_byte(struct _i2c_s_sync_device *const device, const uint8_t data);
|
||||
|
||||
/**
|
||||
* \brief Retrieve I2C slave status
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
*\return I2C slave status
|
||||
*/
|
||||
i2c_s_status_t _i2c_s_sync_get_status(const struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Clear the Data Ready interrupt flag
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Return 0 for success and negative value for error
|
||||
*/
|
||||
int32_t _i2c_s_sync_clear_data_ready_flag(const struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Read a byte from the given I2C instance
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Data received via I2C interface.
|
||||
*/
|
||||
uint8_t _i2c_s_sync_read_byte(const struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Check if I2C is ready to send next byte
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Status of the ready check.
|
||||
* \retval true if the I2C is ready to send next byte
|
||||
* \retval false if the I2C is not ready to send next byte
|
||||
*/
|
||||
bool _i2c_s_sync_is_byte_sent(const struct _i2c_s_sync_device *const device);
|
||||
|
||||
/**
|
||||
* \brief Check if there is data received by I2C
|
||||
*
|
||||
* \param[in] device The pointer to i2c slave device structure
|
||||
*
|
||||
* \return Status of the data received check.
|
||||
* \retval true if the I2C has received a byte
|
||||
* \retval false if the I2C has not received a byte
|
||||
*/
|
||||
bool _i2c_s_sync_is_byte_received(const struct _i2c_s_sync_device *const device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HPL_I2C_S_SYNC_H_INCLUDED */
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Init related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_INIT_H_INCLUDED
|
||||
#define _HPL_INIT_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL Init
|
||||
*
|
||||
* \section hpl_init_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Initializes clock sources
|
||||
*/
|
||||
void _sysctrl_init_sources(void);
|
||||
|
||||
/**
|
||||
* \brief Initializes Power Manager
|
||||
*/
|
||||
void _pm_init(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize generators
|
||||
*/
|
||||
void _gclk_init_generators(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize 32 kHz clock sources
|
||||
*/
|
||||
void _osc32kctrl_init_sources(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize clock sources
|
||||
*/
|
||||
void _oscctrl_init_sources(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize clock sources that need input reference clocks
|
||||
*/
|
||||
void _sysctrl_init_referenced_generators(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize clock sources that need input reference clocks
|
||||
*/
|
||||
void _oscctrl_init_referenced_generators(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize master clock generator
|
||||
*/
|
||||
void _mclk_init(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize clock generator
|
||||
*/
|
||||
void _lpmcu_misc_regs_init(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize clock generator
|
||||
*/
|
||||
void _pmc_init(void);
|
||||
|
||||
/**
|
||||
* \brief Set performance level
|
||||
*
|
||||
* \param[in] level The performance level to set
|
||||
*/
|
||||
void _set_performance_level(const uint8_t level);
|
||||
|
||||
/**
|
||||
* \brief Initialize the chip
|
||||
*/
|
||||
void _init_chip(void);
|
||||
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_INIT_H_INCLUDED */
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief IRQ related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_IRQ_H_INCLUDED
|
||||
#define _HPL_IRQ_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL IRQ
|
||||
*
|
||||
* \section hpl_irq_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief IRQ descriptor
|
||||
*/
|
||||
struct _irq_descriptor {
|
||||
void (*handler)(void *parameter);
|
||||
void *parameter;
|
||||
};
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Retrieve current IRQ number
|
||||
*
|
||||
* \return The current IRQ number
|
||||
*/
|
||||
uint8_t _irq_get_current(void);
|
||||
|
||||
/**
|
||||
* \brief Disable the given IRQ
|
||||
*
|
||||
* \param[in] n The number of IRQ to disable
|
||||
*/
|
||||
void _irq_disable(uint8_t n);
|
||||
|
||||
/**
|
||||
* \brief Set the given IRQ
|
||||
*
|
||||
* \param[in] n The number of IRQ to set
|
||||
*/
|
||||
void _irq_set(uint8_t n);
|
||||
|
||||
/**
|
||||
* \brief Clear the given IRQ
|
||||
*
|
||||
* \param[in] n The number of IRQ to clear
|
||||
*/
|
||||
void _irq_clear(uint8_t n);
|
||||
|
||||
/**
|
||||
* \brief Enable the given IRQ
|
||||
*
|
||||
* \param[in] n The number of IRQ to enable
|
||||
*/
|
||||
void _irq_enable(uint8_t n);
|
||||
|
||||
/**
|
||||
* \brief Register IRQ handler
|
||||
*
|
||||
* \param[in] number The number registered IRQ
|
||||
* \param[in] irq The pointer to irq handler to register
|
||||
*
|
||||
* \return The status of IRQ handler registering
|
||||
* \retval -1 Passed parameters were invalid
|
||||
* \retval 0 The registering is completed successfully
|
||||
*/
|
||||
void _irq_register(const uint8_t number, struct _irq_descriptor *const irq);
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_IRQ_H_INCLUDED */
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Family-dependent missing features expected by HAL
|
||||
*
|
||||
* 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 _HPL_MISSING_FEATURES
|
||||
#define _HPL_MISSING_FEATURES
|
||||
|
||||
#endif /* _HPL_MISSING_FEATURES */
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief RAMECC related 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 _HPL_RAMECC_H_INCLUDED
|
||||
#define _HPL_RAMECC_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL RAMECC
|
||||
*
|
||||
* \section hpl_ramecc_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
#include <hpl_irq.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief RAMECC callback type
|
||||
*/
|
||||
typedef void (*ramecc_cb_t)(const uint32_t data);
|
||||
|
||||
/**
|
||||
* \brief RAMECC callback types
|
||||
*/
|
||||
enum _ramecc_callback_type { RAMECC_DUAL_ERROR_CB, RAMECC_SINGLE_ERROR_CB };
|
||||
|
||||
/**
|
||||
* \brief RAMECC interrupt callbacks
|
||||
*/
|
||||
struct _ramecc_callbacks {
|
||||
ramecc_cb_t dual_bit_err;
|
||||
ramecc_cb_t single_bit_err;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief RAMECC device structure
|
||||
*/
|
||||
struct _ramecc_device {
|
||||
struct _ramecc_callbacks ramecc_cb;
|
||||
struct _irq_descriptor irq;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Initialize RAMECC
|
||||
*
|
||||
* This function does low level RAMECC configuration.
|
||||
*
|
||||
* \return initialize status
|
||||
*/
|
||||
int32_t _ramecc_init(void);
|
||||
|
||||
/**
|
||||
* \brief Register RAMECC callback
|
||||
*
|
||||
* \param[in] type The type of callback
|
||||
* \param[in] cb A callback function
|
||||
*/
|
||||
void _ramecc_register_callback(const enum _ramecc_callback_type type, ramecc_cb_t cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HPL_RAMECC_H_INCLUDED */
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Reset related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_RESET_H_INCLUDED
|
||||
#define _HPL_RESET_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL Reset
|
||||
*
|
||||
* \section hpl_reset_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifndef _UNIT_TEST_
|
||||
#include <compiler.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Reset reason enumeration
|
||||
*
|
||||
* The list of possible reset reasons.
|
||||
*/
|
||||
enum reset_reason {
|
||||
RESET_REASON_POR = 1,
|
||||
RESET_REASON_BOD12 = 2,
|
||||
RESET_REASON_BOD33 = 4,
|
||||
RESET_REASON_NVM = 8,
|
||||
RESET_REASON_EXT = 16,
|
||||
RESET_REASON_WDT = 32,
|
||||
RESET_REASON_SYST = 64,
|
||||
RESET_REASON_BACKUP = 128
|
||||
};
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Retrieve the reset reason
|
||||
*
|
||||
* Retrieves the reset reason of the last MCU reset.
|
||||
*
|
||||
*\return An enum value indicating the reason of the last reset.
|
||||
*/
|
||||
enum reset_reason _get_reset_reason(void);
|
||||
|
||||
/**
|
||||
* \brief Reset MCU
|
||||
*/
|
||||
void _reset_mcu(void);
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_RESET_H_INCLUDED */
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Sleep related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_SLEEP_H_INCLUDED
|
||||
#define _HPL_SLEEP_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL Sleep
|
||||
*
|
||||
* \section hpl_sleep_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifndef _UNIT_TEST_
|
||||
#include <compiler.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Set the sleep mode for the device
|
||||
*
|
||||
* This function sets the sleep mode for the device.
|
||||
* For an overview of which systems are disabled in sleep for the different
|
||||
* sleep modes see datasheet.
|
||||
*
|
||||
* \param[in] mode Sleep mode to use
|
||||
*
|
||||
* \return the status of a sleep request
|
||||
* \retval -1 The requested sleep mode was invalid
|
||||
* \retval 0 The operation completed successfully, sleep mode is set
|
||||
*/
|
||||
int32_t _set_sleep_mode(const uint8_t mode);
|
||||
|
||||
/**
|
||||
* \brief Reset MCU
|
||||
*/
|
||||
void _reset_mcu(void);
|
||||
|
||||
/**
|
||||
* \brief Put MCU to sleep
|
||||
*/
|
||||
void _go_to_sleep(void);
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_SLEEP_H_INCLUDED */
|
||||
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief SPI related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_SPI_H_INCLUDED
|
||||
#define _HPL_SPI_H_INCLUDED
|
||||
|
||||
#include <compiler.h>
|
||||
#include <utils.h>
|
||||
|
||||
/**
|
||||
* \addtogroup hpl_spi HPL SPI
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief SPI Dummy char is used when reading data from the SPI slave
|
||||
*/
|
||||
#define SPI_DUMMY_CHAR 0x1ff
|
||||
|
||||
/**
|
||||
* \brief SPI message to let driver to process
|
||||
*/
|
||||
//@{
|
||||
struct spi_msg {
|
||||
/** Pointer to the output data buffer */
|
||||
uint8_t *txbuf;
|
||||
/** Pointer to the input data buffer */
|
||||
uint8_t *rxbuf;
|
||||
/** Size of the message data in SPI characters */
|
||||
uint32_t size;
|
||||
};
|
||||
//@}
|
||||
|
||||
/**
|
||||
* \brief SPI transfer modes
|
||||
* SPI transfer mode controls clock polarity and clock phase.
|
||||
* Mode 0: leading edge is rising edge, data sample on leading edge.
|
||||
* Mode 1: leading edge is rising edge, data sample on trailing edge.
|
||||
* Mode 2: leading edge is falling edge, data sample on leading edge.
|
||||
* Mode 3: leading edge is falling edge, data sample on trailing edge.
|
||||
*/
|
||||
enum spi_transfer_mode {
|
||||
/** Leading edge is rising edge, data sample on leading edge. */
|
||||
SPI_MODE_0,
|
||||
/** Leading edge is rising edge, data sample on trailing edge. */
|
||||
SPI_MODE_1,
|
||||
/** Leading edge is falling edge, data sample on leading edge. */
|
||||
SPI_MODE_2,
|
||||
/** Leading edge is falling edge, data sample on trailing edge. */
|
||||
SPI_MODE_3
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief SPI character sizes
|
||||
* The character size influence the way the data is sent/received.
|
||||
* For char size <= 8 data is stored byte by byte.
|
||||
* For char size between 9 ~ 16 data is stored in 2-byte length.
|
||||
* Note that the default and recommended char size is 8 bit since it's
|
||||
* supported by all system.
|
||||
*/
|
||||
enum spi_char_size {
|
||||
/** Character size is 8 bit. */
|
||||
SPI_CHAR_SIZE_8 = 0,
|
||||
/** Character size is 9 bit. */
|
||||
SPI_CHAR_SIZE_9 = 1,
|
||||
/** Character size is 10 bit. */
|
||||
SPI_CHAR_SIZE_10 = 2,
|
||||
/** Character size is 11 bit. */
|
||||
SPI_CHAR_SIZE_11 = 3,
|
||||
/** Character size is 12 bit. */
|
||||
SPI_CHAR_SIZE_12 = 4,
|
||||
/** Character size is 13 bit. */
|
||||
SPI_CHAR_SIZE_13 = 5,
|
||||
/** Character size is 14 bit. */
|
||||
SPI_CHAR_SIZE_14 = 6,
|
||||
/** Character size is 15 bit. */
|
||||
SPI_CHAR_SIZE_15 = 7,
|
||||
/** Character size is 16 bit. */
|
||||
SPI_CHAR_SIZE_16 = 8
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief SPI data order
|
||||
*/
|
||||
enum spi_data_order {
|
||||
/** MSB goes first. */
|
||||
SPI_DATA_ORDER_MSB_1ST = 0,
|
||||
/** LSB goes first. */
|
||||
SPI_DATA_ORDER_LSB_1ST = 1
|
||||
};
|
||||
|
||||
/** \brief Transfer descriptor for SPI
|
||||
* Transfer descriptor holds TX and RX buffers
|
||||
*/
|
||||
struct spi_xfer {
|
||||
/** Pointer to data buffer to TX */
|
||||
uint8_t *txbuf;
|
||||
/** Pointer to data buffer to RX */
|
||||
uint8_t *rxbuf;
|
||||
/** Size of data characters to TX & RX */
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/** SPI generic driver. */
|
||||
struct spi_dev {
|
||||
/** Pointer to the hardware base or private data for special device. */
|
||||
void *prvt;
|
||||
/** Reference start of sync/async variables */
|
||||
uint32_t sync_async_misc[1];
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Calculate the baudrate value for hardware to use to set baudrate
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] clk Clock frequency (Hz) for baudrate generation.
|
||||
* \param[in] baud Target baudrate (bps).
|
||||
* \return Error or baudrate value.
|
||||
* \retval >0 Baudrate value.
|
||||
* \retval ERR_INVALID_ARG Calculation fail.
|
||||
*/
|
||||
int32_t _spi_calc_baud_val(struct spi_dev *dev, const uint32_t clk, const uint32_t baud);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
#endif /* ifndef _HPL_SPI_H_INCLUDED */
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Common SPI related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_SPI_ASYNC_H_INCLUDED
|
||||
#define _HPL_SPI_ASYNC_H_INCLUDED
|
||||
|
||||
#include <hpl_spi.h>
|
||||
#include <hpl_irq.h>
|
||||
|
||||
/**
|
||||
* \addtogroup hpl_spi HPL SPI
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Callbacks the SPI driver must offer in async mode
|
||||
*/
|
||||
//@{
|
||||
/** The callback types */
|
||||
enum _spi_async_dev_cb_type {
|
||||
/** Callback type for transmit, see \ref _spi_async_dev_cb_xfer_t. */
|
||||
SPI_DEV_CB_TX,
|
||||
/** Callback type for receive, see \ref _spi_async_dev_cb_xfer_t. */
|
||||
SPI_DEV_CB_RX,
|
||||
/** Callback type for \ref _spi_async_dev_cb_complete_t. */
|
||||
SPI_DEV_CB_COMPLETE,
|
||||
/** Callback type for error */
|
||||
SPI_DEV_CB_ERROR,
|
||||
/** Number of callbacks. */
|
||||
SPI_DEV_CB_N
|
||||
};
|
||||
|
||||
struct _spi_async_dev;
|
||||
|
||||
/** \brief The prototype for callback on SPI transfer error.
|
||||
* If status code is zero, it indicates the normal completion, that is,
|
||||
* SS deactivation.
|
||||
* If status code belows zero, it indicates complete.
|
||||
*/
|
||||
typedef void (*_spi_async_dev_cb_error_t)(struct _spi_async_dev *dev, int32_t status);
|
||||
|
||||
/** \brief The prototype for callback on SPI transmit/receive event
|
||||
* For TX, the callback is invoked when transmit is done or ready to start
|
||||
* transmit.
|
||||
* For RX, the callback is invoked when receive is done or ready to read data,
|
||||
* see \ref _spi_async_dev_read_one_t on data reading.
|
||||
* Without DMA enabled, the callback is invoked on each character event.
|
||||
* With DMA enabled, the callback is invoked on DMA buffer done.
|
||||
*/
|
||||
typedef void (*_spi_async_dev_cb_xfer_t)(struct _spi_async_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief The callbacks offered by SPI driver
|
||||
*/
|
||||
struct _spi_async_dev_callbacks {
|
||||
/** TX callback, see \ref _spi_async_dev_cb_xfer_t. */
|
||||
_spi_async_dev_cb_xfer_t tx;
|
||||
/** RX callback, see \ref _spi_async_dev_cb_xfer_t. */
|
||||
_spi_async_dev_cb_xfer_t rx;
|
||||
/** Complete or complete callback, see \ref _spi_async_dev_cb_complete_t. */
|
||||
_spi_async_dev_cb_xfer_t complete;
|
||||
/** Error callback, see \ref */
|
||||
_spi_async_dev_cb_error_t err;
|
||||
};
|
||||
//@}
|
||||
|
||||
/**
|
||||
* \brief SPI async driver
|
||||
*/
|
||||
//@{
|
||||
|
||||
/** SPI driver to support async HAL */
|
||||
struct _spi_async_dev {
|
||||
/** Pointer to the hardware base or private data for special device. */
|
||||
void *prvt;
|
||||
/** Data size, number of bytes for each character */
|
||||
uint8_t char_size;
|
||||
/** Dummy byte used in master mode when reading the slave */
|
||||
uint16_t dummy_byte;
|
||||
|
||||
/** \brief Pointer to callback functions, ignored for polling mode
|
||||
* Pointer to the callback functions so that initialize the driver to
|
||||
* handle interrupts.
|
||||
*/
|
||||
struct _spi_async_dev_callbacks callbacks;
|
||||
/** IRQ instance for SPI device. */
|
||||
struct _irq_descriptor irq;
|
||||
};
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
#endif /* ifndef _HPL_SPI_ASYNC_H_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief SPI Master DMA related 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 _HPL_SPI_M_DMA_H_INCLUDED
|
||||
#define _HPL_SPI_M_DMA_H_INCLUDED
|
||||
|
||||
#include <hpl_spi.h>
|
||||
#include <hpl_spi_dma.h>
|
||||
|
||||
/**
|
||||
* \addtogroup hpl_spi HPL SPI
|
||||
*
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Uses common SPI dma device driver. */
|
||||
#define _spi_m_dma_dev _spi_dma_dev
|
||||
|
||||
#define _spi_m_dma_dev_cb_type _spi_dma_dev_cb_type
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Initialize SPI for access with interrupts
|
||||
* It will load default hardware configuration and software struct.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] hw Pointer to the hardware base.
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG Input parameter problem.
|
||||
* \retval ERR_BUSY SPI hardware not ready (resetting).
|
||||
* \retval ERR_DENIED SPI has been enabled.
|
||||
* \retval 0 ERR_NONE is operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_init(struct _spi_m_dma_dev *dev, void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Initialize SPI for access with interrupts
|
||||
* Disable, reset the hardware and the software struct.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \return Operation status.
|
||||
* \retval 0 ERR_NONE is operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_deinit(struct _spi_m_dma_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief Enable SPI for access with interrupts
|
||||
* Enable the SPI and enable callback generation of receive and error
|
||||
* interrupts.
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG Input parameter problem.
|
||||
* \retval ERR_BUSY SPI hardware not ready (resetting).
|
||||
* \retval 0 ERR_NONE is operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_enable(struct _spi_m_dma_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief Disable SPI for access without interrupts
|
||||
* Disable SPI and interrupts. Deactivate all CS pins if works as master.
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \return Operation status.
|
||||
* \retval 0 ERR_NONE is operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_disable(struct _spi_m_dma_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief Set SPI transfer mode
|
||||
* Set SPI transfer mode (\ref spi_transfer_mode),
|
||||
* which controls clock polarity and clock phase.
|
||||
* Mode 0: leading edge is rising edge, data sample on leading edge.
|
||||
* Mode 1: leading edge is rising edge, data sample on trailing edge.
|
||||
* Mode 2: leading edge is falling edge, data sample on leading edge.
|
||||
* Mode 3: leading edge is falling edge, data sample on trailing edge.
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \param[in] mode The SPI transfer mode.
|
||||
* \return Operation status.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 ERR_NONE is operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_set_mode(struct _spi_m_dma_dev *dev, const enum spi_transfer_mode mode);
|
||||
|
||||
/**
|
||||
* \brief Set SPI baudrate
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \param[in] baud_val The SPI baudrate value, see \ref _spi_calc_baud_val() on
|
||||
* how it's generated.
|
||||
* \return Operation status.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_set_baudrate(struct _spi_m_dma_dev *dev, const uint32_t baud_val);
|
||||
|
||||
/**
|
||||
* \brief Set SPI baudrate
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] char_size The character size, see \ref spi_char_size.
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG The character size is not supported.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_set_char_size(struct _spi_m_dma_dev *dev, const enum spi_char_size char_size);
|
||||
|
||||
/**
|
||||
* \brief Set SPI data order
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \param[in] dord SPI data order (LSB/MSB first).
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG The character size is not supported.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_dma_set_data_order(struct _spi_m_dma_dev *dev, const enum spi_data_order dord);
|
||||
|
||||
/**
|
||||
* \brief Register the SPI device callback
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \param[in] cb_type The callback type.
|
||||
* \param[in] func The callback function to register. NULL to disable callback.
|
||||
* \return Always 0.
|
||||
*/
|
||||
void _spi_m_dma_register_callback(struct _spi_m_dma_dev *dev, enum _spi_dma_dev_cb_type, _spi_dma_cb_t func);
|
||||
|
||||
/** \brief Do SPI data transfer (TX & RX) with DMA
|
||||
* Log the TX & RX buffers and transfer them in background. It never blocks.
|
||||
*
|
||||
* \param[in] dev Pointer to the SPI device instance.
|
||||
* \param[in] txbuf Pointer to the transfer information (\ref spi_transfer).
|
||||
* \param[out] rxbuf Pointer to the receiver information (\ref spi_receive).
|
||||
* \param[in] length spi transfer data length.
|
||||
*
|
||||
* \return Operation status.
|
||||
* \retval ERR_NONE Success.
|
||||
* \retval ERR_BUSY Busy.
|
||||
*/
|
||||
int32_t _spi_m_dma_transfer(struct _spi_m_dma_dev *dev, uint8_t const *txbuf, uint8_t *const rxbuf,
|
||||
const uint16_t length);
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
#endif /* ifndef _HPL_SPI_M_DMA_H_INCLUDED */
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief SPI related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_SPI_M_SYNC_H_INCLUDED
|
||||
#define _HPL_SPI_M_SYNC_H_INCLUDED
|
||||
|
||||
#include <hpl_spi.h>
|
||||
#include <hpl_spi_sync.h>
|
||||
|
||||
/**
|
||||
* \addtogroup hpl_spi HPL SPI
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Uses common SPI sync device driver. */
|
||||
#define _spi_m_sync_dev _spi_sync_dev
|
||||
|
||||
/**
|
||||
* \name HPL functions
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* \brief Initialize SPI for access without interrupts
|
||||
* It will load default hardware configuration and software struct.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] hw Pointer to the hardware base.
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG Input parameter problem.
|
||||
* \retval ERR_BUSY SPI hardware not ready (resetting).
|
||||
* \retval ERR_DENIED SPI has been enabled.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_init(struct _spi_m_sync_dev *dev, void *const hw);
|
||||
|
||||
/**
|
||||
* \brief Deinitialize SPI
|
||||
* Disable, reset the hardware and the software struct.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \return Operation status.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_deinit(struct _spi_m_sync_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief Enable SPI for access without interrupts
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \return Operation status.
|
||||
* \retval ERR_BUSY SPI hardware not ready (resetting).
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_enable(struct _spi_m_sync_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief Disable SPI for access without interrupts
|
||||
* Disable SPI. Deactivate all CS pins if works as master.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \return Operation status.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_disable(struct _spi_m_sync_dev *dev);
|
||||
|
||||
/**
|
||||
* \brief Set SPI transfer mode
|
||||
* Set SPI transfer mode (\ref spi_transfer_mode),
|
||||
* which controls clock polarity and clock phase.
|
||||
* Mode 0: leading edge is rising edge, data sample on leading edge.
|
||||
* Mode 1: leading edge is rising edge, data sample on trailing edge.
|
||||
* Mode 2: leading edge is falling edge, data sample on leading edge.
|
||||
* Mode 3: leading edge is falling edge, data sample on trailing edge.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] mode The SPI transfer mode.
|
||||
* \return Operation status.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_set_mode(struct _spi_m_sync_dev *dev, const enum spi_transfer_mode mode);
|
||||
|
||||
/**
|
||||
* \brief Set SPI baudrate
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] baud_val The SPI baudrate value, see \ref _spi_calc_baud_val() on
|
||||
* how it's generated.
|
||||
* \return Operation status.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_set_baudrate(struct _spi_m_sync_dev *dev, const uint32_t baud_val);
|
||||
|
||||
/**
|
||||
* \brief Set SPI char size
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] char_size The character size, see \ref spi_char_size.
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG The character size is not supported.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_set_char_size(struct _spi_m_sync_dev *dev, const enum spi_char_size char_size);
|
||||
|
||||
/**
|
||||
* \brief Set SPI data order
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] dord SPI data order (LSB/MSB first).
|
||||
* \return Operation status.
|
||||
* \retval ERR_INVALID_ARG The character size is not supported.
|
||||
* \retval ERR_BUSY SPI is not ready to accept new setting.
|
||||
* \retval 0 Operation done successfully.
|
||||
*/
|
||||
int32_t _spi_m_sync_set_data_order(struct _spi_m_sync_dev *dev, const enum spi_data_order dord);
|
||||
|
||||
/**
|
||||
* \brief Transfer the whole message without interrupt
|
||||
* Transfer the message, it will keep waiting until the message finish or
|
||||
* error.
|
||||
* \param[in, out] dev Pointer to the SPI device instance.
|
||||
* \param[in] msg Pointer to the message instance to process.
|
||||
* \return Error or number of characters transferred.
|
||||
* \retval ERR_BUSY SPI hardware is not ready to start transfer (not
|
||||
* enabled, busy applying settings, ...).
|
||||
* \retval SPI_ERR_OVERFLOW Overflow error.
|
||||
* \retval >=0 Number of characters transferred.
|
||||
*/
|
||||
int32_t _spi_m_sync_trans(struct _spi_m_sync_dev *dev, const struct spi_msg *msg);
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
#endif /* ifndef _HPL_SPI_M_SYNC_H_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief Common SPI related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2015-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 _HPL_SPI_SYNC_H_INCLUDED
|
||||
#define _HPL_SPI_SYNC_H_INCLUDED
|
||||
|
||||
#include <compiler.h>
|
||||
#include <utils.h>
|
||||
|
||||
#include <hpl_spi.h>
|
||||
|
||||
/**
|
||||
* \addtogroup hpl_spi HPL SPI
|
||||
*
|
||||
* \section hpl_spi_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** SPI driver to support sync HAL */
|
||||
struct _spi_sync_dev {
|
||||
/** Pointer to the hardware base or private data for special device. */
|
||||
void *prvt;
|
||||
/** Data size, number of bytes for each character */
|
||||
uint8_t char_size;
|
||||
/** Dummy byte used in master mode when reading the slave */
|
||||
uint16_t dummy_byte;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
#endif /* ifndef _HPL_SPI_SYNC_H_INCLUDED */
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \brief USART related functionality declaration.
|
||||
*
|
||||
* Copyright (c) 2014-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 _HPL_USART_H_INCLUDED
|
||||
#define _HPL_USART_H_INCLUDED
|
||||
|
||||
/**
|
||||
* \addtogroup HPL USART SYNC
|
||||
*
|
||||
* \section hpl_usart_sync_rev Revision History
|
||||
* - v1.0.0 Initial Release
|
||||
*
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief USART flow control state
|
||||
*/
|
||||
union usart_flow_control_state {
|
||||
struct {
|
||||
uint8_t cts : 1;
|
||||
uint8_t rts : 1;
|
||||
uint8_t unavailable : 1;
|
||||
uint8_t reserved : 5;
|
||||
} bit;
|
||||
uint8_t value;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief USART baud rate mode
|
||||
*/
|
||||
enum usart_baud_rate_mode { USART_BAUDRATE_ASYNCH_ARITHMETIC, USART_BAUDRATE_ASYNCH_FRACTIONAL, USART_BAUDRATE_SYNCH };
|
||||
|
||||
/**
|
||||
* \brief USART data order
|
||||
*/
|
||||
enum usart_data_order { USART_DATA_ORDER_MSB = 0, USART_DATA_ORDER_LSB = 1 };
|
||||
|
||||
/**
|
||||
* \brief USART mode
|
||||
*/
|
||||
enum usart_mode { USART_MODE_ASYNCHRONOUS = 0, USART_MODE_SYNCHRONOUS = 1 };
|
||||
|
||||
/**
|
||||
* \brief USART parity
|
||||
*/
|
||||
enum usart_parity {
|
||||
USART_PARITY_EVEN = 0,
|
||||
USART_PARITY_ODD = 1,
|
||||
USART_PARITY_NONE = 2,
|
||||
USART_PARITY_SPACE = 3,
|
||||
USART_PARITY_MARK = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief USART stop bits mode
|
||||
*/
|
||||
enum usart_stop_bits { USART_STOP_BITS_ONE = 0, USART_STOP_BITS_TWO = 1, USART_STOP_BITS_ONE_P_FIVE = 2 };
|
||||
|
||||
/**
|
||||
* \brief USART character size
|
||||
*/
|
||||
enum usart_character_size {
|
||||
USART_CHARACTER_SIZE_8BITS = 0,
|
||||
USART_CHARACTER_SIZE_9BITS = 1,
|
||||
USART_CHARACTER_SIZE_5BITS = 5,
|
||||
USART_CHARACTER_SIZE_6BITS = 6,
|
||||
USART_CHARACTER_SIZE_7BITS = 7
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
#endif /* _HPL_USART_H_INCLUDED */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user