mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
Real AT91 lib defines
This commit is contained in:
@@ -81,7 +81,7 @@ GDB = $(CROSS_COMPILE)gdb
|
||||
NM = $(CROSS_COMPILE)nm
|
||||
|
||||
# Flags
|
||||
INCLUDES = -Iinclude
|
||||
INCLUDES = -Iinclude -Isam3s_examples_include
|
||||
INCLUDES += -Icmsis
|
||||
#INCLUDES += -I$(LIBRARIES)
|
||||
|
||||
|
||||
7735
sam3s_example/sam3s_examples_include/SAM3S.h
Normal file
7735
sam3s_example/sam3s_examples_include/SAM3S.h
Normal file
File diff suppressed because it is too large
Load Diff
303
sam3s_example/sam3s_examples_include/USBD_Config.h
Normal file
303
sam3s_example/sam3s_examples_include/USBD_Config.h
Normal file
@@ -0,0 +1,303 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* USB Device Framework configurations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef USBD_CONFIG_H
|
||||
#define USBD_CONFIG_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_config
|
||||
*@{
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
* Constants
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_ids USBD Device IDs
|
||||
* @{
|
||||
*/
|
||||
#define USBD_VID_ATMEL 0x03EB /**< Vendor ID: Atmel */
|
||||
|
||||
#define USBD_PID_ENUM 0x0001 /**< Product ID: Enum (Core) */
|
||||
#define USBD_PID_CDCDSERIAL 0x6119 /**< Product ID: CDC Serial */
|
||||
#define USBD_PID_HIDKEYBOARD 0x6127 /**< Product ID: HID Keyboard */
|
||||
#define USBD_PID_AUDIO 0x6128 /**< Product ID: Audio devices */
|
||||
#define USBD_PID_MSD 0x6129 /**< Product ID: Massstorage */
|
||||
#define USBD_PID_CDCHID 0x6130 /**< Product ID: composite */
|
||||
#define USBD_PID_CDCAUDIO 0x6131 /**< Product ID: composite */
|
||||
#define USBD_PID_CDCMSD 0x6132 /**< Product ID: composite */
|
||||
#define USBD_PID_CDCCDC 0x6133 /**< Product ID: composite */
|
||||
#define USBD_PID_HIDAUDIO 0x6134 /**< Product ID: composite */
|
||||
#define USBD_PID_HIDMSD 0x6135 /**< Product ID: composite */
|
||||
#define USBD_PID_HIDMOUSE 0x6200 /**< Product ID: HID Mouse */
|
||||
#define USBD_PID_HIDTRANSFER 0x6201 /**< Product ID: HID Transfer */
|
||||
#define USBD_PID_CCID 0x6203 /**< Product ID: CCID */
|
||||
|
||||
#define USBD_RELEASE_1_00 0x0100 /**< Release: 1.00 */
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_general_config USBD General Configure
|
||||
* @{
|
||||
* This page lists general configurations for all USB device drivers.
|
||||
* - \ref USBD_BMATTRIBUTES
|
||||
*/
|
||||
/** default USB Device attributes configuration descriptor
|
||||
* (bus or self powered, remote wakeup) */
|
||||
#define USBD_BMATTRIBUTES BOARD_USB_BMATTRIBUTES
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - Mass storage
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_msdd_config USB MassStorage Configure
|
||||
* @{
|
||||
* This page lists the defines used by the Mass Storage driver.
|
||||
*
|
||||
* \section msd_ep_addr Endpoint Addresses
|
||||
* - \ref MSDDriverDescriptors_BULKOUT
|
||||
* - \ref MSDDriverDescriptors_BULKIN
|
||||
*/
|
||||
/** Address of the Mass Storage bulk-out endpoint.*/
|
||||
#define MSDDriverDescriptors_BULKOUT 1
|
||||
/** Address of the Mass Storage bulk-in endpoint.*/
|
||||
#define MSDDriverDescriptors_BULKIN 2
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - CDC Serial
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_serial_config USB CDC Serial Configure
|
||||
* @{
|
||||
* This page lists the defines used by the CDC Serial Device Driver.
|
||||
*
|
||||
* \section cdcd_ep_addr Endpoint Addresses
|
||||
* - \ref CDCDSerialDriverDescriptors_DATAOUT
|
||||
* - \ref CDCDSerialDriverDescriptors_DATAIN
|
||||
* - \ref CDCDSerialDriverDescriptors_NOTIFICATION
|
||||
*/
|
||||
/** Data OUT endpoint number */
|
||||
#define CDCDSerialDriverDescriptors_DATAOUT 1
|
||||
/** Data IN endpoint number */
|
||||
#define CDCDSerialDriverDescriptors_DATAIN 2
|
||||
/** Notification endpoint number */
|
||||
#define CDCDSerialDriverDescriptors_NOTIFICATION 3
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - Audio
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_audio_config USB Audio General Configure
|
||||
* @{
|
||||
* This page lists definitions for USB Audio Devices Drivers.
|
||||
* - \ref
|
||||
*/
|
||||
#if defined(at91sam7s) || defined(at91sam9xe)
|
||||
/** Sample rate in Hz. */
|
||||
#define AUDDevice_SAMPLERATE 32000UL
|
||||
/** Number of channels in audio stream. */
|
||||
#define AUDDevice_NUMCHANNELS 1
|
||||
/** Number of bytes in one sample. */
|
||||
#define AUDDevice_BYTESPERSAMPLE 2
|
||||
#else
|
||||
/** Sample rate in Hz. */
|
||||
#define AUDDevice_SAMPLERATE 48000UL
|
||||
/** Number of channels in audio stream. */
|
||||
#define AUDDevice_NUMCHANNELS 2
|
||||
/** Number of bytes in one sample. */
|
||||
#define AUDDevice_BYTESPERSAMPLE 2
|
||||
#endif
|
||||
/** Number of bits in one sample. */
|
||||
#define AUDDevice_BITSPERSAMPLE (AUDDevice_BYTESPERSAMPLE * 8)
|
||||
/** Number of bytes in one USB subframe. */
|
||||
#define AUDDevice_BYTESPERSUBFRAME (AUDDevice_NUMCHANNELS * \
|
||||
AUDDevice_BYTESPERSAMPLE)
|
||||
/** Number of samples in one USB frame. */
|
||||
#define AUDDevice_SAMPLESPERFRAME (AUDDevice_SAMPLERATE / 1000 \
|
||||
* AUDDevice_NUMCHANNELS)
|
||||
/** Number of bytes in one USB frame. */
|
||||
#define AUDDevice_BYTESPERFRAME (AUDDevice_SAMPLESPERFRAME * \
|
||||
AUDDevice_BYTESPERSAMPLE)
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - Audio - Desktop Speaker
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_audio_speaker_config USB Speaker Configure
|
||||
* @{
|
||||
* This page lists the definitions for USB Audio Speaker Device Driver.
|
||||
* - \ref AUDDSpeakerDriverDescriptors_DATAOUT
|
||||
* - \ref AUDDSpeakerDriverDescriptors_FS_INTERVAL
|
||||
* - \ref AUDDSpeakerDriverDescriptors_HS_INTERVAL
|
||||
*
|
||||
* \note for UDP, uses IN EPs that support double buffer; for UDPHS, uses
|
||||
* IN EPs that support DMA and High bandwidth.
|
||||
*/
|
||||
/** Data out endpoint number. */
|
||||
#define AUDDSpeakerDriverDescriptors_DATAOUT 0x04
|
||||
/** Endpoint polling interval 2^(x-1) * 125us */
|
||||
#define AUDDSpeakerDriverDescriptors_HS_INTERVAL 0x04
|
||||
/** Endpoint polling interval 2^(x-1) * ms */
|
||||
#define AUDDSpeakerDriverDescriptors_FS_INTERVAL 0x01
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - Audio - Speaker Phone
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_audio_speakerphone_config USB Speaker Phone Configure
|
||||
* @{
|
||||
* This page lists the definitions for USB Audio Speaker Phone Device Driver.
|
||||
* - \ref AUDDSpeakerPhoneDriverDescriptors_DATAOUT
|
||||
* - \ref AUDDSpeakerPhoneDriverDescriptors_DATAIN
|
||||
* - \ref AUDDSpeakerPhoneDriverDescriptors_HS_INTERVAL
|
||||
* - \ref AUDDSpeakerPhoneDriverDescriptors_FS_INTERVAL
|
||||
*/
|
||||
|
||||
#if defined(at91sam7s) || defined(at91sam9xe)
|
||||
/** Data out endpoint number, size 64B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAOUT 0x01
|
||||
/** Data in endpoint number, size 64B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAIN 0x02
|
||||
#elif defined(CHIP_USB_UDP)
|
||||
/** Data out endpoint number, size 192B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAOUT 0x04
|
||||
/** Data in endpoint number, size 192B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAIN 0x05
|
||||
#elif defined(at91sam9m10ek)
|
||||
/** Data out endpoint number, size 192B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAOUT 0x01
|
||||
/** Data in endpoint number, size 192B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAIN 0x06
|
||||
#else
|
||||
/** Data out endpoint number, size 192B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAOUT 0x05
|
||||
/** Data in endpoint number, size 192B */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_DATAIN 0x06
|
||||
#endif
|
||||
/** Endpoint polling interval 2^(x-1) * 125us */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_HS_INTERVAL 0x04
|
||||
/** Endpoint polling interval 2^(x-1) * ms */
|
||||
#define AUDDSpeakerPhoneDriverDescriptors_FS_INTERVAL 0x01
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - HID - Keyboard
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_hid_keyboard_config USB HID Keyboard Device Configure
|
||||
* @{
|
||||
* This page lists the defines used by the HID Keyboard Device Driver.
|
||||
*
|
||||
* \section hidd_k_ep_addr Endpoint Addresses
|
||||
* - \ref HIDDKeyboardDriverDescriptors_INTERRUPTIN
|
||||
* - \ref HIDDKeyboardDriverDescriptors_INTERRUPTOUT
|
||||
* \section hidd_k_ep_polling Endpoint Polling Rate
|
||||
* - \ref HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING
|
||||
* - \ref HIDDKeyboardDriverDescriptors_INTERRUPTOUT_POLLING
|
||||
*/
|
||||
/** Interrupt IN endpoint number */
|
||||
#define HIDDKeyboardDriverDescriptors_INTERRUPTIN 1
|
||||
/** Interrupt IN endpoint polling rate (in milliseconds) */
|
||||
#define HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING 10
|
||||
/** Interrupt OUT endpoint number */
|
||||
#define HIDDKeyboardDriverDescriptors_INTERRUPTOUT 2
|
||||
/** Interrupt OUT endpoint polling rate (in milliseconds) */
|
||||
#define HIDDKeyboardDriverDescriptors_INTERRUPTOUT_POLLING 10
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - HID - Mouse
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_hid_mouse_config USB HID Mouse Device Configure
|
||||
* @{
|
||||
* This page lists the defines used by the HID Mouse Device Driver.
|
||||
*
|
||||
* \section hidd_m_ep_addr Endpoint Addresses
|
||||
* - \ref HIDDMouseDriverDescriptors_INTERRUPTIN
|
||||
* \section hidd_m_ep_polling Endpoint Polling Rate
|
||||
* - \ref HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING
|
||||
*/
|
||||
/** Interrupt IN endpoint number */
|
||||
#define HIDDMouseDriverDescriptors_INTERRUPTIN 1
|
||||
/** Interrupt IN endpoint polling rate (in milliseconds) */
|
||||
#define HIDDMouseDriverDescriptors_INTERRUPTIN_POLLING 10
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - HID - Transfer (Customize device)
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_hid_xfr_config USB HID Transfer Device Configure
|
||||
* @{
|
||||
* This page lists the defines used by the HID Transfer Device Driver.
|
||||
*
|
||||
* \section hidd_t_ep_addr Endpoint Addresses
|
||||
* - \ref HIDDTransferDriverDescriptors_INTERRUPTIN
|
||||
* - \ref HIDDTransferDriverDescriptors_INTERRUPTOUT
|
||||
* \section hidd_t_ep_polling Endpoint Polling Rate
|
||||
* - \ref HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING
|
||||
* - \ref HIDDTransferDriverDescriptors_INTERRUPTOUT_POLLING
|
||||
*/
|
||||
/** Interrupt IN endpoint number. */
|
||||
#define HIDDTransferDriverDescriptors_INTERRUPTIN 1
|
||||
/** Polling rate in ms */
|
||||
#define HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING 50
|
||||
/** Interrupt IN endpoint polling rate (in milliseconds). */
|
||||
#define HIDDTransferDriverDescriptors_INTERRUPTOUT 2
|
||||
/** Polling rate in ms */
|
||||
#define HIDDTransferDriverDescriptors_INTERRUPTOUT_POLLING 50
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* USB Device - Composite
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_composite_config USB Composite Device Configure
|
||||
* @{
|
||||
*/
|
||||
/** @}*/
|
||||
|
||||
/**@}*/
|
||||
#endif //#ifndef USBD_CONFIG_H
|
||||
|
||||
|
||||
73
sam3s_example/sam3s_examples_include/USBD_LEDs.h
Normal file
73
sam3s_example/sam3s_examples_include/USBD_LEDs.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Collection of LEDs for using the USB device controller on AT91
|
||||
* microcontrollers.
|
||||
*/
|
||||
|
||||
#ifndef USBDLEDS_H
|
||||
#define USBDLEDS_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/** \addtogroup usbd_hal
|
||||
*@{
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
* Constants
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_leds USB Device LEDs
|
||||
* @{
|
||||
* This page lists the LEDs used in the USB %device driver.
|
||||
*
|
||||
* - USBD_LEDPOWER
|
||||
* - USBD_LEDUSB
|
||||
* - USBD_LEDOTHER
|
||||
*/
|
||||
|
||||
/** LED for indicating that the device is powered. */
|
||||
#define USBD_LEDPOWER 0
|
||||
/** LED for indicating USB activity. */
|
||||
#define USBD_LEDUSB 1
|
||||
/** LED for custom usage. */
|
||||
#define USBD_LEDOTHER 2
|
||||
/** @}*/
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif //#ifndef USBDLEDS_H
|
||||
|
||||
151
sam3s_example/sam3s_examples_include/acc.h
Normal file
151
sam3s_example/sam3s_examples_include/acc.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Interface for configuration the Analog-to-Digital Converter (ACC) peripheral.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Configurate the pins for ACC
|
||||
* -# Initialize the ACC with ACC_Initialize().
|
||||
* -# Select the active channel using ACC_EnableChannel()
|
||||
* -# Start the conversion with ACC_StartConversion()
|
||||
* -# Wait the end of the conversion by polling status with ACC_GetStatus()
|
||||
* -# Finally, get the converted data using ACC_GetConvertedData()
|
||||
*
|
||||
*/
|
||||
#ifndef _ACC_
|
||||
#define _ACC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define ACC_SELPLUS_AD12B0 0
|
||||
#define ACC_SELPLUS_AD12B1 1
|
||||
#define ACC_SELPLUS_AD12B2 2
|
||||
#define ACC_SELPLUS_AD12B3 3
|
||||
#define ACC_SELPLUS_AD12B4 4
|
||||
#define ACC_SELPLUS_AD12B5 5
|
||||
#define ACC_SELPLUS_AD12B6 6
|
||||
#define ACC_SELPLUS_AD12B7 7
|
||||
#define ACC_SELMINUS_TS 0
|
||||
#define ACC_SELMINUS_ADVREF 1
|
||||
#define ACC_SELMINUS_DAC0 2
|
||||
#define ACC_SELMINUS_DAC1 3
|
||||
#define ACC_SELMINUS_AD12B0 4
|
||||
#define ACC_SELMINUS_AD12B1 5
|
||||
#define ACC_SELMINUS_AD12B2 6
|
||||
#define ACC_SELMINUS_AD12B3 7
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros function of register access
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define ACC_CfgModeReg(pAcc, mode) { \
|
||||
(pAcc)->ACC_MR = (mode);\
|
||||
}
|
||||
|
||||
#define ACC_GetModeReg( pAcc ) ((pAcc)->ACC_MR)
|
||||
|
||||
#define ACC_StartConversion( pAcc ) ((pAcc)->ACC_CR = ACC_CR_START)
|
||||
|
||||
#define ACC_SoftReset( pAcc ) ((pAcc)->ACC_CR = ACC_CR_SWRST)
|
||||
|
||||
#define ACC_EnableChannel( pAcc, dwChannel ) {\
|
||||
assert( dwChannel < 16 ) ;\
|
||||
(pAcc)->ACC_CHER = (1 << (dwChannel));\
|
||||
}
|
||||
|
||||
#define ACC_DisableChannel( pAcc, dwChannel ) {\
|
||||
assert( dwChannel < 16 ) ;\
|
||||
(pAcc)->ACC_CHDR = (1 << (dwChannel));\
|
||||
}
|
||||
|
||||
#define ACC_EnableIt( pAcc, dwMode ) {\
|
||||
assert( ((dwMode)&0xFFF00000)== 0 ) ;\
|
||||
(pAcc)->ACC_IER = (dwMode);\
|
||||
}
|
||||
|
||||
#define ACC_DisableIt( pAcc, dwMode ) {\
|
||||
assert( ((dwMode)&0xFFF00000)== 0 ) ;\
|
||||
(pAcc)->ACC_IDR = (dwMode);\
|
||||
}
|
||||
|
||||
#define ACC_EnableDataReadyIt( pAcc ) ((pAcc)->ACC_IER = AT91C_ACC_DRDY)
|
||||
|
||||
#define ACC_GetStatus( pAcc ) ((pAcc)->ACC_ISR)
|
||||
|
||||
#define ACC_GetChannelStatus( pAcc ) ((pAcc)->ACC_CHSR)
|
||||
|
||||
#define ACC_GetInterruptMaskStatus( pAcc ) ((pAcc)->ACC_IMR)
|
||||
|
||||
#define ACC_GetLastConvertedData( pAcc ) ((pAcc)->ACC_LCDR)
|
||||
|
||||
#define ACC_CfgAnalogCtrlReg( pAcc, dwMode ) {\
|
||||
assert( ((dwMode) & 0xFFFCFF3C) == 0 ) ;\
|
||||
(pAcc)->ACC_ACR = (dwMode);\
|
||||
}
|
||||
|
||||
#define ACC_CfgExtModeReg( pAcc, extmode ) {\
|
||||
assert( ((extmode) & 0xFF00FFFE) == 0 ) ;\
|
||||
(pAcc)->ACC_EMR = (extmode);\
|
||||
}
|
||||
|
||||
#define ACC_GetAnalogCtrlReg( pAcc ) ((pAcc)->ACC_ACR)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern void ACC_Configure( Acc *pAcc, uint8_t idAcc, uint8_t ucSelplus, uint8_t ucSelminus,
|
||||
uint16_t wAc_en, uint16_t wEdge, uint16_t wInvert ) ;
|
||||
|
||||
extern void ACC_SetComparisionPair( Acc *pAcc, uint8_t ucSelplus, uint8_t ucSelminus ) ;
|
||||
|
||||
extern uint32_t ACC_GetComparisionResult( Acc* pAcc, uint32_t dwStatus ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _ACC_ */
|
||||
157
sam3s_example/sam3s_examples_include/adc.h
Normal file
157
sam3s_example/sam3s_examples_include/adc.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Interface for configuration the Analog-to-Digital Converter (ADC) peripheral.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Configurate the pins for ADC
|
||||
* -# Initialize the ADC with ADC_Initialize().
|
||||
* -# Select the active channel using ADC_EnableChannel()
|
||||
* -# Start the conversion with ADC_StartConversion()
|
||||
* -# Wait the end of the conversion by polling status with ADC_GetStatus()
|
||||
* -# Finally, get the converted data using ADC_GetConvertedData()
|
||||
*
|
||||
*/
|
||||
#ifndef _ADC_
|
||||
#define _ADC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
/* SAM3S */
|
||||
#define ADC_FREQ_MAX 20000000
|
||||
#define ADC_FREQ_MIN 1000000
|
||||
|
||||
#define ADC_STARTUP_NORM 40
|
||||
#define ADC_STARTUP_FAST 12
|
||||
|
||||
#define ADC_CHANNEL_0 0
|
||||
#define ADC_CHANNEL_1 1
|
||||
#define ADC_CHANNEL_2 2
|
||||
#define ADC_CHANNEL_3 3
|
||||
#define ADC_CHANNEL_4 4
|
||||
#define ADC_CHANNEL_5 5
|
||||
#define ADC_CHANNEL_6 6
|
||||
#define ADC_CHANNEL_7 7
|
||||
#define ADC_CHANNEL_8 8
|
||||
#define ADC_CHANNEL_9 9
|
||||
#define ADC_CHANNEL_10 10
|
||||
#define ADC_CHANNEL_11 11
|
||||
#define ADC_CHANNEL_12 12
|
||||
#define ADC_CHANNEL_13 13
|
||||
#define ADC_CHANNEL_14 14
|
||||
#define ADC_CHANNEL_15 15
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros function of register access
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#define ADC_GetModeReg( pAdc ) ((pAdc)->ADC_MR)
|
||||
|
||||
#define ADC_StartConversion( pAdc ) ((pAdc)->ADC_CR = ADC_CR_START)
|
||||
|
||||
|
||||
#define ADC_EnableChannel( pAdc, channel ) {\
|
||||
assert( channel < 16 ) ;\
|
||||
(pAdc)->ADC_CHER = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define ADC_DisableChannel(pAdc, channel) {\
|
||||
assert( (channel) < 16 ) ;\
|
||||
(pAdc)->ADC_CHDR = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define ADC_EnableIt(pAdc, dwMode) {\
|
||||
(pAdc)->ADC_IER = (dwMode);\
|
||||
}
|
||||
|
||||
#define ADC_DisableIt(pAdc, dwMode) {\
|
||||
(pAdc)->ADC_IDR = (dwMode);\
|
||||
}
|
||||
|
||||
#define ADC_EnableTS(pAdc,dwMode) {\
|
||||
(pAdc)->ADC_ACR |= dwMode;\
|
||||
}
|
||||
|
||||
#define ADC_EnableDataReadyIt(pAdc) ((pAdc)->ADC_IER = AT91C_ADC_DRDY)
|
||||
|
||||
#define ADC_GetStatus(pAdc) ((pAdc)->ADC_ISR)
|
||||
|
||||
#define ADC_GetCompareMode(pAdc) (((pAdc)->ADC_EMR)& (ADC_EMR_CMPMODE_Msk))
|
||||
|
||||
#define ADC_GetChannelStatus(pAdc) ((pAdc)->ADC_CHSR)
|
||||
|
||||
#define ADC_GetInterruptMaskStatus(pAdc) ((pAdc)->ADC_IMR)
|
||||
|
||||
#define ADC_GetLastConvertedData(pAdc) ((pAdc)->ADC_LCDR)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern void ADC_Initialize( Adc* pAdc, uint32_t idAdc );
|
||||
extern void ADC_CfgTiming( Adc* pAdc, uint32_t tracking, uint32_t settling, uint32_t transfer );
|
||||
extern void ADC_cfgFrequency( Adc* pAdc, uint32_t startup, uint32_t prescal );
|
||||
extern void ADC_CfgTrigering( Adc* pAdc, uint32_t trgEn, uint32_t trgSel, uint32_t freeRun );
|
||||
extern void ADC_CfgLowRes( Adc* pAdc, uint32_t resolution );
|
||||
extern void ADC_CfgPowerSave( Adc* pAdc, uint32_t sleep, uint32_t fwup );
|
||||
extern void ADC_CfgChannelMode( Adc* pAdc, uint32_t useq, uint32_t anach );
|
||||
extern void ADC_check( Adc* pAdc, uint32_t mck_freq );
|
||||
|
||||
extern uint32_t ADC_GetConvertedData( Adc* pAdc, uint32_t dwChannel ) ;
|
||||
extern void ADC_SetCompareChannel( Adc* pAdc, uint32_t dwChannel ) ;
|
||||
extern void ADC_SetCompareMode( Adc* pAdc, uint32_t dwMode ) ;
|
||||
extern void ADC_SetComparisonWindow( Adc* pAdc, uint32_t dwHi_Lo ) ;
|
||||
extern uint32_t ADC_IsInterruptMasked( Adc* pAdc, uint32_t dwFlag ) ;
|
||||
extern uint32_t ADC_IsStatusSet( Adc* pAdc, uint32_t dwFlag ) ;
|
||||
extern uint32_t ADC_IsChannelInterruptStatusSet( uint32_t adc_sr, uint32_t dwChannel ) ;
|
||||
extern uint32_t ADC_ReadBuffer( Adc* pADC, int16_t *pwBuffer, uint32_t dwSize ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _ADC_ */
|
||||
80
sam3s_example/sam3s_examples_include/async.h
Normal file
80
sam3s_example/sam3s_examples_include/async.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Provide a routine for asynchronous transfer.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ASYNC_
|
||||
#define _ASYNC_
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definition
|
||||
*----------------------------------------------------------------------------*/
|
||||
/** Transfer is still pending.*/
|
||||
#define ASYNC_STATUS_PENDING 0xFF
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Type
|
||||
*----------------------------------------------------------------------------*/
|
||||
/** \brief Asynchronous transfer descriptor. */
|
||||
typedef struct _Async
|
||||
{
|
||||
/** Asynchronous transfer status.*/
|
||||
volatile uint8_t status ;
|
||||
/** Callback function to invoke when transfer completes or fails.*/
|
||||
void *callback ;
|
||||
/** Driver storage area; do not use.*/
|
||||
uint32_t pStorage[4] ;
|
||||
} Async ;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern uint32_t ASYNC_IsFinished( Async* pAsync ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _ASYNC_ */
|
||||
|
||||
72
sam3s_example/sam3s_examples_include/chip.h
Normal file
72
sam3s_example/sam3s_examples_include/chip.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef _LIB_SAM3S_
|
||||
#define _LIB_SAM3S_
|
||||
|
||||
/*
|
||||
* Peripherals registers definitions
|
||||
*/
|
||||
#if defined sam3s4
|
||||
#elif defined sam3s2
|
||||
#elif defined sam3s1
|
||||
#else
|
||||
#warning Library does not support the specified chip, specifying sam3s4.
|
||||
#define sam3s4
|
||||
#endif
|
||||
#include "include/SAM3S.h"
|
||||
|
||||
|
||||
/* Define attribute */
|
||||
#if defined ( __CC_ARM ) /* Keil µVision 4 */
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
#define WEAK __weak
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
|
||||
/* Define NO_INIT attribute */
|
||||
#if defined ( __CC_ARM )
|
||||
#define NO_INIT
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define NO_INIT __no_init
|
||||
#elif defined ( __GNUC__ )
|
||||
#define NO_INIT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Core
|
||||
*/
|
||||
|
||||
#include "include/exceptions.h"
|
||||
|
||||
/*
|
||||
* Peripherals
|
||||
*/
|
||||
#include "include/acc.h"
|
||||
#include "include/adc.h"
|
||||
#include "include/async.h"
|
||||
#include "include/crccu.h"
|
||||
#include "include/dacc.h"
|
||||
#include "include/efc.h"
|
||||
#include "include/flashd.h"
|
||||
#include "include/hsmci.h"
|
||||
#include "include/pio.h"
|
||||
#include "include/pio_it.h"
|
||||
#include "include/pio_capture.h"
|
||||
#include "include/pmc.h"
|
||||
#include "include/pwmc.h"
|
||||
#include "include/rtc.h"
|
||||
#include "include/rtt.h"
|
||||
#include "include/spi.h"
|
||||
#include "include/spi_pdc.h"
|
||||
#include "include/ssc.h"
|
||||
#include "include/tc.h"
|
||||
#include "include/twi.h"
|
||||
#include "include/twid.h"
|
||||
#include "include/usart.h"
|
||||
//#include "include/USBD_Config.h"
|
||||
|
||||
#include "include/trace.h"
|
||||
#include "include/wdt.h"
|
||||
|
||||
#endif /* _LIB_SAM3S_ */
|
||||
65
sam3s_example/sam3s_examples_include/crccu.h
Normal file
65
sam3s_example/sam3s_examples_include/crccu.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for Cyclic Redundancy Check Calculation Unit (CRCCU).
|
||||
*/
|
||||
|
||||
#ifndef _CRCCU_
|
||||
#define _CRCCU_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TR_ADDR ;
|
||||
uint32_t TR_CTRL ;
|
||||
} CrcDscr ;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void CRCCU_ResetCrcValue( Crccu* pCrccu ) ;
|
||||
extern void CRCCU_Configure( Crccu* pCrccu, uint32_t dwDscrAddr, uint32_t dwMode ) ;
|
||||
extern uint32_t CRCCU_ComputeCrc( Crccu* pCrccu ) ;
|
||||
|
||||
#endif /* #ifndef _CRCCU_ */
|
||||
|
||||
146
sam3s_example/sam3s_examples_include/dacc.h
Normal file
146
sam3s_example/sam3s_examples_include/dacc.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Interface for configuration the Analog-to-Digital Converter (DACC) peripheral.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Configurate the pins for DACC
|
||||
* -# Initialize the DACC with DACC_Initialize().
|
||||
* -# Select the active channel using DACC_EnableChannel()
|
||||
* -# Start the conversion with DACC_StartConversion()
|
||||
* -# Wait the end of the conversion by polling status with DACC_GetStatus()
|
||||
* -# Finally, get the converted data using DACC_GetConvertedData()
|
||||
*
|
||||
*/
|
||||
#ifndef _DACC_
|
||||
#define _DACC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define DACC_CHANNEL_0 0
|
||||
#define DACC_CHANNEL_1 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros function of register access
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define DACC_CfgModeReg(pDACC, mode) { \
|
||||
(pDACC)->DACC_MR = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_GetModeReg(pDACC) ((pDACC)->DACC_MR)
|
||||
|
||||
#define DACC_StartConversion(pDACC) ((pDACC)->DACC_CR = DACC_CR_START)
|
||||
|
||||
#define DACC_SoftReset(pDACC) ((pDACC)->DACC_CR = DACC_CR_SWRST)
|
||||
|
||||
#define DACC_EnableChannel(pDACC, channel) {\
|
||||
(pDACC)->DACC_CHER = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define DACC_DisableChannel(pDACC, channel) {\
|
||||
(pDACC)->DACC_CHDR = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define DACC_EnableIt(pDACC, mode) {\
|
||||
assert( ((mode)&0xFFF00000)== 0 ) ;\
|
||||
(pDACC)->DACC_IER = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_DisableIt(pDACC, mode) {\
|
||||
assert( ((mode)&0xFFF00000)== 0 ) ;\
|
||||
(pDACC)->DACC_IDR = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_EnableDataReadyIt(pDACC) ((pDACC)->DACC_IER = AT91C_DACC_DRDY)
|
||||
|
||||
#define DACC_GetStatus(pDACC) ((pDACC)->DACC_ISR)
|
||||
|
||||
#define DACC_GetChannelStatus(pDACC) ((pDACC)->DACC_CHSR)
|
||||
|
||||
#define DACC_GetInterruptMaskStatus(pDACC) ((pDACC)->DACC_IMR)
|
||||
|
||||
#define DACC_GetLastConvertedData(pDACC) ((pDACC)->DACC_LCDR)
|
||||
|
||||
#define DACC_CfgAnalogCtrlReg(pDACC,mode) {\
|
||||
assert( ((mode) & 0xFFFCFF3C)==0 ) ;\
|
||||
(pDACC)->DACC_ACR = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_CfgExtModeReg(pDACC, extmode) {\
|
||||
assert( ((extmode) & 0xFF00FFFE)==0 ) ;\
|
||||
(pDACC)->DACC_EMR = (extmode);\
|
||||
}
|
||||
|
||||
#define DACC_GetAnalogCtrlReg(pDACC) ((pDACC)->DACC_ACR)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern void DACC_Initialize( Dacc* pDACC,
|
||||
uint8_t idDACC,
|
||||
uint8_t trgEn,
|
||||
uint8_t trgSel,
|
||||
uint8_t word,
|
||||
uint8_t sleepMode,
|
||||
uint32_t mck,
|
||||
uint8_t refresh,/*refresh period*/
|
||||
uint8_t user_sel,/*user channel selection*/
|
||||
uint32_t tag_mode,/*using tag for channel number*/
|
||||
uint32_t startup
|
||||
);
|
||||
|
||||
|
||||
extern void DACC_SetConversionData( Dacc* pDACC, uint32_t dwData ) ;
|
||||
|
||||
extern uint32_t DACC_WriteBuffer( Dacc* pDACC, uint16_t* pwBuffer, uint32_t dwSize ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _DACC_ */
|
||||
113
sam3s_example/sam3s_examples_include/efc.h
Normal file
113
sam3s_example/sam3s_examples_include/efc.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Interface for configuration the Enhanced Embedded Flash Controller (EEFC) peripheral.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Enable/disable %flash ready interrupt sources using EFC_EnableFrdyIt()
|
||||
* and EFC_DisableFrdyIt().
|
||||
* -# Translates the given address into which EEFC, page and offset values
|
||||
* for difference density %flash memory using EFC_TranslateAddress().
|
||||
* -# Computes the address of a %flash access given the EFC, page and offset
|
||||
* for difference density %flash memory using EFC_ComputeAddress().
|
||||
* -# Start the executing command with EFC_StartCommand()
|
||||
* -# Retrieve the current status of the EFC using EFC_GetStatus().
|
||||
* -# Retrieve the result of the last executed command with EFC_GetResult().
|
||||
*/
|
||||
|
||||
#ifndef _EEFC_
|
||||
#define _EEFC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* EFC command */
|
||||
#define EFC_FCMD_GETD 0x00
|
||||
#define EFC_FCMD_WP 0x01
|
||||
#define EFC_FCMD_WPL 0x02
|
||||
#define EFC_FCMD_EWP 0x03
|
||||
#define EFC_FCMD_EWPL 0x04
|
||||
#define EFC_FCMD_EA 0x05
|
||||
#define EFC_FCMD_SLB 0x08
|
||||
#define EFC_FCMD_CLB 0x09
|
||||
#define EFC_FCMD_GLB 0x0A
|
||||
#define EFC_FCMD_SFB 0x0B
|
||||
#define EFC_FCMD_CFB 0x0C
|
||||
#define EFC_FCMD_GFB 0x0D
|
||||
#define EFC_FCMD_STUI 0x0E /* Start unique ID */
|
||||
#define EFC_FCMD_SPUI 0x0F /* Stop unique ID */
|
||||
|
||||
/* The IAP function entry addreass */
|
||||
#define CHIP_FLASH_IAP_ADDRESS (0x00800008)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void EFC_EnableFrdyIt( Efc* efc ) ;
|
||||
|
||||
extern void EFC_DisableFrdyIt( Efc* efc ) ;
|
||||
|
||||
extern void EFC_SetWaitState( Efc* efc, uint8_t cycles ) ;
|
||||
|
||||
extern void EFC_TranslateAddress( Efc** pEfc, uint32_t dwAddress, uint16_t *pwPage, uint16_t *pwOffset ) ;
|
||||
|
||||
extern void EFC_ComputeAddress( Efc* efc, uint16_t wPage, uint16_t wOffset, uint32_t *pdwAddress ) ;
|
||||
|
||||
extern void EFC_StartCommand( Efc* efc, uint32_t dwCommand, uint32_t dwArgument ) ;
|
||||
|
||||
extern uint32_t EFC_PerformCommand( Efc* efc, uint32_t dwCommand, uint32_t dwArgument, uint32_t dwUseIAP ) ;
|
||||
|
||||
extern uint32_t EFC_GetStatus( Efc* efc ) ;
|
||||
|
||||
extern uint32_t EFC_GetResult( Efc* efc ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _EEFC_ */
|
||||
|
||||
97
sam3s_example/sam3s_examples_include/exceptions.h
Normal file
97
sam3s_example/sam3s_examples_include/exceptions.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Interface for default exception handlers.
|
||||
*/
|
||||
|
||||
#ifndef _EXCEPTIONS_
|
||||
#define _EXCEPTIONS_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Function prototype for exception table items (interrupt handler). */
|
||||
typedef void( *IntFunc )( void ) ;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Default empty handler */
|
||||
extern void IrqHandlerNotUsed( void ) ;
|
||||
|
||||
/* Cortex-M3 core handlers */
|
||||
extern void NMI_Handler( void );
|
||||
extern void HardFault_Handler( void );
|
||||
extern void MemManage_Handler( void );
|
||||
extern void BusFault_Handler( void );
|
||||
extern void UsageFault_Handler( void );
|
||||
extern void SVC_Handler( void );
|
||||
extern void DebugMon_Handler( void );
|
||||
extern void PendSV_Handler( void );
|
||||
extern void SysTick_Handler( void );
|
||||
|
||||
/* Peripherals handlers */
|
||||
extern void ACC_IrqHandler( void ) ;
|
||||
extern void ADC_IrqHandler( void ) ;
|
||||
extern void CRCCU_IrqHandler( void ) ;
|
||||
extern void DAC_IrqHandler( void ) ;
|
||||
extern void EEFC_IrqHandler( void ) ;
|
||||
extern void MCI_IrqHandler( void ) ;
|
||||
extern void PIOA_IrqHandler( void ) ;
|
||||
extern void PIOB_IrqHandler( void ) ;
|
||||
extern void PIOC_IrqHandler( void ) ;
|
||||
extern void PMC_IrqHandler( void ) ;
|
||||
extern void PWM_IrqHandler( void ) ;
|
||||
extern void RSTC_IrqHandler( void ) ;
|
||||
extern void RTC_IrqHandler( void ) ;
|
||||
extern void RTT_IrqHandler( void ) ;
|
||||
extern void SMC_IrqHandler( void ) ;
|
||||
extern void SPI_IrqHandler( void ) ;
|
||||
extern void SSC_IrqHandler( void ) ;
|
||||
extern void SUPC_IrqHandler( void ) ;
|
||||
extern void TC0_IrqHandler( void ) ;
|
||||
extern void TC1_IrqHandler( void ) ;
|
||||
extern void TC2_IrqHandler( void ) ;
|
||||
extern void TC3_IrqHandler( void ) ;
|
||||
extern void TC4_IrqHandler( void ) ;
|
||||
extern void TC5_IrqHandler( void ) ;
|
||||
extern void TWI0_IrqHandler( void ) ;
|
||||
extern void TWI1_IrqHandler( void ) ;
|
||||
extern void UART0_IrqHandler( void ) ;
|
||||
extern void UART1_IrqHandler( void ) ;
|
||||
extern void USART0_IrqHandler( void ) ;
|
||||
extern void USART1_IrqHandler( void ) ;
|
||||
extern void USBD_IrqHandler(void);
|
||||
extern void WDT_IrqHandler( void ) ;
|
||||
|
||||
#endif /* _EXCEPTIONS_ */
|
||||
79
sam3s_example/sam3s_examples_include/flashd.h
Normal file
79
sam3s_example/sam3s_examples_include/flashd.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* The flash driver provides the unified interface for flash program operations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FLASHD_
|
||||
#define _FLASHD_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void FLASHD_Initialize( uint32_t dwMCk, uint32_t dwUseIAP ) ;
|
||||
|
||||
extern uint32_t FLASHD_Erase( uint32_t dwAddress ) ;
|
||||
|
||||
extern uint32_t FLASHD_Write( uint32_t dwAddress, const void *pvBuffer, uint32_t dwSize ) ;
|
||||
|
||||
extern uint32_t FLASHD_Lock( uint32_t dwStart, uint32_t dwEnd, uint32_t *pdwActualStart, uint32_t *pdwActualEnd ) ;
|
||||
|
||||
extern uint32_t FLASHD_Unlock( uint32_t dwStart, uint32_t dwEnd, uint32_t *pdwActualStart, uint32_t *pdwActualEnd ) ;
|
||||
|
||||
extern uint32_t FLASHD_IsLocked( uint32_t dwStart, uint32_t dwEnd ) ;
|
||||
|
||||
extern uint32_t FLASHD_SetGPNVM( uint8_t gpnvm ) ;
|
||||
|
||||
extern uint32_t FLASHD_ClearGPNVM( uint8_t gpnvm ) ;
|
||||
|
||||
extern uint32_t FLASHD_IsGPNVMSet( uint8_t gpnvm ) ;
|
||||
|
||||
#define FLASHD_IsSecurityBitSet() FLASHD_IsGPNVMSet( 0 )
|
||||
|
||||
#define FLASHD_SetSecurityBit() FLASHD_SetGPNVM( 0 )
|
||||
|
||||
extern uint32_t FLASHD_ReadUniqueID( uint32_t* pdwUniqueID ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _FLASHD_ */
|
||||
|
||||
206
sam3s_example/sam3s_examples_include/hsmci.h
Normal file
206
sam3s_example/sam3s_examples_include/hsmci.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup hsmci_module Working with HSMCI
|
||||
* The HSMCI driver provides the interface to configure and use the HSMCI
|
||||
* peripheral.
|
||||
*
|
||||
* The user needs to set the number of wait states depending on the frequency used.\n
|
||||
* Configure number of cycles for flash read/write operations in the FWS field of HSMCI_FMR.
|
||||
*
|
||||
* It offers a function to send flash command to HSMCI and waits for the
|
||||
* flash to be ready.
|
||||
*
|
||||
* To send flash command, the user could do in either of following way:
|
||||
* <ul>
|
||||
* <li>Write a correct key, command and argument in HSMCI_FCR. </li>
|
||||
* <li>Or, Use IAP (In Application Programming) function which is executed from
|
||||
* ROM directly, this allows flash programming to be done by code running in flash.</li>
|
||||
* <li>Once the command is achieved, it can be detected even by polling EEFC_FSR or interrupt.
|
||||
* </ul>
|
||||
*
|
||||
* The command argument could be a page number,GPNVM number or nothing, it depends on
|
||||
* the command itself. Some useful functions in this driver could help user tranlate physical
|
||||
* flash address into a page number and vice verse.
|
||||
*
|
||||
* For more accurate information, please look at the EEFC section of the
|
||||
* Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref hsmci_pdc.c\n
|
||||
* \ref hsmci.h.\n
|
||||
*/
|
||||
/*@{*/
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Implement MultiMediaCard(MCI) Interface Driver
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# MCI_Init(): Initializes a MCI driver instance and the underlying
|
||||
* peripheral.
|
||||
* -# MCI_Handler() : Interrupt handler which is called by ISR handler.
|
||||
* -# MCI_SetSpeed() : Configure the MCI CLKDIV in the _MR register
|
||||
* (\ref Hsmci::HSMCI_MR).
|
||||
* -# MCI_SetBusWidth() : Configure the MCI SDCBUS in the _SDCR register
|
||||
* (\ref Hsmci::HSMCI_SDCR).
|
||||
* -# MCI_EnableHsMode() : Configure the MCI HSMODE in the _CFG register
|
||||
* (\ref Hsmci::HSMCI_CFG).
|
||||
*/
|
||||
|
||||
#ifndef HSMCID_H
|
||||
#define HSMCID_H
|
||||
/** \addtogroup sdmmc_hal
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//#include <memories/sdmmc/sdmmc_cmd.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Constants
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Transfer type */
|
||||
|
||||
/** MultiMedia Transfer type: no data */
|
||||
#define MCI_NO_TRANSFER 0
|
||||
/** MultiMedia Transfer type: Device to Host (read) */
|
||||
#define MCI_START_READ 1
|
||||
/** MultiMedia Transfer type: Host to Device (write) & check BUSY */
|
||||
#define MCI_START_WRITE 2
|
||||
/** Device to Host (read) without command */
|
||||
#define MCI_READ 3
|
||||
/** Host to Device (write) without command & check BUSY */
|
||||
#define MCI_WRITE 4
|
||||
/** MultiMedia Transfer type: STOP transfer */
|
||||
#define MCI_STOP_TRANSFER 5
|
||||
|
||||
/** MCI Initialize clock 400K Hz */
|
||||
#define MCI_INITIAL_SPEED 400000
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief MCI Transfer Request prepared by the application upper layer.
|
||||
*
|
||||
* This structure is sent to the Sdmmc_SendCommand function to start the transfer.
|
||||
* At the end of the transfer, the callback is invoked.
|
||||
*/
|
||||
typedef struct _MciCmd {
|
||||
|
||||
/** Command code. */
|
||||
uint32_t cmd;
|
||||
/** Command argument. */
|
||||
uint32_t arg;
|
||||
/** Data buffer, with MCI_DMA_ENABLE defined 1, the buffer can be
|
||||
* 1, 2 or 4 bytes aligned. It has to be 4 byte aligned if no DMA.
|
||||
*/
|
||||
uint8_t *pData;
|
||||
/** Size of data block in bytes. */
|
||||
uint16_t blockSize;
|
||||
/** Number of blocks to be transfered */
|
||||
uint16_t nbBlock;
|
||||
/** Response buffer. */
|
||||
uint32_t *pResp;
|
||||
/** Optional user-provided callback function. */
|
||||
void (*callback)( uint8_t status, void *pArg ) ;
|
||||
/** Optional argument to the callback function. */
|
||||
void *pArg;
|
||||
/** SD card command option. */
|
||||
uint8_t resType:7, /** Response */
|
||||
busyCheck:1; /** Check busy as end of command */
|
||||
/** Indicate transfer type */
|
||||
uint8_t tranType;
|
||||
|
||||
/** Indicate end of transfer status */
|
||||
uint8_t status;
|
||||
|
||||
/** Command state. */
|
||||
volatile uint8_t state;
|
||||
} MciCmd;
|
||||
|
||||
/**
|
||||
* \brief MCI Driver
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** Pointer to a MCI peripheral. */
|
||||
Hsmci *pMciHw;
|
||||
/** Pointer to currently executing command. */
|
||||
MciCmd *pCommand;
|
||||
/** MCI peripheral identifier. */
|
||||
uint8_t mciId;
|
||||
/** Mutex. */
|
||||
volatile uint8_t semaphore;
|
||||
} Mcid;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void MCI_Disable(Hsmci *pMciHw);
|
||||
extern void MCI_Enable(Hsmci *pMciHw);
|
||||
extern uint8_t MCI_EnableHsMode(Mcid * pMci, uint8_t hsEnable);
|
||||
extern void MCI_Init( Mcid *pMci, Hsmci *pMciHw, uint8_t mciId, uint32_t dwMCk ) ;
|
||||
extern uint32_t MCI_SetBusWidth(Mcid *pMci, uint32_t busWidth);
|
||||
extern uint32_t MCI_SetSpeed(Mcid *pMci, uint32_t mciSpeed, uint32_t mck);
|
||||
|
||||
/* pdc if used */
|
||||
extern void MCI_Reset(Mcid *pMci, uint8_t keepSettings);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
#endif //#ifndef HSMCID_H
|
||||
|
||||
206
sam3s_example/sam3s_examples_include/pio.h
Normal file
206
sam3s_example/sam3s_examples_include/pio.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* This file provides a basic API for PIO configuration and usage of
|
||||
* user-controlled pins. Please refer to the board.h file for a list of
|
||||
* available pin definitions.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Define a constant pin description array such as the following one, using
|
||||
* the existing definitions provided by the board.h file if possible:
|
||||
* \code
|
||||
* const Pin pPins[] = {PIN_USART0_TXD, PIN_USART0_RXD};
|
||||
* \endcode
|
||||
* Alternatively, it is possible to add new pins by provided the full Pin
|
||||
* structure:
|
||||
* \code
|
||||
* // Pin instance to configure PA10 & PA11 as inputs with the internal
|
||||
* // pull-up enabled.
|
||||
* const Pin pPins = {
|
||||
* (1 << 10) | (1 << 11),
|
||||
* REG_PIOA,
|
||||
* ID_PIOA,
|
||||
* PIO_INPUT,
|
||||
* PIO_PULLUP
|
||||
* };
|
||||
* \endcode
|
||||
* -# Configure a pin array by calling PIO_Configure() with a pointer to the
|
||||
* array and its size (which is computed using the PIO_LISTSIZE macro).
|
||||
* -# Change and get the value of a user-controlled pin using the PIO_Set,
|
||||
* PIO_Clear and PIO_Get methods.
|
||||
* -# Get the level being currently output by a user-controlled pin configured
|
||||
* as an output using PIO_GetOutputDataStatus().
|
||||
*/
|
||||
|
||||
#ifndef _PIO_
|
||||
#define _PIO_
|
||||
|
||||
/*
|
||||
* Headers
|
||||
*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Global Definitions
|
||||
*/
|
||||
|
||||
/* The pin is controlled by the associated signal of peripheral A. */
|
||||
#define PIO_PERIPH_A 0
|
||||
/* The pin is controlled by the associated signal of peripheral B. */
|
||||
#define PIO_PERIPH_B 1
|
||||
/* The pin is controlled by the associated signal of peripheral C. */
|
||||
#define PIO_PERIPH_C 2
|
||||
/* The pin is controlled by the associated signal of peripheral D. */
|
||||
#define PIO_PERIPH_D 3
|
||||
/* The pin is an input. */
|
||||
#define PIO_INPUT 4
|
||||
/* The pin is an output and has a default level of 0. */
|
||||
#define PIO_OUTPUT_0 5
|
||||
/* The pin is an output and has a default level of 1. */
|
||||
#define PIO_OUTPUT_1 6
|
||||
|
||||
/* Default pin configuration (no attribute). */
|
||||
#define PIO_DEFAULT (0 << 0)
|
||||
/* The internal pin pull-up is active. */
|
||||
#define PIO_PULLUP (1 << 0)
|
||||
/* The internal glitch filter is active. */
|
||||
#define PIO_DEGLITCH (1 << 1)
|
||||
/* The pin is open-drain. */
|
||||
#define PIO_OPENDRAIN (1 << 2)
|
||||
|
||||
/* The internal debouncing filter is active. */
|
||||
#define PIO_DEBOUNCE (1 << 3)
|
||||
|
||||
/* Enable additional interrupt modes. */
|
||||
#define PIO_IT_AIME (1 << 4)
|
||||
|
||||
/* Interrupt High Level/Rising Edge detection is active. */
|
||||
#define PIO_IT_RE_OR_HL (1 << 5)
|
||||
/* Interrupt Edge detection is active. */
|
||||
#define PIO_IT_EDGE (1 << 6)
|
||||
|
||||
/* Low level interrupt is active */
|
||||
#define PIO_IT_LOW_LEVEL (0 | 0 | PIO_IT_AIME)
|
||||
/* High level interrupt is active */
|
||||
#define PIO_IT_HIGH_LEVEL (PIO_IT_RE_OR_HL | 0 | PIO_IT_AIME)
|
||||
/* Falling edge interrupt is active */
|
||||
#define PIO_IT_FALL_EDGE (0 | PIO_IT_EDGE | PIO_IT_AIME)
|
||||
/* Rising edge interrupt is active */
|
||||
#define PIO_IT_RISE_EDGE (PIO_IT_RE_OR_HL | PIO_IT_EDGE | PIO_IT_AIME)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Global Macros
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculates the size of an array of Pin instances. The array must be defined
|
||||
* locally (i.e. not a pointer), otherwise the computation will not be correct.
|
||||
* \param pPins Local array of Pin instances.
|
||||
* \return Number of elements in array.
|
||||
*/
|
||||
#define PIO_LISTSIZE(pPins) (sizeof(pPins) / sizeof(Pin))
|
||||
|
||||
/*
|
||||
* Global Types
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Describes the type and attribute of one PIO pin or a group of similar pins.
|
||||
* The #type# field can have the following values:
|
||||
* - PIO_PERIPH_A
|
||||
* - PIO_PERIPH_B
|
||||
* - PIO_OUTPUT_0
|
||||
* - PIO_OUTPUT_1
|
||||
* - PIO_INPUT
|
||||
*
|
||||
* The #attribute# field is a bitmask that can either be set to PIO_DEFAULt,
|
||||
* or combine (using bitwise OR '|') any number of the following constants:
|
||||
* - PIO_PULLUP
|
||||
* - PIO_DEGLITCH
|
||||
* - PIO_DEBOUNCE
|
||||
* - PIO_OPENDRAIN
|
||||
* - PIO_IT_LOW_LEVEL
|
||||
* - PIO_IT_HIGH_LEVEL
|
||||
* - PIO_IT_FALL_EDGE
|
||||
* - PIO_IT_RISE_EDGE
|
||||
*/
|
||||
typedef struct _Pin
|
||||
{
|
||||
/* Bitmask indicating which pin(s) to configure. */
|
||||
uint32_t mask;
|
||||
/* Pointer to the PIO controller which has the pin(s). */
|
||||
Pio *pio;
|
||||
/* Peripheral ID of the PIO controller which has the pin(s). */
|
||||
uint8_t id;
|
||||
/* Pin type. */
|
||||
uint8_t type;
|
||||
/* Pin attribute. */
|
||||
uint8_t attribute;
|
||||
} Pin ;
|
||||
|
||||
/*
|
||||
* Global Access Macros
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global Functions
|
||||
*/
|
||||
|
||||
extern uint8_t PIO_Configure( const Pin *list, uint32_t size ) ;
|
||||
|
||||
extern void PIO_Set( const Pin *pin ) ;
|
||||
|
||||
extern void PIO_Clear( const Pin *pin ) ;
|
||||
|
||||
extern uint8_t PIO_Get( const Pin *pin ) ;
|
||||
|
||||
extern uint8_t PIO_GetOutputDataStatus( const Pin *pin ) ;
|
||||
|
||||
extern void PIO_SetDebounceFilter( const Pin *pin, uint32_t cuttoff );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _PIO_ */
|
||||
|
||||
104
sam3s_example/sam3s_examples_include/pio_capture.h
Normal file
104
sam3s_example/sam3s_examples_include/pio_capture.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page sam3s_ppc SAM3S PIO Parallel Capture
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Interface for configuration the PIO Parallel Capture peripheral.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Configurate the interrupt for PIOA, can be done by PIO_InitializeInterrupts()
|
||||
* -# Initialize the PIO Parallel Capture API by filing the SpioCaptureInit structur.
|
||||
* 2 options:
|
||||
* - alwaysSampling: for sample data with or without take in account ENABLE pins.
|
||||
* - halfSampling: for sample all data or only one time out of two
|
||||
* -# Call PIO_CaptureInit() for init and enable the PDC, init the PIO capture.
|
||||
* -# Call PIO_CaptureEnable() for enable the PIO Parallel Capture.
|
||||
* -# When an interrupt is received, the PIO_CaptureHandler() is call and the respective
|
||||
* callback is launch.
|
||||
* -# When the transfer is complete, the user need to disable interrupt with
|
||||
* PIO_CaptureDisableIt(). Otherway, the PDC will send an interrupt.
|
||||
* -# The data receive by the PIO Parallel Capture is inside the buffer passed in the
|
||||
* PIO_CaptureInit().
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PIO_CAPTURE_H
|
||||
#define PIO_CAPTURE_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \brief PIO Parallel Capture structure for initialize.
|
||||
*
|
||||
* At the end of the transfer, the callback is invoked by the interrupt handler.
|
||||
*/
|
||||
typedef struct _SpioCaptureInit {
|
||||
|
||||
/** PIO_PCRHR register is a BYTE, HALF-WORD or WORD */
|
||||
uint8_t dsize;
|
||||
/** PDC size, data to be received */
|
||||
uint16_t dPDCsize;
|
||||
/** Data to be received */
|
||||
uint32_t *pData;
|
||||
/** Parallel Capture Mode Always Sampling */
|
||||
uint8_t alwaysSampling;
|
||||
/** Parallel Capture Mode Half Sampling */
|
||||
uint8_t halfSampling;
|
||||
/** Parallel Capture Mode First Sample */
|
||||
uint8_t modeFirstSample;
|
||||
/** Callback function invoked at Mode Data Ready */
|
||||
void (*CbkDataReady)( struct _SpioCaptureInit* );
|
||||
/** Callback function invoked at Mode Overrun Error */
|
||||
void (*CbkOverrun)( struct _SpioCaptureInit* );
|
||||
/** Callback function invoked at End of Reception Transfer */
|
||||
void (*CbkEndReception)( struct _SpioCaptureInit* );
|
||||
/** Callback function invoked at Reception Buffer Full */
|
||||
void (*CbkBuffFull)( struct _SpioCaptureInit* );
|
||||
/** Callback arguments.*/
|
||||
void *pParam;
|
||||
|
||||
} SpioCaptureInit ;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void PIO_CaptureDisableIt( uint32_t itToDisable ) ;
|
||||
extern void PIO_CaptureEnableIt( uint32_t itToEnable ) ;
|
||||
extern void PIO_CaptureEnable( void ) ;
|
||||
extern void PIO_CaptureDisable( void ) ;
|
||||
extern void PIO_CaptureInit( SpioCaptureInit* pInit ) ;
|
||||
|
||||
#endif /* #ifndef PIO_CAPTURE_H */
|
||||
|
||||
97
sam3s_example/sam3s_examples_include/pio_it.h
Normal file
97
sam3s_example/sam3s_examples_include/pio_it.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Configuration and handling of interrupts on PIO status changes. The API
|
||||
* provided here have several advantages over the traditional PIO interrupt
|
||||
* configuration approach:
|
||||
* - It is highly portable
|
||||
* - It automatically demultiplexes interrupts when multiples pins have been
|
||||
* configured on a single PIO controller
|
||||
* - It allows a group of pins to share the same interrupt
|
||||
*
|
||||
* However, it also has several minor drawbacks that may prevent from using it
|
||||
* in particular applications:
|
||||
* - It enables the clocks of all PIO controllers
|
||||
* - PIO controllers all share the same interrupt handler, which does the
|
||||
* demultiplexing and can be slower than direct configuration
|
||||
* - It reserves space for a fixed number of interrupts, which can be
|
||||
* increased by modifying the appropriate constant in pio_it.c.
|
||||
*
|
||||
* \par Usage
|
||||
*
|
||||
* -# Initialize the PIO interrupt mechanism using PIO_InitializeInterrupts()
|
||||
* with the desired priority (0 ... 7).
|
||||
* -# Configure a status change interrupt on one or more pin(s) with
|
||||
* PIO_ConfigureIt().
|
||||
* -# Enable & disable interrupts on pins using PIO_EnableIt() and
|
||||
* PIO_DisableIt().
|
||||
*/
|
||||
|
||||
#ifndef _PIO_IT_
|
||||
#define _PIO_IT_
|
||||
|
||||
/*
|
||||
* Headers
|
||||
*/
|
||||
|
||||
#include "pio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Global functions
|
||||
*/
|
||||
|
||||
extern void PIO_InitializeInterrupts( uint32_t dwPriority ) ;
|
||||
|
||||
extern void PIO_ConfigureIt( const Pin *pPin, void (*handler)( const Pin* ) ) ;
|
||||
|
||||
extern void PIO_EnableIt( const Pin *pPin ) ;
|
||||
|
||||
extern void PIO_DisableIt( const Pin *pPin ) ;
|
||||
|
||||
extern void PIO_IT_InterruptHandler( void ) ;
|
||||
|
||||
extern void PioInterruptHandler( uint32_t id, Pio *pPio ) ;
|
||||
|
||||
extern void PIO_CaptureHandler( void ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _PIO_IT_ */
|
||||
|
||||
59
sam3s_example/sam3s_examples_include/pmc.h
Normal file
59
sam3s_example/sam3s_examples_include/pmc.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _PMC_
|
||||
#define _PMC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void PMC_EnablePeripheral( uint32_t dwId ) ;
|
||||
extern void PMC_DisablePeripheral( uint32_t dwId ) ;
|
||||
|
||||
extern void PMC_EnableAllPeripherals( void ) ;
|
||||
extern void PMC_DisableAllPeripherals( void ) ;
|
||||
|
||||
extern uint32_t PMC_IsPeriphEnabled( uint32_t dwId ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _PMC_ */
|
||||
|
||||
127
sam3s_example/sam3s_examples_include/pwmc.h
Normal file
127
sam3s_example/sam3s_examples_include/pwmc.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Interface for configuration the Pulse Width Modulation Controller (PWM) peripheral.
|
||||
*
|
||||
* \par Usage
|
||||
*
|
||||
* -# Configures PWM clocks A & B to run at the given frequencies using
|
||||
* \ref PWMC_ConfigureClocks().
|
||||
* -# Configure PWMC channel using \ref PWMC_ConfigureChannel(), \ref PWMC_ConfigureChannelExt()
|
||||
* \ref PWMC_SetPeriod(), \ref PWMC_SetDutyCycle() and \ref PWMC_SetDeadTime().
|
||||
* -# Enable & disable channel using \ref PWMC_EnableChannel() and
|
||||
* \ref PWMC_DisableChannel().
|
||||
* -# Enable & disable the period interrupt for the given PWM channel using
|
||||
* \ref PWMC_EnableChannelIt() and \ref PWMC_DisableChannelIt().
|
||||
* -# Enable & disable the selected interrupts sources on a PWMC peripheral
|
||||
* using \ref PWMC_EnableIt() and \ref PWMC_DisableIt().
|
||||
* -# Control syncronous channel using \ref PWMC_ConfigureSyncChannel(),
|
||||
* \ref PWMC_SetSyncChannelUpdatePeriod() and \ref PWMC_SetSyncChannelUpdateUnlock().
|
||||
* -# Control PWM override output using \ref PWMC_SetOverrideValue(),
|
||||
* \ref PWMC_EnableOverrideOutput() and \ref PWMC_DisableOverrideOutput().
|
||||
* -# Send data through the transmitter using \ref PWMC_WriteBuffer().
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PWMC_
|
||||
#define _PWMC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void PWMC_ConfigureChannel(
|
||||
Pwm* pPwm,
|
||||
uint8_t channel,
|
||||
uint32_t prescaler,
|
||||
uint32_t alignment,
|
||||
uint32_t polarity);
|
||||
extern void PWMC_ConfigureChannelExt(
|
||||
Pwm* pPwm,
|
||||
uint8_t channel,
|
||||
uint32_t prescaler,
|
||||
uint32_t alignment,
|
||||
uint32_t polarity,
|
||||
uint32_t countEventSelect,
|
||||
uint32_t DTEnable,
|
||||
uint32_t DTHInverte,
|
||||
uint32_t DTLInverte);
|
||||
extern void PWMC_ConfigureClocks(uint32_t clka, uint32_t clkb, uint32_t mck);
|
||||
extern void PWMC_SetPeriod( Pwm* pPwm, uint8_t channel, uint16_t period);
|
||||
extern void PWMC_SetDutyCycle( Pwm* pPwm, uint8_t channel, uint16_t duty);
|
||||
extern void PWMC_SetDeadTime( Pwm* pPwm, uint8_t channel, uint16_t timeH, uint16_t timeL);
|
||||
extern void PWMC_ConfigureSyncChannel( Pwm* pPwm,
|
||||
uint32_t channels,
|
||||
uint32_t updateMode,
|
||||
uint32_t requestMode,
|
||||
uint32_t requestComparisonSelect);
|
||||
extern void PWMC_SetSyncChannelUpdatePeriod( Pwm* pPwm, uint8_t period);
|
||||
extern void PWMC_SetSyncChannelUpdateUnlock( Pwm* pPwm );
|
||||
extern void PWMC_EnableChannel( Pwm* pPwm, uint8_t channel);
|
||||
extern void PWMC_DisableChannel( Pwm* pPwm, uint8_t channel);
|
||||
extern void PWMC_EnableChannelIt( Pwm* pPwm, uint8_t channel);
|
||||
extern void PWMC_DisableChannelIt( Pwm* pPwm, uint8_t channel);
|
||||
extern void PWMC_EnableIt( Pwm* pPwm, uint32_t sources1, uint32_t sources2);
|
||||
extern void PWMC_DisableIt( Pwm* pPwm, uint32_t sources1, uint32_t sources2);
|
||||
extern uint8_t PWMC_WriteBuffer(Pwm *pwmc,
|
||||
void *buffer,
|
||||
uint32_t length);
|
||||
extern void PWMC_SetOverrideValue( Pwm* pPwm, uint32_t value);
|
||||
extern void PWMC_EnableOverrideOutput( Pwm* pPwm, uint32_t value, uint32_t sync);
|
||||
extern void PWMC_DisableOverrideOutput( Pwm* pPwm, uint32_t value, uint32_t sync);
|
||||
extern void PWMC_SetFaultMode( Pwm* pPwm, uint32_t mode);
|
||||
extern void PWMC_FaultClear( Pwm* pPwm, uint32_t fault);
|
||||
extern void PWMC_SetFaultProtectionValue( Pwm* pPwm, uint32_t value);
|
||||
extern void PWMC_EnableFaultProtection( Pwm* pPwm, uint32_t value);
|
||||
extern void PWMC_ConfigureComparisonUnit( Pwm* pPwm, uint32_t x, uint32_t value, uint32_t mode);
|
||||
extern void PWMC_ConfigureEventLineMode( Pwm* pPwm, uint32_t x, uint32_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _PWMC_ */
|
||||
|
||||
97
sam3s_example/sam3s_examples_include/rtc.h
Normal file
97
sam3s_example/sam3s_examples_include/rtc.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for Real Time Clock (RTC) controller.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _RTC_
|
||||
#define _RTC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define RTC_HOUR_BIT_LEN_MASK 0x3F
|
||||
#define RTC_MIN_BIT_LEN_MASK 0x7F
|
||||
#define RTC_SEC_BIT_LEN_MASK 0x7F
|
||||
#define RTC_CENT_BIT_LEN_MASK 0x7F
|
||||
#define RTC_YEAR_BIT_LEN_MASK 0xFF
|
||||
#define RTC_MONTH_BIT_LEN_MASK 0x1F
|
||||
#define RTC_DATE_BIT_LEN_MASK 0x3F
|
||||
#define RTC_WEEK_BIT_LEN_MASK 0x07
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void RTC_SetHourMode( Rtc* pRtc, uint32_t dwMode ) ;
|
||||
|
||||
extern uint32_t RTC_GetHourMode( Rtc* pRtc ) ;
|
||||
|
||||
extern void RTC_EnableIt( Rtc* pRtc, uint32_t dwSources ) ;
|
||||
|
||||
extern void RTC_DisableIt( Rtc* pRtc, uint32_t dwSources ) ;
|
||||
|
||||
extern int RTC_SetTime( Rtc* pRtc, uint8_t ucHour, uint8_t ucMinute, uint8_t ucSecond ) ;
|
||||
|
||||
extern void RTC_GetTime( Rtc* pRtc, uint8_t *pucHour, uint8_t *pucMinute, uint8_t *pucSecond ) ;
|
||||
|
||||
extern int RTC_SetTimeAlarm( Rtc* pRtc, uint8_t *pucHour, uint8_t *pucMinute, uint8_t *pucSecond ) ;
|
||||
|
||||
extern void RTC_GetDate( Rtc* pRtc, uint16_t *pwYear, uint8_t *pucMonth, uint8_t *pucDay, uint8_t *pucWeek ) ;
|
||||
|
||||
extern int RTC_SetDate( Rtc* pRtc, uint16_t wYear, uint8_t ucMonth, uint8_t ucDay, uint8_t ucWeek ) ;
|
||||
|
||||
extern int RTC_SetDateAlarm( Rtc* pRtc, uint8_t *pucMonth, uint8_t *pucDay ) ;
|
||||
|
||||
extern void RTC_ClearSCCR( Rtc* pRtc, uint32_t dwMask ) ;
|
||||
|
||||
extern uint32_t RTC_GetSR( Rtc* pRtc, uint32_t dwMask ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _RTC_ */
|
||||
|
||||
82
sam3s_example/sam3s_examples_include/rtt.h
Normal file
82
sam3s_example/sam3s_examples_include/rtt.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Interface for Real Time Timer (RTT) controller.
|
||||
*
|
||||
* \par Usage
|
||||
*
|
||||
* -# Changes the prescaler value of the given RTT and restarts it
|
||||
* using \ref RTT_SetPrescaler().
|
||||
* -# Get current value of the RTT using \ref RTT_GetTime().
|
||||
* -# Enables the specified RTT interrupt using \ref RTT_EnableIT().
|
||||
* -# Get the status register value of the given RTT using \ref RTT_GetStatus().
|
||||
* -# Configures the RTT to generate an alarm at the given time
|
||||
* using \ref RTT_SetAlarm().
|
||||
*/
|
||||
|
||||
#ifndef _RTT_
|
||||
#define _RTT_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void RTT_SetPrescaler( Rtt* pRtt, uint16_t wPrescaler ) ;
|
||||
|
||||
extern uint32_t RTT_GetTime( Rtt* pRtt ) ;
|
||||
|
||||
extern void RTT_EnableIT( Rtt* pRtt, uint32_t dwSources ) ;
|
||||
|
||||
extern uint32_t RTT_GetStatus( Rtt *pRtt ) ;
|
||||
|
||||
extern void RTT_SetAlarm( Rtt *pRtt, uint32_t dwTime ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef RTT_H */
|
||||
|
||||
115
sam3s_example/sam3s_examples_include/spi.h
Normal file
115
sam3s_example/sam3s_examples_include/spi.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for Serial Peripheral Interface (SPI) controller.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SPI_
|
||||
#define _SPI_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Macros
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Here are several macros which should be used when configuring a SPI
|
||||
* peripheral.
|
||||
*
|
||||
* \section spi_configuration_macros SPI Configuration Macros
|
||||
* - \ref SPI_PCS
|
||||
* - \ref SPI_SCBR
|
||||
* - \ref SPI_DLYBS
|
||||
* - \ref SPI_DLYBCT
|
||||
*/
|
||||
|
||||
/** Calculate the PCS field value given the chip select NPCS value */
|
||||
#define SPI_PCS(npcs) ((~(1 << npcs) & 0xF) << 16)
|
||||
|
||||
/** Calculates the value of the CSR SCBR field given the baudrate and MCK. */
|
||||
#define SPI_SCBR(baudrate, masterClock) ((uint32_t) (masterClock / baudrate) << 8)
|
||||
|
||||
/** Calculates the value of the CSR DLYBS field given the desired delay (in ns) */
|
||||
#define SPI_DLYBS(delay, masterClock) ((uint32_t) (((masterClock / 1000000) * delay) / 1000) << 16)
|
||||
|
||||
/** Calculates the value of the CSR DLYBCT field given the desired delay (in ns) */
|
||||
#define SPI_DLYBCT(delay, masterClock) ((uint32_t) (((masterClock / 1000000) * delay) / 32000) << 24)
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void SPI_Enable( Spi* spi ) ;
|
||||
extern void SPI_Disable( Spi* spi ) ;
|
||||
extern void SPI_EnableIt( Spi* spi, uint32_t dwSources ) ;
|
||||
extern void SPI_DisableIt( Spi* spi, uint32_t dwSources ) ;
|
||||
|
||||
extern void SPI_Configure( Spi* spi, uint32_t dwId, uint32_t dwConfiguration ) ;
|
||||
extern void SPI_ConfigureNPCS( Spi* spi, uint32_t dwNpcs, uint32_t dwConfiguration ) ;
|
||||
|
||||
extern uint32_t SPI_Read( Spi* spi ) ;
|
||||
extern void SPI_Write( Spi* spi, uint32_t dwNpcs, uint16_t wData ) ;
|
||||
|
||||
extern uint32_t SPI_GetStatus( Spi* spi ) ;
|
||||
extern uint32_t SPI_IsFinished( Spi* pSpi ) ;
|
||||
|
||||
extern void SPI_PdcEnableTx( Spi* spi ) ;
|
||||
extern void SPI_PdcDisableTx( Spi* spi ) ;
|
||||
extern void SPI_PdcEnableRx( Spi* spi ) ;
|
||||
extern void SPI_PdcDisableRx( Spi* spi ) ;
|
||||
|
||||
extern void SPI_PdcSetTx( Spi* spi, void* pvTxBuf, uint32_t dwTxCount, void* pvTxNextBuf, uint32_t dwTxNextCount ) ;
|
||||
extern void SPI_PdcSetRx( Spi* spi, void* pvRxBuf, uint32_t dwRxCount, void* pvRxNextBuf, uint32_t dwRxNextCount ) ;
|
||||
|
||||
extern uint32_t SPI_WriteBuffer( Spi* spi, void* pvBuffer, uint32_t dwLength ) ;
|
||||
|
||||
extern uint32_t SPI_ReadBuffer( Spi* spi, void* pvBuffer, uint32_t dwLength ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _SPI_ */
|
||||
|
||||
135
sam3s_example/sam3s_examples_include/spi_pdc.h
Normal file
135
sam3s_example/sam3s_examples_include/spi_pdc.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Implementation of SPI PDC driver.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SPI_PDC_
|
||||
#define _SPI_PDC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** An unspecified error has occured.*/
|
||||
#define SPID_ERROR 1
|
||||
|
||||
/** SPI driver is currently in use.*/
|
||||
#define SPID_ERROR_LOCK 2
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Macros
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Calculates the value of the SCBR field of the Chip Select Register given MCK and SPCK.*/
|
||||
#define SPID_CSR_SCBR(mck, spck) (SPI_CSR_SCBR(((mck) / (spck))) )
|
||||
|
||||
/** Calculates the value of the DLYBS field of the Chip Select Register given delay in ns and MCK.*/
|
||||
#define SPID_CSR_DLYBS(mck, delay) ( SPI_CSR_DLYBS(((((delay) * ((mck) / 1000000)) / 1000) + 1)) )
|
||||
|
||||
/** Calculates the value of the DLYBCT field of the Chip Select Register given delay in ns and MCK.*/
|
||||
#define SPID_CSR_DLYBCT(mck, delay) ( SPI_CSR_DLYBCT((((delay) / 32 * ((mck) / 1000000)) / 1000) + 1) )
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** SPI transfer complete callback. */
|
||||
typedef void (*SpidCallback)( uint8_t, void* ) ;
|
||||
|
||||
/** \brief Spi Transfer Request prepared by the application upper layer.
|
||||
*
|
||||
* This structure is sent to the SPI_SendCommand function to start the transfer.
|
||||
* At the end of the transfer, the callback is invoked by the interrupt handler.
|
||||
*/
|
||||
typedef struct _SpidCmd
|
||||
{
|
||||
/** Pointer to the command data. */
|
||||
uint8_t *pCmd;
|
||||
/** Command size in bytes. */
|
||||
uint8_t cmdSize;
|
||||
/** Pointer to the data to be sent. */
|
||||
uint8_t *pData;
|
||||
/** Data size in bytes. */
|
||||
unsigned short dataSize;
|
||||
/** SPI chip select. */
|
||||
uint8_t spiCs;
|
||||
/** Callback function invoked at the end of transfer. */
|
||||
SpidCallback callback;
|
||||
/** Callback arguments. */
|
||||
void *pArgument;
|
||||
} SpidCmd ;
|
||||
|
||||
/** Constant structure associated with SPI port. This structure prevents
|
||||
client applications to have access in the same time. */
|
||||
typedef struct _Spid
|
||||
{
|
||||
/** Pointer to SPI Hardware registers */
|
||||
Spi* pSpiHw ;
|
||||
/** SPI Id as defined in the product datasheet */
|
||||
char spiId ;
|
||||
/** Current SpiCommand being processed */
|
||||
SpidCmd *pCurrentCommand ;
|
||||
/** Mutual exclusion semaphore. */
|
||||
volatile char semaphore ;
|
||||
} Spid ;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern uint32_t SPID_Configure( Spid* pSpid, Spi* pSpiHw, uint8_t spiId ) ;
|
||||
|
||||
extern void SPID_ConfigureCS( Spid* pSpid, uint32_t dwCS, uint32_t dwCsr ) ;
|
||||
|
||||
extern uint32_t SPID_SendCommand( Spid* pSpid, SpidCmd* pCommand ) ;
|
||||
|
||||
extern void SPID_Handler( Spid* pSpid ) ;
|
||||
|
||||
extern uint32_t SPID_IsBusy( const Spid* pSpid ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _SPI_PDC_ */
|
||||
|
||||
73
sam3s_example/sam3s_examples_include/ssc.h
Normal file
73
sam3s_example/sam3s_examples_include/ssc.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for Synchronous Serial (SSC) controller.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SSC_
|
||||
#define _SSC_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void SSC_Configure(uint32_t bitRate, uint32_t masterClock);
|
||||
extern void SSC_ConfigureTransmitter(uint32_t tcmr, uint32_t tfmr);
|
||||
extern void SSC_ConfigureReceiver(uint32_t rcmr, uint32_t rfmr);
|
||||
extern void SSC_EnableTransmitter(void);
|
||||
extern void SSC_DisableTransmitter(void);
|
||||
extern void SSC_EnableReceiver(void);
|
||||
extern void SSC_DisableReceiver(void);
|
||||
extern void SSC_EnableInterrupts(uint32_t sources);
|
||||
extern void SSC_DisableInterrupts(uint32_t sources);
|
||||
extern void SSC_Write(uint32_t frame);
|
||||
extern uint32_t SSC_Read(void);
|
||||
extern uint8_t SSC_WriteBuffer(void *buffer, uint32_t length);
|
||||
extern uint8_t SSC_ReadBuffer(void *buffer, uint32_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _SSC_ */
|
||||
|
||||
78
sam3s_example/sam3s_examples_include/supc.h
Normal file
78
sam3s_example/sam3s_examples_include/supc.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUPC_
|
||||
#define _SUPC_
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Global functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern
|
||||
#ifdef __ICCARM__
|
||||
__ramfunc /* IAR */
|
||||
#endif
|
||||
void SUPC_EnableFlash( Supc* pSupc, uint32_t dwTime ) ;
|
||||
|
||||
extern
|
||||
#ifdef __ICCARM__
|
||||
__ramfunc /* IAR */
|
||||
#endif
|
||||
void SUPC_DisableFlash( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_SetVoltageOutput( Supc* pSupc, uint32_t dwVoltage ) ;
|
||||
|
||||
extern void SUPC_EnableDeepMode( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_EnableSram( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_DisableSram( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_EnableRtc( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_DisableRtc( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_SetBodSampling( Supc* pSupc, uint32_t dwMode ) ;
|
||||
|
||||
extern void SUPC_DisableDeepMode( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_DisableVoltageRegulator( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_Shutdown( Supc* pSupc ) ;
|
||||
|
||||
extern void SUPC_SetWakeUpSources( Supc* pSupc, uint32_t dwSources ) ;
|
||||
|
||||
extern void SUPC_SetWakeUpInputs( Supc* pSupc, uint32_t dwInputs ) ;
|
||||
|
||||
#endif /* #ifndef _SUPC_ */
|
||||
|
||||
76
sam3s_example/sam3s_examples_include/tc.h
Normal file
76
sam3s_example/sam3s_examples_include/tc.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Interface for configuring and using Timer Counter (TC) peripherals.
|
||||
*
|
||||
* \section Usage
|
||||
* -# Optionally, use TC_FindMckDivisor() to let the program find the best
|
||||
* TCCLKS field value automatically.
|
||||
* -# Configure a Timer Counter in the desired mode using TC_Configure().
|
||||
* -# Start or stop the timer clock using TC_Start() and TC_Stop().
|
||||
*/
|
||||
|
||||
#ifndef _TC_
|
||||
#define _TC_
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void TC_Configure( Tc *pTc, uint32_t dwChannel, uint32_t dwMode ) ;
|
||||
|
||||
extern void TC_Start( Tc *pTc, uint32_t dwChannel ) ;
|
||||
|
||||
extern void TC_Stop( Tc *pTc, uint32_t dwChannel ) ;
|
||||
|
||||
extern uint32_t TC_FindMckDivisor( uint32_t dwFreq, uint32_t dwMCk, uint32_t *dwDiv, uint32_t *dwTcClks, uint32_t dwBoardMCK ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _TC_ */
|
||||
|
||||
230
sam3s_example/sam3s_examples_include/trace.h
Normal file
230
sam3s_example/sam3s_examples_include/trace.h
Normal file
@@ -0,0 +1,230 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Standard output methods for reporting debug information, warnings and
|
||||
* errors, which can be easily be turned on/off.
|
||||
*
|
||||
* \par Usage
|
||||
* -# Initialize the DBGU using TRACE_CONFIGURE() if you intend to eventually
|
||||
* disable ALL traces; otherwise use DBGU_Configure().
|
||||
* -# Uses the TRACE_DEBUG(), TRACE_INFO(), TRACE_WARNING(), TRACE_ERROR()
|
||||
* TRACE_FATAL() macros to output traces throughout the program.
|
||||
* -# Each type of trace has a level : Debug 5, Info 4, Warning 3, Error 2
|
||||
* and Fatal 1. Disable a group of traces by changing the value of
|
||||
* TRACE_LEVEL during compilation; traces with a level bigger than TRACE_LEVEL
|
||||
* are not generated. To generate no trace, use the reserved value 0.
|
||||
* -# Trace disabling can be static or dynamic. If dynamic disabling is selected
|
||||
* the trace level can be modified in runtime. If static disabling is selected
|
||||
* the disabled traces are not compiled.
|
||||
*
|
||||
* \par traceLevels Trace level description
|
||||
* -# TRACE_DEBUG (5): Traces whose only purpose is for debugging the program,
|
||||
* and which do not produce meaningful information otherwise.
|
||||
* -# TRACE_INFO (4): Informational trace about the program execution. Should
|
||||
* enable the user to see the execution flow.
|
||||
* -# TRACE_WARNING (3): Indicates that a minor error has happened. In most case
|
||||
* it can be discarded safely; it may even be expected.
|
||||
* -# TRACE_ERROR (2): Indicates an error which may not stop the program execution,
|
||||
* but which indicates there is a problem with the code.
|
||||
* -# TRACE_FATAL (1): Indicates a major error which prevents the program from going
|
||||
* any further.
|
||||
*/
|
||||
|
||||
#ifndef _TRACE_
|
||||
#define _TRACE_
|
||||
|
||||
/*
|
||||
* Headers
|
||||
*/
|
||||
|
||||
#include "pio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Global Definitions
|
||||
*/
|
||||
|
||||
/** Softpack Version */
|
||||
#define SOFTPACK_VERSION "2.0"
|
||||
|
||||
#define TRACE_LEVEL_DEBUG 5
|
||||
#define TRACE_LEVEL_INFO 4
|
||||
#define TRACE_LEVEL_WARNING 3
|
||||
#define TRACE_LEVEL_ERROR 2
|
||||
#define TRACE_LEVEL_FATAL 1
|
||||
#define TRACE_LEVEL_NO_TRACE 0
|
||||
|
||||
/* By default, all traces are output except the debug one. */
|
||||
#if !defined(TRACE_LEVEL)
|
||||
#define TRACE_LEVEL TRACE_LEVEL_INFO
|
||||
#endif
|
||||
|
||||
/* By default, trace level is static (not dynamic) */
|
||||
#if !defined(DYN_TRACES)
|
||||
#define DYN_TRACES 0
|
||||
#endif
|
||||
|
||||
#if defined(NOTRACE)
|
||||
#error "Error: NOTRACE has to be not defined !"
|
||||
#endif
|
||||
|
||||
#undef NOTRACE
|
||||
#if (DYN_TRACES==0)
|
||||
#if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
|
||||
#define NOTRACE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------
|
||||
* Global Macros
|
||||
* ------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void TRACE_CONFIGURE( uint32_t dwBaudRate, uint32_t dwMCk ) ;
|
||||
|
||||
/**
|
||||
* Initializes the DBGU for ISP project
|
||||
*
|
||||
* \param mode DBGU mode.
|
||||
* \param baudrate DBGU baudrate.
|
||||
* \param mck Master clock frequency.
|
||||
*/
|
||||
#ifndef DYNTRACE
|
||||
#define DYNTRACE 0
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL==0) && (DYNTRACE==0)
|
||||
#define TRACE_CONFIGURE_ISP(mode, baudrate, mck) {}
|
||||
#else
|
||||
#define TRACE_CONFIGURE_ISP(mode, baudrate, mck) { \
|
||||
const Pin pinsUART0[] = {PINS_UART}; \
|
||||
PIO_Configure(pinsUART0, PIO_LISTSIZE(pinsUART0)); \
|
||||
UART_Configure( baudrate, mck ) ; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Outputs a formatted string using 'printf' if the log level is high
|
||||
* enough. Can be disabled by defining TRACE_LEVEL=0 during compilation.
|
||||
* \param ... Additional parameters depending on formatted string.
|
||||
*/
|
||||
#if defined(NOTRACE)
|
||||
|
||||
/* Empty macro */
|
||||
#define TRACE_DEBUG(...) { }
|
||||
#define TRACE_INFO(...) { }
|
||||
#define TRACE_WARNING(...) { }
|
||||
#define TRACE_ERROR(...) { }
|
||||
#define TRACE_FATAL(...) { while(1); }
|
||||
|
||||
#define TRACE_DEBUG_WP(...) { }
|
||||
#define TRACE_INFO_WP(...) { }
|
||||
#define TRACE_WARNING_WP(...) { }
|
||||
#define TRACE_ERROR_WP(...) { }
|
||||
#define TRACE_FATAL_WP(...) { while(1); }
|
||||
|
||||
#elif (DYN_TRACES == 1)
|
||||
|
||||
/* Trace output depends on dwTraceLevel value */
|
||||
#define TRACE_DEBUG(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } }
|
||||
#define TRACE_INFO(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } }
|
||||
#define TRACE_WARNING(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
|
||||
#define TRACE_ERROR(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } }
|
||||
#define TRACE_FATAL(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while(1); } }
|
||||
|
||||
#define TRACE_DEBUG_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_INFO_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_ERROR_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_FATAL_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while(1); } }
|
||||
|
||||
#else
|
||||
|
||||
/* Trace compilation depends on TRACE_LEVEL value */
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
|
||||
#define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); }
|
||||
#define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_DEBUG(...) { }
|
||||
#define TRACE_DEBUG_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
|
||||
#define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); }
|
||||
#define TRACE_INFO_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_INFO(...) { }
|
||||
#define TRACE_INFO_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
|
||||
#define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); }
|
||||
#define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_WARNING(...) { }
|
||||
#define TRACE_WARNING_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
|
||||
#define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); }
|
||||
#define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_ERROR(...) { }
|
||||
#define TRACE_ERROR_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
|
||||
#define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while(1); }
|
||||
#define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while(1); }
|
||||
#else
|
||||
#define TRACE_FATAL(...) { while(1); }
|
||||
#define TRACE_FATAL_WP(...) { while(1); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Exported variables
|
||||
*/
|
||||
/** Depending on DYN_TRACES, dwTraceLevel is a modifable runtime variable or a define */
|
||||
#if !defined(NOTRACE) && (DYN_TRACES == 1)
|
||||
extern uint32_t dwTraceLevel ;
|
||||
#endif
|
||||
|
||||
#endif //#ifndef TRACE_H
|
||||
|
||||
111
sam3s_example/sam3s_examples_include/twi.h
Normal file
111
sam3s_example/sam3s_examples_include/twi.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for configuration the Two Wire Interface (TWI) peripheral.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TWI_
|
||||
#define _TWI_
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Macros
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* Returns 1 if the TXRDY bit (ready to transmit data) is set in the given status register value.*/
|
||||
#define TWI_STATUS_TXRDY(status) ((status & TWI_SR_TXRDY) == TWI_SR_TXRDY)
|
||||
|
||||
/* Returns 1 if the RXRDY bit (ready to receive data) is set in the given status register value.*/
|
||||
#define TWI_STATUS_RXRDY(status) ((status & TWI_SR_RXRDY) == TWI_SR_RXRDY)
|
||||
|
||||
/* Returns 1 if the TXCOMP bit (transfer complete) is set in the given status register value.*/
|
||||
#define TWI_STATUS_TXCOMP(status) ((status & TWI_SR_TXCOMP) == TWI_SR_TXCOMP)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* External function
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void TWI_ConfigureMaster(Twi *pTwi, uint32_t twck, uint32_t mck);
|
||||
|
||||
extern void TWI_ConfigureSlave(Twi *pTwi, uint8_t slaveAddress);
|
||||
|
||||
extern void TWI_Stop(Twi *pTwi);
|
||||
|
||||
extern void TWI_StartRead(
|
||||
Twi *pTwi,
|
||||
uint8_t address,
|
||||
uint32_t iaddress,
|
||||
uint8_t isize);
|
||||
|
||||
extern uint8_t TWI_ReadByte(Twi *pTwi);
|
||||
|
||||
extern void TWI_WriteByte(Twi *pTwi, uint8_t byte);
|
||||
|
||||
extern void TWI_StartWrite(
|
||||
Twi *pTwi,
|
||||
uint8_t address,
|
||||
uint32_t iaddress,
|
||||
uint8_t isize,
|
||||
uint8_t byte);
|
||||
|
||||
extern uint8_t TWI_ByteReceived(Twi *pTwi);
|
||||
|
||||
extern uint8_t TWI_ByteSent(Twi *pTwi);
|
||||
|
||||
extern uint8_t TWI_TransferComplete(Twi *pTwi);
|
||||
|
||||
extern void TWI_EnableIt(Twi *pTwi, uint32_t sources);
|
||||
|
||||
extern void TWI_DisableIt(Twi *pTwi, uint32_t sources);
|
||||
|
||||
extern uint32_t TWI_GetStatus(Twi *pTwi);
|
||||
|
||||
extern uint32_t TWI_GetMaskedStatus(Twi *pTwi);
|
||||
|
||||
extern void TWI_SendSTOPCondition(Twi *pTwi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _TWI_ */
|
||||
95
sam3s_example/sam3s_examples_include/twid.h
Normal file
95
sam3s_example/sam3s_examples_include/twid.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _TWID_
|
||||
#define _TWID_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definition
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** TWI driver is currently busy. */
|
||||
#define TWID_ERROR_BUSY 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \brief TWI driver structure. Holds the internal state of the driver.*/
|
||||
typedef struct _Twid
|
||||
{
|
||||
/** Pointer to the underlying TWI peripheral.*/
|
||||
Twi *pTwi ;
|
||||
/** Current asynchronous transfer being processed.*/
|
||||
Async *pTransfer ;
|
||||
} Twid;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Export functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void TWID_Initialize( Twid *pTwid, Twi *pTwi ) ;
|
||||
|
||||
extern void TWID_Handler( Twid *pTwid ) ;
|
||||
|
||||
extern uint8_t TWID_Read(
|
||||
Twid *pTwid,
|
||||
uint8_t address,
|
||||
uint32_t iaddress,
|
||||
uint8_t isize,
|
||||
uint8_t *pData,
|
||||
uint32_t num,
|
||||
Async *pAsync);
|
||||
|
||||
extern uint8_t TWID_Write(
|
||||
Twid *pTwid,
|
||||
uint8_t address,
|
||||
uint32_t iaddress,
|
||||
uint8_t isize,
|
||||
uint8_t *pData,
|
||||
uint32_t num,
|
||||
Async *pAsync);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //#ifndef TWID_H
|
||||
|
||||
133
sam3s_example/sam3s_examples_include/usart.h
Normal file
133
sam3s_example/sam3s_examples_include/usart.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* This module provides several definitions and methods for using an USART
|
||||
* peripheral.
|
||||
*
|
||||
* \par Usage
|
||||
*
|
||||
* -# Enable the USART peripheral clock in the PMC.
|
||||
* -# Enable the required USART PIOs (see pio.h).
|
||||
* -# Configure the UART by calling USART_Configure.
|
||||
* -# Enable the transmitter and/or the receiver of the USART using
|
||||
* USART_SetTransmitterEnabled and USART_SetReceiverEnabled.
|
||||
* -# Send data through the USART using the USART_Write and
|
||||
* USART_WriteBuffer methods.
|
||||
* -# Receive data from the USART using the USART_Read and
|
||||
* USART_ReadBuffer functions; the availability of data can be polled
|
||||
* with USART_IsDataAvailable.
|
||||
* -# Disable the transmitter and/or the receiver of the USART with
|
||||
* USART_SetTransmitterEnabled and USART_SetReceiverEnabled.
|
||||
*/
|
||||
|
||||
#ifndef _USART_
|
||||
#define _USART_
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \section USART_mode USART modes
|
||||
* This section lists several common operating modes for an USART peripheral.
|
||||
*
|
||||
* \b Modes
|
||||
* - USART_MODE_ASYNCHRONOUS
|
||||
* - USART_MODE_IRDA
|
||||
*/
|
||||
|
||||
/** Basic asynchronous mode, i.e. 8 bits no parity.*/
|
||||
#define USART_MODE_ASYNCHRONOUS (US_MR_CHRL_8_BIT | US_MR_PAR_NO)
|
||||
|
||||
/** IRDA mode*/
|
||||
#define USART_MODE_IRDA (AT91C_US_USMODE_IRDA | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_FILTER)
|
||||
|
||||
/** SPI mode*/
|
||||
#define AT91C_US_USMODE_SPIM 0xE
|
||||
#define US_SPI_CPOL_0 (0x0<<16)
|
||||
#define US_SPI_CPHA_0 (0x0<<8)
|
||||
#define US_SPI_CPOL_1 (0x1<<16)
|
||||
#define US_SPI_CPHA_1 (0x1<<8)
|
||||
#define US_SPI_BPMODE_0 (US_SPI_CPOL_0|US_SPI_CPHA_1)
|
||||
#define US_SPI_BPMODE_1 (US_SPI_CPOL_0|US_SPI_CPHA_0)
|
||||
#define US_SPI_BPMODE_2 (US_SPI_CPOL_1|US_SPI_CPHA_1)
|
||||
#define US_SPI_BPMODE_3 (US_SPI_CPOL_1|US_SPI_CPHA_0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Exported functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void USART_Configure( Usart *usart, uint32_t mode, uint32_t baudrate, uint32_t masterClock ) ;
|
||||
extern uint32_t USART_GetStatus( Usart *usart ) ;
|
||||
extern void USART_EnableIt( Usart *usart,uint32_t mode ) ;
|
||||
extern void USART_DisableIt( Usart *usart,uint32_t mode ) ;
|
||||
extern void USART_SetTransmitterEnabled( Usart *usart, uint8_t enabled ) ;
|
||||
|
||||
extern void USART_SetReceiverEnabled( Usart *usart, uint8_t enabled ) ;
|
||||
|
||||
extern void USART_Write( Usart *usart, uint16_t data, volatile uint32_t timeOut ) ;
|
||||
|
||||
extern uint8_t USART_WriteBuffer( Usart *usart, void *buffer, uint32_t size ) ;
|
||||
|
||||
extern uint16_t USART_Read( Usart *usart, volatile uint32_t timeOut ) ;
|
||||
|
||||
extern uint8_t USART_ReadBuffer( Usart *usart, void *buffer, uint32_t size ) ;
|
||||
|
||||
extern uint8_t USART_IsDataAvailable( Usart *usart ) ;
|
||||
|
||||
extern void USART_SetIrdaFilter(Usart *pUsart, uint8_t filter);
|
||||
|
||||
extern void USART_PutChar( Usart *usart, uint8_t c ) ;
|
||||
|
||||
extern uint32_t USART_IsRxReady( Usart *usart ) ;
|
||||
|
||||
extern uint8_t USART_GetChar( Usart *usart ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _USART_ */
|
||||
|
||||
74
sam3s_example/sam3s_examples_include/wdt.h
Normal file
74
sam3s_example/sam3s_examples_include/wdt.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
* Interface for Watchdog Timer (WDT) controller.
|
||||
*
|
||||
* \section Usage
|
||||
* -# Enable watchdog with given mode using \ref WDT_Enable().
|
||||
* -# Disable watchdog using \ref WDT_Disable()
|
||||
* -# Restart the watchdog using \ref WDT_Restart().
|
||||
* -# Get watchdog status using \ref WDT_GetStatus().
|
||||
* -# Caculate watchdog period value using \ref WDT_GetPeriod().
|
||||
*/
|
||||
|
||||
#ifndef _WDT_
|
||||
#define _WDT_
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void WDT_Enable( Wdt* pWDT, uint32_t dwMode ) ;
|
||||
|
||||
extern void WDT_Disable( Wdt* pWDT ) ;
|
||||
|
||||
extern void WDT_Restart( Wdt* pWDT ) ;
|
||||
|
||||
extern uint32_t WDT_GetStatus( Wdt* pWDT ) ;
|
||||
|
||||
extern uint32_t WDT_GetPeriod( uint32_t dwMs ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _WDT_ */
|
||||
|
||||
Reference in New Issue
Block a user