Add ADuCRF101 library code from Analog Devices

This commit is contained in:
Jim Paris 2014-06-21 22:25:44 -04:00
parent d7cf3b1f74
commit ee1ca8ac55
12 changed files with 13047 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0001FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_heap__ = 0x200;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
do not initialize { section .mainstackarea };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place at address mem:0x1FC { readonly section .PageZeroCheckSum };
place at address mem:0x1FFEC { readonly section .sigprot };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };

View File

@ -0,0 +1,99 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/
/**
Module : Retarget.c
Description : uart interface
Date : December 2012
Version : v2.00
Changelog : v1.00 Initial
v2.00 use of UrtLib functions
*/
#include <include.h>
#include "UrtLib.h"
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#define CR 0x0D
/*************************************************************************/
/* size_t __read(int handle,unsigned char *buf,size_t bufSize) */
/* Write data to a stream */
/* Needed for retargetting the IAR DLIB library for the ADUCRF101 */
/*************************************************************************/
size_t __read(int handle,unsigned char *buf,size_t bufSize)
{
size_t i;
for (i=0x0; i<bufSize;i++)
{
// Wait for character available
while(!(COMLSR_DR==(pADI_UART->COMLSR & COMLSR_DR)));
buf[i] = pADI_UART->COMRX;
}
return i;
}
/*************************************************************************/
/* __write(int handle,const unsigned char *buf,size_t bufSize) */
/* Read data from a stream */
/* Needed for retargetting the IAR DLIB library for the ADUCRF101 */
/*************************************************************************/
size_t __write(int handle,const unsigned char *buf,size_t bufSize)
{
size_t i;
for (i=0x0; i<bufSize;i++)
{
if (buf[i] == '\n')
{
while(!(COMLSR_THRE==(UrtLinSta(0) & COMLSR_THRE)));
UrtTx(0, 0x0D);
}
while(!(COMLSR_THRE==(UrtLinSta(0) & COMLSR_THRE)));
UrtTx(0, buf[i]);
}
return i;
}

View File

@ -0,0 +1,224 @@
; Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted (subject to the limitations in the
; disclaimer below) provided that the following conditions are met:
;
; - Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
;
; - Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the
; distribution.
;
; - Neither the name of Analog Devices, Inc. nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
; GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
; HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
; WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
; Module : startup_ADuCRF101.s
; Description : Cortex-M3 startup file - ADuCRF101 - EWARM Version
; Date : 15 February 2012
; Version : v1.00
; Changelog : v1.00 Initial
MODULE ?cstartup
;; Forward declaration of sections.
SECTION CSTACK:DATA:NOROOT(3)
SECTION .intvec:CODE:NOROOT(2)
EXTERN __iar_program_start
PUBLIC __vector_table
DATA
__vector_table
DCD sfe(CSTACK)
DCD __iar_program_start
DCD Nmi_Handler ; The NMI handler
DCD Fault_Handler ; The hard fault handler
DCD MemManage_Handler ; The MPU fault handler
DCD BusFault_Handler ; The bus fault handler
DCD UsageFault_Handler ; The usage fault handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall handler
DCD DebugMon_Handler ; Debug monitor handler
DCD 0 ; Reserved
DCD PendSV_Handler ; The PendSV handler
DCD SysTick_Handler ; The SysTick handler
; External Interrupts
DCD WakeUp_Int_Handler ; Wake Up Timer [ 0]
DCD Ext_Int0_Handler ; External Interrupt 0 [ 1]
DCD Ext_Int1_Handler ; External Interrupt 1 [ 2]
DCD Ext_Int2_Handler ; External Interrupt 2 [ 3]
DCD Ext_Int3_Handler ; External Interrupt 3 [ 4]
DCD Ext_Int4_Handler ; External Interrupt 4 [ 5]
DCD Ext_Int5_Handler ; External Interrupt 5 [ 6]
DCD Ext_Int6_Handler ; External Interrupt 6 [ 7]
DCD Ext_Int7_Handler ; External Interrupt 7 [ 8]
DCD Ext_Int8_Handler ; External Interrupt 8 [ 9]
DCD WDog_Tmr_Int_Handler ; Watchdog timer handler [10]
DCD UnUsed_Handler ; Reserved [11]
DCD GP_Tmr0_Int_Handler ; General purpose timer 0 [12]
DCD GP_Tmr1_Int_Handler ; General purpose timer 1 [13]
DCD ADC0_Int_Handler ; ADC Interrupt [14]
DCD Flsh_Int_Handler ; Flash IRQ [15]
DCD UART_Int_Handler ; UART0 [16]
DCD SPI0_Int_Handler ; SPI 0 [17]
DCD SPI1_Int_Handler ; SPI 1 [18]
DCD I2C0_Slave_Int_Handler ; I2C0 Slave [19]
DCD I2C0_Master_Int_Handler ; I2C0 Master [20]
DCD UnUsed_Handler ; Reserved [21]
DCD UnUsed_Handler ; Reserved [22]
DCD DMA_Err_Int_Handler ; DMA Error interrupt [23]
DCD DMA_SPI1_TX_Int_Handler ; DMA SPI1 TX [24]
DCD DMA_SPI1_RX_Int_Handler ; DMA SPI1 RX [25]
DCD DMA_UART_TX_Int_Handler ; DMA UART TX [26]
DCD DMA_UART_RX_Int_Handler ; DMA UART RX [27]
DCD DMA_I2C0_STX_Int_Handler ; DMA I2C0 Slave TX [28]
DCD DMA_I2C0_SRX_Int_Handler ; DMA I2C0 Slave RX [29]
DCD DMA_I2C0_MTX_Int_Handler ; DMA I2C0 Master TX [30]
DCD DMA_I2C0_MRX_Int_Handler ; DMA I2C0 Master RX [31]
DCD UnUsed_Handler ; Reserved [32]
DCD UnUsed_Handler ; Reserved [33]
DCD UnUsed_Handler ; Reserved [34]
DCD DMA_ADC_Int_Handler ; DMA ADC [35]
DCD DMA_SPI0_TX_Int_Handler ; DMA SPI0 TX [36]
DCD DMA_SPI0_RX_Int_Handler ; DMA SPI0 RX [37]
DCD PWMTrip_Int_Handler ; PWM Trip [38]
DCD PWM0_Int_Handler ; PWM 0 [39]
DCD PWM1_Int_Handler ; PWM 1 [40]
DCD PWM2_Int_Handler ; PWM 2 [41]
DCD PWM3_Int_Handler ; PWM 3 [42]
DCD UnUsed_Handler ; Unused [43]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Default interrupt handlers.
;;
PUBWEAK SysTick_Handler
PUBWEAK Nmi_Handler
PUBWEAK Fault_Handler
PUBWEAK MemManage_Handler
PUBWEAK BusFault_Handler
PUBWEAK UsageFault_Handler
PUBWEAK SVC_Handler
PUBWEAK DebugMon_Handler
PUBWEAK PendSV_Handler
PUBWEAK WakeUp_Int_Handler
PUBWEAK Ext_Int0_Handler
PUBWEAK Ext_Int1_Handler
PUBWEAK Ext_Int2_Handler
PUBWEAK Ext_Int3_Handler
PUBWEAK Ext_Int4_Handler
PUBWEAK Ext_Int5_Handler
PUBWEAK Ext_Int6_Handler
PUBWEAK Ext_Int7_Handler
PUBWEAK Ext_Int8_Handler
PUBWEAK WDog_Tmr_Int_Handler
PUBWEAK GP_Tmr0_Int_Handler
PUBWEAK GP_Tmr1_Int_Handler
PUBWEAK ADC0_Int_Handler
PUBWEAK Flsh_Int_Handler
PUBWEAK UART_Int_Handler
PUBWEAK SPI0_Int_Handler
PUBWEAK SPI1_Int_Handler
PUBWEAK I2C0_Slave_Int_Handler
PUBWEAK I2C0_Master_Int_Handler
PUBWEAK DMA_Err_Int_Handler
PUBWEAK DMA_SPI1_TX_Int_Handler
PUBWEAK DMA_SPI1_RX_Int_Handler
PUBWEAK DMA_UART_TX_Int_Handler
PUBWEAK DMA_UART_RX_Int_Handler
PUBWEAK DMA_I2C0_STX_Int_Handler
PUBWEAK DMA_I2C0_SRX_Int_Handler
PUBWEAK DMA_I2C0_MTX_Int_Handler
PUBWEAK DMA_I2C0_MRX_Int_Handler
PUBWEAK DMA_ADC_Int_Handler
PUBWEAK DMA_SPI0_TX_Int_Handler
PUBWEAK DMA_SPI0_RX_Int_Handler
PUBWEAK PWMTrip_Int_Handler
PUBWEAK PWM0_Int_Handler
PUBWEAK PWM1_Int_Handler
PUBWEAK PWM2_Int_Handler
PUBWEAK PWM3_Int_Handler
PUBWEAK UnUsed_Handler
THUMB
SECTION .text:CODE:REORDER(1)
Nmi_Handler
Fault_Handler
MemManage_Handler
BusFault_Handler
UsageFault_Handler
SVC_Handler
DebugMon_Handler
PendSV_Handler
SysTick_Handler
WakeUp_Int_Handler
Ext_Int0_Handler
Ext_Int1_Handler
Ext_Int2_Handler
Ext_Int3_Handler
Ext_Int4_Handler
Ext_Int5_Handler
Ext_Int6_Handler
Ext_Int7_Handler
Ext_Int8_Handler
WDog_Tmr_Int_Handler
GP_Tmr0_Int_Handler
GP_Tmr1_Int_Handler
ADC0_Int_Handler
Flsh_Int_Handler
UART_Int_Handler
SPI0_Int_Handler
SPI1_Int_Handler
I2C0_Slave_Int_Handler
I2C0_Master_Int_Handler
DMA_Err_Int_Handler
DMA_SPI1_TX_Int_Handler
DMA_SPI1_RX_Int_Handler
DMA_UART_TX_Int_Handler
DMA_UART_RX_Int_Handler
DMA_I2C0_STX_Int_Handler
DMA_I2C0_SRX_Int_Handler
DMA_I2C0_MTX_Int_Handler
DMA_I2C0_MRX_Int_Handler
DMA_ADC_Int_Handler
DMA_SPI0_TX_Int_Handler
DMA_SPI0_RX_Int_Handler
PWMTrip_Int_Handler
PWM0_Int_Handler
PWM1_Int_Handler
PWM2_Int_Handler
PWM3_Int_Handler
UnUsed_Handler
B UnUsed_Handler
END

View File

@ -0,0 +1,106 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/
/**
Module : retarget.c
Description :
Date : December 2012
Version : v2.00
Changelog : v1.00 Initial
v2.00 use of UrtLib functions
*/
#include <stdio.h>
#include <rt_misc.h>
#include <include.h>
#pragma import(__use_no_semihosting_swi)
#define CR 0x0D
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
// Re-targetting the Realview library functions
/*
* writes the character specified by c (converted to an unsigned char) to
* the output stream pointed to by stream, at the position indicated by the
* asociated file position indicator (if defined), and advances the
* indicator appropriately. If the file position indicator is not defined,
* the character is appended to the output stream.
* Returns: the character written. If a write error occurs, the error
* indicator is set and fputc returns EOF.
*/
int fputc(int ch, FILE * stream )
{
if(ch == '\n')
while(!(COMLSR_THRE==(UrtLinSta(0) & COMLSR_THRE)));
UrtTx(0, CR); /* output CR */
while(!(COMLSR_THRE==(UrtLinSta(0) & COMLSR_THRE)));
UrtTx(0, ch);
return(ch);
}
int __backspace(FILE *stream)
{
return 0x0;
}
/*
* obtains the next character (if present) as an unsigned char converted to
* an int, from the input stream pointed to by stream, and advances the
* associated file position indicator (if defined).
* Returns: the next character from the input stream pointed to by stream.
* If the stream is at end-of-file, the end-of-file indicator is
* set and fgetc returns EOF. If a read error occurs, the error
* indicator is set and fgetc returns EOF.
*/
int fgetc(FILE * stream)
{
return (UrtRx(0));
}
int ferror(FILE *f) {
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch) { UrtTx(0, ch); }
void _sys_exit(int return_code) {
label: goto label; /* endless loop */
}

View File

@ -0,0 +1,312 @@
; Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted (subject to the limitations in the
; disclaimer below) provided that the following conditions are met:
;
; - Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
;
; - Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the
; distribution.
;
; - Neither the name of Analog Devices, Inc. nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
; GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
; HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
; WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
; Module : startup_ADuCRF101.s
; Description : Cortex-M3 startup file - ADuCRF101 - RealView Version
; Date : 14 January 2013
; Version : v1.01
; Changelog : v1.01 Added call to SystemInit
; Changelog : v1.00 Initial
IMPORT __use_no_semihosting_swi
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; The NMI handler
DCD HardFault_Handler ; The hard fault handler
DCD MemManage_Handler ; The MPU fault handler
DCD BusFault_Handler ; The bus fault handler
DCD UsageFault_Handler ; The usage fault handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall handler
DCD DebugMon_Handler ; Debug monitor handler
DCD 0 ; Reserved
DCD PendSV_Handler ; The PendSV handler
DCD SysTick_Handler ; The SysTick handler
; External Interrupts
DCD WakeUp_Int_Handler ; Wake Up Timer [ 0]
DCD Ext_Int0_Handler ; External Interrupt 0 [ 1]
DCD Ext_Int1_Handler ; External Interrupt 1 [ 2]
DCD Ext_Int2_Handler ; External Interrupt 2 [ 3]
DCD Ext_Int3_Handler ; External Interrupt 3 [ 4]
DCD Ext_Int4_Handler ; External Interrupt 4 [ 5]
DCD Ext_Int5_Handler ; External Interrupt 5 [ 6]
DCD Ext_Int6_Handler ; External Interrupt 6 [ 7]
DCD Ext_Int7_Handler ; External Interrupt 7 [ 8]
DCD Ext_Int8_Handler ; External Interrupt 8 [ 9]
DCD WDog_Tmr_Int_Handler ; Watchdog timer handler [10]
DCD UnUsed_Handler ; Reserved [11]
DCD GP_Tmr0_Int_Handler ; General purpose timer 0 [12]
DCD GP_Tmr1_Int_Handler ; General purpose timer 1 [13]
DCD ADC0_Int_Handler ; ADC Interrupt [14]
DCD Flsh_Int_Handler ; Flash IRQ [15]
DCD UART_Int_Handler ; UART0 [16]
DCD SPI0_Int_Handler ; SPI 0 [17]
DCD SPI1_Int_Handler ; SPI 1 [18]
DCD I2C0_Slave_Int_Handler ; I2C0 Slave [19]
DCD I2C0_Master_Int_Handler ; I2C0 Master [20]
DCD UnUsed_Handler ; Reserved [21]
DCD UnUsed_Handler ; Reserved [22]
DCD DMA_Err_Int_Handler ; DMA Error interrupt [23]
DCD DMA_SPI1_TX_Int_Handler ; DMA SPI1 TX [24]
DCD DMA_SPI1_RX_Int_Handler ; DMA SPI1 RX [25]
DCD DMA_UART_TX_Int_Handler ; DMA UART TX [26]
DCD DMA_UART_RX_Int_Handler ; DMA UART RX [27]
DCD DMA_I2C0_STX_Int_Handler ; DMA I2C0 Slave TX [28]
DCD DMA_I2C0_SRX_Int_Handler ; DMA I2C0 Slave RX [29]
DCD DMA_I2C0_MTX_Int_Handler ; DMA I2C0 Master TX [30]
DCD DMA_I2C0_MRX_Int_Handler ; DMA I2C0 Master RX [31]
DCD UnUsed_Handler ; Reserved [32]
DCD UnUsed_Handler ; Reserved [33]
DCD UnUsed_Handler ; Reserved [34]
DCD DMA_ADC_Int_Handler ; DMA ADC [35]
DCD DMA_SPI0_TX_Int_Handler ; DMA SPI0 TX [36]
DCD DMA_SPI0_RX_Int_Handler ; DMA SPI0 RX [37]
DCD PWMTrip_Int_Handler ; PWM Trip [38]
DCD PWM0_Int_Handler ; PWM 0 [39]
DCD PWM1_Int_Handler ; PWM 1 [40]
DCD PWM2_Int_Handler ; PWM 2 [41]
DCD PWM3_Int_Handler ; PWM 3 [42]
DCD UnUsed_Handler ; Unused [43]
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit ; Defined in system_ADuCRF101.c
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WakeUp_Int_Handler [WEAK]
EXPORT Ext_Int0_Handler [WEAK]
EXPORT Ext_Int1_Handler [WEAK]
EXPORT Ext_Int2_Handler [WEAK]
EXPORT Ext_Int3_Handler [WEAK]
EXPORT Ext_Int4_Handler [WEAK]
EXPORT Ext_Int5_Handler [WEAK]
EXPORT Ext_Int6_Handler [WEAK]
EXPORT Ext_Int7_Handler [WEAK]
EXPORT Ext_Int8_Handler [WEAK]
EXPORT WDog_Tmr_Int_Handler [WEAK]
EXPORT GP_Tmr0_Int_Handler [WEAK]
EXPORT GP_Tmr1_Int_Handler [WEAK]
EXPORT ADC0_Int_Handler [WEAK]
EXPORT Flsh_Int_Handler [WEAK]
EXPORT UART_Int_Handler [WEAK]
EXPORT SPI0_Int_Handler [WEAK]
EXPORT SPI1_Int_Handler [WEAK]
EXPORT I2C0_Slave_Int_Handler [WEAK]
EXPORT I2C0_Master_Int_Handler [WEAK]
EXPORT DMA_Err_Int_Handler [WEAK]
EXPORT DMA_SPI1_TX_Int_Handler [WEAK]
EXPORT DMA_SPI1_RX_Int_Handler [WEAK]
EXPORT DMA_UART_TX_Int_Handler [WEAK]
EXPORT DMA_UART_RX_Int_Handler [WEAK]
EXPORT DMA_I2C0_STX_Int_Handler [WEAK]
EXPORT DMA_I2C0_SRX_Int_Handler [WEAK]
EXPORT DMA_I2C0_MTX_Int_Handler [WEAK]
EXPORT DMA_I2C0_MRX_Int_Handler [WEAK]
EXPORT DMA_ADC_Int_Handler [WEAK]
EXPORT DMA_SPI0_TX_Int_Handler [WEAK]
EXPORT DMA_SPI0_RX_Int_Handler [WEAK]
EXPORT PWMTrip_Int_Handler [WEAK]
EXPORT PWM0_Int_Handler [WEAK]
EXPORT PWM1_Int_Handler [WEAK]
EXPORT PWM2_Int_Handler [WEAK]
EXPORT PWM3_Int_Handler [WEAK]
EXPORT UnUsed_Handler [WEAK]
WakeUp_Int_Handler
Ext_Int0_Handler
Ext_Int1_Handler
Ext_Int2_Handler
Ext_Int3_Handler
Ext_Int4_Handler
Ext_Int5_Handler
Ext_Int6_Handler
Ext_Int7_Handler
Ext_Int8_Handler
WDog_Tmr_Int_Handler
GP_Tmr0_Int_Handler
GP_Tmr1_Int_Handler
ADC0_Int_Handler
Flsh_Int_Handler
UART_Int_Handler
SPI0_Int_Handler
SPI1_Int_Handler
I2C0_Slave_Int_Handler
I2C0_Master_Int_Handler
DMA_Err_Int_Handler
DMA_SPI1_TX_Int_Handler
DMA_SPI1_RX_Int_Handler
DMA_UART_TX_Int_Handler
DMA_UART_RX_Int_Handler
DMA_I2C0_STX_Int_Handler
DMA_I2C0_SRX_Int_Handler
DMA_I2C0_MTX_Int_Handler
DMA_I2C0_MRX_Int_Handler
DMA_ADC_Int_Handler
DMA_SPI0_TX_Int_Handler
DMA_SPI0_RX_Int_Handler
PWMTrip_Int_Handler
PWM0_Int_Handler
PWM1_Int_Handler
PWM2_Int_Handler
PWM3_Int_Handler
UnUsed_Handler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END

View File

@ -0,0 +1,61 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/
/**
@module include.h
@brief Main Include file
@version V0.2
@author PAD CSE group, Analog Devices Inc
@date January 2013
@par Revision History:
- V0.1, February 2012: initial version.
- V0.2, January 2013: addition of PwmLib, FeeLib and DmaLib
remove uart.h
**/
#ifndef __INCLUDE_H
#define __INCLUDE_H
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <defs.h>
#include <ADuCRF101.h>
#include "radioeng.h"
#endif // __INCLUDE_H

View File

@ -0,0 +1,42 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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 defs.h
@brief Global definitions.
@version V0.1
@author PAD CSE group, Analog Devices Inc
@date January 2012
**/
typedef enum {FALSE = 0, TRUE = !FALSE} boolean;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,174 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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 radioeng.h
@brief Radio Interface Engine Functions
@version v1.0
@author PAD CSE group, Analog Devices Inc
@date May 08th 2013
**/
#define RIE_U32 unsigned long
#define RIE_U16 unsigned short int
#define RIE_U8 unsigned char
#define RIE_S8 signed char
/*! \enum RIE_BaseConfigs
* Variables of this type are used to define the Base Configuration
*/
/*! \var RIE_BaseConfigs DR_1_0kbps_Dev10_0kHz
* Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation.
Use for achieving longer distances.
*/
/*! \var RIE_BaseConfigs DR_38_4kbps_Dev20kHz
* Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
Use as a compromise of distance and power.
*/
/*! \var RIE_BaseConfigs DR_300_0kbps_Dev75_0kHz
* Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
Use for achieving faster transmission times hence lower power.
*/
typedef enum
{
DR_1_0kbps_Dev10_0kHz = 0x0,
DR_38_4kbps_Dev20kHz = 0x1,
DR_300_0kbps_Dev75_0kHz = 0x2,
UnsupportedDRDev
} RIE_BaseConfigs;
/*! \enum RIE_ModulationTypes
* Variables of this type are used to define a tx modulation type
*/
/*! \var RIE_ModulationTypes FSK_Modulation
* FSK Modulation
*/
/*! \var RIE_ModulationTypes GFSK_Modulation
* GFSK Modulation
*/
typedef enum {FSK_Modulation = 0, GFSK_Modulation = 1} RIE_ModulationTypes;
/*! \enum RIE_PATypes
* Variables of this type are used to define a PA type
*/
/*! \var RIE_PATypes DifferentialPA
* Differential PA
*/
/*! \var RIE_PATypes SingleEndedPA
* Single Ended PA
*/
typedef enum {DifferentialPA = 0, SingleEndedPA = 1} RIE_PATypes;
typedef enum {PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3,
PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7,
PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11,
PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15
} RIE_PAPowerLevel;
/*! \enum RIE_BOOL
* Variables of this type are used to define a TRUE or FALSE condition
*/
/*! \var RIE_BOOL RIE_TRUE
* TRUE condition
*/
/*! \var RIE_BOOL RIE_FALSE
* FALSE condition
*/
typedef enum {RIE_FALSE = 0, RIE_TRUE = !RIE_FALSE} RIE_BOOL;
/*! \enum RIE_Responses
* Variables of this type are used to define the return value from functions
*/
/*! \var RIE_Responses RIE_Success
* Successful completion
*/
/*! \var RIE_Responses RIE_RadioSPICommsFail
* SPI communications with the radio failure.
*/
/*! \var RIE_Responses RIE_UnsupportedRadioConfig
* This is an unsupported radio configuration
*/
/*! \var RIE_Responses RIE_Unimplemented
* This feature has not been implemented
*/
/*! \var RIE_Responses RIE_InvalidParamter
* An invaild parameter was passed
*/
typedef enum
{
RIE_Success = 0x0,
RIE_RadioSPICommsFail = 0x1,
RIE_UnsupportedRadioConfig = 0x2,
RIE_Unimplemented = 0x3,
RIE_InvalidParamter = 0x4,
} RIE_Responses;
// Added in Radio Interface Engine v0.1
RIE_Responses RadioGetAPIVersion (RIE_U32 *pVersion);
RIE_Responses RadioInit (RIE_BaseConfigs BaseConfig);
RIE_Responses RadioPowerOff (void);
RIE_Responses RadioTerminateRadioOp (void);
RIE_Responses RadioSetFrequency (RIE_U32 Frequency);
RIE_Responses RadioSetModulationType (RIE_ModulationTypes ModulationType);
RIE_Responses RadioPayldManchesterEncode(RIE_BOOL bEnable);
RIE_Responses RadioPayldDataWhitening (RIE_BOOL bEnable);
RIE_Responses RadioTxPacketFixedLen (RIE_U8 Len, RIE_U8 *pData);
RIE_BOOL RadioTxPacketComplete (void);
RIE_Responses RadioTxSetPA (RIE_PATypes PAType,RIE_PAPowerLevel Power);
RIE_Responses RadioTxCarrier (void);
RIE_Responses RadioTxPreamble (void);
RIE_Responses RadioRxPacketFixedLen (RIE_U8 Len);
RIE_BOOL RadioRxPacketAvailable (void);
RIE_Responses RadioRxPacketRead (RIE_U8 BufferLen,RIE_U8 *pPktLen,RIE_U8 *pData,RIE_S8 *pRSSIdBm);
RIE_Responses RadioRxBERTestMode (void);
// Added in Radio Interface Engine v0.2
RIE_Responses RadioSwitchConfig (RIE_BaseConfigs BaseConfig);
RIE_Responses RadioRadioGetRSSI (RIE_S8 *pRSSIdBm);
RIE_Responses RadioTxSetPower (RIE_PAPowerLevel Power);
// Added in Radio Interface Engine v0.3
RIE_Responses RadioTxPacketVariableLen (RIE_U8 Len, RIE_U8 *pData);
RIE_Responses RadioRxPacketVariableLen (void);
// Added in Radio Interface Engine v0.5
RIE_Responses RadioDeInit (void);

View File

@ -0,0 +1,179 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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 system_ADUCRF101.c
@brief CMSIS Cortex-M3 Device Peripheral Access Layer Implementation File
for the ADuCRF101
@version v1.0
@author PAD CSE group, Analog Devices Inc
@date January 14th 2013
**/
#include <stdint.h>
#include "ADuCRF101.h"
/*----------------------------------------------------------------------------
DEFINES
*---------------------------------------------------------------------------*/
/* Extract the Clock Divider */
#define __CCLK_DIV (1 << (pADI_CLKCTL->CLKCON & CLKCON_CD_MSK) )
/* define the clock multiplexer input frequencies */
#define __HFOSC 16000000
#define __LFXTAL 32768
#define __LFOSC 32768
/*----------------------------------------------------------------------------
Internal Clock Variables
*---------------------------------------------------------------------------*/
static uint32_t uClk = 0; /* Undivided System Clock Frequency (UCLK) */
static uint32_t uClkDiv = 0; /* Divided System Clock Frequency (UCLK_DIV) */
/* Frequency of the external clock source connected to P0.5 */
static uint32_t SystemExtClock = 0;
/*----------------------------------------------------------------------------
Clock functions
*---------------------------------------------------------------------------*/
void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */
{
/* pre-processor verification that clock mux mask and allowed values agree */
#if ((CLKCON_CLKMUX_HFOSC \
| CLKCON_CLKMUX_LFXTAL \
| CLKCON_CLKMUX_LFOSC \
| CLKCON_CLKMUX_EXTP05) \
== CLKCON_CLKMUX_MSK)
/* update the system core clock according the the current clock mux setting */
switch (pADI_CLKCTL->CLKCON & CLKCON_CLKMUX_MSK ) {
case CLKCON_CLKMUX_HFOSC:
uClk = __HFOSC;
break;
case CLKCON_CLKMUX_LFXTAL:
uClk = __LFXTAL;
break;
case CLKCON_CLKMUX_LFOSC:
uClk = __LFOSC;
break;
case CLKCON_CLKMUX_ECLKIN:
uClk = SystemExtClock;
break;
/* no need to catch default case due to pre-processor test */
}
/* update the divided system clock */
uClkDiv = uClk / __CCLK_DIV;
#else
#error "Clock mux mask and allowed value mismatch!"
#endif
}
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemFrequency variable.
*/
void SystemInit (void)
{
/* reset CLKCON register */
pADI_CLKCTL->CLKCON = CLKCON_RVAL;
/* reset XOSCCON register */
pADI_CLKCTL->XOSCCON = XOSCCON_RVAL;
/* compute internal clocks */
SystemCoreClockUpdate();
}
/**
* @brief Sets the system external clock frequency
*
* @param ExtClkFreq External clock frequency in Hz
* @return none
*
* Sets the clock frequency of the source connected to P0.5 clock input source
*/
void SetSystemExtClkFreq (uint32_t ExtClkFreq)
{
SystemExtClock = ExtClkFreq;
}
/**
* @brief Gets the system external clock frequency
*
* @return External Clock frequency
*
* Gets the clock frequency of the source connected to P0.5 clock input source
*/
uint32_t GetSystemExtClkFreq (void)
{
return SystemExtClock;
}
/* set the system clock dividers */
void SystemSetClockDivider(uint16_t div)
{
/* critical region */
__disable_irq();
/* read-modify-write without any interrupts */
pADI_CLKCTL->CLKCON &= ~(CLKCON_CD_MSK); /* keep everything else */
pADI_CLKCTL->CLKCON |= div; /* set new value */
/* end critical region */
__enable_irq();
/* refresh internal clock variables */
SystemCoreClockUpdate();
}
uint32_t SystemGetClockFrequency(void)
{
return uClkDiv;
}

View File

@ -0,0 +1,116 @@
/**
* Copyright (c) 2014, Analog Devices, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Analog Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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 system_ADUCRF101.h
@brief: CMSIS Cortex-M3 Device Peripheral Access Layer Header File
for the ADuCRF101
@version v0.2
@author PAD CSE group, Analog Devices Inc
@date March 09th 2012
**/
/** @addtogroup CMSIS
* @{
*/
/** @addtogroup aducrf101_system
* @{
*/
#ifndef __SYSTEM_ADUCRF101_H__
#define __SYSTEM_ADUCRF101_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize the system
*
* @param none
* @return none
*
* Setup the microcontroller system.
* Initialize the System and update the SystemCoreClock variable.
*/
extern void SystemInit (void);
/**
* @brief Update internal SystemCoreClock variable
*
* @param none
* @return none
*
* Updates the internal SystemCoreClock with current core
* Clock retrieved from cpu registers.
*/
extern void SystemCoreClockUpdate (void);
/**
* @brief Sets the system external clock frequency
*
* @param ExtClkFreq External clock frequency in Hz
* @return none
*
* Sets the clock frequency of the source connected to P0.5 clock input source
*/
extern void SetSystemExtClkFreq (uint32_t ExtClkFreq);
/**
* @brief Gets the system external clock frequency
*
* @return External Clock frequency
*
* Gets the clock frequency of the source connected to P0.5 clock input source
*/
extern uint32_t GetSystemExtClkFreq (void);
#ifdef __cplusplus
}
#endif
#endif /* __SYSTEM_ADUCRF101_H__ */
/**
* @}
*/
/**
* @}
*/