├── targetspi.h ├── sam3u_hal ├── inc │ ├── compiler.h │ ├── tasks.h │ ├── usart_driver.h │ ├── usb.h │ ├── fpga_xmem.h │ ├── udi_composite_conf.h │ ├── preprocessor.h │ ├── sam3u.h │ ├── instance │ │ ├── instance_gpbr.h │ │ ├── instance_chipid.h │ │ ├── instance_wdt.h │ │ ├── instance_rstc.h │ │ ├── instance_rtt.h │ │ ├── instance_efc0.h │ │ └── instance_efc1.h │ ├── usb_protocol_vendor.h │ ├── exceptions.h │ ├── pio_handler.h │ ├── pio │ │ └── pio_handler.h │ ├── ui.h │ ├── led.h │ ├── system_sam3u.h │ ├── sam_gpio │ │ └── sam_gpio.h │ ├── component │ │ └── component_gpbr.h │ └── stringz.h ├── libarm_cortexM3l_math.a ├── sleepmgr.c ├── cycle_counter.c └── usart_serial.c ├── sam3x_hal ├── libarm_cortexM3l_math.a ├── inc │ ├── usb.h │ ├── udi_composite_conf.h │ ├── preprocessor.h │ ├── usb_class_todo_files │ │ ├── composite │ │ │ └── device │ │ │ │ └── udi_composite_conf.h │ │ └── vendor │ │ │ ├── usb_protocol_vendor.h │ │ │ └── device │ │ │ └── example │ │ │ └── sam3u4e_sam3u_ek │ │ │ └── device │ │ │ └── example │ │ │ └── sam3u4e_sam3u_ek │ │ │ └── ui.c │ ├── cmsis_version.h │ ├── instance │ │ ├── instance_gpbr.h │ │ ├── instance_chipid.h │ │ ├── instance_wdt.h │ │ ├── instance_rstc.h │ │ ├── instance_rtt.h │ │ ├── instance_efc0.h │ │ ├── instance_efc1.h │ │ └── instance_trng.h │ ├── sam3xa.h │ ├── exceptions.h │ ├── pio_handler.h │ ├── usb_protocol_vendor.h │ ├── system_sam3x.h │ ├── component │ │ └── component_gpbr.h │ ├── stringz.h │ ├── sam_gpio │ │ └── sam_gpio.h │ └── chipid.h ├── init.c ├── sleepmgr.c ├── cycle_counter.c └── usart_serial.c ├── sam4s_hal ├── libarm_cortexM4l_math.a ├── inc │ ├── udi_composite_conf.h │ ├── device │ │ └── udi_composite_conf.h │ ├── preprocessor.h │ ├── instance │ │ ├── instance_gpbr.h │ │ ├── instance_chipid.h │ │ ├── instance_wdt.h │ │ ├── instance_rstc.h │ │ ├── instance_rtt.h │ │ ├── instance_efc0.h │ │ └── instance_efc1.h │ ├── pio_handler.h │ ├── led.h │ ├── usb_protocol_vendor.h │ ├── system_sam4s.h │ ├── sam4s.h │ ├── sam_gpio │ │ └── sam_gpio.h │ ├── component │ │ └── component_gpbr.h │ ├── stringz.h │ ├── gpio.h │ ├── interrupt │ │ └── interrupt_sam_nvic.c │ └── chipid.h ├── cycle_counter.c ├── usart_serial.c └── interrupt_sam_nvic.c ├── fpga_selectmap.h ├── i2c_util.h ├── XPROGTimeout.h ├── naeusb_openadc.h ├── usart_driver.h ├── naeusb_usart.h ├── naeusb_fpga_target.h ├── cdce906.h ├── tps56520.h ├── naeusb_default.h ├── naeusb.h ├── cdce906.c ├── naeusb_mpsse.h ├── README.md ├── fpgaspi_program.c ├── tps56520.c ├── circbuffer.h ├── usb_xmem.h ├── V2Protocol.h ├── ISPProtocol.h └── i2c_util.c /targetspi.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sam3u_hal/inc/compiler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newaetech/naeusb/HEAD/sam3u_hal/inc/compiler.h -------------------------------------------------------------------------------- /sam3u_hal/libarm_cortexM3l_math.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newaetech/naeusb/HEAD/sam3u_hal/libarm_cortexM3l_math.a -------------------------------------------------------------------------------- /sam3x_hal/libarm_cortexM3l_math.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newaetech/naeusb/HEAD/sam3x_hal/libarm_cortexM3l_math.a -------------------------------------------------------------------------------- /sam4s_hal/libarm_cortexM4l_math.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newaetech/naeusb/HEAD/sam4s_hal/libarm_cortexM4l_math.a -------------------------------------------------------------------------------- /sam3u_hal/inc/tasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 NewAE Technology Inc. All Rights Reserved. 3 | */ 4 | 5 | #ifndef TASKS_H_ 6 | #define TASKS_H_ 7 | 8 | void process_events(void); 9 | void do_task(void); 10 | 11 | extern volatile uint32_t task_tickCnt; 12 | 13 | 14 | #endif /* TASKS_H_ */ -------------------------------------------------------------------------------- /fpga_selectmap.h: -------------------------------------------------------------------------------- 1 | #ifndef _FPGA_SELECTMAP_H 2 | #define _FPGA_SELECTMAP_H 3 | 4 | void fpga_selectmap_setup1(uint8_t bytemode, uint16_t SETUP_TIME); 5 | void fpga_selectmap_setup2(void); 6 | // void fpga_selectmap_sendbyte(uint8_t databyte); 7 | 8 | // void fpga_selectmap_bulk_setup(void); 9 | // void fpga_selectmap_bulk_callback(void); 10 | void fpga_selectmap_setup3(void); 11 | 12 | #endif -------------------------------------------------------------------------------- /i2c_util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | // extern volatile uint8_t I2C_LOCK; 4 | 5 | void i2c_setup(void); 6 | void i2c_reset(void); 7 | 8 | int i2c_write(uint8_t chip_addr, uint8_t reg_addr, void *data, uint8_t len); 9 | int i2c_read(uint8_t chip_addr, uint8_t reg_addr, void *data, uint8_t len); 10 | 11 | int i2c_is_locked(void); 12 | int raw_i2c_read(twi_package_t *packet); 13 | int raw_i2c_send(twi_package_t *packet); -------------------------------------------------------------------------------- /sam3u_hal/inc/usart_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rs232_driver.h 3 | * 4 | * Created: 16/12/2014 10:02:58 AM 5 | * Author: colin 6 | */ 7 | 8 | #ifndef USART_DRIVER_H_ 9 | #define USART_DRIVER_H_ 10 | 11 | #include "circbuffer.h" 12 | 13 | bool ctrl_usart(Usart * usart, bool directionIn); 14 | void usart_driver_putchar(Usart * usart, tcirc_buf * txbuf, uint8_t data); 15 | uint8_t usart_driver_getchar(Usart * usart); 16 | 17 | #endif /* USART_DRIVER_H_ */ -------------------------------------------------------------------------------- /XPROGTimeout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XPROGTimeout.h 3 | * 4 | * Created: 14/12/2014 3:28:50 PM 5 | * Author: colin 6 | */ 7 | 8 | 9 | #ifndef XPROGTIMEOUT_H_ 10 | #define XPROGTIMEOUT_H_ 11 | 12 | #include 13 | 14 | void setup_timeoutcnt(void); 15 | void start_timeoutcnt(void); 16 | void stop_timeoutcnt(void); 17 | void disable_timeoutcnt(void); 18 | void set_timeout(uint32_t timeoutTicks); 19 | 20 | extern uint32_t TimeoutTicksRemaining; 21 | 22 | #endif /* XPROGTIMEOUT_H_ */ -------------------------------------------------------------------------------- /naeusb_openadc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "naeusb.h" 3 | #include "fpga_program.h" 4 | 5 | #define REQ_MEMREAD_BULK 0x10 6 | #define REQ_MEMWRITE_BULK 0x11 7 | #define REQ_MEMREAD_CTRL 0x12 8 | #define REQ_MEMWRITE_CTRL 0x13 9 | 10 | #define REQ_FPGA_STATUS 0x15 11 | #define REQ_FPGA_PROGRAM 0x16 12 | 13 | #define REQ_FPGA_RESET 0x25 14 | 15 | void openadc_register_handlers(void); 16 | 17 | void main_vendor_bulk_in_received(udd_ep_status_t status, 18 | iram_size_t nb_transfered, udd_ep_id_t ep); -------------------------------------------------------------------------------- /usart_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rs232_driver.h 3 | * 4 | * Created: 16/12/2014 10:02:58 AM 5 | * Author: colin 6 | */ 7 | 8 | #ifndef USART_DRIVER_H_ 9 | #define USART_DRIVER_H_ 10 | 11 | #include "circbuffer.h" 12 | 13 | extern tcirc_buf rx0buf, tx0buf; 14 | extern tcirc_buf rx1buf, tx1buf; 15 | extern tcirc_buf rx2buf, tx2buf; 16 | extern tcirc_buf rx3buf, tx3buf; 17 | extern tcirc_buf usb_usart_circ_buf; 18 | 19 | 20 | #if 0 21 | #define USART_TARGET USART0 22 | #define PIN_USART0_RXD (PIO_PA19_IDX) 23 | #define PIN_USART0_RXD_FLAGS (PIO_PERIPH_A | PIO_DEFAULT) 24 | #define PIN_USART0_TXD (PIO_PA18_IDX) 25 | #define PIN_USART0_TXD_FLAGS (PIO_PERIPH_A | PIO_DEFAULT) 26 | #endif 27 | 28 | #endif /* USART_DRIVER_H_ */ -------------------------------------------------------------------------------- /naeusb_usart.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "naeusb.h" 3 | 4 | #define REQ_USART0_DATA 0x1A 5 | #define REQ_USART0_CONFIG 0x1B 6 | #define REQ_XMEGA_PROGRAM 0x20 7 | #define REQ_AVR_PROGRAM 0x21 8 | #define REQ_CDC_SETTINGS_EN 0x31 9 | 10 | /* Target/Extra SPI Transfer */ 11 | #define REQ_FPGASPI1_XFER 0x35 12 | 13 | typedef struct { 14 | Usart * usart; 15 | sam_usart_opt_t usartopts; 16 | tcirc_buf rxbuf; 17 | tcirc_buf txbuf; 18 | tcirc_buf rx_cdc_buf; 19 | int usart_id; 20 | int cdc_port; 21 | uint8_t cdc_supported:1; 22 | uint8_t enabled:1; 23 | uint8_t cdc_enabled:1; 24 | uint8_t cdc_settings_change:1; 25 | uint8_t currently_xoff:1; 26 | uint8_t xonxoff_enabled:1; 27 | } usart_driver; 28 | 29 | 30 | void naeusart_register_handlers(void); 31 | usart_driver *get_usart_from_id(int id); 32 | usart_driver *get_nth_available_driver(int id); 33 | 34 | // void cdc_send_to_pc(void); -------------------------------------------------------------------------------- /naeusb_fpga_target.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "naeusb.h" 3 | #include "fpga_program.h" 4 | 5 | #define REQ_MEMREAD_BULK 0x10 6 | #define REQ_MEMWRITE_BULK 0x11 7 | #define REQ_MEMREAD_CTRL 0x12 8 | #define REQ_MEMWRITE_CTRL 0x13 9 | 10 | #define REQ_MEMWRITE_CTRL_SAMU3 0x15 11 | 12 | #define REQ_FPGA_STATUS 0x15 13 | #define REQ_FPGA_PROGRAM 0x16 14 | 15 | #define REQ_FPGA_RESET 0x25 16 | 17 | #define REQ_CDCE906 0x30 18 | 19 | /* Set VCC-INT Voltage */ 20 | #define REQ_VCCINT 0x31 21 | 22 | /* Send SPI commands to chip on FPGA */ 23 | #define REQ_FPGASPI_PROGRAM 0x33 24 | 25 | /* Configure IO */ 26 | #define REQ_FPGAIO_UTIL 0x34 27 | 28 | /* SPI1 Utility */ 29 | #define FREQ_FPGASPI1_XFER 0x35 30 | 31 | #define REQ_XMEGA_PROGRAM 0x20 32 | 33 | void fpga_target_register_handlers(void); 34 | 35 | void main_vendor_bulk_in_received(udd_ep_status_t status, 36 | iram_size_t nb_transfered, udd_ep_id_t ep); -------------------------------------------------------------------------------- /sam3u_hal/inc/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | 19 | #ifndef USB_H_ 20 | #define USB_H_ 21 | 22 | 23 | /* Size of loopback */ 24 | #define MAIN_LOOPBACK_SIZE 1024 25 | 26 | extern volatile bool g_captureinprogress; 27 | 28 | 29 | 30 | #endif /* USB_H_ */ -------------------------------------------------------------------------------- /sam3x_hal/inc/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | 19 | #ifndef USB_H_ 20 | #define USB_H_ 21 | 22 | 23 | /* Size of loopback */ 24 | #define MAIN_LOOPBACK_SIZE 1024 25 | 26 | extern volatile bool g_captureinprogress; 27 | 28 | 29 | 30 | #endif /* USB_H_ */ -------------------------------------------------------------------------------- /cdce906.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CDCE906_H_ 19 | #define CDCE906_H_ 20 | 21 | 22 | int cdce906_write(uint8_t addr, uint8_t data); 23 | int cdce906_read(uint8_t addr, uint8_t * data); 24 | bool cdce906_init(void); 25 | 26 | 27 | #endif /* CDCE906_H_ */ -------------------------------------------------------------------------------- /tps56520.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | 19 | #ifndef TPS56520_H_ 20 | #define TPS56520_H_ 21 | 22 | bool tps56520_init(void); 23 | bool tps56520_set(uint16_t mv_output); 24 | bool tps56520_detect(void); 25 | 26 | extern uint8_t TPS_CONNECTED; 27 | 28 | #endif /* TPS56520_H_ */ -------------------------------------------------------------------------------- /naeusb_default.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "naeusb.h" 4 | 5 | #define REQ_SAM_CFG 0x22 6 | #define REQ_SAM_STATUS 0x22 7 | 8 | #define SAM_SLOW_CLOCK_ON 0x01 9 | #define SAM_SLOW_CLOCK_OFF 0x02 10 | #define SAM_ENTER_BOOTLOADER 0x03 11 | #define SAM_RESET 0x10 12 | #define SAM_RELEASE_LOCK 0x11 13 | #define SAM_LED_SETTINGS 0x12 14 | #define SAM_CLEAR_ERRORS 0x13 15 | 16 | // void naeusb_sam_cfg_out(void); 17 | 18 | #define REQ_FW_VERSION 0x17 19 | 20 | // bool naeusb_fw_version_in(void); 21 | 22 | #define REQ_BUILD_DATE 0x40 23 | 24 | #define CW_LED_DEFAULT_SETTING 0x00 25 | #define CW_LED_DEBUG_SETTING 0x01 26 | #define CW_LED_ERR_SETTING 0x02 27 | 28 | extern uint8_t LED_SETTING; 29 | extern uint16_t CURRENT_ERRORS; 30 | 31 | #define CW_ERR_USART_RX_OVERFLOW (1 << 0) 32 | #define CW_ERR_USART_TX_OVERFLOW (1 << 1) 33 | 34 | // bool naeusb_build_date_in(void); 35 | 36 | 37 | // void naeusb_cdc_settings_out(void); 38 | // bool naeusb_cdc_settings_in(void); 39 | void naeusb_register_handlers(void); -------------------------------------------------------------------------------- /naeusb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "usb_xmem.h" 4 | #include "conf_usb.h" 5 | #include "usb.h" 6 | #define NAEUSB_MAX_HANDLERS 16 7 | #define CTRLBUFFER_WORDPTR ((uint32_t *) ((void *)ctrlbuffer)) 8 | 9 | typedef bool (*usb_request_handle_func)(void); 10 | 11 | typedef bool (*usb_bulk_handle_func)(udd_ep_status_t, iram_size_t, udd_ep_id_t); 12 | 13 | bool naeusb_add_in_handler(usb_request_handle_func new_handler); 14 | bool naeusb_add_out_handler(usb_request_handle_func new_handler); 15 | 16 | // NOTE: bulk in handler doesn't make any sense 17 | bool naeusb_add_bulk_out_handler(usb_bulk_handle_func); 18 | 19 | extern COMPILER_WORD_ALIGNED uint8_t ctrlbuffer[128]; 20 | extern COMPILER_WORD_ALIGNED uint8_t respbuf[128]; 21 | 22 | COMPILER_WORD_ALIGNED 23 | extern uint8_t main_buf_loopback[MAIN_LOOPBACK_SIZE]; 24 | 25 | void main_suspend_action(void); 26 | void main_resume_action(void); 27 | void main_sof_action(void); 28 | bool main_vendor_enable(void); 29 | void main_vendor_disable(void); 30 | bool main_setup_out_received(void); 31 | bool main_setup_in_received(void); 32 | bool usb_is_enabled(void); -------------------------------------------------------------------------------- /sam3u_hal/inc/fpga_xmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #ifndef FPGA_XMEM_H_ 19 | #define FPGA_XMEM_H_ 20 | 21 | #include 22 | 23 | typedef enum fpga_lockstatus_e {fpga_unlocked = 0, fpga_generic, fpga_blockin, fpga_blockout, fpga_ctrlmem} fpga_lockstatus_t; 24 | void FPGA_setlock(fpga_lockstatus_t lockstatus); 25 | fpga_lockstatus_t FPGA_lockstatus(void); 26 | 27 | void FPGA_setaddr(uint32_t addr); 28 | 29 | /* Access pointer for FPGA Interface */ 30 | #define PSRAM_BASE_ADDRESS (0x60000000) 31 | extern uint8_t volatile *xram; 32 | 33 | 34 | #endif /* FPGA_XMEM_H_ */ -------------------------------------------------------------------------------- /cdce906.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include "cdce906.h" 20 | #include "i2c_util.h" 21 | 22 | #define CDCE906_ADDR 0x69 23 | 24 | // volatile uint8_t I2C_LOCK = 0; 25 | 26 | /* Init the CDCE906 chip, set offline */ 27 | bool cdce906_init(void) 28 | { 29 | i2c_setup(); 30 | 31 | uint8_t data = 0; 32 | 33 | /* Read addr 0 */ 34 | if (cdce906_read(0, &data) != 0){ 35 | return false; 36 | } 37 | 38 | /* Check vendor ID matches expected */ 39 | if ((data & 0x0F) == 0x01){ 40 | return true; 41 | } 42 | 43 | return false; 44 | } 45 | 46 | int cdce906_write(uint8_t addr, uint8_t data) 47 | { 48 | /* bit 7 of reg address set to 1 = byte mode*/ 49 | return i2c_write(CDCE906_ADDR, addr | 0x80, &data, 1); 50 | } 51 | 52 | int cdce906_read(uint8_t addr, uint8_t * data) 53 | { 54 | /* bit 7 of reg address set to 1 = byte mode*/ 55 | return i2c_read(CDCE906_ADDR, addr | 0x80, data, 1); 56 | } -------------------------------------------------------------------------------- /sam3u_hal/inc/udi_composite_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Descriptors for an USB Composite Device MSC and HID mouse 5 | * 6 | * Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _UDI_COMPOSITE_CONF_H_ 38 | #define _UDI_COMPOSITE_CONF_H_ 39 | 40 | #endif // _UDI_COMPOSITE_CONF_H_ 41 | -------------------------------------------------------------------------------- /sam3x_hal/inc/udi_composite_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Descriptors for an USB Composite Device MSC and HID mouse 5 | * 6 | * Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _UDI_COMPOSITE_CONF_H_ 38 | #define _UDI_COMPOSITE_CONF_H_ 39 | 40 | #endif // _UDI_COMPOSITE_CONF_H_ 41 | -------------------------------------------------------------------------------- /sam4s_hal/inc/udi_composite_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Descriptors for an USB Composite Device MSC and HID mouse 5 | * 6 | * Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _UDI_COMPOSITE_CONF_H_ 38 | #define _UDI_COMPOSITE_CONF_H_ 39 | 40 | #endif // _UDI_COMPOSITE_CONF_H_ 41 | -------------------------------------------------------------------------------- /sam4s_hal/inc/device/udi_composite_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Descriptors for an USB Composite Device MSC and HID mouse 5 | * 6 | * Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _UDI_COMPOSITE_CONF_H_ 38 | #define _UDI_COMPOSITE_CONF_H_ 39 | 40 | #endif // _UDI_COMPOSITE_CONF_H_ 41 | -------------------------------------------------------------------------------- /sam3x_hal/init.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Arduino Due/X board init. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #include "compiler.h" 38 | #include "board.h" 39 | #include "conf_board.h" 40 | #include "gpio.h" 41 | #include "ioport.h" 42 | 43 | void board_init(void) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sam3x_hal/inc/preprocessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor utils. 5 | * 6 | * Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _PREPROCESSOR_H_ 38 | #define _PREPROCESSOR_H_ 39 | 40 | #include "tpaste.h" 41 | #include "stringz.h" 42 | #include "mrepeat.h" 43 | 44 | 45 | #endif // _PREPROCESSOR_H_ 46 | -------------------------------------------------------------------------------- /sam4s_hal/inc/preprocessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor utils. 5 | * 6 | * Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _PREPROCESSOR_H_ 38 | #define _PREPROCESSOR_H_ 39 | 40 | #include "tpaste.h" 41 | #include "stringz.h" 42 | #include "mrepeat.h" 43 | 44 | 45 | #endif // _PREPROCESSOR_H_ 46 | -------------------------------------------------------------------------------- /sam3x_hal/inc/usb_class_todo_files/composite/device/udi_composite_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Descriptors for an USB Composite Device MSC and HID mouse 5 | * 6 | * Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _UDI_COMPOSITE_CONF_H_ 38 | #define _UDI_COMPOSITE_CONF_H_ 39 | 40 | #endif // _UDI_COMPOSITE_CONF_H_ 41 | -------------------------------------------------------------------------------- /sam3x_hal/inc/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.4.0 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /naeusb_mpsse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "naeusb.h" 3 | 4 | void mpsse_register_handlers(void); 5 | void MPSSE_main_sendrecv_byte(void); 6 | uint8_t mpsse_enabled(void); 7 | 8 | // extern uint8_t MPSSE_ENABLED; 9 | 10 | enum FTDI_CMD_BITS { 11 | FTDI_NEG_CLK_WRITE = 1 << 0, // output data on negative clock edge 12 | FTDI_BIT_MODE = 1 << 1, // send 1-8 bytes 13 | FTDI_NEG_CLK_READ = 1 << 2, // read data on negative clock edge 14 | FTDI_LITTLE_ENDIAN = 1 << 3, // bytes data are in little endian format 15 | FTDI_WRITE_TDI = 1 << 4, // do a write on TDI 16 | FTDI_READ_TDO = 1 << 5, // read data from TDO 17 | FTDI_WRITE_TMS = 1 << 6, // do a write on TMS (bit mode only, 1/7 bits on TDO) 18 | FTDI_SPECIAL_CMD = 1 << 7, // special commands 19 | }; 20 | 21 | enum FTDI_SPECIAL_CMDS { 22 | FTDI_SET_OPLB = 0x80, // configure IO pins 0-7 23 | FTDI_READ_IPLB, // read IO pins values 0-7 24 | FTDI_SET_OPHB, // configure IO pins 8-11 25 | FTDI_READ_IPHB, // read IO pins 8-11 26 | FTDI_EN_LOOPBACK, // enable loopback 27 | FTDI_DIS_LOOPBACK, // disable loopback 28 | FTDI_DIS_CLK_DIV_5 = 0x8A, // ignored 29 | FTDI_EN_CLK_DIV_5 = 0x8A, // ignored 30 | FTDI_SEND_IMM=0x87, // send data back to PC (hacky implementation due to small buffer, depends on async USB from openocd) 31 | FTDI_ADT_CLK_ON=0x96, // adaptive clock for ARM (ignored) 32 | FTDI_ADT_CLK_OFF // ignored 33 | }; 34 | 35 | // control USB requests, can mostly ignore 36 | #define BITMODE_MPSSE 0x02 37 | 38 | #define SIO_RESET_REQUEST 0x00 39 | #define SIO_SET_LATENCY_TIMER_REQUEST 0x09 40 | #define SIO_GET_LATENCY_TIMER_REQUEST 0x0A 41 | #define SIO_SET_BITMODE_REQUEST 0x0B 42 | 43 | #define SIO_RESET_SIO 0 44 | #define SIO_RESET_PURGE_RX 1 45 | #define SIO_RESET_PURGE_TX 2 -------------------------------------------------------------------------------- /sam4s_hal/cycle_counter.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief ARM functions for busy-wait delay loops 5 | * 6 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #include "cycle_counter.h" 38 | 39 | // Delay loop is put to SRAM so that FWS will not affect delay time 40 | OPTIMIZE_HIGH 41 | RAMFUNC 42 | void portable_delay_cycles(unsigned long n) 43 | { 44 | UNUSED(n); 45 | 46 | __asm ( 47 | "loop: DMB \n" 48 | "SUBS R0, R0, #1 \n" 49 | "BNE.N loop " 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # naeusb 2 | USB library and build system for ChipWhisperer devices 3 | 4 | Also includes other shared driver code (usart_driver, fpga_program code, etc.) 5 | 6 | ## Building 7 | 8 | To build, navigate to the directory above this one (i.e. `cd ..`) and run `make`. 9 | 10 | The makefile supports multiple jobs (`-j` flag) and supports the following options: 11 | 12 | * `VERBOSE`: If not "false", output the full build command for each file. Defaults to "false" 13 | * `GCCCOLOURS`: If "yes", force gcc to always output coloured text. If auto, leave it up to gcc. Otherwise, do not print colours. Defaults to "yes". 14 | 15 | ## Programming 16 | 17 | Running `make program` will attempt to erase and program the device with the newly built firmware. 18 | 19 | ## Using the build system 20 | 21 | 1. Add this repository as a submodule in the project's firmware directory 22 | 1. Create a makefile in your project's firmware directory with the following lines: 23 | 1. `TARGET = `, where `` is your target's name (e.g. ChipWhisperer-Husky) 24 | 1. `SRC += ` where `` are your custom source files (e.g. main.c, others) 25 | 1. `SRC += ` where `` are any source files you need from this directory 26 | 1. `LINKERFILE = ` where `` is the linker file you need to use 27 | 1. `OPT=` where `` is the optimization level 28 | 1. `include naeusb/makefile.cw` 29 | 1. Add a target entry for your target in `makefile.cw` 30 | 1. If you need to need to add a new HAL, create a new folder and put the files in there 31 | 1. The following files are required to be in the project's firmware directory 32 | 1. conf_board.h 33 | 1. conf_clock.h 34 | 1. conf_sleepmgr.h 35 | 1. conf_uart_serial.h 36 | 1. conf_usb.h 37 | 1. naeusb_board_config.h 38 | 39 | ## REQ_SAM3U_CFG 40 | 41 | wValue & 0xFF: 42 | 43 | 1. 0xFx: Device specific config 44 | 1. 0x4x: MPSSE config -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_GPBR_INSTANCE_ 36 | #define _SAM3XA_GPBR_INSTANCE_ 37 | 38 | /* ========== Register definition for GPBR peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_GPBR_GPBR (0x400E1A90U) /**< \brief (GPBR) General Purpose Backup Register */ 41 | #else 42 | #define REG_GPBR_GPBR (*(RwReg*)0x400E1A90U) /**< \brief (GPBR) General Purpose Backup Register */ 43 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 44 | 45 | #endif /* _SAM3XA_GPBR_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /sam3x_hal/inc/sam3xa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_ 36 | #define _SAM3XA_ 37 | 38 | #if defined __SAM3A4C__ 39 | #include "sam3a4c.h" 40 | #elif defined __SAM3A8C__ 41 | #include "sam3a8c.h" 42 | #elif defined __SAM3X4C__ 43 | #include "sam3x4c.h" 44 | #elif defined __SAM3X4E__ 45 | #include "sam3x4e.h" 46 | #elif defined __SAM3X8C__ 47 | #include "sam3x8c.h" 48 | #elif defined __SAM3X8E__ 49 | #include "sam3x8e.h" 50 | #elif defined __SAM3X8H__ 51 | #include "sam3x8h.h" 52 | #else 53 | #error Library does not support the specified device. 54 | #endif 55 | 56 | #endif /* _SAM3XA_ */ 57 | -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_GPBR_INSTANCE_ 36 | #define _SAM4S_GPBR_INSTANCE_ 37 | 38 | /* ========== Register definition for GPBR peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_GPBR_GPBR (0x400E1490U) /**< \brief (GPBR) General Purpose Backup Register */ 41 | #else 42 | #define REG_GPBR_GPBR (*(__IO uint32_t*)0x400E1490U) /**< \brief (GPBR) General Purpose Backup Register */ 43 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 44 | 45 | #endif /* _SAM4S_GPBR_INSTANCE_ */ 46 | -------------------------------------------------------------------------------- /sam3u_hal/inc/preprocessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor utils. 5 | * 6 | * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _PREPROCESSOR_H_ 45 | #define _PREPROCESSOR_H_ 46 | 47 | #include "tpaste.h" 48 | #include "stringz.h" 49 | #include "mrepeat.h" 50 | 51 | 52 | #endif // _PREPROCESSOR_H_ 53 | -------------------------------------------------------------------------------- /sam3u_hal/sleepmgr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM3/SAM4 Sleep manager implementation. 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include 45 | #include 46 | 47 | #if defined(CONFIG_SLEEPMGR_ENABLE) || defined(__DOXYGEN__) 48 | 49 | uint8_t sleepmgr_locks[SLEEPMGR_NR_OF_MODES]; 50 | 51 | #endif /* CONFIG_SLEEPMGR_ENABLE */ 52 | -------------------------------------------------------------------------------- /sam3x_hal/sleepmgr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM3/SAM4 Sleep manager implementation. 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include 45 | #include 46 | 47 | #if defined(CONFIG_SLEEPMGR_ENABLE) || defined(__DOXYGEN__) 48 | 49 | uint8_t sleepmgr_locks[SLEEPMGR_NR_OF_MODES]; 50 | 51 | #endif /* CONFIG_SLEEPMGR_ENABLE */ 52 | -------------------------------------------------------------------------------- /sam3x_hal/inc/exceptions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief This file contains the interface for default exception handlers. 5 | * 6 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef EXCEPTIONS_H_INCLUDED 38 | #define EXCEPTIONS_H_INCLUDED 39 | 40 | #include "sam3xa.h" 41 | 42 | /* @cond 0 */ 43 | /**INDENT-OFF**/ 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | /**INDENT-ON**/ 48 | /* @endcond */ 49 | 50 | /* Function prototype for exception table items (interrupt handler). */ 51 | typedef void (*IntFunc) (void); 52 | 53 | /* Default empty handler */ 54 | void Dummy_Handler(void); 55 | 56 | /* @cond 0 */ 57 | /**INDENT-OFF**/ 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | /**INDENT-ON**/ 62 | /* @endcond */ 63 | 64 | #endif /* EXCEPTIONS_H_INCLUDED */ 65 | -------------------------------------------------------------------------------- /fpgaspi_program.c: -------------------------------------------------------------------------------- 1 | /* 2 | Xilinx Spartan 6 FPGA Programming Routines 3 | 4 | Copyright (c) 2014-2015 NewAE Technology Inc. All rights reserved. 5 | Author: Colin O'Flynn, 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | #include "gpio.h" 23 | #include "fpgaspi_program.h" 24 | #include "spi.h" 25 | 26 | /* FPGA Programming: Init pins - assumes FPGA already programmed to use these */ 27 | void fpgaspi_program_init(void) 28 | { 29 | FPGASPI_CCLK_SETUP(); 30 | FPGASPI_DO_SETUP(); 31 | FPGASPI_DI_SETUP(); 32 | FPGASPI_CS_SETUP(); 33 | FPGASPI_CS_HIGH(); 34 | FPGASPI_CCLK_LOW(); 35 | } 36 | 37 | 38 | /* SPI CS Pin Low */ 39 | void fpgaspi_cs_low(void) 40 | { 41 | FPGASPI_CS_LOW(); 42 | } 43 | 44 | /* SPI CS Pin High */ 45 | void fpgaspi_cs_high(void) 46 | { 47 | FPGASPI_CS_HIGH(); 48 | } 49 | 50 | 51 | /* SPI data byte transfer */ 52 | uint8_t fpgaspi_xferbyte(uint8_t databyte) 53 | { 54 | uint8_t result = 0; 55 | 56 | for(unsigned int i=0; i < 8; i++){ 57 | //On first read this gets thrown away 58 | result |= FPGASPI_DI_STATUS() ? (1) : 0; 59 | FPGASPI_CCLK_LOW(); 60 | 61 | if (databyte & 0x80){ 62 | FPGASPI_DO_HIGH(); 63 | } else { 64 | FPGASPI_DO_LOW(); 65 | } 66 | 67 | FPGASPI_CCLK_HIGH(); 68 | databyte = databyte << 1; 69 | result = result << 1; 70 | } 71 | 72 | result |= FPGASPI_DI_STATUS() ? (1) : 0; 73 | 74 | FPGASPI_CCLK_LOW(); 75 | 76 | return result; 77 | } 78 | 79 | 80 | void fpgaspi_program_deinit(void) 81 | { 82 | FPGASPI_CCLK_RELEASE(); 83 | FPGASPI_DO_RELEASE(); 84 | FPGASPI_CS_RELEASE(); 85 | } -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_CHIPID_INSTANCE_ 36 | #define _SAM3XA_CHIPID_INSTANCE_ 37 | 38 | /* ========== Register definition for CHIPID peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_CHIPID_CIDR (0x400E0940U) /**< \brief (CHIPID) Chip ID Register */ 41 | #define REG_CHIPID_EXID (0x400E0944U) /**< \brief (CHIPID) Chip ID Extension Register */ 42 | #else 43 | #define REG_CHIPID_CIDR (*(RoReg*)0x400E0940U) /**< \brief (CHIPID) Chip ID Register */ 44 | #define REG_CHIPID_EXID (*(RoReg*)0x400E0944U) /**< \brief (CHIPID) Chip ID Extension Register */ 45 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 46 | 47 | #endif /* _SAM3XA_CHIPID_INSTANCE_ */ 48 | -------------------------------------------------------------------------------- /sam3u_hal/cycle_counter.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief ARM functions for busy-wait delay loops 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include "cycle_counter.h" 45 | 46 | // Delay loop is put to SRAM so that FWS will not affect delay time 47 | OPTIMIZE_HIGH 48 | RAMFUNC 49 | void portable_delay_cycles(unsigned long n) 50 | { 51 | UNUSED(n); 52 | 53 | __asm ( 54 | "loop: DMB \n" 55 | "SUBS R0, R0, #1 \n" 56 | "BNE.N loop " 57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /sam3x_hal/cycle_counter.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief ARM functions for busy-wait delay loops 5 | * 6 | * Copyright (c) 2012-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include "cycle_counter.h" 45 | 46 | // Delay loop is put to SRAM so that FWS will not affect delay time 47 | OPTIMIZE_HIGH 48 | RAMFUNC 49 | void portable_delay_cycles(unsigned long n) 50 | { 51 | UNUSED(n); 52 | 53 | __asm ( 54 | "loop: DMB \n" 55 | "SUBS R0, R0, #1 \n" 56 | "BNE.N loop " 57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /tps56520.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016 NewAE Technology Inc. All rights reserved. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include "tps56520.h" 20 | #include "i2c_util.h" 21 | 22 | #define TPS56520_ADDR 0x34 23 | 24 | uint8_t TPS_CONNECTED = 0; 25 | 26 | unsigned char checkoddparity(unsigned char p); 27 | 28 | /* Is current byte odd-parity already? */ 29 | unsigned char checkoddparity(unsigned char p) 30 | { 31 | p = p ^ (p >> 4 | p << 4); 32 | p = p ^ (p >> 2); 33 | p = p ^ (p >> 1); 34 | return p & 1; 35 | } 36 | 37 | /* Init the TPS56520 chip, set to 1.00V output */ 38 | bool tps56520_init(void) 39 | { 40 | for(int retry = 3; retry > 0; retry--){ 41 | if(tps56520_set(1100)){ 42 | return true; 43 | } 44 | } 45 | 46 | return false; 47 | } 48 | 49 | bool tps56520_detect(void) 50 | { 51 | return twi_probe(TWI0, TPS56520_ADDR); 52 | } 53 | 54 | /* Set voltage in mV for FPGA VCC_INT Voltage */ 55 | bool tps56520_set(uint16_t mv_output) 56 | { 57 | /* Validate output voltage is in range */ 58 | if ((mv_output < 600) || (mv_output > 1800)){ 59 | return false; 60 | } 61 | 62 | /* Avoid frying FPGA */ 63 | if (mv_output > 1200){ 64 | return false; 65 | } 66 | 67 | uint8_t setting = (mv_output - 600) / 10; 68 | 69 | if (!checkoddparity(setting)){ 70 | setting |= 1<<7; 71 | } 72 | 73 | if (i2c_write(TPS56520_ADDR, 0, &setting, 1)) { 74 | return false; 75 | } 76 | 77 | uint8_t volt_read; 78 | 79 | if (i2c_read(TPS56520_ADDR, 0, &volt_read, 1)) { 80 | return false; 81 | } 82 | 83 | if (volt_read == setting){ 84 | return true; 85 | } 86 | 87 | return false; 88 | } -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_CHIPID_INSTANCE_ 36 | #define _SAM4S_CHIPID_INSTANCE_ 37 | 38 | /* ========== Register definition for CHIPID peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_CHIPID_CIDR (0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ 41 | #define REG_CHIPID_EXID (0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ 42 | #else 43 | #define REG_CHIPID_CIDR (*(__I uint32_t*)0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ 44 | #define REG_CHIPID_EXID (*(__I uint32_t*)0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ 45 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 46 | 47 | #endif /* _SAM4S_CHIPID_INSTANCE_ */ 48 | -------------------------------------------------------------------------------- /sam3x_hal/inc/pio_handler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Parallel Input/Output (PIO) interrupt handler for SAM. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef PIO_HANDLER_H_INCLUDED 38 | #define PIO_HANDLER_H_INCLUDED 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | void pio_handler_process(Pio *p_pio, uint32_t ul_id); 45 | void pio_handler_set_priority(Pio *p_pio, IRQn_Type ul_irqn, uint32_t ul_priority); 46 | uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, 47 | uint32_t ul_attr, void (*p_handler) (uint32_t, uint32_t)); 48 | uint32_t pio_handler_set_pin(uint32_t ul_pin, uint32_t ul_flag, 49 | void (*p_handler) (uint32_t, uint32_t)); 50 | 51 | #if (SAM3S || SAM4S || SAM4E) 52 | void pio_capture_handler_set(void (*p_handler)(Pio *)); 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* PIO_HANDLER_H_INCLUDED */ 60 | -------------------------------------------------------------------------------- /sam4s_hal/inc/pio_handler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Parallel Input/Output (PIO) interrupt handler for SAM. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef PIO_HANDLER_H_INCLUDED 38 | #define PIO_HANDLER_H_INCLUDED 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | void pio_handler_process(Pio *p_pio, uint32_t ul_id); 45 | void pio_handler_set_priority(Pio *p_pio, IRQn_Type ul_irqn, uint32_t ul_priority); 46 | uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, 47 | uint32_t ul_attr, void (*p_handler) (uint32_t, uint32_t)); 48 | uint32_t pio_handler_set_pin(uint32_t ul_pin, uint32_t ul_flag, 49 | void (*p_handler) (uint32_t, uint32_t)); 50 | 51 | #if (SAM3S || SAM4S || SAM4E) 52 | void pio_capture_handler_set(void (*p_handler)(Pio *)); 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* PIO_HANDLER_H_INCLUDED */ 60 | -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_WDT_INSTANCE_ 36 | #define _SAM3XA_WDT_INSTANCE_ 37 | 38 | /* ========== Register definition for WDT peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_WDT_CR (0x400E1A50U) /**< \brief (WDT) Control Register */ 41 | #define REG_WDT_MR (0x400E1A54U) /**< \brief (WDT) Mode Register */ 42 | #define REG_WDT_SR (0x400E1A58U) /**< \brief (WDT) Status Register */ 43 | #else 44 | #define REG_WDT_CR (*(WoReg*)0x400E1A50U) /**< \brief (WDT) Control Register */ 45 | #define REG_WDT_MR (*(RwReg*)0x400E1A54U) /**< \brief (WDT) Mode Register */ 46 | #define REG_WDT_SR (*(RoReg*)0x400E1A58U) /**< \brief (WDT) Status Register */ 47 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 48 | 49 | #endif /* _SAM3XA_WDT_INSTANCE_ */ 50 | -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_rstc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_RSTC_INSTANCE_ 36 | #define _SAM3XA_RSTC_INSTANCE_ 37 | 38 | /* ========== Register definition for RSTC peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_RSTC_CR (0x400E1A00U) /**< \brief (RSTC) Control Register */ 41 | #define REG_RSTC_SR (0x400E1A04U) /**< \brief (RSTC) Status Register */ 42 | #define REG_RSTC_MR (0x400E1A08U) /**< \brief (RSTC) Mode Register */ 43 | #else 44 | #define REG_RSTC_CR (*(WoReg*)0x400E1A00U) /**< \brief (RSTC) Control Register */ 45 | #define REG_RSTC_SR (*(RoReg*)0x400E1A04U) /**< \brief (RSTC) Status Register */ 46 | #define REG_RSTC_MR (*(RwReg*)0x400E1A08U) /**< \brief (RSTC) Mode Register */ 47 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 48 | 49 | #endif /* _SAM3XA_RSTC_INSTANCE_ */ 50 | -------------------------------------------------------------------------------- /sam3u_hal/inc/sam3u.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_ 43 | #define _SAM3U_ 44 | 45 | #if defined __SAM3U1C__ 46 | #include "sam3u1c.h" 47 | #elif defined __SAM3U1E__ 48 | #include "sam3u1e.h" 49 | #elif defined __SAM3U2C__ 50 | #include "sam3u2c.h" 51 | #elif defined __SAM3U2E__ 52 | #include "sam3u2e.h" 53 | #elif defined __SAM3U4C__ 54 | #include "sam3u4c.h" 55 | #elif defined __SAM3U4E__ 56 | #include "sam3u4e.h" 57 | #else 58 | #error Library does not support the specified device. 59 | #endif 60 | 61 | #endif /* _SAM3U_ */ 62 | -------------------------------------------------------------------------------- /sam4s_hal/inc/led.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM4S-XPLAINED LEDs support package. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _LED_H_ 38 | #define _LED_H_ 39 | 40 | #include "gpio.h" 41 | 42 | /*! \brief Turns off the specified LEDs. 43 | * 44 | * \param led_gpio LED to turn off (LEDx_GPIO). 45 | * 46 | * \note The pins of the specified LEDs are set to GPIO output mode. 47 | */ 48 | void LED_Off(uint32_t led_gpio); 49 | 50 | /*! \brief Turns on the specified LEDs. 51 | * 52 | * \param led_gpio LED to turn on (LEDx_GPIO). 53 | * 54 | * \note The pins of the specified LEDs are set to GPIO output mode. 55 | */ 56 | void LED_On(uint32_t led_gpio); 57 | 58 | /*! \brief Toggles the specified LEDs. 59 | * 60 | * \param led_gpio LED to toggle (LEDx_GPIO). 61 | * 62 | * \note The pins of the specified LEDs are set to GPIO output mode. 63 | */ 64 | #define LED_Toggle(led_gpio) gpio_toggle_pin(led_gpio) 65 | 66 | #endif // _LED_H_ 67 | -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_WDT_INSTANCE_ 36 | #define _SAM4S_WDT_INSTANCE_ 37 | 38 | /* ========== Register definition for WDT peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_WDT_CR (0x400E1450U) /**< \brief (WDT) Control Register */ 41 | #define REG_WDT_MR (0x400E1454U) /**< \brief (WDT) Mode Register */ 42 | #define REG_WDT_SR (0x400E1458U) /**< \brief (WDT) Status Register */ 43 | #else 44 | #define REG_WDT_CR (*(__O uint32_t*)0x400E1450U) /**< \brief (WDT) Control Register */ 45 | #define REG_WDT_MR (*(__IO uint32_t*)0x400E1454U) /**< \brief (WDT) Mode Register */ 46 | #define REG_WDT_SR (*(__I uint32_t*)0x400E1458U) /**< \brief (WDT) Status Register */ 47 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 48 | 49 | #endif /* _SAM4S_WDT_INSTANCE_ */ 50 | -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_rstc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_RSTC_INSTANCE_ 36 | #define _SAM4S_RSTC_INSTANCE_ 37 | 38 | /* ========== Register definition for RSTC peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_RSTC_CR (0x400E1400U) /**< \brief (RSTC) Control Register */ 41 | #define REG_RSTC_SR (0x400E1404U) /**< \brief (RSTC) Status Register */ 42 | #define REG_RSTC_MR (0x400E1408U) /**< \brief (RSTC) Mode Register */ 43 | #else 44 | #define REG_RSTC_CR (*(__O uint32_t*)0x400E1400U) /**< \brief (RSTC) Control Register */ 45 | #define REG_RSTC_SR (*(__I uint32_t*)0x400E1404U) /**< \brief (RSTC) Status Register */ 46 | #define REG_RSTC_MR (*(__IO uint32_t*)0x400E1408U) /**< \brief (RSTC) Mode Register */ 47 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 48 | 49 | #endif /* _SAM4S_RSTC_INSTANCE_ */ 50 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_GPBR_INSTANCE_ 43 | #define _SAM3U_GPBR_INSTANCE_ 44 | 45 | /* ========== Register definition for GPBR peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_GPBR_GPBR (0x400E1290U) /**< \brief (GPBR) General Purpose Backup Register */ 48 | #else 49 | #define REG_GPBR_GPBR (*(RwReg*)0x400E1290U) /**< \brief (GPBR) General Purpose Backup Register */ 50 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 51 | 52 | #endif /* _SAM3U_GPBR_INSTANCE_ */ 53 | -------------------------------------------------------------------------------- /sam3u_hal/inc/usb_protocol_vendor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief USB Vendor class protocol definitions. 5 | * 6 | * Copyright (c) 2011 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _USB_PROTOCOL_VENDOR_H_ 45 | #define _USB_PROTOCOL_VENDOR_H_ 46 | 47 | /** 48 | * \ingroup usb_protocol_group 49 | * \defgroup usb_vendor_protocol USB Vendor Class definitions 50 | * 51 | * @{ 52 | */ 53 | 54 | /** 55 | * \name Vendor class values 56 | */ 57 | //@{ 58 | #define VENDOR_CLASS 0xFF 59 | #define VENDOR_SUBCLASS 0xFF 60 | #define VENDOR_PROTOCOL 0xFF 61 | //@} 62 | 63 | 64 | //@} 65 | 66 | #endif // _USB_PROTOCOL_VENDOR_H_ 67 | -------------------------------------------------------------------------------- /sam3x_hal/inc/usb_protocol_vendor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief USB Vendor class protocol definitions. 5 | * 6 | * Copyright (c) 2011 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _USB_PROTOCOL_VENDOR_H_ 45 | #define _USB_PROTOCOL_VENDOR_H_ 46 | 47 | /** 48 | * \ingroup usb_protocol_group 49 | * \defgroup usb_vendor_protocol USB Vendor Class definitions 50 | * 51 | * @{ 52 | */ 53 | 54 | /** 55 | * \name Vendor class values 56 | */ 57 | //@{ 58 | #define VENDOR_CLASS 0xFF 59 | #define VENDOR_SUBCLASS 0xFF 60 | #define VENDOR_PROTOCOL 0xFF 61 | //@} 62 | 63 | 64 | //@} 65 | 66 | #endif // _USB_PROTOCOL_VENDOR_H_ 67 | -------------------------------------------------------------------------------- /sam4s_hal/inc/usb_protocol_vendor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief USB Vendor class protocol definitions. 5 | * 6 | * Copyright (c) 2011 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _USB_PROTOCOL_VENDOR_H_ 45 | #define _USB_PROTOCOL_VENDOR_H_ 46 | 47 | /** 48 | * \ingroup usb_protocol_group 49 | * \defgroup usb_vendor_protocol USB Vendor Class definitions 50 | * 51 | * @{ 52 | */ 53 | 54 | /** 55 | * \name Vendor class values 56 | */ 57 | //@{ 58 | #define VENDOR_CLASS 0xFF 59 | #define VENDOR_SUBCLASS 0xFF 60 | #define VENDOR_PROTOCOL 0xFF 61 | //@} 62 | 63 | 64 | //@} 65 | 66 | #endif // _USB_PROTOCOL_VENDOR_H_ 67 | -------------------------------------------------------------------------------- /sam3x_hal/inc/usb_class_todo_files/vendor/usb_protocol_vendor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief USB Vendor class protocol definitions. 5 | * 6 | * Copyright (c) 2011 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _USB_PROTOCOL_VENDOR_H_ 45 | #define _USB_PROTOCOL_VENDOR_H_ 46 | 47 | /** 48 | * \ingroup usb_protocol_group 49 | * \defgroup usb_vendor_protocol USB Vendor Class definitions 50 | * 51 | * @{ 52 | */ 53 | 54 | /** 55 | * \name Vendor class values 56 | */ 57 | //@{ 58 | #define VENDOR_CLASS 0xFF 59 | #define VENDOR_SUBCLASS 0xFF 60 | #define VENDOR_PROTOCOL 0xFF 61 | //@} 62 | 63 | 64 | //@} 65 | 66 | #endif // _USB_PROTOCOL_VENDOR_H_ 67 | -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_rtt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_RTT_INSTANCE_ 36 | #define _SAM3XA_RTT_INSTANCE_ 37 | 38 | /* ========== Register definition for RTT peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_RTT_MR (0x400E1A30U) /**< \brief (RTT) Mode Register */ 41 | #define REG_RTT_AR (0x400E1A34U) /**< \brief (RTT) Alarm Register */ 42 | #define REG_RTT_VR (0x400E1A38U) /**< \brief (RTT) Value Register */ 43 | #define REG_RTT_SR (0x400E1A3CU) /**< \brief (RTT) Status Register */ 44 | #else 45 | #define REG_RTT_MR (*(RwReg*)0x400E1A30U) /**< \brief (RTT) Mode Register */ 46 | #define REG_RTT_AR (*(RwReg*)0x400E1A34U) /**< \brief (RTT) Alarm Register */ 47 | #define REG_RTT_VR (*(RoReg*)0x400E1A38U) /**< \brief (RTT) Value Register */ 48 | #define REG_RTT_SR (*(RoReg*)0x400E1A3CU) /**< \brief (RTT) Status Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAM3XA_RTT_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /circbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 NewAE Technology Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or other 13 | * materials provided with the distribution. 14 | * 15 | * * Neither the name of the author nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without specific 17 | * prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 22 | * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 27 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 28 | * DAMAGE. 29 | */ 30 | #ifndef CIRCBUFFER_H 31 | #define CIRCBUFFER_H 32 | 33 | 34 | #include 35 | 36 | #ifndef CIRCBUFSIZE 37 | #define CIRCBUFSIZE 200 38 | #define CIRCBUFHALF 100 39 | #endif 40 | 41 | #define SERIAL_ERR 0xFF 42 | 43 | #include 44 | 45 | typedef struct { 46 | volatile unsigned int head; 47 | volatile unsigned int tail; 48 | volatile unsigned int dropped; 49 | uint8_t buf[CIRCBUFSIZE]; 50 | } tcirc_buf; 51 | 52 | void init_circ_buf(tcirc_buf * cbuf); 53 | void add_to_circ_buf(tcirc_buf *cbuf, uint8_t ch, bool block); 54 | bool circ_buf_has_char(tcirc_buf *cbuf); 55 | uint8_t get_from_circ_buf(tcirc_buf *cbuf); 56 | unsigned int circ_buf_count(tcirc_buf *cbuf); 57 | static inline unsigned int circ_buf_count_left(tcirc_buf *cbuf) 58 | { 59 | return CIRCBUFSIZE - circ_buf_count(cbuf); 60 | } 61 | 62 | #endif //CIRCBUFFER_H 63 | -------------------------------------------------------------------------------- /sam4s_hal/usart_serial.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * \file 4 | * 5 | * \brief USART Serial driver functions. 6 | * 7 | * 8 | * Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries. 9 | * 10 | * \asf_license_start 11 | * 12 | * \page License 13 | * 14 | * Subject to your compliance with these terms, you may use Microchip 15 | * software and any derivatives exclusively with Microchip products. 16 | * It is your responsibility to comply with third party license terms applicable 17 | * to your use of third party software (including open source software) that 18 | * may accompany Microchip software. 19 | * 20 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 21 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 22 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 23 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 24 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 25 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 26 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 27 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 28 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 29 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 30 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 31 | * 32 | * \asf_license_stop 33 | * 34 | */ 35 | /* 36 | * Support and FAQ: visit Microchip Support 37 | */ 38 | #include "serial.h" 39 | 40 | /** 41 | * \brief Send a sequence of bytes to USART device 42 | * 43 | * \param usart Base address of the USART instance. 44 | * \param data Data buffer to read 45 | * \param len Length of data 46 | * 47 | */ 48 | status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data, 49 | size_t len) 50 | { 51 | while (len) { 52 | usart_serial_putchar(usart, *data); 53 | len--; 54 | data++; 55 | } 56 | return STATUS_OK; 57 | } 58 | 59 | 60 | /** 61 | * \brief Receive a sequence of bytes from USART device 62 | * 63 | * \param usart Base address of the USART instance. 64 | * \param data Data buffer to write 65 | * \param len Length of data 66 | * 67 | */ 68 | status_code_t usart_serial_read_packet(usart_if usart, uint8_t *data, 69 | size_t len) 70 | { 71 | while (len) { 72 | usart_serial_getchar(usart, data); 73 | len--; 74 | data++; 75 | } 76 | return STATUS_OK; 77 | } 78 | -------------------------------------------------------------------------------- /sam4s_hal/inc/system_sam4s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Provides the low-level initialization functions that called 5 | * on chip startup. 6 | * 7 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 8 | * 9 | * \asf_license_start 10 | * 11 | * \page License 12 | * 13 | * Subject to your compliance with these terms, you may use Microchip 14 | * software and any derivatives exclusively with Microchip products. 15 | * It is your responsibility to comply with third party license terms applicable 16 | * to your use of third party software (including open source software) that 17 | * may accompany Microchip software. 18 | * 19 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 20 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 21 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 22 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 23 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 24 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 25 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 26 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 27 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 28 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 29 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 30 | * 31 | * \asf_license_stop 32 | * 33 | */ 34 | /* 35 | * Support and FAQ: visit Microchip Support 36 | */ 37 | 38 | #ifndef SYSTEM_SAM4S_H_INCLUDED 39 | #define SYSTEM_SAM4S_H_INCLUDED 40 | 41 | /* @cond 0 */ 42 | /**INDENT-OFF**/ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | /**INDENT-ON**/ 47 | /* @endcond */ 48 | 49 | #include 50 | 51 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 52 | 53 | /** 54 | * @brief Setup the microcontroller system. 55 | * Initialize the System and update the SystemCoreClock variable. 56 | */ 57 | void SystemInit(void); 58 | 59 | /** 60 | * @brief Updates the SystemCoreClock with current core Clock 61 | * retrieved from cpu registers. 62 | */ 63 | void SystemCoreClockUpdate(void); 64 | 65 | /** 66 | * Initialize flash. 67 | */ 68 | void system_init_flash(uint32_t dw_clk); 69 | 70 | /* @cond 0 */ 71 | /**INDENT-OFF**/ 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | /**INDENT-ON**/ 76 | /* @endcond */ 77 | 78 | #endif /* SYSTEM_SAM4S_H_INCLUDED */ 79 | -------------------------------------------------------------------------------- /sam3u_hal/inc/exceptions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief This file contains the interface for default exception handlers. 5 | * 6 | * Copyright (c) 2011 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef EXCEPTIONS_H_INCLUDED 45 | #define EXCEPTIONS_H_INCLUDED 46 | 47 | #include "sam3u.h" 48 | 49 | /* @cond 0 */ 50 | /**INDENT-OFF**/ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | /**INDENT-ON**/ 55 | /* @endcond */ 56 | 57 | /* Function prototype for exception table items (interrupt handler). */ 58 | typedef void (*IntFunc) (void); 59 | 60 | /* Default empty handler */ 61 | void Dummy_Handler(void); 62 | 63 | /* @cond 0 */ 64 | /**INDENT-OFF**/ 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | /**INDENT-ON**/ 69 | /* @endcond */ 70 | 71 | #endif /* EXCEPTIONS_H_INCLUDED */ 72 | -------------------------------------------------------------------------------- /sam3x_hal/inc/system_sam3x.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Provides the low-level initialization functions that called 5 | * on chip startup. 6 | * 7 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 8 | * 9 | * \asf_license_start 10 | * 11 | * \page License 12 | * 13 | * Subject to your compliance with these terms, you may use Microchip 14 | * software and any derivatives exclusively with Microchip products. 15 | * It is your responsibility to comply with third party license terms applicable 16 | * to your use of third party software (including open source software) that 17 | * may accompany Microchip software. 18 | * 19 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 20 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 21 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 22 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 23 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 24 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 25 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 26 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 27 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 28 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 29 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 30 | * 31 | * \asf_license_stop 32 | * 33 | */ 34 | /* 35 | * Support and FAQ: visit Microchip Support 36 | */ 37 | 38 | #ifndef SYSTEM_SAM3X_H_INCLUDED 39 | #define SYSTEM_SAM3X_H_INCLUDED 40 | 41 | /* @cond 0 */ 42 | /**INDENT-OFF**/ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | /**INDENT-ON**/ 47 | /* @endcond */ 48 | 49 | #include 50 | #include 51 | 52 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 53 | 54 | /** 55 | * @brief Setup the microcontroller system. 56 | * Initialize the System and update the SystemCoreClock variable. 57 | */ 58 | void SystemInit(void); 59 | 60 | /** 61 | * @brief Updates the SystemCoreClock with current core Clock 62 | * retrieved from cpu registers. 63 | */ 64 | void SystemCoreClockUpdate(void); 65 | 66 | /** 67 | * Initialize flash. 68 | */ 69 | void system_init_flash(uint32_t ul_clk); 70 | 71 | /* @cond 0 */ 72 | /**INDENT-OFF**/ 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | /**INDENT-ON**/ 77 | /* @endcond */ 78 | 79 | #endif /* SYSTEM_SAM3X_H_INCLUDED */ 80 | -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_rtt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_RTT_INSTANCE_ 36 | #define _SAM4S_RTT_INSTANCE_ 37 | 38 | /* ========== Register definition for RTT peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_RTT_MR (0x400E1430U) /**< \brief (RTT) Mode Register */ 41 | #define REG_RTT_AR (0x400E1434U) /**< \brief (RTT) Alarm Register */ 42 | #define REG_RTT_VR (0x400E1438U) /**< \brief (RTT) Value Register */ 43 | #define REG_RTT_SR (0x400E143CU) /**< \brief (RTT) Status Register */ 44 | #else 45 | #define REG_RTT_MR (*(__IO uint32_t*)0x400E1430U) /**< \brief (RTT) Mode Register */ 46 | #define REG_RTT_AR (*(__IO uint32_t*)0x400E1434U) /**< \brief (RTT) Alarm Register */ 47 | #define REG_RTT_VR (*(__I uint32_t*)0x400E1438U) /**< \brief (RTT) Value Register */ 48 | #define REG_RTT_SR (*(__I uint32_t*)0x400E143CU) /**< \brief (RTT) Status Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAM4S_RTT_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_CHIPID_INSTANCE_ 43 | #define _SAM3U_CHIPID_INSTANCE_ 44 | 45 | /* ========== Register definition for CHIPID peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_CHIPID_CIDR (0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ 48 | #define REG_CHIPID_EXID (0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ 49 | #else 50 | #define REG_CHIPID_CIDR (*(RoReg*)0x400E0740U) /**< \brief (CHIPID) Chip ID Register */ 51 | #define REG_CHIPID_EXID (*(RoReg*)0x400E0744U) /**< \brief (CHIPID) Chip ID Extension Register */ 52 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 53 | 54 | #endif /* _SAM3U_CHIPID_INSTANCE_ */ 55 | -------------------------------------------------------------------------------- /sam4s_hal/inc/sam4s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_ 36 | #define _SAM4S_ 37 | 38 | #if defined __SAM4SA16B__ 39 | #include "sam4sa16b.h" 40 | #elif defined __SAM4SA16C__ 41 | #include "sam4sa16c.h" 42 | #elif defined __SAM4SD16B__ 43 | #include "sam4sd16b.h" 44 | #elif defined __SAM4SD16C__ 45 | #include "sam4sd16c.h" 46 | #elif defined __SAM4SD32B__ 47 | #include "sam4sd32b.h" 48 | #elif defined __SAM4SD32C__ 49 | #include "sam4sd32c.h" 50 | #elif defined __SAM4S2A__ 51 | #include "sam4s2a.h" 52 | #elif defined __SAM4S2B__ 53 | #include "sam4s2b.h" 54 | #elif defined __SAM4S2C__ 55 | #include "sam4s2c.h" 56 | #elif defined __SAM4S4A__ 57 | #include "sam4s4a.h" 58 | #elif defined __SAM4S4B__ 59 | #include "sam4s4b.h" 60 | #elif defined __SAM4S4C__ 61 | #include "sam4s4c.h" 62 | #elif defined __SAM4S8B__ 63 | #include "sam4s8b.h" 64 | #elif defined __SAM4S8C__ 65 | #include "sam4s8c.h" 66 | #elif defined __SAM4S16B__ 67 | #include "sam4s16b.h" 68 | #elif defined __SAM4S16C__ 69 | #include "sam4s16c.h" 70 | #else 71 | #error Library does not support the specified device. 72 | #endif 73 | 74 | #endif /* _SAM4S_ */ 75 | -------------------------------------------------------------------------------- /sam4s_hal/inc/sam_gpio/sam_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief GPIO service for SAM. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef SAM_GPIO_H_INCLUDED 38 | #define SAM_GPIO_H_INCLUDED 39 | 40 | #include "compiler.h" 41 | #include "pio.h" 42 | 43 | #define gpio_pin_is_low(io_id) \ 44 | (pio_get_pin_value(io_id) ? 0 : 1) 45 | 46 | #define gpio_pin_is_high(io_id) \ 47 | (pio_get_pin_value(io_id) ? 1 : 0) 48 | 49 | #define gpio_set_pin_high(io_id) \ 50 | pio_set_pin_high(io_id) 51 | 52 | #define gpio_set_pin_low(io_id) \ 53 | pio_set_pin_low(io_id) 54 | 55 | #define gpio_toggle_pin(io_id) \ 56 | pio_toggle_pin(io_id) 57 | 58 | #define gpio_configure_pin(io_id,io_flags) \ 59 | pio_configure_pin(io_id,io_flags) 60 | 61 | #define gpio_configure_group(port_id,port_mask,io_flags) \ 62 | pio_configure_pin_group(port_id,port_mask,io_flags) 63 | 64 | #define gpio_set_pin_group_high(port_id,mask) \ 65 | pio_set_pin_group_high(port_id,mask) 66 | 67 | #define gpio_set_pin_group_low(port_id,mask) \ 68 | pio_set_pin_group_low(port_id,mask) 69 | 70 | #define gpio_toggle_pin_group(port_id,mask) \ 71 | pio_toggle_pin_group(port_id,mask) 72 | 73 | #endif /* SAM_GPIO_H_INCLUDED */ 74 | -------------------------------------------------------------------------------- /usb_xmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 NewAE Technology Inc. All rights reserved. 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | #ifndef USB_XMEM_H_ 16 | #define USB_XMEM_H_ 17 | 18 | #include 19 | 20 | typedef enum fpga_lockstatus_e {fpga_unlocked = 0, fpga_generic, fpga_blockin, fpga_streamin, fpga_blockout, fpga_ctrlmem, fpga_usblocked} fpga_lockstatus_t; 21 | // Try to get the FPGA lock. Returns 1 if it's ours and 0 if we cannot proceed. 22 | // lockstatus: the lock we're trying to apply 23 | // interrupts_on: should interrupts be enabled 24 | int FPGA_setlock(fpga_lockstatus_t lockstatus); 25 | 26 | // Release the lock. 27 | void FPGA_releaselock(void); 28 | 29 | // Check the lock status. Useful in the USB stack 30 | fpga_lockstatus_t FPGA_lockstatus(void); 31 | 32 | // Useful functions for entering/exiting critical sections 33 | int try_enter_cs(void); 34 | void exit_cs(void); 35 | 36 | // Read 4 bytes into a single uint32_t 37 | uint32_t unsafe_readuint32(uint16_t fpgaaddr); 38 | uint32_t safe_readuint32(uint16_t fpgaaddr); 39 | 40 | // Read a number of bytes into a byte array 41 | void unsafe_readbytes(uint16_t fpgaaddr, uint8_t* data, int numBytes); 42 | void safe_readbytes(uint16_t fpgaaddr, uint8_t* data, int numBytes); 43 | 44 | // Write a number of bytes to the FPGA 45 | void unsafe_writebytes(uint16_t fpgaaddr, uint8_t* data, int numBytes); 46 | 47 | void FPGA_setaddr(uint32_t addr); 48 | 49 | void smc_fasttiming(void); 50 | void smc_normaltiming(void); 51 | 52 | /* Access pointer for FPGA Interface */ 53 | #define PSRAM_BASE_ADDRESS (0x60000000) 54 | extern uint8_t volatile *xram; 55 | extern uint16_t volatile *xram16; 56 | 57 | typedef enum { 58 | bep_emem=0, 59 | bep_fpgabitstream=10, 60 | bep_fpgabitstreamspi=20 61 | } blockep_usage_t; 62 | 63 | extern blockep_usage_t blockendpoint_usage; 64 | //#define FPGA_ADDR_PINS (PIO_PB0 | PIO_PB1 | PIO_PB2 | PIO_PB3 | PIO_PB4 | PIO_PB5 | PIO_PB7 | PIO_PB8 ) 65 | //#define FPGA_ADDR_PORT PIOB 66 | 67 | #endif /* USB_XMEM_H_ */ 68 | -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_efc0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_EFC0_INSTANCE_ 36 | #define _SAM3XA_EFC0_INSTANCE_ 37 | 38 | /* ========== Register definition for EFC0 peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_EFC0_FMR (0x400E0A00U) /**< \brief (EFC0) EEFC Flash Mode Register */ 41 | #define REG_EFC0_FCR (0x400E0A04U) /**< \brief (EFC0) EEFC Flash Command Register */ 42 | #define REG_EFC0_FSR (0x400E0A08U) /**< \brief (EFC0) EEFC Flash Status Register */ 43 | #define REG_EFC0_FRR (0x400E0A0CU) /**< \brief (EFC0) EEFC Flash Result Register */ 44 | #else 45 | #define REG_EFC0_FMR (*(RwReg*)0x400E0A00U) /**< \brief (EFC0) EEFC Flash Mode Register */ 46 | #define REG_EFC0_FCR (*(WoReg*)0x400E0A04U) /**< \brief (EFC0) EEFC Flash Command Register */ 47 | #define REG_EFC0_FSR (*(RoReg*)0x400E0A08U) /**< \brief (EFC0) EEFC Flash Status Register */ 48 | #define REG_EFC0_FRR (*(RoReg*)0x400E0A0CU) /**< \brief (EFC0) EEFC Flash Result Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAM3XA_EFC0_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_efc1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_EFC1_INSTANCE_ 36 | #define _SAM3XA_EFC1_INSTANCE_ 37 | 38 | /* ========== Register definition for EFC1 peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_EFC1_FMR (0x400E0C00U) /**< \brief (EFC1) EEFC Flash Mode Register */ 41 | #define REG_EFC1_FCR (0x400E0C04U) /**< \brief (EFC1) EEFC Flash Command Register */ 42 | #define REG_EFC1_FSR (0x400E0C08U) /**< \brief (EFC1) EEFC Flash Status Register */ 43 | #define REG_EFC1_FRR (0x400E0C0CU) /**< \brief (EFC1) EEFC Flash Result Register */ 44 | #else 45 | #define REG_EFC1_FMR (*(RwReg*)0x400E0C00U) /**< \brief (EFC1) EEFC Flash Mode Register */ 46 | #define REG_EFC1_FCR (*(WoReg*)0x400E0C04U) /**< \brief (EFC1) EEFC Flash Command Register */ 47 | #define REG_EFC1_FSR (*(RoReg*)0x400E0C08U) /**< \brief (EFC1) EEFC Flash Status Register */ 48 | #define REG_EFC1_FRR (*(RoReg*)0x400E0C0CU) /**< \brief (EFC1) EEFC Flash Result Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAM3XA_EFC1_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /sam3x_hal/inc/component/component_gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_GPBR_COMPONENT_ 36 | #define _SAM3XA_GPBR_COMPONENT_ 37 | 38 | /* ============================================================================= */ 39 | /** SOFTWARE API DEFINITION FOR General Purpose Backup Register */ 40 | /* ============================================================================= */ 41 | /** \addtogroup SAM3XA_GPBR General Purpose Backup Register */ 42 | /*@{*/ 43 | 44 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 45 | /** \brief Gpbr hardware registers */ 46 | typedef struct { 47 | RwReg SYS_GPBR[8]; /**< \brief (Gpbr Offset: 0x0) General Purpose Backup Register */ 48 | } Gpbr; 49 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | /* -------- SYS_GPBR[8] : (GPBR Offset: 0x0) General Purpose Backup Register -------- */ 51 | #define SYS_GPBR_GPBR_VALUE_Pos 0 52 | #define SYS_GPBR_GPBR_VALUE_Msk (0xffffffffu << SYS_GPBR_GPBR_VALUE_Pos) /**< \brief (SYS_GPBR[8]) Value of GPBR x */ 53 | #define SYS_GPBR_GPBR_VALUE(value) ((SYS_GPBR_GPBR_VALUE_Msk & ((value) << SYS_GPBR_GPBR_VALUE_Pos))) 54 | 55 | /*@}*/ 56 | 57 | 58 | #endif /* _SAM3XA_GPBR_COMPONENT_ */ 59 | -------------------------------------------------------------------------------- /sam4s_hal/inc/component/component_gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_GPBR_COMPONENT_ 36 | #define _SAM4S_GPBR_COMPONENT_ 37 | 38 | /* ============================================================================= */ 39 | /** SOFTWARE API DEFINITION FOR General Purpose Backup Registers */ 40 | /* ============================================================================= */ 41 | /** \addtogroup SAM4S_GPBR General Purpose Backup Registers */ 42 | /*@{*/ 43 | 44 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 45 | /** \brief Gpbr hardware registers */ 46 | typedef struct { 47 | __IO uint32_t SYS_GPBR[8]; /**< \brief (Gpbr Offset: 0x0) General Purpose Backup Register */ 48 | } Gpbr; 49 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | /* -------- SYS_GPBR[8] : (GPBR Offset: 0x0) General Purpose Backup Register -------- */ 51 | #define SYS_GPBR_GPBR_VALUE_Pos 0 52 | #define SYS_GPBR_GPBR_VALUE_Msk (0xffffffffu << SYS_GPBR_GPBR_VALUE_Pos) /**< \brief (SYS_GPBR[8]) Value of GPBR x */ 53 | #define SYS_GPBR_GPBR_VALUE(value) ((SYS_GPBR_GPBR_VALUE_Msk & ((value) << SYS_GPBR_GPBR_VALUE_Pos))) 54 | 55 | /*@}*/ 56 | 57 | 58 | #endif /* _SAM4S_GPBR_COMPONENT_ */ 59 | -------------------------------------------------------------------------------- /sam3u_hal/inc/pio_handler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Parallel Input/Output (PIO) interrupt handler for SAM. 5 | * 6 | * Copyright (c) 2011-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef PIO_HANDLER_H_INCLUDED 45 | #define PIO_HANDLER_H_INCLUDED 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | void pio_handler_process(Pio *p_pio, uint32_t ul_id); 52 | void pio_handler_set_priority(Pio *p_pio, IRQn_Type ul_irqn, uint32_t ul_priority); 53 | uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, 54 | uint32_t ul_attr, void (*p_handler) (uint32_t, uint32_t)); 55 | uint32_t pio_handler_set_pin(uint32_t ul_pin, uint32_t ul_flag, 56 | void (*p_handler) (uint32_t, uint32_t)); 57 | 58 | #if (SAM3S || SAM4S || SAM4E) 59 | void pio_capture_handler_set(void (*p_handler)(Pio *)); 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* PIO_HANDLER_H_INCLUDED */ 67 | -------------------------------------------------------------------------------- /sam3u_hal/inc/pio/pio_handler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Parallel Input/Output (PIO) interrupt handler for SAM. 5 | * 6 | * Copyright (c) 2011-2013 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef PIO_HANDLER_H_INCLUDED 45 | #define PIO_HANDLER_H_INCLUDED 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | void pio_handler_process(Pio *p_pio, uint32_t ul_id); 52 | void pio_handler_set_priority(Pio *p_pio, IRQn_Type ul_irqn, uint32_t ul_priority); 53 | uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, 54 | uint32_t ul_attr, void (*p_handler) (uint32_t, uint32_t)); 55 | uint32_t pio_handler_set_pin(uint32_t ul_pin, uint32_t ul_flag, 56 | void (*p_handler) (uint32_t, uint32_t)); 57 | 58 | #if (SAM3S || SAM4S || SAM4E) 59 | void pio_capture_handler_set(void (*p_handler)(Pio *)); 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* PIO_HANDLER_H_INCLUDED */ 67 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_WDT_INSTANCE_ 43 | #define _SAM3U_WDT_INSTANCE_ 44 | 45 | /* ========== Register definition for WDT peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_WDT_CR (0x400E1250U) /**< \brief (WDT) Control Register */ 48 | #define REG_WDT_MR (0x400E1254U) /**< \brief (WDT) Mode Register */ 49 | #define REG_WDT_SR (0x400E1258U) /**< \brief (WDT) Status Register */ 50 | #else 51 | #define REG_WDT_CR (*(WoReg*)0x400E1250U) /**< \brief (WDT) Control Register */ 52 | #define REG_WDT_MR (*(RwReg*)0x400E1254U) /**< \brief (WDT) Mode Register */ 53 | #define REG_WDT_SR (*(RoReg*)0x400E1258U) /**< \brief (WDT) Status Register */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | #endif /* _SAM3U_WDT_INSTANCE_ */ 57 | -------------------------------------------------------------------------------- /sam3x_hal/inc/stringz.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor stringizing utils. 5 | * 6 | * Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _STRINGZ_H_ 38 | #define _STRINGZ_H_ 39 | 40 | /** 41 | * \defgroup group_sam_utils_stringz Preprocessor - Stringize 42 | * 43 | * \ingroup group_sam_utils 44 | * 45 | * \{ 46 | */ 47 | 48 | /*! \brief Stringize. 49 | * 50 | * Stringize a preprocessing token, this token being allowed to be \#defined. 51 | * 52 | * May be used only within macros with the token passed as an argument if the token is \#defined. 53 | * 54 | * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN) 55 | * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to 56 | * writing "A0". 57 | */ 58 | #define STRINGZ(x) #x 59 | 60 | /*! \brief Absolute stringize. 61 | * 62 | * Stringize a preprocessing token, this token being allowed to be \#defined. 63 | * 64 | * No restriction of use if the token is \#defined. 65 | * 66 | * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is 67 | * equivalent to writing "A0". 68 | */ 69 | #define ASTRINGZ(x) STRINGZ(x) 70 | 71 | /** 72 | * \} 73 | */ 74 | 75 | #endif // _STRINGZ_H_ 76 | -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_efc0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_EFC0_INSTANCE_ 36 | #define _SAM4S_EFC0_INSTANCE_ 37 | 38 | /* ========== Register definition for EFC0 peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_EFC0_FMR (0x400E0A00U) /**< \brief (EFC0) EEFC Flash Mode Register */ 41 | #define REG_EFC0_FCR (0x400E0A04U) /**< \brief (EFC0) EEFC Flash Command Register */ 42 | #define REG_EFC0_FSR (0x400E0A08U) /**< \brief (EFC0) EEFC Flash Status Register */ 43 | #define REG_EFC0_FRR (0x400E0A0CU) /**< \brief (EFC0) EEFC Flash Result Register */ 44 | #else 45 | #define REG_EFC0_FMR (*(__IO uint32_t*)0x400E0A00U) /**< \brief (EFC0) EEFC Flash Mode Register */ 46 | #define REG_EFC0_FCR (*(__O uint32_t*)0x400E0A04U) /**< \brief (EFC0) EEFC Flash Command Register */ 47 | #define REG_EFC0_FSR (*(__I uint32_t*)0x400E0A08U) /**< \brief (EFC0) EEFC Flash Status Register */ 48 | #define REG_EFC0_FRR (*(__I uint32_t*)0x400E0A0CU) /**< \brief (EFC0) EEFC Flash Result Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAM4S_EFC0_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /sam4s_hal/inc/instance/instance_efc1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM4S_EFC1_INSTANCE_ 36 | #define _SAM4S_EFC1_INSTANCE_ 37 | 38 | /* ========== Register definition for EFC1 peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_EFC1_FMR (0x400E0C00U) /**< \brief (EFC1) EEFC Flash Mode Register */ 41 | #define REG_EFC1_FCR (0x400E0C04U) /**< \brief (EFC1) EEFC Flash Command Register */ 42 | #define REG_EFC1_FSR (0x400E0C08U) /**< \brief (EFC1) EEFC Flash Status Register */ 43 | #define REG_EFC1_FRR (0x400E0C0CU) /**< \brief (EFC1) EEFC Flash Result Register */ 44 | #else 45 | #define REG_EFC1_FMR (*(__IO uint32_t*)0x400E0C00U) /**< \brief (EFC1) EEFC Flash Mode Register */ 46 | #define REG_EFC1_FCR (*(__O uint32_t*)0x400E0C04U) /**< \brief (EFC1) EEFC Flash Command Register */ 47 | #define REG_EFC1_FSR (*(__I uint32_t*)0x400E0C08U) /**< \brief (EFC1) EEFC Flash Status Register */ 48 | #define REG_EFC1_FRR (*(__I uint32_t*)0x400E0C0CU) /**< \brief (EFC1) EEFC Flash Result Register */ 49 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 50 | 51 | #endif /* _SAM4S_EFC1_INSTANCE_ */ 52 | -------------------------------------------------------------------------------- /sam4s_hal/inc/stringz.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor stringizing utils. 5 | * 6 | * Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef _STRINGZ_H_ 38 | #define _STRINGZ_H_ 39 | 40 | /** 41 | * \defgroup group_sam_utils_stringz Preprocessor - Stringize 42 | * 43 | * \ingroup group_sam_utils 44 | * 45 | * \{ 46 | */ 47 | 48 | /*! \brief Stringize. 49 | * 50 | * Stringize a preprocessing token, this token being allowed to be \#defined. 51 | * 52 | * May be used only within macros with the token passed as an argument if the token is \#defined. 53 | * 54 | * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN) 55 | * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to 56 | * writing "A0". 57 | */ 58 | #define STRINGZ(x) #x 59 | 60 | /*! \brief Absolute stringize. 61 | * 62 | * Stringize a preprocessing token, this token being allowed to be \#defined. 63 | * 64 | * No restriction of use if the token is \#defined. 65 | * 66 | * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is 67 | * equivalent to writing "A0". 68 | */ 69 | #define ASTRINGZ(x) STRINGZ(x) 70 | 71 | /** 72 | * \} 73 | */ 74 | 75 | #endif // _STRINGZ_H_ 76 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_rstc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_RSTC_INSTANCE_ 43 | #define _SAM3U_RSTC_INSTANCE_ 44 | 45 | /* ========== Register definition for RSTC peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_RSTC_CR (0x400E1200U) /**< \brief (RSTC) Control Register */ 48 | #define REG_RSTC_SR (0x400E1204U) /**< \brief (RSTC) Status Register */ 49 | #define REG_RSTC_MR (0x400E1208U) /**< \brief (RSTC) Mode Register */ 50 | #else 51 | #define REG_RSTC_CR (*(WoReg*)0x400E1200U) /**< \brief (RSTC) Control Register */ 52 | #define REG_RSTC_SR (*(RoReg*)0x400E1204U) /**< \brief (RSTC) Status Register */ 53 | #define REG_RSTC_MR (*(RwReg*)0x400E1208U) /**< \brief (RSTC) Mode Register */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | #endif /* _SAM3U_RSTC_INSTANCE_ */ 57 | -------------------------------------------------------------------------------- /sam3u_hal/inc/ui.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Common User Interface for USB vendor class application 5 | * 6 | * Copyright (c) 2011 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _UI_H_ 45 | #define _UI_H_ 46 | 47 | //! \brief Initializes the user interface 48 | void ui_init(void); 49 | 50 | //! \brief Enters the user interface in power down mode 51 | void ui_powerdown(void); 52 | 53 | //! \brief Exits the user interface of power down mode 54 | void ui_wakeup(void); 55 | 56 | /*! \brief Notify the state of loopback 57 | * It is called when a the loopback is started and stopped. 58 | * 59 | * \param b_started loopback started if true, else stopped 60 | */ 61 | void ui_loop_back_state(bool b_started); 62 | 63 | /*! \brief This process is called each 1ms 64 | * It is called only if the USB interface is enabled. 65 | * 66 | * \param framenumber Current frame number 67 | */ 68 | void ui_process(uint16_t framenumber); 69 | 70 | #endif // _UI_H_ 71 | -------------------------------------------------------------------------------- /sam3u_hal/inc/led.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief SAM3U-EK LEDs support package. 5 | * 6 | * Copyright (c) 2011-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _LED_H_ 45 | #define _LED_H_ 46 | 47 | #include "gpio.h" 48 | 49 | /*! \brief Turns off the specified LEDs. 50 | * 51 | * \param led_gpio LED to turn off (LEDx_GPIO). 52 | * 53 | * \note The pins of the specified LEDs are set to GPIO output mode. 54 | */ 55 | void LED_Off(uint32_t led_gpio); 56 | 57 | /*! \brief Turns on the specified LEDs. 58 | * 59 | * \param led_gpio LED to turn on (LEDx_GPIO). 60 | * 61 | * \note The pins of the specified LEDs are set to GPIO output mode. 62 | */ 63 | void LED_On(uint32_t led_gpio); 64 | 65 | /*! \brief Toggles the specified LEDs. 66 | * 67 | * \param led_gpio LED to toggle (LEDx_GPIO). 68 | * 69 | * \note The pins of the specified LEDs are set to GPIO output mode. 70 | */ 71 | #define LED_Toggle(led_gpio) gpio_toggle_pin(led_gpio) 72 | 73 | #endif // _LED_H_ 74 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_rtt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_RTT_INSTANCE_ 43 | #define _SAM3U_RTT_INSTANCE_ 44 | 45 | /* ========== Register definition for RTT peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_RTT_MR (0x400E1230U) /**< \brief (RTT) Mode Register */ 48 | #define REG_RTT_AR (0x400E1234U) /**< \brief (RTT) Alarm Register */ 49 | #define REG_RTT_VR (0x400E1238U) /**< \brief (RTT) Value Register */ 50 | #define REG_RTT_SR (0x400E123CU) /**< \brief (RTT) Status Register */ 51 | #else 52 | #define REG_RTT_MR (*(RwReg*)0x400E1230U) /**< \brief (RTT) Mode Register */ 53 | #define REG_RTT_AR (*(RwReg*)0x400E1234U) /**< \brief (RTT) Alarm Register */ 54 | #define REG_RTT_VR (*(RoReg*)0x400E1238U) /**< \brief (RTT) Value Register */ 55 | #define REG_RTT_SR (*(RoReg*)0x400E123CU) /**< \brief (RTT) Status Register */ 56 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 57 | 58 | #endif /* _SAM3U_RTT_INSTANCE_ */ 59 | -------------------------------------------------------------------------------- /sam3u_hal/usart_serial.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * \file 4 | * 5 | * \brief USART Serial driver functions. 6 | * 7 | * 8 | * Copyright (c) 2010-2013 Atmel Corporation. All rights reserved. 9 | * 10 | * \asf_license_start 11 | * 12 | * \page License 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 24 | * 3. The name of Atmel may not be used to endorse or promote products derived 25 | * from this software without specific prior written permission. 26 | * 27 | * 4. This software may only be redistributed and used in connection with an 28 | * Atmel microcontroller product. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 31 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 32 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 33 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * 42 | * \asf_license_stop 43 | * 44 | */ 45 | #include "serial.h" 46 | 47 | /** 48 | * \brief Send a sequence of bytes to USART device 49 | * 50 | * \param usart Base address of the USART instance. 51 | * \param data Data buffer to read 52 | * \param len Length of data 53 | * 54 | */ 55 | status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data, 56 | size_t len) 57 | { 58 | while (len) { 59 | usart_serial_putchar(usart, *data); 60 | len--; 61 | data++; 62 | } 63 | return STATUS_OK; 64 | } 65 | 66 | 67 | /** 68 | * \brief Receive a sequence of bytes from USART device 69 | * 70 | * \param usart Base address of the USART instance. 71 | * \param data Data buffer to write 72 | * \param len Length of data 73 | * 74 | */ 75 | status_code_t usart_serial_read_packet(usart_if usart, uint8_t *data, 76 | size_t len) 77 | { 78 | while (len) { 79 | usart_serial_getchar(usart, data); 80 | len--; 81 | data++; 82 | } 83 | return STATUS_OK; 84 | } 85 | -------------------------------------------------------------------------------- /sam3x_hal/usart_serial.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * \file 4 | * 5 | * \brief USART Serial driver functions. 6 | * 7 | * 8 | * Copyright (c) 2010-2013 Atmel Corporation. All rights reserved. 9 | * 10 | * \asf_license_start 11 | * 12 | * \page License 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 24 | * 3. The name of Atmel may not be used to endorse or promote products derived 25 | * from this software without specific prior written permission. 26 | * 27 | * 4. This software may only be redistributed and used in connection with an 28 | * Atmel microcontroller product. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 31 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 32 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 33 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * 42 | * \asf_license_stop 43 | * 44 | */ 45 | #include "serial.h" 46 | 47 | /** 48 | * \brief Send a sequence of bytes to USART device 49 | * 50 | * \param usart Base address of the USART instance. 51 | * \param data Data buffer to read 52 | * \param len Length of data 53 | * 54 | */ 55 | status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data, 56 | size_t len) 57 | { 58 | while (len) { 59 | usart_serial_putchar(usart, *data); 60 | len--; 61 | data++; 62 | } 63 | return STATUS_OK; 64 | } 65 | 66 | 67 | /** 68 | * \brief Receive a sequence of bytes from USART device 69 | * 70 | * \param usart Base address of the USART instance. 71 | * \param data Data buffer to write 72 | * \param len Length of data 73 | * 74 | */ 75 | status_code_t usart_serial_read_packet(usart_if usart, uint8_t *data, 76 | size_t len) 77 | { 78 | while (len) { 79 | usart_serial_getchar(usart, data); 80 | len--; 81 | data++; 82 | } 83 | return STATUS_OK; 84 | } 85 | -------------------------------------------------------------------------------- /sam3x_hal/inc/usb_class_todo_files/vendor/device/example/sam3u4e_sam3u_ek/device/example/sam3u4e_sam3u_ek/ui.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief User Interface 5 | * 6 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include 45 | #include "ui.h" 46 | 47 | void ui_init(void) 48 | { 49 | // Initialize LEDs 50 | LED_Off(LED0_GPIO); 51 | LED_Off(LED1_GPIO); 52 | } 53 | 54 | void ui_powerdown(void) 55 | { 56 | LED_Off(LED0_GPIO); 57 | LED_Off(LED1_GPIO); 58 | } 59 | 60 | void ui_wakeup(void) 61 | { 62 | LED_On(LED0_GPIO); 63 | } 64 | 65 | void ui_loop_back_state(bool b_started) 66 | { 67 | if (b_started) { 68 | LED_On(LED1_GPIO); 69 | } else { 70 | LED_Off(LED1_GPIO); 71 | } 72 | } 73 | 74 | void ui_process(uint16_t framenumber) 75 | { 76 | if ((framenumber % 1000) == 0) { 77 | LED_On(LED0_GPIO); 78 | } 79 | if ((framenumber % 1000) == 500) { 80 | LED_Off(LED0_GPIO); 81 | } 82 | } 83 | 84 | /** 85 | * \defgroup UI User Interface 86 | * 87 | * Human interface on SAM3U-EK: 88 | * - Led 0 (D2) blinks when USB host has checked and enabled vendor interface 89 | * - Led 1 (D3) is on when loopback is running 90 | */ 91 | -------------------------------------------------------------------------------- /sam4s_hal/inc/gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Common GPIO API. 5 | * 6 | * Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | #ifndef _GPIO_H_ 37 | #define _GPIO_H_ 38 | 39 | #include 40 | 41 | #if (SAM3S || SAM3U || SAM3N || SAM3XA || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 42 | # include "sam_gpio/sam_gpio.h" 43 | #elif XMEGA 44 | # include "xmega_gpio/xmega_gpio.h" 45 | #elif MEGA || MEGA_RF 46 | # include "mega_gpio/mega_gpio.h" 47 | #else 48 | # error Unsupported chip type 49 | #endif 50 | 51 | /** 52 | * \defgroup gpio_group General Purpose Input/Output 53 | * 54 | * This is the common API for GPIO. Additional features are available 55 | * in the documentation of the specific modules. 56 | * 57 | * \section io_group_platform Platform Dependencies 58 | * 59 | * The following functions are available on all platforms, but there may 60 | * be variations in the function signature (i.e. parameters) and 61 | * behaviour. These functions are typically called by platform-specific 62 | * parts of drivers, and applications that aren't intended to be 63 | * portable: 64 | * - gpio_pin_is_low() 65 | * - gpio_pin_is_high() 66 | * - gpio_set_pin_high() 67 | * - gpio_set_pin_group_high() 68 | * - gpio_set_pin_low() 69 | * - gpio_set_pin_group_low() 70 | * - gpio_toggle_pin() 71 | * - gpio_toggle_pin_group() 72 | * - gpio_configure_pin() 73 | * - gpio_configure_group() 74 | */ 75 | 76 | #endif /* _GPIO_H_ */ 77 | -------------------------------------------------------------------------------- /sam4s_hal/interrupt_sam_nvic.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Global interrupt management for SAM D20, SAM3 and SAM4 (NVIC based) 5 | * 6 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #include "interrupt_sam_nvic.h" 38 | 39 | #if !defined(__DOXYGEN__) 40 | /* Deprecated - global flag to determine the global interrupt state. Required by 41 | * QTouch library, however new applications should use cpu_irq_is_enabled() 42 | * which probes the true global interrupt state from the CPU special registers. 43 | */ 44 | volatile bool g_interrupt_enabled = true; 45 | #endif 46 | 47 | void cpu_irq_enter_critical(void) 48 | { 49 | if (cpu_irq_critical_section_counter == 0) { 50 | if (cpu_irq_is_enabled()) { 51 | cpu_irq_disable(); 52 | cpu_irq_prev_interrupt_state = true; 53 | } else { 54 | /* Make sure the to save the prev state as false */ 55 | cpu_irq_prev_interrupt_state = false; 56 | } 57 | 58 | } 59 | 60 | cpu_irq_critical_section_counter++; 61 | } 62 | 63 | void cpu_irq_leave_critical(void) 64 | { 65 | /* Check if the user is trying to leave a critical section when not in a critical section */ 66 | Assert(cpu_irq_critical_section_counter > 0); 67 | 68 | cpu_irq_critical_section_counter--; 69 | 70 | /* Only enable global interrupts when the counter reaches 0 and the state of the global interrupt flag 71 | was enabled when entering critical state */ 72 | if ((cpu_irq_critical_section_counter == 0) && (cpu_irq_prev_interrupt_state)) { 73 | cpu_irq_enable(); 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /sam3u_hal/inc/system_sam3u.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Provides the low-level initialization functions that called 5 | * on chip startup. 6 | * 7 | * Copyright (c) 2011-2014 Atmel Corporation. All rights reserved. 8 | * 9 | * \asf_license_start 10 | * 11 | * \page License 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * 3. The name of Atmel may not be used to endorse or promote products derived 24 | * from this software without specific prior written permission. 25 | * 26 | * 4. This software may only be redistributed and used in connection with an 27 | * Atmel microcontroller product. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 30 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 31 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 32 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 33 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 39 | * POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * \asf_license_stop 42 | * 43 | */ 44 | 45 | #ifndef SYSTEM_SAM3U_H_INCLUDED 46 | #define SYSTEM_SAM3U_H_INCLUDED 47 | 48 | /* @cond 0 */ 49 | /**INDENT-OFF**/ 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | /**INDENT-ON**/ 54 | /* @endcond */ 55 | 56 | #include 57 | #include 58 | 59 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 60 | 61 | /** 62 | * @brief Setup the microcontroller system. 63 | * Initialize the System and update the SystemCoreClock variable. 64 | */ 65 | void SystemInit(void); 66 | 67 | /** 68 | * @brief Updates the SystemCoreClock with current core Clock 69 | * retrieved from cpu registers. 70 | */ 71 | void SystemCoreClockUpdate(void); 72 | 73 | /** 74 | * Initialize flash. 75 | */ 76 | void system_init_flash(uint32_t ul_clk); 77 | 78 | /* @cond 0 */ 79 | /**INDENT-OFF**/ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | /**INDENT-ON**/ 84 | /* @endcond */ 85 | 86 | #endif /* SYSTEM_SAM3U_H_INCLUDED */ 87 | -------------------------------------------------------------------------------- /sam4s_hal/inc/interrupt/interrupt_sam_nvic.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Global interrupt management for SAM D20, SAM3 and SAM4 (NVIC based) 5 | * 6 | * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #include "interrupt_sam_nvic.h" 38 | 39 | #if !defined(__DOXYGEN__) 40 | /* Deprecated - global flag to determine the global interrupt state. Required by 41 | * QTouch library, however new applications should use cpu_irq_is_enabled() 42 | * which probes the true global interrupt state from the CPU special registers. 43 | */ 44 | volatile bool g_interrupt_enabled = true; 45 | #endif 46 | 47 | void cpu_irq_enter_critical(void) 48 | { 49 | if (cpu_irq_critical_section_counter == 0) { 50 | if (cpu_irq_is_enabled()) { 51 | cpu_irq_disable(); 52 | cpu_irq_prev_interrupt_state = true; 53 | } else { 54 | /* Make sure the to save the prev state as false */ 55 | cpu_irq_prev_interrupt_state = false; 56 | } 57 | 58 | } 59 | 60 | cpu_irq_critical_section_counter++; 61 | } 62 | 63 | void cpu_irq_leave_critical(void) 64 | { 65 | /* Check if the user is trying to leave a critical section when not in a critical section */ 66 | Assert(cpu_irq_critical_section_counter > 0); 67 | 68 | cpu_irq_critical_section_counter--; 69 | 70 | /* Only enable global interrupts when the counter reaches 0 and the state of the global interrupt flag 71 | was enabled when entering critical state */ 72 | if ((cpu_irq_critical_section_counter == 0) && (cpu_irq_prev_interrupt_state)) { 73 | cpu_irq_enable(); 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /V2Protocol.h: -------------------------------------------------------------------------------- 1 | /* This file is based on the excellent LUFA Library, which is: 2 | Copyright (C) Dean Camera, 2013. See www.lufa-lib.org 3 | 4 | Note it has been modified for the SAM3U by NewAE Technology Inc., 5 | changes Copyright (C) NewAE Technology Inc, 2015. Changes have 6 | generally basterdized and reduced the functionality of the original 7 | code, so please see original code if using this to port. 8 | */ 9 | 10 | /* 11 | Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com) 12 | 13 | Permission to use, copy, modify, distribute, and sell this 14 | software and its documentation for any purpose is hereby granted 15 | without fee, provided that the above copyright notice appear in 16 | all copies and that both that the copyright notice and this 17 | permission notice and warranty disclaimer appear in supporting 18 | documentation, and that the name of the author not be used in 19 | advertising or publicity pertaining to distribution of the 20 | software without specific, written prior permission. 21 | 22 | The author disclaims all warranties with regard to this 23 | software, including all implied warranties of merchantability 24 | and fitness. In no event shall the author be liable for any 25 | special, indirect or consequential damages or any damages 26 | whatsoever resulting from loss of use, data or profits, whether 27 | in an action of contract, negligence or other tortious action, 28 | arising out of or in connection with the use or performance of 29 | this software. 30 | */ 31 | 32 | /** \file 33 | * 34 | * Header file for V2Protocol.c. 35 | */ 36 | 37 | #ifndef _V2_PROTOCOL_ 38 | #define _V2_PROTOCOL_ 39 | 40 | /* Includes: */ 41 | #include 42 | 43 | #include "V2ProtocolConstants.h" 44 | #include "V2ProtocolParams.h" 45 | #include "ISPProtocol.h" 46 | #include "XPROGTimeout.h" 47 | 48 | /* Macros: */ 49 | /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */ 50 | #define PROGRAMMER_ID "CWLITE_AVRISP" 51 | 52 | /** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */ 53 | #define COMMAND_TIMEOUT_TICKS 100 54 | 55 | /* External Variables: */ 56 | extern uint32_t CurrentAddress; 57 | extern bool MustLoadExtendedAddress; 58 | //extern uint32_t TimeoutTicksRemaining; 59 | 60 | extern uint8_t avrisp_status_payload[32]; 61 | extern uint16_t avrisp_status_payload_size; 62 | 63 | /* Function Prototypes: */ 64 | void V2Protocol_Init(void); 65 | bool V2Protocol_ProcessCommand(void); 66 | 67 | #if defined(INCLUDE_FROM_V2PROTOCOL_C) 68 | static void V2Protocol_UnknownCommand(const uint8_t V2Command); 69 | static void V2Protocol_SignOn(void); 70 | static void V2Protocol_GetSetParam(const uint8_t V2Command); 71 | static void V2Protocol_ResetProtection(void); 72 | static void V2Protocol_LoadAddress(void); 73 | #endif 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /ISPProtocol.h: -------------------------------------------------------------------------------- 1 | /* This file is based on the excellent LUFA Library, which is: 2 | Copyright (C) Dean Camera, 2013. See www.lufa-lib.org 3 | 4 | Note it has been modified for the SAM3U by NewAE Technology Inc., 5 | changes Copyright (C) NewAE Technology Inc, 2015. Changes have 6 | generally basterdized and reduced the functionality of the original 7 | code, so please see original code if using this to port. 8 | */ 9 | 10 | /* 11 | Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com) 12 | 13 | Permission to use, copy, modify, distribute, and sell this 14 | software and its documentation for any purpose is hereby granted 15 | without fee, provided that the above copyright notice appear in 16 | all copies and that both that the copyright notice and this 17 | permission notice and warranty disclaimer appear in supporting 18 | documentation, and that the name of the author not be used in 19 | advertising or publicity pertaining to distribution of the 20 | software without specific, written prior permission. 21 | 22 | The author disclaims all warranties with regard to this 23 | software, including all implied warranties of merchantability 24 | and fitness. In no event shall the author be liable for any 25 | special, indirect or consequential damages or any damages 26 | whatsoever resulting from loss of use, data or profits, whether 27 | in an action of contract, negligence or other tortious action, 28 | arising out of or in connection with the use or performance of 29 | this software. 30 | */ 31 | 32 | /** \file 33 | * 34 | * Header file for ISPProtocol.c. 35 | */ 36 | 37 | #ifndef _ISP_PROTOCOL_ 38 | #define _ISP_PROTOCOL_ 39 | 40 | /* Includes: */ 41 | #include 42 | #include "delay.h" 43 | #include "V2Protocol.h" 44 | 45 | /* Macros: */ 46 | /** Mask for the reading or writing of the high byte in a FLASH word when issuing a low-level programming command. */ 47 | #define READ_WRITE_HIGH_BYTE_MASK (1 << 3) 48 | 49 | #define PROG_MODE_PAGED_WRITES_MASK (1 << 0) 50 | #define PROG_MODE_WORD_TIMEDELAY_MASK (1 << 1) 51 | #define PROG_MODE_WORD_VALUE_MASK (1 << 2) 52 | #define PROG_MODE_WORD_READYBUSY_MASK (1 << 3) 53 | #define PROG_MODE_PAGED_TIMEDELAY_MASK (1 << 4) 54 | #define PROG_MODE_PAGED_VALUE_MASK (1 << 5) 55 | #define PROG_MODE_PAGED_READYBUSY_MASK (1 << 6) 56 | #define PROG_MODE_COMMIT_PAGE_MASK (1 << 7) 57 | 58 | /* Function Prototypes: */ 59 | void ISPProtocol_EnterISPMode(void); 60 | void ISPProtocol_LeaveISPMode(void); 61 | void ISPProtocol_ProgramMemory(const uint8_t V2Command, uint8_t * buffer); 62 | void ISPProtocol_ReadMemory(const uint8_t V2Command, uint8_t * buffer); 63 | void ISPProtocol_ChipErase(void); 64 | void ISPProtocol_ReadFuseLockSigOSCCAL(const uint8_t V2Command); 65 | void ISPProtocol_WriteFuseLock(const uint8_t V2Command); 66 | void ISPProtocol_SPIMulti(void); 67 | void ISPProtocol_DelayMS(uint8_t DelayMS); 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /sam3u_hal/inc/sam_gpio/sam_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief GPIO service for SAM. 5 | * 6 | * Copyright (c) 2011-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef SAM_GPIO_H_INCLUDED 45 | #define SAM_GPIO_H_INCLUDED 46 | 47 | #include "compiler.h" 48 | #include "pio.h" 49 | 50 | #define gpio_pin_is_low(io_id) \ 51 | (pio_get_pin_value(io_id) ? 0 : 1) 52 | 53 | #define gpio_pin_is_high(io_id) \ 54 | (pio_get_pin_value(io_id) ? 1 : 0) 55 | 56 | #define gpio_set_pin_high(io_id) \ 57 | pio_set_pin_high(io_id) 58 | 59 | #define gpio_set_pin_low(io_id) \ 60 | pio_set_pin_low(io_id) 61 | 62 | #define gpio_toggle_pin(io_id) \ 63 | pio_toggle_pin(io_id) 64 | 65 | #define gpio_configure_pin(io_id,io_flags) \ 66 | pio_configure_pin(io_id,io_flags) 67 | 68 | #define gpio_configure_group(port_id,port_mask,io_flags) \ 69 | pio_configure_pin_group(port_id,port_mask,io_flags) 70 | 71 | #define gpio_set_pin_group_high(port_id,mask) \ 72 | pio_set_pin_group_high(port_id,mask) 73 | 74 | #define gpio_set_pin_group_low(port_id,mask) \ 75 | pio_set_pin_group_low(port_id,mask) 76 | 77 | #define gpio_toggle_pin_group(port_id,mask) \ 78 | pio_toggle_pin_group(port_id,mask) 79 | 80 | #endif /* SAM_GPIO_H_INCLUDED */ 81 | -------------------------------------------------------------------------------- /sam3x_hal/inc/sam_gpio/sam_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief GPIO service for SAM. 5 | * 6 | * Copyright (c) 2011-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef SAM_GPIO_H_INCLUDED 45 | #define SAM_GPIO_H_INCLUDED 46 | 47 | #include "compiler.h" 48 | #include "pio.h" 49 | 50 | #define gpio_pin_is_low(io_id) \ 51 | (pio_get_pin_value(io_id) ? 0 : 1) 52 | 53 | #define gpio_pin_is_high(io_id) \ 54 | (pio_get_pin_value(io_id) ? 1 : 0) 55 | 56 | #define gpio_set_pin_high(io_id) \ 57 | pio_set_pin_high(io_id) 58 | 59 | #define gpio_set_pin_low(io_id) \ 60 | pio_set_pin_low(io_id) 61 | 62 | #define gpio_toggle_pin(io_id) \ 63 | pio_toggle_pin(io_id) 64 | 65 | #define gpio_configure_pin(io_id,io_flags) \ 66 | pio_configure_pin(io_id,io_flags) 67 | 68 | #define gpio_configure_group(port_id,port_mask,io_flags) \ 69 | pio_configure_pin_group(port_id,port_mask,io_flags) 70 | 71 | #define gpio_set_pin_group_high(port_id,mask) \ 72 | pio_set_pin_group_high(port_id,mask) 73 | 74 | #define gpio_set_pin_group_low(port_id,mask) \ 75 | pio_set_pin_group_low(port_id,mask) 76 | 77 | #define gpio_toggle_pin_group(port_id,mask) \ 78 | pio_toggle_pin_group(port_id,mask) 79 | 80 | #endif /* SAM_GPIO_H_INCLUDED */ 81 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_efc0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_EFC0_INSTANCE_ 43 | #define _SAM3U_EFC0_INSTANCE_ 44 | 45 | /* ========== Register definition for EFC0 peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_EFC0_FMR (0x400E0800U) /**< \brief (EFC0) EEFC Flash Mode Register */ 48 | #define REG_EFC0_FCR (0x400E0804U) /**< \brief (EFC0) EEFC Flash Command Register */ 49 | #define REG_EFC0_FSR (0x400E0808U) /**< \brief (EFC0) EEFC Flash Status Register */ 50 | #define REG_EFC0_FRR (0x400E080CU) /**< \brief (EFC0) EEFC Flash Result Register */ 51 | #else 52 | #define REG_EFC0_FMR (*(RwReg*)0x400E0800U) /**< \brief (EFC0) EEFC Flash Mode Register */ 53 | #define REG_EFC0_FCR (*(WoReg*)0x400E0804U) /**< \brief (EFC0) EEFC Flash Command Register */ 54 | #define REG_EFC0_FSR (*(RoReg*)0x400E0808U) /**< \brief (EFC0) EEFC Flash Status Register */ 55 | #define REG_EFC0_FRR (*(RoReg*)0x400E080CU) /**< \brief (EFC0) EEFC Flash Result Register */ 56 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 57 | 58 | #endif /* _SAM3U_EFC0_INSTANCE_ */ 59 | -------------------------------------------------------------------------------- /sam3u_hal/inc/instance/instance_efc1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_EFC1_INSTANCE_ 43 | #define _SAM3U_EFC1_INSTANCE_ 44 | 45 | /* ========== Register definition for EFC1 peripheral ========== */ 46 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 47 | #define REG_EFC1_FMR (0x400E0A00U) /**< \brief (EFC1) EEFC Flash Mode Register */ 48 | #define REG_EFC1_FCR (0x400E0A04U) /**< \brief (EFC1) EEFC Flash Command Register */ 49 | #define REG_EFC1_FSR (0x400E0A08U) /**< \brief (EFC1) EEFC Flash Status Register */ 50 | #define REG_EFC1_FRR (0x400E0A0CU) /**< \brief (EFC1) EEFC Flash Result Register */ 51 | #else 52 | #define REG_EFC1_FMR (*(RwReg*)0x400E0A00U) /**< \brief (EFC1) EEFC Flash Mode Register */ 53 | #define REG_EFC1_FCR (*(WoReg*)0x400E0A04U) /**< \brief (EFC1) EEFC Flash Command Register */ 54 | #define REG_EFC1_FSR (*(RoReg*)0x400E0A08U) /**< \brief (EFC1) EEFC Flash Status Register */ 55 | #define REG_EFC1_FRR (*(RoReg*)0x400E0A0CU) /**< \brief (EFC1) EEFC Flash Result Register */ 56 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 57 | 58 | #endif /* _SAM3U_EFC1_INSTANCE_ */ 59 | -------------------------------------------------------------------------------- /sam3x_hal/inc/instance/instance_trng.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Subject to your compliance with these terms, you may use Microchip 11 | * software and any derivatives exclusively with Microchip products. 12 | * It is your responsibility to comply with third party license terms applicable 13 | * to your use of third party software (including open source software) that 14 | * may accompany Microchip software. 15 | * 16 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 17 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 18 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 19 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 20 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 21 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 22 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 23 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 24 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 25 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 27 | * 28 | * \asf_license_stop 29 | * 30 | */ 31 | /* 32 | * Support and FAQ: visit Microchip Support 33 | */ 34 | 35 | #ifndef _SAM3XA_TRNG_INSTANCE_ 36 | #define _SAM3XA_TRNG_INSTANCE_ 37 | 38 | /* ========== Register definition for TRNG peripheral ========== */ 39 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 40 | #define REG_TRNG_CR (0x400BC000U) /**< \brief (TRNG) Control Register */ 41 | #define REG_TRNG_IER (0x400BC010U) /**< \brief (TRNG) Interrupt Enable Register */ 42 | #define REG_TRNG_IDR (0x400BC014U) /**< \brief (TRNG) Interrupt Disable Register */ 43 | #define REG_TRNG_IMR (0x400BC018U) /**< \brief (TRNG) Interrupt Mask Register */ 44 | #define REG_TRNG_ISR (0x400BC01CU) /**< \brief (TRNG) Interrupt Status Register */ 45 | #define REG_TRNG_ODATA (0x400BC050U) /**< \brief (TRNG) Output Data Register */ 46 | #else 47 | #define REG_TRNG_CR (*(WoReg*)0x400BC000U) /**< \brief (TRNG) Control Register */ 48 | #define REG_TRNG_IER (*(WoReg*)0x400BC010U) /**< \brief (TRNG) Interrupt Enable Register */ 49 | #define REG_TRNG_IDR (*(WoReg*)0x400BC014U) /**< \brief (TRNG) Interrupt Disable Register */ 50 | #define REG_TRNG_IMR (*(RoReg*)0x400BC018U) /**< \brief (TRNG) Interrupt Mask Register */ 51 | #define REG_TRNG_ISR (*(RoReg*)0x400BC01CU) /**< \brief (TRNG) Interrupt Status Register */ 52 | #define REG_TRNG_ODATA (*(RoReg*)0x400BC050U) /**< \brief (TRNG) Output Data Register */ 53 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 54 | 55 | #endif /* _SAM3XA_TRNG_INSTANCE_ */ 56 | -------------------------------------------------------------------------------- /sam3u_hal/inc/component/component_gpbr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * Copyright (c) 2012 Atmel Corporation. All rights reserved. 5 | * 6 | * \asf_license_start 7 | * 8 | * \page License 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 20 | * 3. The name of Atmel may not be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * 4. This software may only be redistributed and used in connection with an 24 | * Atmel microcontroller product. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 29 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * \asf_license_stop 39 | * 40 | */ 41 | 42 | #ifndef _SAM3U_GPBR_COMPONENT_ 43 | #define _SAM3U_GPBR_COMPONENT_ 44 | 45 | /* ============================================================================= */ 46 | /** SOFTWARE API DEFINITION FOR General Purpose Backup Register */ 47 | /* ============================================================================= */ 48 | /** \addtogroup SAM3U_GPBR General Purpose Backup Register */ 49 | /*@{*/ 50 | 51 | #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 52 | /** \brief Gpbr hardware registers */ 53 | typedef struct { 54 | RwReg SYS_GPBR[4]; /**< \brief (Gpbr Offset: 0x0) General Purpose Backup Register */ 55 | } Gpbr; 56 | #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 57 | /* -------- SYS_GPBR[4] : (GPBR Offset: 0x0) General Purpose Backup Register -------- */ 58 | #define SYS_GPBR_GPBR_VALUE_Pos 0 59 | #define SYS_GPBR_GPBR_VALUE_Msk (0xffffffffu << SYS_GPBR_GPBR_VALUE_Pos) /**< \brief (SYS_GPBR[4]) Value of GPBR x */ 60 | #define SYS_GPBR_GPBR_VALUE(value) ((SYS_GPBR_GPBR_VALUE_Msk & ((value) << SYS_GPBR_GPBR_VALUE_Pos))) 61 | 62 | /*@}*/ 63 | 64 | 65 | #endif /* _SAM3U_GPBR_COMPONENT_ */ 66 | -------------------------------------------------------------------------------- /i2c_util.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "i2c_util.h" 3 | 4 | #ifndef TWI 5 | #define TWI TWI0 6 | #endif 7 | 8 | static volatile uint8_t I2C_LOCK = 0; 9 | static volatile uint8_t I2C_SETUP = 0; 10 | void i2c_setup(void) 11 | { 12 | gpio_configure_pin(PIN_I2C_SDA, PIN_I2C_SDA_FLAGS); 13 | gpio_configure_pin(PIN_I2C_SCL, PIN_I2C_SCL_FLAGS); 14 | 15 | I2C_LOCK = 0; 16 | if (I2C_SETUP) return; 17 | 18 | // limited to 400kHz 19 | twi_master_options_t opt = { 20 | .speed = 100E3, 21 | .chip = 0x00 22 | }; 23 | 24 | twi_master_setup(TWI, &opt); 25 | I2C_SETUP = 1; 26 | } 27 | 28 | void i2c_reset(void) 29 | { 30 | twi_master_options_t opt = { 31 | .speed = 100E3, 32 | .chip = 0x00 33 | }; 34 | twi_reset(TWI); 35 | twi_master_setup(TWI, &opt); 36 | I2C_LOCK = 0; 37 | // I2C_SETUP = 0; 38 | } 39 | 40 | int i2c_write(uint8_t chip_addr, uint8_t reg_addr, void *data, uint8_t len) 41 | { 42 | if (I2C_LOCK) { 43 | return -10; 44 | } 45 | I2C_LOCK = 1; 46 | twi_package_t packet_write = { 47 | .addr = {reg_addr}, // TWI slave memory address data 48 | .addr_length = 1, // TWI slave memory address data size 49 | .chip = chip_addr, // TWI slave bus address 50 | .buffer = data, // transfer data source buffer 51 | .length = len // transfer data size (bytes) 52 | }; 53 | 54 | int rtn = 0; 55 | if (rtn = twi_master_write(TWI, &packet_write), rtn == TWI_SUCCESS){ 56 | I2C_LOCK = 0; 57 | return 0; 58 | } else { 59 | // reset just in case 60 | i2c_reset(); 61 | I2C_LOCK = 0; 62 | return rtn; 63 | } 64 | } 65 | 66 | int i2c_read(uint8_t chip_addr, uint8_t reg_addr, void *data, uint8_t len) 67 | { 68 | if (I2C_LOCK) { 69 | return -10; 70 | } 71 | I2C_LOCK = 1; 72 | twi_package_t packet_read = { 73 | .addr = {reg_addr}, // TWI slave memory address data 74 | .addr_length = 1, // TWI slave memory address data size 75 | .chip = chip_addr, // TWI slave bus address 76 | .buffer = data, // transfer data destination buffer 77 | .length = len, // transfer data size (bytes) 78 | }; 79 | 80 | int rtn = 0; 81 | if(rtn = twi_master_read(TWI, &packet_read), rtn == TWI_SUCCESS){ 82 | I2C_LOCK = 0; 83 | return 0; 84 | } else { 85 | //reset just in case 86 | i2c_reset(); 87 | I2C_LOCK = 0; 88 | return rtn; 89 | } 90 | } 91 | 92 | int i2c_is_locked(void) 93 | { 94 | return I2C_LOCK; 95 | } 96 | 97 | int raw_i2c_read(twi_package_t *packet) 98 | { 99 | uint32_t rtn = 0; 100 | if (I2C_LOCK) { 101 | return -10; 102 | } 103 | I2C_LOCK = 1; 104 | rtn = twi_master_read(TWI0, packet); 105 | I2C_LOCK = 0; 106 | return rtn; 107 | } 108 | 109 | int raw_i2c_send(twi_package_t *packet) 110 | { 111 | uint32_t rtn = 0; 112 | if (I2C_LOCK) { 113 | return -10; 114 | } 115 | I2C_LOCK = 1; 116 | rtn = twi_master_write(TWI0, packet); 117 | I2C_LOCK = 0; 118 | return rtn; 119 | } -------------------------------------------------------------------------------- /sam3u_hal/inc/stringz.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Preprocessor stringizing utils. 5 | * 6 | * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _STRINGZ_H_ 45 | #define _STRINGZ_H_ 46 | 47 | /** 48 | * \defgroup group_sam_utils_stringz Preprocessor - Stringize 49 | * 50 | * \ingroup group_sam_utils 51 | * 52 | * \{ 53 | */ 54 | 55 | /*! \brief Stringize. 56 | * 57 | * Stringize a preprocessing token, this token being allowed to be \#defined. 58 | * 59 | * May be used only within macros with the token passed as an argument if the token is \#defined. 60 | * 61 | * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN) 62 | * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to 63 | * writing "A0". 64 | */ 65 | #define STRINGZ(x) #x 66 | 67 | /*! \brief Absolute stringize. 68 | * 69 | * Stringize a preprocessing token, this token being allowed to be \#defined. 70 | * 71 | * No restriction of use if the token is \#defined. 72 | * 73 | * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is 74 | * equivalent to writing "A0". 75 | */ 76 | #define ASTRINGZ(x) STRINGZ(x) 77 | 78 | /** 79 | * \} 80 | */ 81 | 82 | #endif // _STRINGZ_H_ 83 | -------------------------------------------------------------------------------- /sam3x_hal/inc/chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Chip Identifier (CHIPID) driver for SAM. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef CHIPID_H_INCLUDED 38 | #define CHIPID_H_INCLUDED 39 | 40 | #include "compiler.h" 41 | 42 | /// @cond 0 43 | /**INDENT-OFF**/ 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | /**INDENT-ON**/ 48 | /// @endcond 49 | 50 | //! Definition for chip id register data struct 51 | typedef struct chipid_data { 52 | 53 | //! Version of the device 54 | uint32_t ul_version; 55 | //! Embedded processor 56 | uint32_t ul_eproc; 57 | //! Non-volatile program memory size 58 | uint32_t ul_nvpsiz; 59 | //! Second non-volatile program memory size 60 | uint32_t ul_nvpsiz2; 61 | //! Internal SRAM size 62 | uint32_t ul_sramsiz; 63 | //! Architecture identifier 64 | uint32_t ul_arch; 65 | //! Non-volatile program memory type 66 | uint32_t ul_nvptyp; 67 | //! Extension flag 68 | uint32_t ul_extflag; 69 | //! Chip ID extension 70 | uint32_t ul_extid; 71 | } chipid_data_t; 72 | 73 | uint32_t chipid_read(Chipid *p_chipid, chipid_data_t *p_chipid_data); 74 | uint32_t chipid_read_version(Chipid *p_chipid); 75 | uint32_t chipid_read_processor(Chipid *p_chipid); 76 | uint32_t chipid_read_arch(Chipid *p_chipid); 77 | uint32_t chipid_read_sramsize(Chipid *p_chipid); 78 | uint32_t chipid_read_nvpmsize(Chipid *p_chipid); 79 | uint32_t chipid_read_nvpm2size(Chipid *p_chipid); 80 | uint32_t chipid_read_nvpmtype(Chipid *p_chipid); 81 | uint32_t chipid_read_extchipid(Chipid *p_chipid); 82 | 83 | /// @cond 0 84 | /**INDENT-OFF**/ 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | /**INDENT-ON**/ 89 | /// @endcond 90 | 91 | #endif /* CHIPID_H_INCLUDED */ 92 | -------------------------------------------------------------------------------- /sam4s_hal/inc/chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Chip Identifier (CHIPID) driver for SAM. 5 | * 6 | * Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Subject to your compliance with these terms, you may use Microchip 13 | * software and any derivatives exclusively with Microchip products. 14 | * It is your responsibility to comply with third party license terms applicable 15 | * to your use of third party software (including open source software) that 16 | * may accompany Microchip software. 17 | * 18 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, 19 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, 20 | * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE 22 | * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL 23 | * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE 24 | * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE 25 | * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT 26 | * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY 27 | * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 28 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 29 | * 30 | * \asf_license_stop 31 | * 32 | */ 33 | /* 34 | * Support and FAQ: visit Microchip Support 35 | */ 36 | 37 | #ifndef CHIPID_H_INCLUDED 38 | #define CHIPID_H_INCLUDED 39 | 40 | #include "compiler.h" 41 | 42 | /// @cond 0 43 | /**INDENT-OFF**/ 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | /**INDENT-ON**/ 48 | /// @endcond 49 | 50 | //! Definition for chip id register data struct 51 | typedef struct chipid_data { 52 | 53 | //! Version of the device 54 | uint32_t ul_version; 55 | //! Embedded processor 56 | uint32_t ul_eproc; 57 | //! Non-volatile program memory size 58 | uint32_t ul_nvpsiz; 59 | //! Second non-volatile program memory size 60 | uint32_t ul_nvpsiz2; 61 | //! Internal SRAM size 62 | uint32_t ul_sramsiz; 63 | //! Architecture identifier 64 | uint32_t ul_arch; 65 | //! Non-volatile program memory type 66 | uint32_t ul_nvptyp; 67 | //! Extension flag 68 | uint32_t ul_extflag; 69 | //! Chip ID extension 70 | uint32_t ul_extid; 71 | } chipid_data_t; 72 | 73 | uint32_t chipid_read(Chipid *p_chipid, chipid_data_t *p_chipid_data); 74 | uint32_t chipid_read_version(Chipid *p_chipid); 75 | uint32_t chipid_read_processor(Chipid *p_chipid); 76 | uint32_t chipid_read_arch(Chipid *p_chipid); 77 | uint32_t chipid_read_sramsize(Chipid *p_chipid); 78 | uint32_t chipid_read_nvpmsize(Chipid *p_chipid); 79 | uint32_t chipid_read_nvpm2size(Chipid *p_chipid); 80 | uint32_t chipid_read_nvpmtype(Chipid *p_chipid); 81 | uint32_t chipid_read_extchipid(Chipid *p_chipid); 82 | 83 | /// @cond 0 84 | /**INDENT-OFF**/ 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | /**INDENT-ON**/ 89 | /// @endcond 90 | 91 | #endif /* CHIPID_H_INCLUDED */ 92 | --------------------------------------------------------------------------------