sysmon: Add new version 7.1
Added new version 7.1 and deprecated old version 7.0 Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com>
This commit is contained in:
parent
ec8a0b20f7
commit
603530af24
21 changed files with 7910 additions and 0 deletions
55
XilinxProcessorIPLib/drivers/sysmon/data/sysmon.mdd
Executable file
55
XilinxProcessorIPLib/drivers/sysmon/data/sysmon.mdd
Executable file
|
@ -0,0 +1,55 @@
|
|||
##############################################################################
|
||||
#
|
||||
# (c) Copyright 2007-2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# This file contains confidential and proprietary information of Xilinx, Inc.
|
||||
# and is protected under U.S. and international copyright and other
|
||||
# intellectual property laws.
|
||||
#
|
||||
# DISCLAIMER
|
||||
# This disclaimer is not a license and does not grant any rights to the
|
||||
# materials distributed herewith. Except as otherwise provided in a valid
|
||||
# license issued to you by Xilinx, and to the maximum extent permitted by
|
||||
# applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
|
||||
# FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
|
||||
# IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
|
||||
# MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
|
||||
# and (2) Xilinx shall not be liable (whether in contract or tort, including
|
||||
# negligence, or under any other theory of liability) for any loss or damage
|
||||
# of any kind or nature related to, arising under or in connection with these
|
||||
# materials, including for any direct, or any indirect, special, incidental,
|
||||
# or consequential loss or damage (including loss of data, profits, goodwill,
|
||||
# or any type of loss or damage suffered as a result of any action brought by
|
||||
# a third party) even if such damage or loss was reasonably foreseeable or
|
||||
# Xilinx had been advised of the possibility of the same.
|
||||
#
|
||||
# CRITICAL APPLICATIONS
|
||||
# Xilinx products are not designed or intended to be fail-safe, or for use in
|
||||
# any application requiring fail-safe performance, such as life-support or
|
||||
# safety devices or systems, Class III medical devices, nuclear facilities,
|
||||
# applications related to the deployment of airbags, or any other applications
|
||||
# that could lead to death, personal injury, or severe property or
|
||||
# environmental damage (individually and collectively, "Critical
|
||||
# Applications"). Customer assumes the sole risk and liability of any use of
|
||||
# Xilinx products in Critical Applications, subject only to applicable laws
|
||||
# and regulations governing limitations on product liability.
|
||||
#
|
||||
# THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
|
||||
# AT ALL TIMES.
|
||||
# MODIFICATION HISTORY:
|
||||
# Ver Who Date Changes
|
||||
# -------- ------ -------- --------------------------------------------------
|
||||
# 6.0 adk 10/12/13 Removed support for xps_sysmon_adc
|
||||
# 7.0 bss 7/25/14 Added support for Ultrascale.
|
||||
##############################################################################
|
||||
OPTION psf_version = 2.1;
|
||||
|
||||
BEGIN driver sysmon
|
||||
|
||||
OPTION supported_peripherals = (axi_sysmon_adc axi_xadc xadc_wiz system_management_wiz);
|
||||
OPTION copyfiles = all;
|
||||
OPTION driver_state = ACTIVE;
|
||||
OPTION VERSION = 7.1;
|
||||
OPTION NAME = sysmon;
|
||||
|
||||
END driver
|
181
XilinxProcessorIPLib/drivers/sysmon/data/sysmon.tcl
Executable file
181
XilinxProcessorIPLib/drivers/sysmon/data/sysmon.tcl
Executable file
|
@ -0,0 +1,181 @@
|
|||
###############################################################################
|
||||
#
|
||||
# Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# Use of the Software is limited solely to applications:
|
||||
# (a) running on a Xilinx device, or
|
||||
# (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
# MODIFICATION HISTORY:
|
||||
# Ver Who Date Changes
|
||||
# -------- ------ -------- --------------------------------------------------
|
||||
# 7.0 bss 7/25/14 Added support for Ultrascale.
|
||||
##############################################################################
|
||||
|
||||
#uses "xillib.tcl"
|
||||
|
||||
proc generate {drv_handle} {
|
||||
xdefine_include_file $drv_handle "xparameters.h" "XSysMon" "NUM_INSTANCES" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_INCLUDE_INTR"
|
||||
::hsi::utils::define_config_file $drv_handle "xsysmon_g.c" "XSysMon" "DEVICE_ID" "C_BASEADDR" "C_INCLUDE_INTR" "IP_TYPE"
|
||||
|
||||
xdefine_canonical_xpars $drv_handle "xparameters.h" "SysMon" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR" "C_INCLUDE_INTR"
|
||||
}
|
||||
|
||||
proc xdefine_include_file {drv_handle file_name drv_string args} {
|
||||
set args [::hsi::utils::get_exact_arg_list $args]
|
||||
# Open include file
|
||||
set file_handle [::hsi::utils::open_include_file $file_name]
|
||||
|
||||
# Get all peripherals connected to this driver
|
||||
set periphs [::hsi::utils::get_common_driver_ips $drv_handle]
|
||||
|
||||
# Handle special cases
|
||||
set arg "NUM_INSTANCES"
|
||||
set posn [lsearch -exact $args $arg]
|
||||
if {$posn > -1} {
|
||||
puts $file_handle "/* Definitions for driver [string toupper [common::get_property name $drv_handle]] */"
|
||||
# Define NUM_INSTANCES
|
||||
puts $file_handle "#define [::hsi::utils::get_driver_param_name $drv_string $arg] [llength $periphs]"
|
||||
set args [lreplace $args $posn $posn]
|
||||
}
|
||||
|
||||
# Check if it is a driver parameter
|
||||
lappend newargs
|
||||
foreach arg $args {
|
||||
set value [common::get_property CONFIG.$arg $drv_handle]
|
||||
if {[llength $value] == 0} {
|
||||
lappend newargs $arg
|
||||
} else {
|
||||
puts $file_handle "#define [::hsi::utils::get_driver_param_name $drv_string $arg] [common::get_property $arg $drv_handle]"
|
||||
}
|
||||
}
|
||||
set args $newargs
|
||||
|
||||
# Print all parameters for all peripherals
|
||||
set device_id 0
|
||||
foreach periph $periphs {
|
||||
puts $file_handle ""
|
||||
puts $file_handle "/* Definitions for peripheral [string toupper [common::get_property NAME $periph]] */"
|
||||
|
||||
set ipname [string tolower [common::get_property IP_NAME $periph]]
|
||||
if {[string compare -nocase "system_management_wiz" $ipname] == 0} {
|
||||
puts $file_handle "#define [::hsi::utils::get_ip_param_name $periph "IP_TYPE"] 1"
|
||||
} else {
|
||||
puts $file_handle "#define [::hsi::utils::get_ip_param_name $periph "IP_TYPE"] 0"
|
||||
}
|
||||
|
||||
foreach arg $args {
|
||||
if {[string compare -nocase "DEVICE_ID" $arg] == 0} {
|
||||
set value $device_id
|
||||
incr device_id
|
||||
} else {
|
||||
set value [common::get_property CONFIG.$arg $periph]
|
||||
}
|
||||
if {[llength $value] == 0} {
|
||||
set value 0
|
||||
}
|
||||
set value [::hsi::utils::format_addr_string $value $arg]
|
||||
if {[string compare -nocase "HW_VER" $arg] == 0} {
|
||||
puts $file_handle "#define [::hsi::utils::get_ip_param_name $periph $arg] \"$value\""
|
||||
} else {
|
||||
puts $file_handle "#define [::hsi::utils::get_ip_param_name $periph $arg] $value"
|
||||
}
|
||||
}
|
||||
puts $file_handle ""
|
||||
}
|
||||
puts $file_handle "\n/******************************************************************/\n"
|
||||
close $file_handle
|
||||
}
|
||||
|
||||
proc xdefine_canonical_xpars {drv_handle file_name drv_string args} {
|
||||
set args [::hsi::utils::get_exact_arg_list $args]
|
||||
# Open include file
|
||||
set file_handle [::hsi::utils::open_include_file $file_name]
|
||||
|
||||
# Get all the peripherals connected to this driver
|
||||
set periphs [::hsi::utils::get_common_driver_ips $drv_handle]
|
||||
|
||||
# Get the names of all the peripherals connected to this driver
|
||||
foreach periph $periphs {
|
||||
set peripheral_name [string toupper [common::get_property NAME $periph]]
|
||||
lappend peripherals $peripheral_name
|
||||
}
|
||||
|
||||
# Get possible canonical names for all the peripherals connected to this
|
||||
# driver
|
||||
set device_id 0
|
||||
foreach periph $periphs {
|
||||
set canonical_name [string toupper [format "%s_%s" $drv_string $device_id]]
|
||||
lappend canonicals $canonical_name
|
||||
|
||||
# Create a list of IDs of the peripherals whose hardware instance name
|
||||
# doesn't match the canonical name. These IDs can be used later to
|
||||
# generate canonical definitions
|
||||
if { [lsearch $peripherals $canonical_name] < 0 } {
|
||||
lappend indices $device_id
|
||||
}
|
||||
incr device_id
|
||||
}
|
||||
|
||||
set i 0
|
||||
foreach periph $periphs {
|
||||
set periph_name [string toupper [common::get_property NAME $periph]]
|
||||
|
||||
# Generate canonical definitions only for the peripherals whose
|
||||
# canonical name is not the same as hardware instance name
|
||||
if { [lsearch $canonicals $periph_name] < 0 } {
|
||||
puts $file_handle "/* Canonical definitions for peripheral $periph_name */"
|
||||
set canonical_name [format "%s_%s" $drv_string [lindex $indices $i]]
|
||||
|
||||
set ipname [string tolower [common::get_property IP_NAME $periph]]
|
||||
if {[string compare -nocase "system_management_wiz" $ipname] == 0} {
|
||||
puts $file_handle "#define [::hsi::utils::get_driver_param_name $canonical_name "IP_TYPE"] 1"
|
||||
} else {
|
||||
puts $file_handle "#define [::hsi::utils::get_driver_param_name $canonical_name "IP_TYPE"] 0"
|
||||
}
|
||||
|
||||
foreach arg $args {
|
||||
set lvalue [::hsi::utils::get_driver_param_name $canonical_name $arg]
|
||||
|
||||
# The commented out rvalue is the name of the instance-specific constant
|
||||
# set rvalue [::hsi::utils::get_ip_param_name $periph $arg]
|
||||
# The rvalue set below is the actual value of the parameter
|
||||
set rvalue [::hsi::utils::get_param_value $periph $arg]
|
||||
if {[llength $rvalue] == 0} {
|
||||
set rvalue 0
|
||||
}
|
||||
set rvalue [::hsi::utils::format_addr_string $rvalue $arg]
|
||||
|
||||
puts $file_handle "#define $lvalue $rvalue"
|
||||
|
||||
}
|
||||
puts $file_handle ""
|
||||
incr i
|
||||
}
|
||||
}
|
||||
|
||||
puts $file_handle "\n/******************************************************************/\n"
|
||||
close $file_handle
|
||||
}
|
36
XilinxProcessorIPLib/drivers/sysmon/data/sysmon_header.h
Normal file
36
XilinxProcessorIPLib/drivers/sysmon/data/sysmon_header.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
int SysMonPolledExample(u16 SysMonDeviceId, int *Temp);
|
|
@ -0,0 +1,49 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
#ifdef XPAR_INTC_0_DEVICE_ID
|
||||
int SysMonIntrExample(XIntc* IntcInstancePtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId,
|
||||
int *Temp);
|
||||
#else
|
||||
int SysMonIntrExample(XScuGic* IntcInstancePtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId,
|
||||
int *Temp);
|
||||
|
||||
#endif
|
235
XilinxProcessorIPLib/drivers/sysmon/data/sysmon_tapp.tcl
Executable file
235
XilinxProcessorIPLib/drivers/sysmon/data/sysmon_tapp.tcl
Executable file
|
@ -0,0 +1,235 @@
|
|||
###############################################################################
|
||||
#
|
||||
# Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# Use of the Software is limited solely to applications:
|
||||
# (a) running on a Xilinx device, or
|
||||
# (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
# MODIFICATION HISTORY:
|
||||
# Ver Who Date Changes
|
||||
# -------- ------ -------- ------------------------------------
|
||||
# 6.0 adk 12/10/13 Updated as per the New Tcl API's
|
||||
##############################################################################
|
||||
|
||||
## @BEGIN_CHANGELOG EDK_Jm
|
||||
##
|
||||
## - Added support for generation of multiple applications.
|
||||
## All TCL procedures are now required to have a software
|
||||
## project type as its first argument
|
||||
##
|
||||
## @END_CHANGELOG
|
||||
|
||||
# Uses $XILINX_EDK/bin/lib/xillib_sw.tcl
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Software Project Types (swproj):
|
||||
# 0 : MemoryTest - Calls basic memorytest routines from common driver dir
|
||||
# 1 : PeripheralTest - Calls any existing polled_example and/or selftest
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# TCL Procedures:
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
proc gen_include_files {swproj mhsinst} {
|
||||
if {$swproj == 0} {
|
||||
return ""
|
||||
}
|
||||
if {$swproj == 1} {
|
||||
set ifsysmonintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
|
||||
if {$ifsysmonintr == 1} {
|
||||
set inc_file_lines {xsysmon.h sysmon_header.h sysmon_intr_header.h}
|
||||
} else {
|
||||
set inc_file_lines {xsysmon.h sysmon_header.h}
|
||||
}
|
||||
return $inc_file_lines
|
||||
}
|
||||
}
|
||||
|
||||
proc gen_src_files {swproj mhsinst} {
|
||||
if {$swproj == 0} {
|
||||
return ""
|
||||
}
|
||||
if {$swproj == 1} {
|
||||
set ifsysmonintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
|
||||
|
||||
if {$ifsysmonintr == 1} {
|
||||
set inc_file_lines {examples/xsysmon_polled_example.c examples/xsysmon_intr_example.c data/sysmon_header.h data/sysmon_intr_header.h}
|
||||
} else {
|
||||
set inc_file_lines {examples/xsysmon_polled_example.c data/sysmon_header.h}
|
||||
}
|
||||
return $inc_file_lines
|
||||
}
|
||||
}
|
||||
|
||||
proc gen_testfunc_def {swproj mhsinst} {
|
||||
return ""
|
||||
}
|
||||
|
||||
proc gen_init_code {swproj mhsinst} {
|
||||
|
||||
if {$swproj == 0} {
|
||||
return ""
|
||||
}
|
||||
if {$swproj == 1} {
|
||||
|
||||
set ipname [common::get_property NAME $mhsinst]
|
||||
set ifsysmonintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
|
||||
if {$ifsysmonintr == 1} {
|
||||
set decl " static XSysMon ${ipname}_SysMon_ADC;"
|
||||
set inc_file_lines $decl
|
||||
return $inc_file_lines
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
proc gen_testfunc_call {swproj mhsinst} {
|
||||
|
||||
if {$swproj == 0} {
|
||||
return ""
|
||||
}
|
||||
|
||||
set ifsysmonintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
|
||||
set ipname [common::get_property NAME $mhsinst]
|
||||
set deviceid [::hsi::utils::get_ip_param_name $mhsinst "DEVICE_ID"]
|
||||
set stdout [common::get_property CONFIG.STDOUT [hsi::get_os]]
|
||||
if { $stdout == "" || $stdout == "none" } {
|
||||
set hasStdout 0
|
||||
} else {
|
||||
set hasStdout 1
|
||||
}
|
||||
|
||||
if {$ifsysmonintr == 1} {
|
||||
set intr_pin_name [hsi::get_pins -of_objects [hsi::get_cells $ipname] -filter "TYPE==INTERRUPT"]
|
||||
set intcname [::hsi::utils::get_connected_intr_cntrl $ipname $intr_pin_name]
|
||||
set intcvar intc
|
||||
set proc [common::get_property IP_NAME [hsi::get_cells [hsi::get_sw_processor]]]
|
||||
}
|
||||
|
||||
set testfunc_call ""
|
||||
|
||||
if {${hasStdout} == 0} {
|
||||
|
||||
append testfunc_call "
|
||||
|
||||
{
|
||||
int status;
|
||||
int Temp;
|
||||
|
||||
status = SysMonPolledExample(${deviceid}, &Temp);
|
||||
|
||||
}"
|
||||
|
||||
|
||||
if {$ifsysmonintr == 1} {
|
||||
if {
|
||||
$proc == "microblaze"
|
||||
} then {
|
||||
set intr_id "XPAR_${intcname}_${ipname}_${intr_pin_name}_INTR"
|
||||
} else {
|
||||
set intr_id "XPAR_FABRIC_${ipname}_${intr_pin_name}_INTR"
|
||||
}
|
||||
set intr_id [string toupper $intr_id]
|
||||
|
||||
append testfunc_call "
|
||||
|
||||
{
|
||||
int Status;
|
||||
int Temp;
|
||||
|
||||
Status = SysMonIntrExample(&${intcvar}, &${ipname}_SysMon_ADC, \\
|
||||
${deviceid}, \\
|
||||
${intr_id}, \\
|
||||
&Temp);
|
||||
}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
append testfunc_call "
|
||||
|
||||
{
|
||||
int status;
|
||||
int Temp;
|
||||
|
||||
print(\"\\r\\n Running SysMonPolledExample() for ${ipname}...\\r\\n\");
|
||||
|
||||
status = SysMonPolledExample(${deviceid}, &Temp);
|
||||
|
||||
if (status == 0) {
|
||||
print(\"SysMonPolledExample PASSED\\r\\n\");
|
||||
xil_printf(\"The Current Temperature is \%d Centigrades.\\n\\r\", Temp);
|
||||
}
|
||||
else {
|
||||
print(\"SysMonPolledExample FAILED\\r\\n\");
|
||||
}
|
||||
}"
|
||||
|
||||
|
||||
if {$ifsysmonintr == 1} {
|
||||
if {
|
||||
$proc == "microblaze"
|
||||
} then {
|
||||
set intr_id "XPAR_${intcname}_${ipname}_${intr_pin_name}_INTR"
|
||||
} else {
|
||||
set intr_id "XPAR_FABRIC_${ipname}_${intr_pin_name}_INTR"
|
||||
}
|
||||
set intr_id [string toupper $intr_id]
|
||||
|
||||
append testfunc_call "
|
||||
{
|
||||
int Status;
|
||||
int Temp;
|
||||
|
||||
print(\"\\r\\n Running Interrupt Test for ${ipname}...\\r\\n\");
|
||||
|
||||
Status = SysMonIntrExample(&${intcvar}, &${ipname}_SysMon_ADC, \\
|
||||
${deviceid}, \\
|
||||
${intr_id}, \\
|
||||
&Temp);
|
||||
|
||||
if (Status == 0) {
|
||||
print(\"SysMon ADC Interrupt Test PASSED\\r\\n\");
|
||||
xil_printf(\"The Current Temperature is \%d Centigrades.\\n\\r\", Temp);
|
||||
}
|
||||
else {
|
||||
print(\"SysMon ADC Interrupt Test FAILED\\r\\n\");
|
||||
}
|
||||
|
||||
}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $testfunc_call
|
||||
}
|
23
XilinxProcessorIPLib/drivers/sysmon/examples/index.html
Executable file
23
XilinxProcessorIPLib/drivers/sysmon/examples/index.html
Executable file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Driver example applications</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1> Example Applications for the driver sysmon_v7_0 </h1>
|
||||
<HR>
|
||||
<ul>
|
||||
<li>xsysmon_intr_printf_example.c <a href="xsysmon_intr_printf_example.c">(source)</a> </li>
|
||||
<li>xsysmon_intr_example.c <a href="xsysmon_intr_example.c">(source)</a> </li>
|
||||
<li>xsysmon_low_level_example.c <a href="xsysmon_low_level_example.c">(source)</a> </li>
|
||||
<li>xsysmon_polled_example.c <a href="xsysmon_polled_example.c">(source)</a> </li>
|
||||
<li>xsysmon_polled_printf_example.c <a href="xsysmon_polled_printf_example.c">(source)</a> </li>
|
||||
<li>xsysmon_single_ch_intr_example.c <a href="xsysmon_single_ch_intr_example.c">(source)</a> </li>
|
||||
<li>xsysmon_extmux_example.c <a href="xsysmon_extmux_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<p><font face="Times New Roman" color="#800000">Copyright <20> 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,433 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2011 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_extmux_example.c
|
||||
*
|
||||
* This file contains a design example using the driver functions
|
||||
* of the System Monitor/ADC driver. This example shows the usage of the
|
||||
* driver/device in interrupt mode with external mux and XADC in Simulateneous
|
||||
* Sequencer mode. This example hasn't been tested with the analog inputs
|
||||
* connected through external mux. It is provided to illustrate the usage of
|
||||
* external mux.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* This code assumes that no Operating System is being used.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------------
|
||||
* 5.00a sdm 08/30/11 First release
|
||||
* 5.03a bss 04/25/13 Modified SysMonIntrExample function to set
|
||||
* Sequencer Mode as Safe mode instead of Single
|
||||
* channel mode before configuring Sequencer registers.
|
||||
* CR #703729
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
#include "xintc.h"
|
||||
#include "stdio.h"
|
||||
#include "xil_exception.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
|
||||
#define INTC_DEVICE_ID XPAR_INTC_0_DEVICE_ID
|
||||
#define INTR_ID XPAR_INTC_0_SYSMON_0_VEC_ID
|
||||
|
||||
#define printf xil_printf /* Small foot-print printf function */
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
static int SysMonIntrExample(XIntc* IntcInstPtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId);
|
||||
|
||||
|
||||
static void SysMonInterruptHandler(void *CallBackRef);
|
||||
|
||||
static int SysMonSetupInterruptSystem(XIntc* IntcInstPtr,
|
||||
XSysMon *SysMonPtr,
|
||||
u16 IntrId );
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
static XSysMon SysMonInst; /* System Monitor driver instance */
|
||||
static XIntc IntcInst; /* Instance of the XIntc driver */
|
||||
|
||||
volatile static int EosFlag = FALSE; /* EOS interrupt */
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the Interrupt example.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor interrupt example, specify the parameters that
|
||||
* are generated in xparameters.h.
|
||||
*/
|
||||
Status = SysMonIntrExample(&IntcInst, &SysMonInst,
|
||||
SYSMON_DEVICE_ID, INTR_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the XADC device using the driver APIs.
|
||||
*
|
||||
* The function does the following tasks:
|
||||
* - Initiate the XADC device driver instance
|
||||
* - Run self-test on the device
|
||||
* - Reset the device
|
||||
* - Set up sequencer registers to continuously monitor the auxiliary
|
||||
* channel pairs avaibale in XADC
|
||||
* - Setup interrupt system
|
||||
* - Enable interrupts
|
||||
* - Set up configuration registers to start the sequencer in simultaneous
|
||||
* sampling mode
|
||||
* - Wait until End of sequence interrupt occurs and read the conversion
|
||||
* data
|
||||
*
|
||||
* @param IntcInstPtr is a pointer to the Interrupt Controller
|
||||
* driver Instance.
|
||||
* @param SysMonInstPtr is a pointer to the XSysMon driver Instance.
|
||||
* @param SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value
|
||||
* from xparameters.h.
|
||||
* @param SysMonIntrId is
|
||||
* XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note This function may never return if no interrupt occurs.
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SysMonIntrExample(XIntc* IntcInstPtr, XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId, u16 SysMonIntrId)
|
||||
{
|
||||
int Status;
|
||||
XSysMon_Config *ConfigPtr;
|
||||
u32 IntrStatus;
|
||||
u32 IntrEnable;
|
||||
u32 AdcData[8];
|
||||
int Index;
|
||||
|
||||
printf("\r\nXADC External MUX Example. \r\n");
|
||||
|
||||
/*
|
||||
* Initialize the SysMon driver.
|
||||
*/
|
||||
ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr, ConfigPtr->BaseAddress);
|
||||
|
||||
/*
|
||||
* Self Test the System Monitor/ADC device.
|
||||
*/
|
||||
Status = XSysMon_SelfTest(SysMonInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the Channel Sequencer before configuring the Sequencer.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);
|
||||
|
||||
/*
|
||||
* Enable the following auxiliary channel pairs in the Sequencer
|
||||
* registers:
|
||||
* - Auxiliary Channel 0 & 8
|
||||
* - Auxiliary Channel 1 & 9
|
||||
* - Auxiliary Channel 2 & 10
|
||||
* - Auxiliary Channel 3 & 11
|
||||
*/
|
||||
Status = XSysMon_SetSeqChEnables(SysMonInstPtr, 0x0F0000);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
|
||||
|
||||
/*
|
||||
* Setup the interrupt system.
|
||||
*/
|
||||
Status = SysMonSetupInterruptSystem(IntcInstPtr, SysMonInstPtr,
|
||||
SysMonIntrId);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalEnable(SysMonInstPtr);
|
||||
|
||||
/*
|
||||
* Clear any pending interrupts.
|
||||
*/
|
||||
IntrStatus = XSysMon_IntrGetStatus(SysMonInstPtr);
|
||||
XSysMon_IntrClear(SysMonInstPtr, IntrStatus);
|
||||
|
||||
/*
|
||||
* Enable EOS interrupts.
|
||||
*/
|
||||
XSysMon_IntrEnable(SysMonInstPtr, XSM_IPIXR_EOS_MASK);
|
||||
IntrEnable = XSysMon_IntrGetEnabled(SysMonInstPtr);
|
||||
if ((IntrEnable & XSM_IPIXR_EOS_MASK) != XSM_IPIXR_EOS_MASK) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable external Mux and connect to Aux CH0 and Aux CH8.
|
||||
*/
|
||||
XSysMon_SetExtenalMux(SysMonInstPtr, 0x10); /* 0b'10000 to CH[4:0] */
|
||||
|
||||
/*
|
||||
* Enable simultaneous sequencer mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SIMUL);
|
||||
|
||||
while (EosFlag != TRUE);
|
||||
EosFlag = FALSE; /* Clear the Flag */
|
||||
XSysMon_GetStatus(SysMonInstPtr); /* Clear the latched status */
|
||||
|
||||
/*
|
||||
* Read the ADC converted Data from the data registers.
|
||||
*/
|
||||
/* Read ADC data for channels 0 - 3 */
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
AdcData[Index] = XSysMon_GetAdcData(SysMonInstPtr,
|
||||
XSM_CH_AUX_MIN + Index);
|
||||
}
|
||||
|
||||
/* Read ADC data for channels 8 - 11 */
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
AdcData[Index + 4] = XSysMon_GetAdcData(SysMonInstPtr,
|
||||
XSM_CH_AUX_MIN + Index + 8);
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is the Interrupt Service Routine for the XADC device.
|
||||
* It will be called by the processor when an interrupt is asserted by the
|
||||
* device.
|
||||
*
|
||||
* There are 10 different interrupts supported
|
||||
* - Over Temperature
|
||||
* - ALARM 0
|
||||
* - ALARM 1
|
||||
* - ALARM 2
|
||||
* - End of Sequence
|
||||
* - End of Conversion
|
||||
* - JTAG Locked
|
||||
* - JATG Modified
|
||||
* - Over Temperature DeActive
|
||||
* - ALARM 0 DeActive
|
||||
*
|
||||
* This function only handles EOS interrupts.
|
||||
* User of this code may need to modify the code to meet the needs of the
|
||||
* application.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the Interrupt
|
||||
* controller driver, which in our case is a pointer to the
|
||||
* driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is called within interrupt context.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void SysMonInterruptHandler(void *CallBackRef)
|
||||
{
|
||||
u32 IntrStatusValue;
|
||||
XSysMon *SysMonPtr = (XSysMon *)CallBackRef;
|
||||
|
||||
/*
|
||||
* Get the interrupt status from the device and check the value.
|
||||
*/
|
||||
IntrStatusValue = XSysMon_IntrGetStatus(SysMonPtr);
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_EOS_MASK) {
|
||||
/*
|
||||
* Set End of Conversion interrupt flag so the code
|
||||
* in application context can be aware of this interrupt.
|
||||
*/
|
||||
EosFlag = TRUE;
|
||||
XSysMon_GetStatus(SysMonPtr); /* Clear the latched status */
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all bits in Interrupt Status Register.
|
||||
*/
|
||||
XSysMon_IntrClear(SysMonPtr, IntrStatusValue);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* System Monitor/ADC. The function is application-specific since the actual
|
||||
* system may or may not have an interrupt controller. The System Monitor/ADC
|
||||
* device could be directly connected to a processor without an interrupt
|
||||
* controller. The user should modify this function to fit the application.
|
||||
*
|
||||
* @param IntcInstPtr is a pointer to the Interrupt Controller driver
|
||||
* Instance.
|
||||
* @param SysMonPtr is a pointer to the driver instance for the System
|
||||
* Monitor device which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
|
||||
* value from xparameters.h
|
||||
*
|
||||
* @return XST_SUCCESS if successful, or XST_FAILURE.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SysMonSetupInterruptSystem(XIntc* IntcInstPtr, XSysMon *SysMonPtr,
|
||||
u16 IntrId )
|
||||
{
|
||||
int Status;
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver so that it's ready to use.
|
||||
*/
|
||||
Status = XIntc_Initialize(IntcInstPtr, INTC_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the handler that will be called when an interrupt
|
||||
* for the device occurs, the handler defined above performs the
|
||||
* specific interrupt processing for the device.
|
||||
*/
|
||||
Status = XIntc_Connect(IntcInstPtr,
|
||||
IntrId,
|
||||
(XInterruptHandler) SysMonInterruptHandler,
|
||||
SysMonPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the interrupt controller so interrupts are enabled for all
|
||||
* devices that cause interrupts. Specify real mode so that the System
|
||||
* Monitor/ACD device can cause interrupts through the interrupt
|
||||
* controller.
|
||||
*/
|
||||
Status = XIntc_Start(IntcInstPtr, XIN_REAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the System Monitor/ADC device.
|
||||
*/
|
||||
XIntc_Enable(IntcInstPtr, IntrId);
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the exception table.
|
||||
*/
|
||||
Xil_ExceptionInit();
|
||||
|
||||
/*
|
||||
* Register the interrupt controller handler with the exception table.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XIntc_InterruptHandler,
|
||||
IntcInstPtr);
|
||||
|
||||
/*
|
||||
* Enable non-critical exceptions.
|
||||
*/
|
||||
Xil_ExceptionEnable();
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,577 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_intr_example.c
|
||||
*
|
||||
* This file contains a design example using the driver functions
|
||||
* of the System Monitor/ADC driver. This example here shows the usage of the
|
||||
* driver/device in interrupt mode to handle on-chip temperature and voltage
|
||||
* alarm interrupts.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* This code assumes that no Operating System is being used.
|
||||
*
|
||||
* The values of the on-chip temperature and the on-chip Vccaux voltage are read
|
||||
* from the device and then the alarm thresholds are set in such a manner that
|
||||
* the alarms occur.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sv 06/22/08 Modified the function description of the interrupt
|
||||
* handler
|
||||
* 2.00a sdm 09/26/08 Added code to return temperature value to the main
|
||||
* function. TestappPeripheral prints the temperature
|
||||
* 4.00a ktn 10/22/09 Updated the example to use HAL processor APIs/macros.
|
||||
* Updated the example to use macros that have been
|
||||
* renamed to remove _m from the name of the macro.
|
||||
* 5.03a bss 04/25/13 Modified SysMonIntrExample function to set
|
||||
* Sequencer Mode as Safe mode instead of Single
|
||||
* channel mode before configuring Sequencer registers.
|
||||
* CR #703729
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
#include "xintc.h"
|
||||
#include "xil_exception.h"
|
||||
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#ifndef TESTAPP_GEN
|
||||
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
|
||||
#define INTC_DEVICE_ID XPAR_INTC_0_DEVICE_ID
|
||||
#define INTR_ID XPAR_INTC_0_SYSMON_0_VEC_ID
|
||||
#endif
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
int SysMonIntrExample(XIntc* IntcInstancePtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId,
|
||||
int *Temp);
|
||||
|
||||
static void SysMonInterruptHandler(void *CallBackRef);
|
||||
|
||||
static int SysMonSetupInterruptSystem(XIntc* IntcInstancePtr,
|
||||
XSysMon *SysMonPtr,
|
||||
u16 IntrId );
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
static XSysMon SysMonInst; /* System Monitor driver instance */
|
||||
static XIntc InterruptController; /* Instance of the XIntc driver. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Shared variables used to test the callbacks.
|
||||
*/
|
||||
volatile static int TemperatureIntr = FALSE; /* Temperature alarm intr */
|
||||
volatile static int VccauxIntr = FALSE; /* VCCAUX alarm interrupt */
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the Interrupt example.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
int Temp;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor interrupt example, specify the parameters that
|
||||
* are generated in xparameters.h.
|
||||
*/
|
||||
Status = SysMonIntrExample(&InterruptController,
|
||||
&SysMonInst,
|
||||
SYSMON_DEVICE_ID,
|
||||
INTR_ID,
|
||||
&Temp);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
#endif /* TESTAPP_GEN */
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the System Monitor/ADC device using the
|
||||
* driver APIs.
|
||||
*
|
||||
* The function does the following tasks:
|
||||
* - Initiate the System Monitor/ADC device driver instance
|
||||
* - Run self-test on the device
|
||||
* - Reset the device
|
||||
* - Set up alarms for on-chip temperature and VCCAUX
|
||||
* - Set up sequence registers to continuously monitor on-chip temperature
|
||||
* and VCCAUX
|
||||
* - Setup interrupt system
|
||||
* - Enable interrupts
|
||||
* - Set up configuration registers to start the sequence
|
||||
* - Wait until temperature alarm interrupt or VCCAUX alarm interrupt
|
||||
* occurs
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the Interrupt Controller
|
||||
* driver Instance.
|
||||
* @param SysMonInstPtr is a pointer to the XSysMon driver Instance.
|
||||
* @param SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value
|
||||
* from xparameters.h.
|
||||
* @param SysMonIntrId is
|
||||
* XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID value from
|
||||
* xparameters.h
|
||||
* @param Temp is an output parameter, it is a pointer through which the
|
||||
* current temperature value is returned to the main function.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note This function may never return if no interrupt occurs.
|
||||
*
|
||||
****************************************************************************/
|
||||
int SysMonIntrExample(XIntc* IntcInstancePtr, XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId, u16 SysMonIntrId, int *Temp)
|
||||
{
|
||||
int Status;
|
||||
XSysMon_Config *ConfigPtr;
|
||||
u16 TempData;
|
||||
u16 VccauxData;
|
||||
u32 IntrStatus;
|
||||
|
||||
/*
|
||||
* Initialize the SysMon driver.
|
||||
*/
|
||||
ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr, ConfigPtr->BaseAddress);
|
||||
|
||||
/*
|
||||
* Self Test the System Monitor/ADC device.
|
||||
*/
|
||||
Status = XSysMon_SelfTest(SysMonInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the Channel Sequencer before configuring the Sequence
|
||||
* registers.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);
|
||||
|
||||
/*
|
||||
* Setup the Averaging to be done for the channels in the
|
||||
* Configuration 0 register as 16 samples:
|
||||
*/
|
||||
XSysMon_SetAvg(SysMonInstPtr, XSM_AVG_16_SAMPLES);
|
||||
|
||||
/*
|
||||
* Setup the Sequence register for 1st Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Bipolar Mode
|
||||
*
|
||||
* Setup the Sequence register for 16th Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Unipolar Mode
|
||||
*/
|
||||
Status = XSysMon_SetSeqInputMode(SysMonInstPtr, XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XSysMon_SetSeqAcqTime(SysMonInstPtr, XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the averaging on the following channels in the Sequencer
|
||||
* registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqAvgEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the following channels in the Sequencer registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqChEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
|
||||
|
||||
|
||||
/*
|
||||
* Enable the Channel Sequencer in continuous sequencer cycling mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);
|
||||
|
||||
/*
|
||||
* Wait till the End of Sequence occurs
|
||||
*/
|
||||
XSysMon_GetStatus(SysMonInstPtr); /* Clear the old status */
|
||||
while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) !=
|
||||
XSM_SR_EOS_MASK);
|
||||
|
||||
/*
|
||||
* Read the ADC converted Data from the data registers for on-chip
|
||||
* temperature and on-chip VCCAUX voltage.
|
||||
*/
|
||||
TempData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);
|
||||
VccauxData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCAUX);
|
||||
|
||||
/*
|
||||
* Convert the ADC data into temperature
|
||||
*/
|
||||
*Temp = XSysMon_RawToTemperature(TempData);
|
||||
|
||||
/*
|
||||
* Disable all the alarms in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
|
||||
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for the on-chip temperature and
|
||||
* VCCAUX High limit and lower limit so that the alarms DONOT occur.
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_UPPER, 0xFFFF);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_LOWER, 0xFFFF);
|
||||
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_UPPER, 0xFFFF);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_LOWER, 0x0);
|
||||
|
||||
/*
|
||||
* Setup the interrupt system.
|
||||
*/
|
||||
Status = SysMonSetupInterruptSystem(IntcInstancePtr,
|
||||
SysMonInstPtr,
|
||||
SysMonIntrId);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear any bits set in the Interrupt Status Register.
|
||||
*/
|
||||
IntrStatus = XSysMon_IntrGetStatus(SysMonInstPtr);
|
||||
XSysMon_IntrClear(SysMonInstPtr, IntrStatus);
|
||||
|
||||
|
||||
/*
|
||||
* Enable Alarm 0 interrupt for on-chip temperature and Alarm 2
|
||||
* interrupt for on-chip VCCAUX.
|
||||
*/
|
||||
XSysMon_IntrEnable(SysMonInstPtr,
|
||||
XSM_IPIXR_TEMP_MASK |
|
||||
XSM_IPIXR_VCCAUX_MASK);
|
||||
|
||||
/*
|
||||
* Enable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalEnable(SysMonInstPtr);
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for
|
||||
* On-chip Temperature High limit
|
||||
* On-chip Temperature Low limit
|
||||
* VCCAUX High limit
|
||||
* VCCAUX Low limit
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_UPPER,
|
||||
TempData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_LOWER,
|
||||
TempData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_UPPER,
|
||||
VccauxData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_LOWER,
|
||||
VccauxData + 0x007F);
|
||||
|
||||
|
||||
/*
|
||||
* Enable Alarm 0 for on-chip temperature and Alarm 2 for on-chip
|
||||
* VCCAUX in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, (XSM_CFR1_ALM_VCCAUX_MASK |
|
||||
XSM_CFR1_ALM_TEMP_MASK));
|
||||
|
||||
|
||||
/*
|
||||
* Wait until an Alarm 0 or Alarm 2 interrupt occurs.
|
||||
*/
|
||||
while (1) {
|
||||
if (TemperatureIntr == TRUE) {
|
||||
/*
|
||||
* Alarm 0 - Temperature alarm interrupt has occurred.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
if (VccauxIntr == TRUE) {
|
||||
/*
|
||||
* Alarm 2 - VCCAUX alarm interrupt has occurred.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalDisable(SysMonInstPtr);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is the Interrupt Service Routine for the System Monitor device.
|
||||
* It will be called by the processor whenever an interrupt is asserted
|
||||
* by the device.
|
||||
*
|
||||
* There are 10 different interrupts supported
|
||||
* - Over Temperature
|
||||
* - ALARM 0
|
||||
* - ALARM 1
|
||||
* - ALARM 2
|
||||
* - End of Sequence
|
||||
* - End of Conversion
|
||||
* - JTAG Locked
|
||||
* - JATG Modified
|
||||
* - Over Temperature DeActive
|
||||
* - ALARM 0 DeActive
|
||||
*
|
||||
* This function only handles ALARM 0 and ALARM 2 interrupts. User of this
|
||||
* code may need to modify the code to meet needs of the application.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the Interrupt
|
||||
* controller driver, which in our case is a pointer to the
|
||||
* driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is called within interrupt context.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void SysMonInterruptHandler(void *CallBackRef)
|
||||
{
|
||||
u32 IntrStatusValue;
|
||||
XSysMon *SysMonPtr = (XSysMon *)CallBackRef;
|
||||
|
||||
/*
|
||||
* Get the interrupt status from the device and check the value.
|
||||
*/
|
||||
IntrStatusValue = XSysMon_IntrGetStatus(SysMonPtr);
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_TEMP_MASK) {
|
||||
/*
|
||||
* Set Temperature interrupt flag so the code
|
||||
* in application context can be aware of this interrupt.
|
||||
*/
|
||||
TemperatureIntr = TRUE;
|
||||
}
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_VCCAUX_MASK) {
|
||||
/*
|
||||
* Set VCCAUX interrupt flag so the code in application context
|
||||
* can be aware of this interrupt.
|
||||
*/
|
||||
|
||||
VccauxIntr = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all bits in Interrupt Status Register.
|
||||
*/
|
||||
XSysMon_IntrClear(SysMonPtr, IntrStatusValue);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* System Monitor/ADC. The function is application-specific since the actual
|
||||
* system may or may not have an interrupt controller. The System Monitor/ADC
|
||||
* device could be directly connected to a processor without an interrupt
|
||||
* controller. The user should modify this function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the Interrupt Controller
|
||||
* driver Instance.
|
||||
* @param SysMonPtr is a pointer to the driver instance for the System
|
||||
* Monitor device which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
|
||||
* value from xparameters.h.
|
||||
*
|
||||
* @return XST_SUCCESS if successful, or XST_FAILURE.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SysMonSetupInterruptSystem(XIntc* IntcInstancePtr,
|
||||
XSysMon *SysMonPtr,
|
||||
u16 IntrId )
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/*
|
||||
* Initialize the interrupt controller driver so that it's ready to use.
|
||||
*/
|
||||
Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Connect the handler that will be called when an interrupt
|
||||
* for the device occurs, the handler defined above performs the
|
||||
* specific interrupt processing for the device.
|
||||
*/
|
||||
Status = XIntc_Connect(IntcInstancePtr,
|
||||
IntrId,
|
||||
(XInterruptHandler) SysMonInterruptHandler,
|
||||
SysMonPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/*
|
||||
* Start the interrupt controller so interrupts are enabled for all
|
||||
* devices that cause interrupts. Specify real mode so that the System
|
||||
* Monitor/ACD device can cause interrupts through the interrupt
|
||||
* controller.
|
||||
*/
|
||||
Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Enable the interrupt for the System Monitor/ADC device.
|
||||
*/
|
||||
XIntc_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
|
||||
/*
|
||||
* Initialize the exception table.
|
||||
*/
|
||||
Xil_ExceptionInit();
|
||||
|
||||
/*
|
||||
* Register the interrupt controller handler with the exception table.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XIntc_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
/*
|
||||
* Enable exceptions.
|
||||
*/
|
||||
Xil_ExceptionEnable();
|
||||
|
||||
#endif /* TESTAPP_GEN */
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,865 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_intr_printf_example.c
|
||||
*
|
||||
* This file contains a design example using the driver functions
|
||||
* of the System Monitor/ADC driver. This example here shows the usage of the
|
||||
* driver/device in interrupt mode to handle on-chip temperature and voltage
|
||||
* alarm interrupts.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* This code assumes that no Operating System is being used.
|
||||
*
|
||||
* The values of the on-chip Temperature, VccInt voltage and VccAux voltage are
|
||||
* read from the device and then the alarm thresholds are set in such a manner
|
||||
* that the alarms occur.
|
||||
*
|
||||
* This examples also assumes that there is a STDIO device in the system.
|
||||
* This example has floating point calculations and uses printfs for outputting
|
||||
* floating point data, therefore the memory allocated for the Stack must be
|
||||
* more.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sv 06/22/08 Added printfs and used conversion macros
|
||||
* 4.00a ktn 10/22/09 Updated the example to use HAL Processor APIs/macros.
|
||||
* Updated the example to use macros that have been
|
||||
* renamed to remove _m from the name of the macro.
|
||||
* 5.01a bss 03/13/12 Updated for Zynq.
|
||||
* 5.03a bss 04/25/13 Modified SysMonIntrExample function to set
|
||||
* Sequencer Mode as Safe mode instead of Single
|
||||
* channel mode before configuring Sequencer registers.
|
||||
* CR #703729
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
#include "stdio.h"
|
||||
#include "xil_exception.h"
|
||||
|
||||
#ifdef XPAR_INTC_0_DEVICE_ID
|
||||
#include "xintc.h"
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include "xscugic.h"
|
||||
#include "xil_printf.h"
|
||||
#endif
|
||||
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
|
||||
|
||||
|
||||
#ifdef XPAR_INTC_0_DEVICE_ID /* Interrupt Controller */
|
||||
#define INTC_DEVICE_ID XPAR_INTC_0_DEVICE_ID
|
||||
#define INTR_ID XPAR_INTC_0_SYSMON_0_VEC_ID
|
||||
#else /* SCUGIC Interrupt Controller */
|
||||
#define INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
#define INTR_ID XPAR_FABRIC_SYSMON_0_VEC_ID
|
||||
#endif /* XPAR_INTC_0_DEVICE_ID */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following are the definitions of the Alarm Limits to be programmed to
|
||||
* the threshold registers. The user needs to change these according to the
|
||||
* needs of the application.
|
||||
*/
|
||||
#define TEST_TEMP_UPPER 85.0f /* Temperature Upper Alarm Limit */
|
||||
#define TEST_TEMP_LOWER 65.0f /* Temperature Lower Alarm Limit */
|
||||
|
||||
#define TEST_VCCINT_UPPER 1.05f /* VccInt Upper Alarm Limit */
|
||||
#define TEST_VCCINT_LOWER 0.95f /* VccInt Lower Alarm Limit */
|
||||
|
||||
#define TEST_VCCAUX_UPPER 2.625f /* VccAux Upper Alarm Limit */
|
||||
#define TEST_VCCAUX_LOWER 2.375f /* VccAux Lower Alarm Limit */
|
||||
|
||||
#define printf xil_printf /* Small foot-print printf function */
|
||||
|
||||
#ifdef XPAR_INTC_0_DEVICE_ID /* Interrupt Controller */
|
||||
#define INTC XIntc
|
||||
#define INTC_HANDLER XIntc_InterruptHandler
|
||||
#else /* SCUGIC Interrupt Controller */
|
||||
#define INTC XScuGic
|
||||
#define INTC_HANDLER XScuGic_InterruptHandler
|
||||
#endif /* XPAR_INTC_0_DEVICE_ID */
|
||||
|
||||
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
static int SysMonIntrExample(INTC* IntcInstPtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId);
|
||||
|
||||
|
||||
static void SysMonInterruptHandler(void *CallBackRef);
|
||||
|
||||
static int SysMonSetupInterruptSystem(INTC* IntcInstPtr,
|
||||
XSysMon *SysMonPtr,
|
||||
u16 IntrId );
|
||||
|
||||
static int SysMonFractionToInt(float FloatNum);
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
static XSysMon SysMonInst; /* System Monitor driver instance */
|
||||
static INTC IntcInst; /* Instance of the XIntc driver */
|
||||
|
||||
/*
|
||||
* Shared variables used to test the callbacks.
|
||||
*/
|
||||
volatile static int TempIntrActive = FALSE; /* Temperature alarm intr active */
|
||||
volatile static int VccIntIntr = FALSE; /* VCCINT alarm interrupt */
|
||||
volatile static int VccAuxIntr = FALSE; /* VCCAUX alarm interrupt */
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the Interrupt example.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor interrupt example, specify the parameters that
|
||||
* are generated in xparameters.h.
|
||||
*/
|
||||
Status = SysMonIntrExample(&IntcInst, &SysMonInst, SYSMON_DEVICE_ID,
|
||||
INTR_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the System Monitor/ADC device using the
|
||||
* driver APIs.
|
||||
*
|
||||
* The function does the following tasks:
|
||||
* - Initiate the System Monitor/ADC device driver instance
|
||||
* - Run self-test on the device
|
||||
* - Reset the device
|
||||
* - Set up alarms for on-chip temperature, VCCINT and VCCAUX
|
||||
* - Set up sequence registers to continuously monitor on-chip
|
||||
* temperature, VCCINT and VCCAUX
|
||||
* - Setup interrupt system
|
||||
* - Enable interrupts
|
||||
* - Set up configuration registers to start the sequence
|
||||
* - Wait until temperature alarm interrupt or VCCINT alarm interrupt
|
||||
* or VCCAUX alarm interrupt occurs
|
||||
*
|
||||
* @param IntcInstPtr is a pointer to the Interrupt Controller
|
||||
* driver Instance.
|
||||
* @param SysMonInstPtr is a pointer to the XSysMon driver Instance.
|
||||
* @param SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID
|
||||
* value from xparameters.h.
|
||||
* @param SysMonIntrId is
|
||||
* XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note This function may never return if no interrupt occurs.
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SysMonIntrExample(INTC* IntcInstPtr, XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId, u16 SysMonIntrId)
|
||||
{
|
||||
int Status;
|
||||
XSysMon_Config *ConfigPtr;
|
||||
u32 Data;
|
||||
u32 TempRawData;
|
||||
u32 VccAuxRawData;
|
||||
u32 VccIntRawData;
|
||||
float TempData;
|
||||
float VccAuxData;
|
||||
float VccIntData;
|
||||
float MaxData;
|
||||
float MinData;
|
||||
u32 IntrStatus;
|
||||
|
||||
printf("\r\nEntering the SysMon Interrupt Example. \r\n");
|
||||
|
||||
/*
|
||||
* Initialize the SysMon driver.
|
||||
*/
|
||||
ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr, ConfigPtr->BaseAddress);
|
||||
|
||||
/*
|
||||
* Self Test the System Monitor/ADC device.
|
||||
*/
|
||||
Status = XSysMon_SelfTest(SysMonInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the Channel Sequencer before configuring the Sequence
|
||||
* registers.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);
|
||||
|
||||
/*
|
||||
* Setup the Averaging to be done for the channels in the
|
||||
* Configuration 0 register as 16 samples:
|
||||
*/
|
||||
XSysMon_SetAvg(SysMonInstPtr, XSM_AVG_16_SAMPLES);
|
||||
|
||||
/*
|
||||
* Setup the Sequence register for 1st Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Bipolar Mode
|
||||
*
|
||||
* Setup the Sequence register for 16th Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Unipolar Mode
|
||||
*/
|
||||
Status = XSysMon_SetSeqInputMode(SysMonInstPtr, XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XSysMon_SetSeqAcqTime(SysMonInstPtr, XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the averaging on the following channels in the Sequencer
|
||||
* registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCINT supply sensor
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
* - Calibration Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqAvgEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCINT |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_CALIB);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the following channels in the Sequencer registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCINT supply sensor
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
* - Calibration Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqChEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCINT |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_CALIB);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
|
||||
|
||||
/*
|
||||
* Set the Calibration enables.
|
||||
*/
|
||||
XSysMon_SetCalibEnables(SysMonInstPtr,
|
||||
XSM_CFR1_CAL_PS_GAIN_OFFSET_MASK |
|
||||
XSM_CFR1_CAL_ADC_GAIN_OFFSET_MASK);
|
||||
|
||||
/*
|
||||
* Enable the Channel Sequencer in continuous sequencer cycling mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);
|
||||
|
||||
/*
|
||||
* Wait till the End of Sequence occurs.
|
||||
*/
|
||||
XSysMon_GetStatus(SysMonInstPtr); /* Clear the old status */
|
||||
while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) !=
|
||||
XSM_SR_EOS_MASK);
|
||||
|
||||
/*
|
||||
* Read the ADC converted Data from the data registers for on-chip
|
||||
* temperature, on-chip VCCINT voltage and on-chip VCCAUX voltage.
|
||||
*/
|
||||
TempRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);
|
||||
VccIntRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT);
|
||||
VccAuxRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCAUX);
|
||||
|
||||
/*
|
||||
* Convert the Raw Data to Degrees Centigrade and Voltage.
|
||||
*/
|
||||
TempData = XSysMon_RawToTemperature(TempRawData);
|
||||
VccIntData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
VccAuxData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
|
||||
|
||||
printf("\r\nThe Current Temperature is %0d.%03d Centigrade.\r\n",
|
||||
(int)(TempData), SysMonFractionToInt(TempData));
|
||||
printf("\r\nThe Current VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(VccIntData), SysMonFractionToInt(VccIntData));
|
||||
printf("\r\nThe Current VCCAUX is %0d.%03d Volts. \r\n",
|
||||
(int)(VccAuxData), SysMonFractionToInt(VccAuxData));
|
||||
|
||||
/*
|
||||
* Disable all the alarms in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for the on-chip temperature and
|
||||
* VCCAUX/VCCINT High limit and lower limit so that the alarms
|
||||
* DONOT occur.
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_UPPER,
|
||||
XSysMon_TemperatureToRaw(TEST_TEMP_UPPER));
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_LOWER,
|
||||
XSysMon_TemperatureToRaw(TEST_TEMP_LOWER));
|
||||
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER,
|
||||
XSysMon_VoltageToRaw(TEST_VCCINT_UPPER));
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER,
|
||||
XSysMon_VoltageToRaw(TEST_VCCINT_LOWER));
|
||||
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_UPPER,
|
||||
XSysMon_VoltageToRaw(TEST_VCCAUX_UPPER));
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_LOWER,
|
||||
XSysMon_VoltageToRaw(TEST_VCCAUX_LOWER));
|
||||
|
||||
/*
|
||||
* Setup the interrupt system.
|
||||
*/
|
||||
Status = SysMonSetupInterruptSystem(IntcInstPtr,
|
||||
SysMonInstPtr,
|
||||
SysMonIntrId);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear any bits set in the Interrupt Status Register.
|
||||
*/
|
||||
IntrStatus = XSysMon_IntrGetStatus(SysMonInstPtr);
|
||||
XSysMon_IntrClear(SysMonInstPtr, IntrStatus);
|
||||
|
||||
|
||||
/*
|
||||
* Enable Alarm 0 interrupt for on-chip temperature,
|
||||
* Alarm 1 interrupt for on-chip VCCINT and
|
||||
* Alarm 2 interrupt for on-chip VCCAUX.
|
||||
*/
|
||||
XSysMon_IntrEnable(SysMonInstPtr,
|
||||
XSM_IPIXR_TEMP_MASK |
|
||||
XSM_IPIXR_VCCINT_MASK |
|
||||
XSM_IPIXR_VCCAUX_MASK );
|
||||
|
||||
/*
|
||||
* Enable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalEnable(SysMonInstPtr);
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for
|
||||
* - On-chip Temperature High/Low limit
|
||||
* - VCCINT High/Low limit
|
||||
* - VCCAUX High/Low limit
|
||||
* so that the Alarms occur.
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_UPPER,
|
||||
XSysMon_TemperatureToRaw(TempData - 10));
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_LOWER,
|
||||
XSysMon_TemperatureToRaw(TempData - 20));
|
||||
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER,
|
||||
XSysMon_VoltageToRaw(VccIntData - 0.2));
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER,
|
||||
XSysMon_VoltageToRaw(VccIntData + 0.2));
|
||||
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_UPPER,
|
||||
XSysMon_VoltageToRaw(VccAuxData - 0.2));
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_LOWER,
|
||||
XSysMon_VoltageToRaw(VccAuxData + 0.2));
|
||||
|
||||
|
||||
/*
|
||||
* Read the Temperature Alarm Threshold registers.
|
||||
*/
|
||||
Data = XSysMon_GetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_UPPER);
|
||||
MaxData = XSysMon_RawToTemperature(Data);
|
||||
printf("\r\nTemperature Alarm(0) ");
|
||||
printf("HIGH Threshold is %0d.%03d Centigrade. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
|
||||
Data = XSysMon_GetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_LOWER);
|
||||
MinData = XSysMon_RawToTemperature(Data);
|
||||
printf("Temperature Alarm(0) ");
|
||||
printf("LOW Threshold is %0d.%03d Centigrade. \r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
/*
|
||||
* Read the VCCINT Alarm Threshold registers.
|
||||
*/
|
||||
Data = XSysMon_GetAlarmThreshold(SysMonInstPtr,
|
||||
XSM_ATR_VCCINT_UPPER);
|
||||
MaxData = XSysMon_RawToVoltage(Data);
|
||||
printf("VCCINT Alarm(1) HIGH Threshold is %0d.%03d Volts. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
|
||||
Data = XSysMon_GetAlarmThreshold(SysMonInstPtr,
|
||||
XSM_ATR_VCCINT_LOWER);
|
||||
MinData = XSysMon_RawToVoltage(Data);
|
||||
printf("VCCINT Alarm(1) LOW Threshold is %0d.%03d Volts. \r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
/*
|
||||
* Read the VCCAUX Alarm Threshold registers.
|
||||
*/
|
||||
Data = XSysMon_GetAlarmThreshold(SysMonInstPtr,
|
||||
XSM_ATR_VCCAUX_UPPER);
|
||||
MaxData = XSysMon_RawToVoltage(Data);
|
||||
printf("VCCAUX Alarm(2) HIGH Threshold is %0d.%03d Volts. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
|
||||
Data = XSysMon_GetAlarmThreshold(SysMonInstPtr,
|
||||
XSM_ATR_VCCAUX_LOWER);
|
||||
MinData = XSysMon_RawToVoltage(Data);
|
||||
printf("VCCAUX Alarm(2) LOW Threshold is %0d.%03d Volts. \r\n\r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
|
||||
/*
|
||||
* Enable Alarm 0 for on-chip temperature , Alarm 1 for on-chip VCCINT
|
||||
* and Alarm 2 for on-chip VCCAUX in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, (XSM_CFR1_ALM_TEMP_MASK |
|
||||
XSM_CFR1_ALM_VCCINT_MASK |
|
||||
XSM_CFR1_ALM_VCCAUX_MASK));
|
||||
|
||||
/*
|
||||
* Wait until an Alarm 0 or Alarm 1 or Alarm 2 interrupt occurs.
|
||||
*/
|
||||
while (1) {
|
||||
if (TempIntrActive == TRUE) {
|
||||
/*
|
||||
* Alarm 0 - Temperature alarm interrupt has occurred.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
printf("Alarm 0 - Temperature alarm has occured \r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (VccIntIntr == TRUE) {
|
||||
/*
|
||||
* Alarm 1 - VCCINT alarm interrupt has occurred.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
printf("Alarm 1 - VCCINT alarm has occured \r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (VccAuxIntr == TRUE) {
|
||||
/*
|
||||
* Alarm 2 - VCCAUX alarm interrupt has occurred.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
printf("Alarm 2 - VCCAUX alarm has occured \r\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the on-chip Temperature Data (Current/Maximum/Minimum)
|
||||
* from the ADC data registers.
|
||||
*/
|
||||
TempRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);
|
||||
TempData = XSysMon_RawToTemperature(TempRawData);
|
||||
|
||||
TempRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MAX_TEMP);
|
||||
MaxData = XSysMon_RawToTemperature(TempRawData);
|
||||
|
||||
TempRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MIN_TEMP);
|
||||
MinData = XSysMon_RawToTemperature(TempRawData);
|
||||
|
||||
printf("\r\nThe Current Temperature is %0d.%03d Centigrade.\r\n",
|
||||
(int)(TempData), SysMonFractionToInt(TempData));
|
||||
printf("The Maximum Temperature is %0d.%03d Centigrade. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
printf("The Minimum Temperature is %0d.%03d Centigrade. \r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
|
||||
/*
|
||||
* Read the VccInt Votage Data (Current/Maximum/Minimum) from the
|
||||
* ADC data registers.
|
||||
*/
|
||||
VccIntRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT);
|
||||
VccIntData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
|
||||
VccIntRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MAX_VCCINT);
|
||||
MaxData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
|
||||
VccIntRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MIN_VCCINT);
|
||||
MinData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
|
||||
printf("\r\nThe Current VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(VccIntData), SysMonFractionToInt(VccIntData));
|
||||
printf("The Maximum VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
printf("The Minimum VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
|
||||
/*
|
||||
* Read the VccAux Voltage Data (Current/Maximum/Minimum) from the
|
||||
* ADC data registers.
|
||||
*/
|
||||
VccAuxRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCAUX);
|
||||
VccAuxData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
|
||||
VccAuxRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MAX_VCCAUX);
|
||||
MaxData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
|
||||
VccAuxRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MIN_VCCAUX);
|
||||
MinData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
|
||||
printf("\r\nThe Current VCCAUX is %0d.%03d Volts. \r\n",
|
||||
(int)(VccAuxData), SysMonFractionToInt(VccAuxData));
|
||||
printf("The Maximum VCCAUX is %0d.%03d Volts. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
printf("The Minimum VCCAUX is %0d.%03d Volts. \r\n\r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
printf("Exiting the SysMon Interrupt Example. \r\n");
|
||||
|
||||
/*
|
||||
* Disable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalDisable(SysMonInstPtr);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is the Interrupt Service Routine for the System Monitor device.
|
||||
* It will be called by the processor whenever an interrupt is asserted
|
||||
* by the device.
|
||||
*
|
||||
* There are 10 different interrupts supported
|
||||
* - Over Temperature
|
||||
* - ALARM 0
|
||||
* - ALARM 1
|
||||
* - ALARM 2
|
||||
* - End of Sequence
|
||||
* - End of Conversion
|
||||
* - JTAG Locked
|
||||
* - JATG Modified
|
||||
* - Over Temperature DeActive
|
||||
* - ALARM 0 DeActive
|
||||
*
|
||||
* This function only handles ALARM 0, ALARM 1 and ALARM 2 interrupts.
|
||||
* User of this code may need to modify the code to meet the needs of the
|
||||
* application.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the Interrupt
|
||||
* controller driver, which in our case is a pointer to the
|
||||
* driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is called within interrupt context.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void SysMonInterruptHandler(void *CallBackRef)
|
||||
{
|
||||
u32 IntrStatusValue;
|
||||
XSysMon *SysMonPtr = (XSysMon *)CallBackRef;
|
||||
|
||||
/*
|
||||
* Get the interrupt status from the device and check the value.
|
||||
*/
|
||||
IntrStatusValue = XSysMon_IntrGetStatus(SysMonPtr);
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_TEMP_MASK) {
|
||||
/*
|
||||
* Set Temperature interrupt flag so the code
|
||||
* in application context can be aware of this interrupt.
|
||||
*/
|
||||
TempIntrActive = TRUE;
|
||||
}
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_VCCINT_MASK) {
|
||||
/*
|
||||
* Set VCCINT interrupt flag so the code in application context
|
||||
* can be aware of this interrupt.
|
||||
*/
|
||||
VccIntIntr = TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_VCCAUX_MASK) {
|
||||
/*
|
||||
* Set VCCAUX interrupt flag so the code in application context
|
||||
* can be aware of this interrupt.
|
||||
*/
|
||||
VccAuxIntr = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all bits in Interrupt Status Register.
|
||||
*/
|
||||
XSysMon_IntrClear(SysMonPtr, IntrStatusValue);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* System Monitor/ADC. The function is application-specific since the actual
|
||||
* system may or may not have an interrupt controller. The System Monitor/ADC
|
||||
* device could be directly connected to a processor without an interrupt
|
||||
* controller. The user should modify this function to fit the application.
|
||||
*
|
||||
* @param IntcInstPtr is a pointer to the Interrupt Controller driver
|
||||
* Instance.
|
||||
* @param SysMonPtr is a pointer to the driver instance for the System
|
||||
* Monitor device which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
|
||||
* value from xparameters.h
|
||||
*
|
||||
* @return XST_SUCCESS if successful, or XST_FAILURE.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SysMonSetupInterruptSystem(INTC* IntcInstPtr, XSysMon *SysMonPtr,
|
||||
u16 IntrId )
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifdef XPAR_INTC_0_DEVICE_ID
|
||||
/*
|
||||
* Initialize the interrupt controller driver so that it's ready to
|
||||
* use.
|
||||
*/
|
||||
Status = XIntc_Initialize(IntcInstPtr, INTC_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the handler that will be called when an interrupt
|
||||
* for the device occurs, the handler defined above performs the
|
||||
* specific interrupt processing for the device.
|
||||
*/
|
||||
Status = XIntc_Connect(IntcInstPtr,
|
||||
IntrId,
|
||||
(XInterruptHandler) SysMonInterruptHandler,
|
||||
SysMonPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the interrupt controller so interrupts are enabled for all
|
||||
* devices that cause interrupts. Specify real mode so that the System
|
||||
* Monitor/ACD device can cause interrupts through the interrupt
|
||||
* controller.
|
||||
*/
|
||||
Status = XIntc_Start(IntcInstPtr, XIN_REAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the System Monitor/ADC device.
|
||||
*/
|
||||
XIntc_Enable(IntcInstPtr, IntrId);
|
||||
#else
|
||||
|
||||
XScuGic_Config *IntcConfig;
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver so that it is ready to
|
||||
* use.
|
||||
*/
|
||||
IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
|
||||
if (NULL == IntcConfig) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XScuGic_CfgInitialize(IntcInstPtr, IntcConfig,
|
||||
IntcConfig->CpuBaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
XScuGic_SetPriorityTriggerType(IntcInstPtr, IntrId, 0xA0, 0x3);
|
||||
|
||||
/*
|
||||
* Connect the interrupt handler that will be called when an
|
||||
* interrupt occurs for the device.
|
||||
*/
|
||||
Status = XScuGic_Connect(IntcInstPtr, IntrId,
|
||||
(Xil_ExceptionHandler)SysMonInterruptHandler,
|
||||
SysMonPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the Timer device.
|
||||
*/
|
||||
XScuGic_Enable(IntcInstPtr, IntrId);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the exception table.
|
||||
*/
|
||||
Xil_ExceptionInit();
|
||||
|
||||
/*
|
||||
* Register the interrupt controller handler with the exception table.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) INTC_HANDLER,
|
||||
IntcInstPtr);
|
||||
|
||||
/*
|
||||
* Enable non-critical exceptions.
|
||||
*/
|
||||
Xil_ExceptionEnable();
|
||||
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/*
|
||||
*
|
||||
* This function converts the fraction part of the given floating point number
|
||||
* (after the decimal point)to an integer.
|
||||
*
|
||||
* @param FloatNum is the floating point number.
|
||||
*
|
||||
* @return Integer number to a precision of 3 digits.
|
||||
*
|
||||
* @note
|
||||
* This function is used in the printing of floating point data to a STDIO
|
||||
* device using the xil_printf function. The xil_printf is a very small
|
||||
* foot-print printf function and does not support the printing of floating
|
||||
* point numbers.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int SysMonFractionToInt(float FloatNum)
|
||||
{
|
||||
float Temp;
|
||||
|
||||
Temp = FloatNum;
|
||||
if (FloatNum < 0) {
|
||||
Temp = -(FloatNum);
|
||||
}
|
||||
|
||||
return( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));
|
||||
}
|
|
@ -0,0 +1,358 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_low_level_example.c
|
||||
*
|
||||
* This file contains a design example using the basic driver functions
|
||||
* of the System Monitor driver. The example here shows using the
|
||||
* driver/device in polled mode to check the on-chip temperature and voltages.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* The values of the on-chip temperature and the on-chip Vccaux voltage are read
|
||||
* from the device and then the alarm thresholds are set in such a manner that
|
||||
* the alarms occur.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sv 07/07/08 Changed the example to read 16 bits of data from the
|
||||
* the ADC data registers.
|
||||
* 4.00a ktn 10/22/09 Updated the example to use macros that have been
|
||||
* renamed to remove _m from the name of the macro.
|
||||
* 5.01a bss 03/13/12 Modified while loop condition to wait for EOS bit
|
||||
* to become high
|
||||
* 5.03a bss 04/25/13 Modified SysMonLowLevelExample function to set
|
||||
* Sequencer Mode as Safe mode instead of Single
|
||||
* channel mode before configuring Sequencer registers.
|
||||
* CR #703729
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon_hw.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define SYSMON_BASEADDR XPAR_SYSMON_0_BASEADDR
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
int SysMonLowLevelExample(u32 BaseAddress);
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the example given in this file.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor Low level example, specify the Base Address that
|
||||
* is generated in xparameters.h.
|
||||
*/
|
||||
Status = SysMonLowLevelExample(SYSMON_BASEADDR);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the System Monitor device using the
|
||||
* basic driver functions.
|
||||
* The function does the following tasks:
|
||||
* - Reset the device
|
||||
* - Setup alarm thresholds for on-chip temperature and VCCAUX.
|
||||
* - Setup sequence registers to continuously monitor on-chip temperature
|
||||
* and VCCAUX.
|
||||
* - Setup configuration registers to start the sequence.
|
||||
* - Read latest on-chip temperature and VCCAUX, as well as their maximum
|
||||
* and minimum values. Also check if alarm(s) are set.
|
||||
*
|
||||
* @param BaseAddress is the XPAR_<SYSMON_ADC_instance>_BASEADDRESS value
|
||||
* from xparameters.h.
|
||||
*
|
||||
* @return XST_SUCCESS
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
****************************************************************************/
|
||||
int SysMonLowLevelExample(u32 BaseAddress)
|
||||
{
|
||||
u32 RegValue;
|
||||
u16 TempData;
|
||||
u16 VccauxData;
|
||||
|
||||
/*
|
||||
* Reset the device.
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress, XSM_SRR_OFFSET, XSM_SRR_IPRST_MASK);
|
||||
|
||||
/*
|
||||
* Disable the Channel Sequencer before configuring the Sequence
|
||||
* registers.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_CFR1_OFFSET) &
|
||||
(~ XSM_CFR1_SEQ_VALID_MASK);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_CFR1_OFFSET, RegValue |
|
||||
XSM_CFR1_SEQ_SAFEMODE_MASK);
|
||||
|
||||
|
||||
/*
|
||||
* Setup the Averaging to be done for the channels in the
|
||||
* Configuration 0 register as 16 samples:
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress,
|
||||
XSM_CFR0_OFFSET) & (~XSM_CFR0_AVG_VALID_MASK);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_CFR0_OFFSET,
|
||||
RegValue | XSM_CFR0_AVG16_MASK);
|
||||
|
||||
/*
|
||||
* Setup the Sequence register for 1st Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Bipolar Mode
|
||||
*
|
||||
* Setup the Sequence register for 16th Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Unipolar Mode
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set the Acquisition time for the specified channels.
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress,XSM_SEQ07_OFFSET,
|
||||
(XSM_SEQ_CH_AUX00 | XSM_SEQ_CH_AUX15) >>
|
||||
XSM_SEQ_CH_AUX_SHIFT);
|
||||
|
||||
/*
|
||||
* Set the input mode for the specified channels.
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress, XSM_SEQ05_OFFSET,
|
||||
XSM_SEQ_CH_AUX00 >> XSM_SEQ_CH_AUX_SHIFT);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Enable the averaging on the following channels in the Sequencer
|
||||
* registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress,XSM_SEQ02_OFFSET,
|
||||
XSM_SEQ_CH_TEMP | XSM_SEQ_CH_VCCAUX);
|
||||
|
||||
XSysMon_WriteReg(BaseAddress, XSM_SEQ03_OFFSET,
|
||||
(XSM_SEQ_CH_AUX00 | XSM_SEQ_CH_AUX15) >>
|
||||
XSM_SEQ_CH_AUX_SHIFT);
|
||||
|
||||
|
||||
/*
|
||||
* Enable the following channels in the Sequencer registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress, XSM_SEQ00_OFFSET,
|
||||
XSM_SEQ_CH_TEMP | XSM_SEQ_CH_VCCAUX);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_SEQ01_OFFSET,
|
||||
(XSM_SEQ_CH_AUX00 | XSM_SEQ_CH_AUX15) >>
|
||||
XSM_SEQ_CH_AUX_SHIFT);
|
||||
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress, XSM_CFR2_OFFSET, 32 <<
|
||||
XSM_CFR2_CD_SHIFT);
|
||||
|
||||
|
||||
/*
|
||||
* Enable the Channel Sequencer in continuous sequencer cycling mode.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_CFR1_OFFSET) &
|
||||
(~ XSM_CFR1_SEQ_VALID_MASK);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_CFR1_OFFSET, RegValue |
|
||||
XSM_CFR1_SEQ_CONTINPASS_MASK);
|
||||
|
||||
|
||||
/*
|
||||
* Wait till the End of Sequence occurs
|
||||
*/
|
||||
XSysMon_ReadReg(BaseAddress, XSM_SR_OFFSET); /* Clear the old status */
|
||||
while (((XSysMon_ReadReg(BaseAddress, XSM_SR_OFFSET)) &
|
||||
XSM_SR_EOS_MASK) != XSM_SR_EOS_MASK);
|
||||
|
||||
|
||||
/*
|
||||
* Read the current value of the on-chip temperature.
|
||||
*/
|
||||
TempData = XSysMon_ReadReg(BaseAddress, XSM_TEMP_OFFSET);
|
||||
/*
|
||||
* Read the current value of the on-chip VCCAUX voltage.
|
||||
*/
|
||||
VccauxData = XSysMon_ReadReg(BaseAddress, XSM_VCCAUX_OFFSET);
|
||||
|
||||
|
||||
/*
|
||||
* Disable all the alarms in the Configuration Register 1.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_CFR1_OFFSET);
|
||||
RegValue |= XSM_CFR1_ALM_ALL_MASK;
|
||||
XSysMon_WriteReg(BaseAddress, XSM_CFR1_OFFSET, RegValue);
|
||||
|
||||
/*
|
||||
* Setup Alarm threshold registers for
|
||||
* On-chip Temperature High limit
|
||||
* VCCAUX High limit
|
||||
* VCCAUX Low limit
|
||||
*/
|
||||
XSysMon_WriteReg(BaseAddress, XSM_ATR_TEMP_UPPER_OFFSET,
|
||||
TempData - 0x6F);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_ATR_VCCAUX_UPPER_OFFSET,
|
||||
VccauxData - 0x6F);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_ATR_VCCAUX_LOWER_OFFSET,
|
||||
VccauxData + 0x6F);
|
||||
|
||||
|
||||
/*
|
||||
* Enable Alarm 0 for on-chip temperature and Alarm 2 for on-chip
|
||||
* VCCAUX in the Configuration Register 1.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress,
|
||||
XSM_CFR1_OFFSET) & (~XSM_CFR1_ALM_ALL_MASK);
|
||||
RegValue |= ((~(XSM_CFR1_ALM_VCCAUX_MASK | XSM_CFR1_ALM_TEMP_MASK)) &
|
||||
XSM_CFR1_ALM_ALL_MASK);
|
||||
XSysMon_WriteReg(BaseAddress, XSM_CFR1_OFFSET, RegValue);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Read the current value of on-chip temperature.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_TEMP_OFFSET);
|
||||
|
||||
/*
|
||||
* Read the Maximum value of on-chip temperature.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_MAX_TEMP_OFFSET);
|
||||
|
||||
/*
|
||||
* Read the Minimum value of on-chip temperature.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_MIN_TEMP_OFFSET);
|
||||
|
||||
/*
|
||||
* Check if alarm for on-chip temperature is set.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_AOR_OFFSET) &
|
||||
XSM_AOR_TEMP_MASK;
|
||||
if (RegValue) {
|
||||
/*
|
||||
* Alarm for on-chip temperature is set.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read the current value of on-chip VCCAUX.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_VCCAUX_OFFSET);
|
||||
|
||||
/*
|
||||
* Read the Maximum value of on-chip VCCAUX.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_MAX_VCCAUX_OFFSET);
|
||||
|
||||
/*
|
||||
* Read the Minimum value of on-chip VCCAUX.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_MIN_VCCAUX_OFFSET);
|
||||
|
||||
/*
|
||||
* Check if the alarm for on-chip VCCAUX is set.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(BaseAddress, XSM_AOR_OFFSET) &
|
||||
XSM_AOR_VCCAUX_MASK;
|
||||
if (RegValue) {
|
||||
/*
|
||||
* Alarm for on-chip VCCAUX is set.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,372 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_polled_example.c
|
||||
*
|
||||
* This file contains a design example using the driver functions
|
||||
* of the System Monitor driver. The example here shows the
|
||||
* driver/device in polled mode to check the on-chip temperature and voltages.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* The values of the on-chip temperature and the on-chip Vccaux voltage are read
|
||||
* from the device and then the alarm thresholds are set in such a manner that
|
||||
* the alarms occur.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sdm 09/26/08 Added code to return temperature value to the main
|
||||
* function. TestappPeripheral prints the temperature
|
||||
* 4.00a ktn 10/22/09 Updated the example to use macros that have been
|
||||
* renamed to remove _m from the name of the macro.
|
||||
* 5.03a bss 04/25/13 Modified SysMonPolledExample function to set
|
||||
* Sequencer Mode as Safe mode instead of Single
|
||||
* channel mode before configuring Sequencer registers.
|
||||
* CR #703729
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
|
||||
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
int SysMonPolledExample(u16 SysMonDeviceId, int *Temp);
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
static XSysMon SysMonInst; /* System Monitor driver instance */
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the polled example in this file.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
int Temp;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor polled example, specify the Device ID that is
|
||||
* generated in xparameters.h .
|
||||
*/
|
||||
Status = SysMonPolledExample(SYSMON_DEVICE_ID, &Temp);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
#endif /* TESTAPP_GEN */
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the System Monitor/ADC device using the
|
||||
* driver APIs.
|
||||
* This function does the following tasks:
|
||||
* - Initiate the System Monitor device driver instance
|
||||
* - Run self-test on the device
|
||||
* - Setup alarms for on-chip temperature and VCCAUX
|
||||
* - Setup the sequence registers to continuously monitor on-chip
|
||||
* temperature and VCCAUX
|
||||
* - Setup configuration registers to start the sequence
|
||||
* - Read latest on-chip temperature and VCCAUX, as well as their maximum
|
||||
* and minimum values. Also check if alarm(s) are set
|
||||
*
|
||||
* @param SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value
|
||||
* from xparameters.h.
|
||||
* @param Temp is an output parameter, it is a pointer through which the
|
||||
* current temperature value is returned to the main function.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
****************************************************************************/
|
||||
int SysMonPolledExample(u16 SysMonDeviceId, int *Temp)
|
||||
{
|
||||
int Status;
|
||||
volatile u32 Value;
|
||||
XSysMon_Config *ConfigPtr;
|
||||
u16 TempData;
|
||||
u16 VccauxData;
|
||||
XSysMon *SysMonInstPtr = &SysMonInst;
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the SysMon driver.
|
||||
*/
|
||||
ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr,
|
||||
ConfigPtr->BaseAddress);
|
||||
|
||||
/*
|
||||
* Self Test the System Monitor/ADC device
|
||||
*/
|
||||
Status = XSysMon_SelfTest(SysMonInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the Channel Sequencer before configuring the Sequence
|
||||
* registers.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);
|
||||
|
||||
|
||||
/*
|
||||
* Setup the Averaging to be done for the channels in the
|
||||
* Configuration 0 register as 16 samples:
|
||||
*/
|
||||
XSysMon_SetAvg(SysMonInstPtr, XSM_AVG_16_SAMPLES);
|
||||
|
||||
/*
|
||||
* Setup the Sequence register for 1st Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Bipolar Mode
|
||||
*
|
||||
* Setup the Sequence register for 16th Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Unipolar Mode
|
||||
*/
|
||||
Status = XSysMon_SetSeqInputMode(SysMonInstPtr, XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XSysMon_SetSeqAcqTime(SysMonInstPtr, XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Enable the averaging on the following channels in the Sequencer
|
||||
* registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqAvgEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the following channels in the Sequencer registers:
|
||||
* - On-chip Temperature
|
||||
* - On-chip VCCAUX supply sensor
|
||||
* - 1st Auxiliary Channel
|
||||
* - 16th Auxiliary Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqChEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
|
||||
|
||||
/*
|
||||
* Enable the Channel Sequencer in continuous sequencer cycling mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);
|
||||
|
||||
/*
|
||||
* Wait till the End of Sequence occurs
|
||||
*/
|
||||
XSysMon_GetStatus(SysMonInstPtr); /* Clear the old status */
|
||||
while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) !=
|
||||
XSM_SR_EOS_MASK);
|
||||
|
||||
/*
|
||||
* Disable all the alarms in the Configuration Register 1
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
|
||||
|
||||
|
||||
/*
|
||||
* Read the ADC converted Data from the data registers for on-chip
|
||||
* temperature and on-chip VCCAUX
|
||||
*/
|
||||
TempData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);
|
||||
VccauxData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCAUX);
|
||||
|
||||
/*
|
||||
* Convert the ADC data into temperature
|
||||
*/
|
||||
*Temp = XSysMon_RawToTemperature(TempData);
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for
|
||||
* On-chip Temperature High limit
|
||||
* On-chip Temperature Low limit
|
||||
* VCCAUX High limit
|
||||
* VCCAUX Low limit
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_UPPER,
|
||||
TempData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_TEMP_LOWER,
|
||||
TempData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_UPPER,
|
||||
VccauxData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCAUX_LOWER,
|
||||
VccauxData + 0x007F);
|
||||
|
||||
/*
|
||||
* Enable Alarm 0 for on-chip temperature and Alarm 2 for on-chip
|
||||
* VCCAUX in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, (XSM_CFR1_ALM_VCCAUX_MASK |
|
||||
XSM_CFR1_ALM_TEMP_MASK));
|
||||
|
||||
/*
|
||||
* Enable the Channel Sequencer in continuous cycling mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);
|
||||
|
||||
/*
|
||||
* Read the current value of on-chip Temperature.
|
||||
*/
|
||||
Value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);
|
||||
|
||||
/*
|
||||
* Read the Maximum value of on-chip Temperature.
|
||||
*/
|
||||
Value = XSysMon_GetMinMaxMeasurement(SysMonInstPtr, XSM_MAX_TEMP);
|
||||
|
||||
/*
|
||||
* Read the Minimum value of on-chip Temperature.
|
||||
*/
|
||||
Value = XSysMon_GetMinMaxMeasurement(SysMonInstPtr, XSM_MIN_TEMP);
|
||||
|
||||
/*
|
||||
* Check if alarm for on-chip temperature is set.
|
||||
*/
|
||||
Value = XSysMon_GetAlarmOutputStatus(SysMonInstPtr) & XSM_AOR_TEMP_MASK;
|
||||
if (Value) {
|
||||
/*
|
||||
* Alarm for on-chip temperature is set.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the current value of on-chip VCCAUX.
|
||||
*/
|
||||
Value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCAUX);
|
||||
|
||||
/*
|
||||
* Read the Maximum value of on-chip VCCAUX.
|
||||
*/
|
||||
Value = XSysMon_GetMinMaxMeasurement(SysMonInstPtr, XSM_MAX_VCCAUX);
|
||||
|
||||
/*
|
||||
* Read the Minimum value of on-chip VCCAUX.
|
||||
*/
|
||||
Value = XSysMon_GetMinMaxMeasurement(SysMonInstPtr, XSM_MIN_VCCAUX);
|
||||
|
||||
/*
|
||||
* Check if alarm for on-chip VCCAUX is set.
|
||||
*/
|
||||
Value = XSysMon_GetAlarmOutputStatus(SysMonInstPtr) &
|
||||
XSM_AOR_VCCAUX_MASK;
|
||||
if (Value) {
|
||||
/*
|
||||
* Alarm for on-chip VCCAUX is set.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,381 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_polled_printf_example.c
|
||||
*
|
||||
* This file contains a design example using the driver functions
|
||||
* of the System Monitor driver. The example here shows the
|
||||
* driver/device in polled mode to check the on-chip temperature and voltages.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* This examples also assumes that there is a STDIO device in the system.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sv 06/22/08 Added printfs and used conversion macros
|
||||
* 4.00a ktn 10/22/09 Updated the example to use macros that have been
|
||||
* renamed to remove _m from the name of the macro.
|
||||
* 5.03a bss 04/25/13 Modified SysMonPolledPrintfExample function to
|
||||
* set Sequencer Mode as Safe mode instead of Single
|
||||
* channel mode before configuring Sequencer registers.
|
||||
* CR #703729
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
#include "stdio.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
|
||||
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
#define printf xil_printf /* Small foot-print printf function */
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
static int SysMonPolledPrintfExample(u16 SysMonDeviceId);
|
||||
static int SysMonFractionToInt(float FloatNum);
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
static XSysMon SysMonInst; /* System Monitor driver instance */
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the polled example in this file.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor polled example, specify the Device ID that is
|
||||
* generated in xparameters.h.
|
||||
*/
|
||||
Status = SysMonPolledPrintfExample(SYSMON_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the System Monitor/ADC device using the
|
||||
* driver APIs.
|
||||
* This function does the following tasks:
|
||||
* - Initiate the System Monitor device driver instance
|
||||
* - Run self-test on the device
|
||||
* - Setup the sequence registers to continuously monitor on-chip
|
||||
* temperature, VCCINT and VCCAUX
|
||||
* - Setup configuration registers to start the sequence
|
||||
* - Read the latest on-chip temperature, VCCINT and VCCAUX
|
||||
*
|
||||
* @param SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value
|
||||
* from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
****************************************************************************/
|
||||
int SysMonPolledPrintfExample(u16 SysMonDeviceId)
|
||||
{
|
||||
int Status;
|
||||
XSysMon_Config *ConfigPtr;
|
||||
u32 TempRawData;
|
||||
u32 VccAuxRawData;
|
||||
u32 VccIntRawData;
|
||||
float TempData;
|
||||
float VccAuxData;
|
||||
float VccIntData;
|
||||
float MaxData;
|
||||
float MinData;
|
||||
XSysMon *SysMonInstPtr = &SysMonInst;
|
||||
|
||||
printf("\r\nEntering the SysMon Polled Example. \r\n");
|
||||
|
||||
/*
|
||||
* Initialize the SysMon driver.
|
||||
*/
|
||||
ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr,
|
||||
ConfigPtr->BaseAddress);
|
||||
|
||||
/*
|
||||
* Self Test the System Monitor/ADC device
|
||||
*/
|
||||
Status = XSysMon_SelfTest(SysMonInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the Channel Sequencer before configuring the Sequence
|
||||
* registers.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);
|
||||
|
||||
|
||||
/*
|
||||
* Disable all the alarms in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
|
||||
|
||||
|
||||
/*
|
||||
* Setup the Averaging to be done for the channels in the
|
||||
* Configuration 0 register as 16 samples:
|
||||
*/
|
||||
XSysMon_SetAvg(SysMonInstPtr, XSM_AVG_16_SAMPLES);
|
||||
|
||||
/*
|
||||
* Setup the Sequence register for 1st Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Bipolar Mode
|
||||
*
|
||||
* Setup the Sequence register for 16th Auxiliary channel
|
||||
* Setting is:
|
||||
* - Add acquisition time by 6 ADCCLK cycles.
|
||||
* - Unipolar Mode
|
||||
*/
|
||||
Status = XSysMon_SetSeqInputMode(SysMonInstPtr, XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XSysMon_SetSeqAcqTime(SysMonInstPtr, XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_AUX00);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Enable the averaging on the following channels in the Sequencer
|
||||
* registers:
|
||||
* - On-chip Temperature, VCCINT/VCCAUX supply sensors
|
||||
* - 1st/16th Auxiliary Channels
|
||||
* - Calibration Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqAvgEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCINT |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_CALIB);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the following channels in the Sequencer registers:
|
||||
* - On-chip Temperature, VCCINT/VCCAUX supply sensors
|
||||
* - 1st/16th Auxiliary Channel
|
||||
* - Calibration Channel
|
||||
*/
|
||||
Status = XSysMon_SetSeqChEnables(SysMonInstPtr, XSM_SEQ_CH_TEMP |
|
||||
XSM_SEQ_CH_VCCINT |
|
||||
XSM_SEQ_CH_VCCAUX |
|
||||
XSM_SEQ_CH_AUX00 |
|
||||
XSM_SEQ_CH_AUX15 |
|
||||
XSM_SEQ_CH_CALIB);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
|
||||
|
||||
|
||||
/*
|
||||
* Set the Calibration enables.
|
||||
*/
|
||||
XSysMon_SetCalibEnables(SysMonInstPtr,
|
||||
XSM_CFR1_CAL_PS_GAIN_OFFSET_MASK |
|
||||
XSM_CFR1_CAL_ADC_GAIN_OFFSET_MASK);
|
||||
|
||||
/*
|
||||
* Enable the Channel Sequencer in continuous sequencer cycling mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);
|
||||
|
||||
/*
|
||||
* Wait till the End of Sequence occurs
|
||||
*/
|
||||
XSysMon_GetStatus(SysMonInstPtr); /* Clear the old status */
|
||||
while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) !=
|
||||
XSM_SR_EOS_MASK);
|
||||
|
||||
/*
|
||||
* Read the on-chip Temperature Data (Current/Maximum/Minimum)
|
||||
* from the ADC data registers.
|
||||
*/
|
||||
TempRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_TEMP);
|
||||
TempData = XSysMon_RawToTemperature(TempRawData);
|
||||
printf("\r\nThe Current Temperature is %0d.%03d Centigrades.\r\n",
|
||||
(int)(TempData), SysMonFractionToInt(TempData));
|
||||
|
||||
|
||||
TempRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr, XSM_MAX_TEMP);
|
||||
MaxData = XSysMon_RawToTemperature(TempRawData);
|
||||
printf("The Maximum Temperature is %0d.%03d Centigrades. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
|
||||
TempRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr, XSM_MIN_TEMP);
|
||||
MinData = XSysMon_RawToTemperature(TempRawData);
|
||||
printf("The Minimum Temperature is %0d.%03d Centigrades. \r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
/*
|
||||
* Read the VccInt Votage Data (Current/Maximum/Minimum) from the
|
||||
* ADC data registers.
|
||||
*/
|
||||
VccIntRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT);
|
||||
VccIntData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
printf("\r\nThe Current VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(VccIntData), SysMonFractionToInt(VccIntData));
|
||||
|
||||
VccIntRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MAX_VCCINT);
|
||||
MaxData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
printf("The Maximum VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
|
||||
VccIntRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MIN_VCCINT);
|
||||
MinData = XSysMon_RawToVoltage(VccIntRawData);
|
||||
printf("The Minimum VCCINT is %0d.%03d Volts. \r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
/*
|
||||
* Read the VccAux Votage Data (Current/Maximum/Minimum) from the
|
||||
* ADC data registers.
|
||||
*/
|
||||
VccAuxRawData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCAUX);
|
||||
VccAuxData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
printf("\r\nThe Current VCCAUX is %0d.%03d Volts. \r\n",
|
||||
(int)(VccAuxData), SysMonFractionToInt(VccAuxData));
|
||||
|
||||
VccAuxRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MAX_VCCAUX);
|
||||
MaxData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
printf("The Maximum VCCAUX is %0d.%03d Volts. \r\n",
|
||||
(int)(MaxData), SysMonFractionToInt(MaxData));
|
||||
|
||||
|
||||
VccAuxRawData = XSysMon_GetMinMaxMeasurement(SysMonInstPtr,
|
||||
XSM_MIN_VCCAUX);
|
||||
MinData = XSysMon_RawToVoltage(VccAuxRawData);
|
||||
printf("The Minimum VCCAUX is %0d.%03d Volts. \r\n\r\n",
|
||||
(int)(MinData), SysMonFractionToInt(MinData));
|
||||
|
||||
printf("Exiting the SysMon Polled Example. \r\n");
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/*
|
||||
*
|
||||
* This function converts the fraction part of the given floating point number
|
||||
* (after the decimal point)to an integer.
|
||||
*
|
||||
* @param FloatNum is the floating point number.
|
||||
*
|
||||
* @return Integer number to a precision of 3 digits.
|
||||
*
|
||||
* @note
|
||||
* This function is used in the printing of floating point data to a STDIO device
|
||||
* using the xil_printf function. The xil_printf is a very small foot-print
|
||||
* printf function and does not support the printing of floating point numbers.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int SysMonFractionToInt(float FloatNum)
|
||||
{
|
||||
float Temp;
|
||||
|
||||
Temp = FloatNum;
|
||||
if (FloatNum < 0) {
|
||||
Temp = -(FloatNum);
|
||||
}
|
||||
|
||||
return( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));
|
||||
}
|
|
@ -0,0 +1,483 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_single_ch_intr_example.c
|
||||
*
|
||||
* This file contains a design example using the driver functions of the
|
||||
* System Monitor/ADC driver.
|
||||
* This example here shows the usage of the driver/device in single channel
|
||||
* interrupt mode to handle End of Conversion (EOC) and VCCINT alarm interrupts.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* This code assumes that no Operating System is being used.
|
||||
*
|
||||
* The value of the on-chip Vccint voltage is read from the device and then the
|
||||
* alarm thresholds are set in such a manner that the alarm occurs.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a sv 09/04/07 First release
|
||||
* 4.00a ktn 10/22/09 Updated the example to use HAL Processor APIs/macros.
|
||||
* Updated the example to use macros that have been
|
||||
* renamed to remove _m from the name of the macro.
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
#include "xstatus.h"
|
||||
#include "xintc.h"
|
||||
#include "xil_exception.h"
|
||||
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#ifndef TESTAPP_GEN
|
||||
#define SYSMON_DEVICE_ID XPAR_SYSMON_0_DEVICE_ID
|
||||
#define INTC_DEVICE_ID XPAR_INTC_0_DEVICE_ID
|
||||
#define INTR_ID XPAR_INTC_0_SYSMON_0_VEC_ID
|
||||
#endif
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
int SysMonSingleChannelIntrExample(XIntc* IntcInstancePtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId);
|
||||
|
||||
|
||||
static void SysMonInterruptHandler(void *CallBackRef);
|
||||
|
||||
static int SysMonSetupInterruptSystem(XIntc* IntcInstancePtr,
|
||||
XSysMon *SysMonPtr,
|
||||
u16 IntrId );
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
static XSysMon SysMonInst; /* System Monitor driver instance */
|
||||
static XIntc InterruptController; /* Instance of the XIntc driver. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Shared variables used to test the callbacks.
|
||||
*/
|
||||
volatile static int EocFlag = FALSE; /* EOC interrupt */
|
||||
volatile static int VccintIntr = FALSE; /* VCCINT alarm interrupt */
|
||||
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function that invokes the Single Channel Interrupt example.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int Status;
|
||||
|
||||
/*
|
||||
* Run the SysMonitor interrupt example, specify the parameters that
|
||||
* are generated in xparameters.h.
|
||||
*/
|
||||
Status = SysMonSingleChannelIntrExample(&InterruptController,
|
||||
&SysMonInst,
|
||||
SYSMON_DEVICE_ID,
|
||||
INTR_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
#endif /* TESTAPP_GEN */
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a test on the System Monitor/ADC device using the
|
||||
* driver APIs.
|
||||
*
|
||||
* The function does the following tasks:
|
||||
* - Initiate the System Monitor/ADC device driver instance
|
||||
* - Run self-test on the device
|
||||
* - Reset the device
|
||||
* - Set up alarm for VCCINT
|
||||
* - Set up the configuration registers for single channel continuous mode
|
||||
* for VCCINT channel
|
||||
* - Setup interrupt system
|
||||
* - Enable interrupts
|
||||
* - Wait until the VCCINT alarm interrupt occurs
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the Interrupt Controller
|
||||
* driver Instance.
|
||||
* @param SysMonInstPtr is a pointer to the XSysMon driver Instance.
|
||||
* @param SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value
|
||||
* from xparameters.h.
|
||||
* @param SysMonIntrId is
|
||||
* XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
|
||||
* value from xparameters.h
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the example has completed successfully.
|
||||
* - XST_FAILURE if the example has failed.
|
||||
*
|
||||
* @note This function may never return if no interrupt occurs.
|
||||
*
|
||||
****************************************************************************/
|
||||
int SysMonSingleChannelIntrExample(XIntc* IntcInstancePtr,
|
||||
XSysMon* SysMonInstPtr,
|
||||
u16 SysMonDeviceId,
|
||||
u16 SysMonIntrId)
|
||||
{
|
||||
int Status;
|
||||
XSysMon_Config *ConfigPtr;
|
||||
u16 VccintData;
|
||||
u32 IntrStatus;
|
||||
|
||||
/*
|
||||
* Initialize the SysMon driver.
|
||||
*/
|
||||
ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
|
||||
if (ConfigPtr == NULL) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr, ConfigPtr->BaseAddress);
|
||||
|
||||
/*
|
||||
* Self Test the System Monitor/ADC device.
|
||||
*/
|
||||
Status = XSysMon_SelfTest(SysMonInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the ADCCLK frequency equal to 1/32 of System clock for the System
|
||||
* Monitor/ADC in the Configuration Register 2.
|
||||
*/
|
||||
XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
|
||||
|
||||
/*
|
||||
* Set the sequencer in Single channel mode.
|
||||
*/
|
||||
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);
|
||||
|
||||
/*
|
||||
* Set the configuration registers for single channel continuous mode
|
||||
* of operation for the VCCINT channel.
|
||||
*/
|
||||
Status= XSysMon_SetSingleChParams(SysMonInstPtr, XSM_CH_VCCINT,
|
||||
FALSE, FALSE, FALSE);
|
||||
if(Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Disable all the alarms in the Configuration Register 1.
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for the VCCINT
|
||||
* High limit and lower limit so that the alarm does not occur.
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER, 0xFFFF);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER, 0x0);
|
||||
|
||||
|
||||
/*
|
||||
* Setup the interrupt system.
|
||||
*/
|
||||
Status = SysMonSetupInterruptSystem(IntcInstancePtr,
|
||||
SysMonInstPtr,
|
||||
SysMonIntrId);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Clear any bits set in the Interrupt Status Register.
|
||||
*/
|
||||
IntrStatus = XSysMon_IntrGetStatus(SysMonInstPtr);
|
||||
XSysMon_IntrClear(SysMonInstPtr, IntrStatus);
|
||||
|
||||
|
||||
/*
|
||||
* Enable EOC interrupt and Alarm 1 interrupt for on-chip VCCINT.
|
||||
*/
|
||||
XSysMon_IntrEnable(SysMonInstPtr, XSM_IPIXR_EOC_MASK |
|
||||
XSM_IPIXR_VCCINT_MASK);
|
||||
|
||||
/*
|
||||
* Enable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalEnable(SysMonInstPtr);
|
||||
|
||||
|
||||
/*
|
||||
* Wait till the End of Conversion occurs.
|
||||
*/
|
||||
EocFlag = FALSE; /* Clear the EOC Flag */
|
||||
while (EocFlag != TRUE);
|
||||
|
||||
|
||||
/*
|
||||
* Read the ADC converted Data from the data registers for VCCINT.
|
||||
*/
|
||||
VccintData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT);
|
||||
|
||||
|
||||
/*
|
||||
* Set up Alarm threshold registers for the VCCINT
|
||||
* High limit and lower limit so that the alarm occurs.
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER,
|
||||
VccintData - 0x007F);
|
||||
XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER,
|
||||
VccintData - 0x007F);
|
||||
|
||||
|
||||
VccintIntr = FALSE; /* Clear the flag */
|
||||
|
||||
|
||||
/*
|
||||
* Enable Alarm 1 for VCCINT
|
||||
*/
|
||||
XSysMon_SetAlarmEnables(SysMonInstPtr, XSM_CFR1_ALM_VCCINT_MASK);
|
||||
|
||||
/*
|
||||
* Wait until an Alarm 1 interrupt occurs.
|
||||
*/
|
||||
while (1) {
|
||||
|
||||
if (VccintIntr == TRUE) {
|
||||
/*
|
||||
* Alarm 1 - VCCINT alarm interrupt has occurred.
|
||||
* The required processing should be put here.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable global interrupt of System Monitor.
|
||||
*/
|
||||
XSysMon_IntrGlobalDisable(SysMonInstPtr);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is the Interrupt Service Routine for the System Monitor device.
|
||||
* It will be called by the processor whenever an interrupt is asserted
|
||||
* by the device.
|
||||
*
|
||||
* There are 8 different interrupt types supported
|
||||
* - Over Temperature
|
||||
* - ALARM 0
|
||||
* - ALARM 1
|
||||
* - ALARM 2
|
||||
* - End of Sequence
|
||||
* - End of Conversion
|
||||
* - Over Temperature DeActivated
|
||||
* - ALARM 0 DeActivated
|
||||
*
|
||||
* This function only handles the EOC interrupt and ALARM 1 interrupt.
|
||||
* User of this code should modify the code to meet needs of the application.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the Interrupt
|
||||
* controller driver, which in our case is a pointer to the
|
||||
* driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is called within interrupt context.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void SysMonInterruptHandler(void *CallBackRef)
|
||||
{
|
||||
u32 IntrStatusValue;
|
||||
XSysMon *SysMonPtr = (XSysMon *)CallBackRef;
|
||||
|
||||
/*
|
||||
* Get the interrupt status from the device and check the value.
|
||||
*/
|
||||
IntrStatusValue = XSysMon_IntrGetStatus(SysMonPtr);
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_EOC_MASK) {
|
||||
/*
|
||||
* Set End of Conversion interrupt flag so the code
|
||||
* in application context can be aware of this interrupt.
|
||||
*/
|
||||
EocFlag = TRUE;
|
||||
XSysMon_GetStatus(SysMonPtr); /* Clear the latched status */
|
||||
}
|
||||
|
||||
if (IntrStatusValue & XSM_IPIXR_VCCINT_MASK) {
|
||||
/*
|
||||
* Set VCCINT interrupt flag so the code in application context
|
||||
* can be aware of this interrupt.
|
||||
*/
|
||||
VccintIntr = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all bits in Interrupt Status Register.
|
||||
*/
|
||||
XSysMon_IntrClear(SysMonPtr, IntrStatusValue);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* System Monitor/ADC. The function is application-specific since the actual
|
||||
* system may or may not have an interrupt controller. The System Monitor/ADC
|
||||
* device could be directly connected to a processor without an interrupt
|
||||
* controller. The user should modify this function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the Interrupt Controller
|
||||
* driver Instance
|
||||
* @param SysMonPtr is a pointer to the driver instance for the System
|
||||
* Monitor device which is going to be connected to the interrupt
|
||||
* controller
|
||||
* @param IntrId is XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
|
||||
* value from xparameters.h
|
||||
*
|
||||
* @return XST_SUCCESS if successful, or XST_FAILURE.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SysMonSetupInterruptSystem(XIntc* IntcInstancePtr,
|
||||
XSysMon *SysMonPtr,
|
||||
u16 IntrId )
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/*
|
||||
* Initialize the interrupt controller driver so that it's ready to use.
|
||||
*/
|
||||
Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Connect the handler that will be called when an interrupt
|
||||
* for the device occurs, the handler defined above performs the
|
||||
* specific interrupt processing for the device.
|
||||
*/
|
||||
Status = XIntc_Connect(IntcInstancePtr,
|
||||
IntrId,
|
||||
(XInterruptHandler) SysMonInterruptHandler,
|
||||
SysMonPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
/*
|
||||
* Start the interrupt controller so interrupts are enabled for all
|
||||
* devices that cause interrupts. Specify real mode so that the System
|
||||
* Monitor/ACD device can cause interrupts through the interrupt
|
||||
* controller.
|
||||
*/
|
||||
Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Enable the interrupt for the System Monitor/ADC device
|
||||
*/
|
||||
XIntc_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
|
||||
/*
|
||||
* Initialize the exception table.
|
||||
*/
|
||||
Xil_ExceptionInit();
|
||||
|
||||
/*
|
||||
* Register the interrupt controller handler with the exception table.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XIntc_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
/*
|
||||
* Enable exceptions.
|
||||
*/
|
||||
Xil_ExceptionEnable();
|
||||
|
||||
#endif /* TESTAPP_GEN */
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
27
XilinxProcessorIPLib/drivers/sysmon/src/Makefile
Normal file
27
XilinxProcessorIPLib/drivers/sysmon/src/Makefile
Normal file
|
@ -0,0 +1,27 @@
|
|||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
RELEASEDIR=../../../lib
|
||||
INCLUDEDIR=../../../include
|
||||
INCLUDES=-I./. -I${INCLUDEDIR}
|
||||
|
||||
INCLUDEFILES=*.h
|
||||
LIBSOURCES=*.c
|
||||
OUTS = *.o
|
||||
|
||||
|
||||
libs:
|
||||
echo "Compiling sysmon"
|
||||
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
|
||||
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
|
||||
make clean
|
||||
|
||||
include:
|
||||
${CP} ${INCLUDEFILES} ${INCLUDEDIR}
|
||||
|
||||
clean:
|
||||
rm -rf ${OUTS}
|
1894
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon.c
Normal file
1894
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon.c
Normal file
File diff suppressed because it is too large
Load diff
617
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon.h
Normal file
617
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon.h
Normal file
|
@ -0,0 +1,617 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon.h
|
||||
*
|
||||
* The XSysMon driver supports the Xilinx System Monitor/ADC device.
|
||||
*
|
||||
* The System Monitor/ADC device has the following features:
|
||||
* - 10-bit, 200-KSPS (kilo samples per second)
|
||||
* Analog-to-Digital Converter (ADC)
|
||||
* - Monitoring of on-chip supply voltages and temperature
|
||||
* - 1 dedicated differential analog-input pair and
|
||||
* 16 auxiliary differential analog-input pairs
|
||||
* - Automatic alarms based on user defined limits for the on-chip
|
||||
* supply voltages and temperature
|
||||
* - Automatic Channel Sequencer, programmable averaging, programmable
|
||||
* acquisition time for the external inputs, unipolar or differential
|
||||
* input selection for the external inputs
|
||||
* - Inbuilt Calibration
|
||||
* - Optional interrupt request generation
|
||||
* - External Mux (7 Series and Zynq XADC)
|
||||
*
|
||||
*
|
||||
* The user should refer to the hardware device specification for detailed
|
||||
* information about the device.
|
||||
*
|
||||
* This header file contains the prototypes of driver functions that can
|
||||
* be used to access the System Monitor/ADC device.
|
||||
*
|
||||
*
|
||||
* <b> System Monitor Channel Sequencer Modes </b>
|
||||
*
|
||||
* The System Monitor Channel Sequencer supports the following operating modes:
|
||||
*
|
||||
* - <b> Default </b>: This is the default mode after power up.
|
||||
* In this mode of operation the System Monitor operates in
|
||||
* a sequence mode, monitoring the on chip sensors:
|
||||
* Temperature, VCCINT, and VCCAUX.
|
||||
* - <b> One pass through sequence </b>: In this mode the System Monitor
|
||||
* converts the channels enabled in the Sequencer Channel Enable
|
||||
* registers for a single pass and then stops.
|
||||
* - <b> Continuous cycling of sequence </b>: In this mode the System Monitor
|
||||
* converts the channels enabled in the Sequencer Channel Enable
|
||||
* registers continuously.
|
||||
* - <b> Single channel mode</b>: In this mode the System Monitor Channel
|
||||
* Sequencer is disabled and the System Monitor operates in a
|
||||
* Single Channel Mode.
|
||||
* The System Monitor can operate either in a Continuous or Event
|
||||
* driven sampling mode in the single channel mode.
|
||||
* - <b> Simultaneous sampling mode</b>: This mode is available only in
|
||||
* 7 Series and Zynq XADC devices. In this mode both ADCs sample and
|
||||
* digitizes two different analog input signals at the same time.
|
||||
* - <b> Independent ADC mode</b>: This mode is available only in 7 Series and
|
||||
* Zynq XADC devices. In this mode ADC A is used to implement a
|
||||
* fixed monitoring mode which is similar to default mode, but the
|
||||
* fixed alarm functions are enabled. ADC B is available to be used
|
||||
* with the external analog input channels only.
|
||||
*
|
||||
* <b> Initialization and Configuration </b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate to the System Monitor/ADC device.
|
||||
*
|
||||
* XSysMon_CfgInitialize() API is used to initialize the System Monitor/ADC
|
||||
* device. The user needs to first call the XSysMon_LookupConfig() API which
|
||||
* returns the Configuration structure pointer which is passed as a parameter to
|
||||
* the XSysMon_CfgInitialize() API.
|
||||
*
|
||||
*
|
||||
* <b>Interrupts</b>
|
||||
*
|
||||
* The System Monitor/ADC device supports interrupt driven mode and the default
|
||||
* operation mode is polling mode.
|
||||
*
|
||||
* The interrupt mode is available only if hardware is configured to support
|
||||
* interrupts.
|
||||
*
|
||||
* This driver does not provide a Interrupt Service Routine (ISR) for the device.
|
||||
* It is the responsibility of the application to provide one if needed. Refer to
|
||||
* the interrupt example provided with this driver for details on using the
|
||||
* device in interrupt mode.
|
||||
*
|
||||
*
|
||||
* <b> Virtual Memory </b>
|
||||
*
|
||||
* This driver supports Virtual Memory. The RTOS is responsible for calculating
|
||||
* the correct device base address in Virtual Memory space.
|
||||
*
|
||||
*
|
||||
* <b> Threads </b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
*
|
||||
* <b> Asserts </b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
*
|
||||
* <b> Building the driver </b>
|
||||
*
|
||||
* The XSysMon driver is composed of several source files. This allows the user
|
||||
* to build and link only those parts of the driver that are necessary.
|
||||
*
|
||||
* <b> Limitations of the driver </b>
|
||||
*
|
||||
* System Monitor/ADC device can be accessed through the JTAG port and the AXI
|
||||
* interface. The driver implementation does not support the simultaneous access
|
||||
* of the device by both these interfaces. The user has to care of this situation
|
||||
* in the user application code.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <br><br>
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sv 07/07/08 Added bit definitions for new Alarm Interrupts in the
|
||||
* Interrupt Registers. Changed the ADC data functions
|
||||
* to return 16 bits of data. Added macros for conversion
|
||||
* from Raw Data to Temperature/Voltage and vice-versa.
|
||||
* 3.00a sdm 02/09/09 Added APIs and bit definitions for V6 SysMon.
|
||||
* 4.00a ktn 10/22/09 Updated the driver to use the HAL Processor APIs/macros.
|
||||
* The macros have been renamed to remove _m from the name
|
||||
* in all the driver files.
|
||||
* 5.00a sdm 06/15/11 Added support for XADC 7 Series.
|
||||
* 5.01a bss 02/28/12 Added support for Zynq,
|
||||
* renamed XSM_ATR_BRAM_UPPER to XSM_ATR_VBRAM_UPPER
|
||||
* renamed XSM_ATR_BRAM_LOWER to XSM_ATR_VBRAM_LOWER
|
||||
* 5.02a bss 11/23/12 Added APIs and Macros to support Temperature Updation
|
||||
* over TEMP_OUT port(CR #679872)
|
||||
* 5.03a bss 04/25/13 Modified XSysMon_SetSeqChEnables,
|
||||
* XSysMon_SetSeqAvgEnables, XSysMon_SetSeqInputMode
|
||||
* and XSysMon_SetSeqAcqTime APIs to check for Safe Mode
|
||||
* instead of Single Channel mode(CR #703729) in xsysmon.c
|
||||
* Modified examples: xsysmon_polled_example.c,
|
||||
* xsysmon_low_level_example.c,
|
||||
* xsysmon_intr_printf_example.c, xsysmon_intr_example.c
|
||||
* xsysmon_extmux_example.c and
|
||||
* xsysmon_polled_printf_example.c to set Sequencer Mode
|
||||
* as Safe mode instead of Single channel mode before
|
||||
* configuring Sequencer registers.
|
||||
* 6.0 adk 19/12/13 Updated as per the New Tcl API's
|
||||
* 7.0 bss 7/25/14 To support Ultrascale:
|
||||
* Added XSM_CH_VUSR0 - XSMXSM_CH_VUSR3,XSM_MAX_VUSR0 -
|
||||
* XSM_MIN_VUSR3,XSM_ATR_VUSR0_UPPER -
|
||||
* XSM_ATR_VUSR3_LOWER macros.
|
||||
* Added XSM_IP_OFFSET macro(since register
|
||||
* offsets are different for Ultrascale comapared to
|
||||
* earlier familes),Offsets,Masks for VUSER0 to
|
||||
* VUSER3 channels, Configuration Register 3 and
|
||||
* Sequence Registers 8 and 9 in xsysmon_hw.h.
|
||||
* Modified XSysMon_GetAdcData,
|
||||
* XSysMon_GetMinMaxMeasurement,
|
||||
* XSysMon_SetSingleChParams, XSysMon_SetAlarmEnables,
|
||||
* XSysMon_GetAlarmEnables,XSysMon_SetSeqChEnables,
|
||||
* XSysMon_GetSeqChEnables,XSysMon_SetSeqAvgEnables,
|
||||
* XSysMon_GetSeqAvgEnables,XSysMon_SetAlarmThreshold
|
||||
* and XSysMon_GetAlarmThreshold in xsysmon.c.
|
||||
* Modified driver tcl to generate XPAR_SYSMON_0_IP_TYPE
|
||||
* parameter.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef XSYSMON_H /* Prevent circular inclusions */
|
||||
#define XSYSMON_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
#include "xsysmon_hw.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
|
||||
/**
|
||||
* @name Indexes for the different channels.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CH_TEMP 0x0 /**< On Chip Temperature */
|
||||
#define XSM_CH_VCCINT 0x1 /**< VCCINT */
|
||||
#define XSM_CH_VCCAUX 0x2 /**< VCCAUX */
|
||||
#define XSM_CH_VPVN 0x3 /**< VP/VN Dedicated analog inputs */
|
||||
#define XSM_CH_VREFP 0x4 /**< VREFP */
|
||||
#define XSM_CH_VREFN 0x5 /**< VREFN */
|
||||
#define XSM_CH_VBRAM 0x6 /**< VBRAM - 7 Series and Zynq */
|
||||
#define XSM_CH_SUPPLY_CALIB 0x07 /**< Supply Calib Data Reg */
|
||||
#define XSM_CH_ADC_CALIB 0x08 /**< ADC Offset Channel Reg */
|
||||
#define XSM_CH_GAINERR_CALIB 0x09 /**< Gain Error Channel Reg */
|
||||
#define XSM_CH_VCCPINT 0x0D /**< On-chip PS VCCPINT Channel, Zynq */
|
||||
#define XSM_CH_VCCPAUX 0x0E /**< On-chip PS VCCPAUX Channel, Zynq */
|
||||
#define XSM_CH_VCCPDRO 0x0F /**< On-chip PS VCCPDRO Channel, Zynq */
|
||||
#define XSM_CH_AUX_MIN 16 /**< Channel number for 1st Aux Channel */
|
||||
#define XSM_CH_AUX_MAX 31 /**< Channel number for Last Aux channel */
|
||||
#define XSM_CH_VUSR0 32 /**< VUSER0 Supply - UltraScale */
|
||||
#define XSM_CH_VUSR1 33 /**< VUSER1 Supply - UltraScale */
|
||||
#define XSM_CH_VUSR2 34 /**< VUSER2 Supply - UltraScale */
|
||||
#define XSM_CH_VUSR3 35 /**< VUSER3 Supply - UltraScale */
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Indexes for reading the Calibration Coefficient Data.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CALIB_SUPPLY_OFFSET_COEFF 0 /**< Supply Offset Calib Coefficient */
|
||||
#define XSM_CALIB_ADC_OFFSET_COEFF 1 /**< ADC Offset Calib Coefficient */
|
||||
#define XSM_CALIB_GAIN_ERROR_COEFF 2 /**< Gain Error Calib Coefficient*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Indexes for reading the Minimum/Maximum Measurement Data.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_MAX_TEMP 0 /**< Maximum Temperature Data */
|
||||
#define XSM_MAX_VCCINT 1 /**< Maximum VCCINT Data */
|
||||
#define XSM_MAX_VCCAUX 2 /**< Maximum VCCAUX Data */
|
||||
#define XSM_MAX_VCCBRAM 3 /**< Maximum VCCBRAM Data, 7 Series/Zynq */
|
||||
#define XSM_MIN_TEMP 4 /**< Minimum Temperature Data */
|
||||
#define XSM_MIN_VCCINT 5 /**< Minimum VCCINT Data */
|
||||
#define XSM_MIN_VCCAUX 6 /**< Minimum VCCAUX Data */
|
||||
#define XSM_MIN_VCCBRAM 7 /**< Minimum VCCBRAM Data, 7 Series/Zynq */
|
||||
#define XSM_MAX_VCCPINT 8 /**< Maximum VCCPINT Data, Zynq */
|
||||
#define XSM_MAX_VCCPAUX 9 /**< Maximum VCCPAUX Data, Zynq */
|
||||
#define XSM_MAX_VCCPDRO 0xA /**< Maximum VCCPDRO Data, Zynq */
|
||||
#define XSM_MIN_VCCPINT 0xC /**< Minimum VCCPINT Data, Zynq */
|
||||
#define XSM_MIN_VCCPAUX 0xD /**< Minimum VCCPAUX Data, Zynq */
|
||||
#define XSM_MIN_VCCPDRO 0xE /**< Minimum VCCPDRO Data, Zynq */
|
||||
#define XSM_MAX_VUSR0 0x80 /**< Maximum VUSR0 Data, Ultrascale */
|
||||
#define XSM_MAX_VUSR1 0x81 /**< Maximum VUSR1 Data, Ultrascale */
|
||||
#define XSM_MAX_VUSR2 0x82 /**< Maximum VUSR2 Data, Ultrascale */
|
||||
#define XSM_MAX_VUSR3 0x83 /**< Maximum VUSR3 Data, Ultrascale */
|
||||
#define XSM_MIN_VUSR0 0x88 /**< Minimum VUSR0 Data, Ultrascale */
|
||||
#define XSM_MIN_VUSR1 0x89 /**< Minimum VUSR1 Data, Ultrascale */
|
||||
#define XSM_MIN_VUSR2 0x8A /**< Minimum VUSR2 Data, Ultrascale */
|
||||
#define XSM_MIN_VUSR3 0x8B /**< Minimum VUSR3 Data, Ultrascale */
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Alarm Threshold(Limit) Register (ATR) indexes.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_ATR_TEMP_UPPER 0 /**< High user Temperature */
|
||||
#define XSM_ATR_VCCINT_UPPER 1 /**< VCCINT high voltage limit */
|
||||
#define XSM_ATR_VCCAUX_UPPER 2 /**< VCCAUX high voltage limit */
|
||||
#define XSM_ATR_OT_UPPER 3 /**< Lower Over Temperature limit */
|
||||
#define XSM_ATR_TEMP_LOWER 4 /**< Low user Temperature */
|
||||
#define XSM_ATR_VCCINT_LOWER 5 /**< VCCINT low voltage limit */
|
||||
#define XSM_ATR_VCCAUX_LOWER 6 /**< VCCAUX low voltage limit */
|
||||
#define XSM_ATR_OT_LOWER 7 /**< Lower Over Temperature limit */
|
||||
#define XSM_ATR_VBRAM_UPPER 8 /**< VBRAM high voltage limit */
|
||||
#define XSM_ATR_VCCPINT_UPPER 9 /**< VCCPINT Upper Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPAUX_UPPER 0xA /**< VCCPAUX Upper Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPDRO_UPPER 0xB /**< VCCPDRO Upper Alarm, Zynq */
|
||||
#define XSM_ATR_VBRAM_LOWER 0xC /**< VRBAM Lower Alarm, 7 Series and Zynq*/
|
||||
#define XSM_ATR_VCCPINT_LOWER 0xD /**< VCCPINT Lower Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPAUX_LOWER 0xE /**< VCCPAUX Lower Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPDRO_LOWER 0xF /**< VCCPDRO Lower Alarm, Zynq */
|
||||
#define XSM_ATR_VUSR0_UPPER 0x10 /**< VUSER0 Upper Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR1_UPPER 0x11 /**< VUSER1 Upper Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR2_UPPER 0x12 /**< VUSER2 Upper Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR3_UPPER 0x13 /**< VUSER3 Upper Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR0_LOWER 0x18 /**< VUSER0 Lower Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR1_LOWER 0x19 /**< VUSER1 Lower Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR2_LOWER 0x1A /**< VUSER2 Lower Alarm, Ultrascale */
|
||||
#define XSM_ATR_VUSR3_LOWER 0x1B /**< VUSER3 Lower Alarm, Ultrascale */
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Averaging to be done for the channels.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_AVG_0_SAMPLES 0 /**< No Averaging */
|
||||
#define XSM_AVG_16_SAMPLES 1 /**< Average 16 samples */
|
||||
#define XSM_AVG_64_SAMPLES 2 /**< Average 64 samples */
|
||||
#define XSM_AVG_256_SAMPLES 3 /**< Average 256 samples */
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Channel Sequencer Modes of operation.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_SEQ_MODE_SAFE 0 /**< Default Safe Mode */
|
||||
#define XSM_SEQ_MODE_ONEPASS 1 /**< Onepass through Sequencer */
|
||||
#define XSM_SEQ_MODE_CONTINPASS 2 /**< Continuous Cycling Seqquencer */
|
||||
#define XSM_SEQ_MODE_SINGCHAN 3 /**< Single channel - No Sequencing */
|
||||
#define XSM_SEQ_MODE_SIMUL 4 /**< Simultaneous Cycling Sequencer,
|
||||
* 7 Series and Zynq XADC only */
|
||||
#define XSM_SEQ_MODE_INDEPENDENT 8 /**< Independent ADC Sequencer,
|
||||
* 7 Series and Zynq XADC only */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/* For backwards compatabilty */
|
||||
#define XSM_CH_CALIBRATION XSM_CH_ADC_CALIB
|
||||
#define XSM_ATR_BRAM_UPPER XSM_ATR_VBRAM_UPPER
|
||||
#define XSM_ATR_BRAM_LOWER XSM_ATR_VBRAM_LOWER
|
||||
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the System Monitor/ADC
|
||||
* device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddress; /**< Device base address */
|
||||
int IncludeInterrupt; /**< Supports Interrupt driven mode */
|
||||
u8 IpType; /**< 1 - System Management */
|
||||
/**< 0 - XADC/System Monoitor */
|
||||
} XSysMon_Config;
|
||||
|
||||
|
||||
/**
|
||||
* The driver's instance data. The user is required to allocate a variable
|
||||
* of this type for every System Monitor/ADC device in the system. A pointer to
|
||||
* a variable of this type is then passed to the driver API functions.
|
||||
*/
|
||||
typedef struct {
|
||||
XSysMon_Config Config; /**< XSysMon_Config of current device */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
u32 Mask; /**< Store the previously written value
|
||||
in CONVST register */
|
||||
} XSysMon;
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro checks if the SysMonitor/ADC device is in Event Sampling mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the device is in Event Sampling Mode.
|
||||
* - FALSE if the device is in Continuous Sampling Mode.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* int XSysMon_IsEventSamplingMode(XSysMon *InstancePtr);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_IsEventSamplingModeSet(InstancePtr) \
|
||||
(((XSysMon_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XSM_CFR0_OFFSET) & XSM_CFR0_EC_MASK) ? \
|
||||
TRUE : FALSE))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro checks if the Dynamic Reconfiguration Port (DRP) transaction from
|
||||
* the JTAG is in progress.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the DRP transaction from JTAG is in Progress.
|
||||
* - FALSE if there is no DRP transaction from the JTAG.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* int XSysMon_IsDrpBusy(XSysMon *InstancePtr);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_IsDrpBusy(InstancePtr) \
|
||||
((XSysMon_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XSM_SR_OFFSET) & XSM_SR_JTAG_BUSY_MASK) ? \
|
||||
TRUE : FALSE)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro checks if the Dynamic Reconfiguration Port (DRP) is locked by the
|
||||
* JTAG.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the DRP is locked by the JTAG.
|
||||
* - FALSE if the DRP is not locked by the JTAG.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* int XSysMon_IsDrpLocked(XSysMon *InstancePtr);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_IsDrpLocked(InstancePtr) \
|
||||
(((XSysMon_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XSM_SR_OFFSET) & XSM_SR_JTAG_LOCKED_MASK) ? \
|
||||
TRUE : FALSE))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro converts System Monitor/ADC Raw Data to Temperature(centigrades).
|
||||
*
|
||||
* @param AdcData is the SysMon Raw ADC Data.
|
||||
*
|
||||
* @return The Temperature in centigrades.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* float XSysMon_RawToTemperature(u32 AdcData);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_RawToTemperature(AdcData) \
|
||||
((((float)(AdcData)/65536.0f)/0.00198421639f ) - 273.15f)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro converts System Monitor/ADC Raw Data to Voltage(volts).
|
||||
*
|
||||
* @param AdcData is the System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @return The Voltage in volts.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* float XSysMon_RawToVoltage(u32 AdcData);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_RawToVoltage(AdcData) \
|
||||
((((float)(AdcData))* (3.0f))/65536.0f)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro converts Temperature in centigrades to System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @param Temperature is the Temperature in centigrades to be
|
||||
* converted to System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @return The System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* int XSysMon_TemperatureToRaw(float Temperature);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_TemperatureToRaw(Temperature) \
|
||||
((int)(((Temperature) + 273.15f)*65536.0f*0.00198421639f))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro converts Voltage in Volts to System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @param Voltage is the Voltage in volts to be converted to
|
||||
* System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @return The System Monitor/ADC Raw Data.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* int XSysMon_VoltageToRaw(float Voltage);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSysMon_VoltageToRaw(Voltage) \
|
||||
((int)((Voltage)*65536.0f/3.0f))
|
||||
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/**
|
||||
* Functions in xsysmon_sinit.c
|
||||
*/
|
||||
XSysMon_Config *XSysMon_LookupConfig(u16 DeviceId);
|
||||
|
||||
/**
|
||||
* Functions in xsysmon.c
|
||||
*/
|
||||
int XSysMon_CfgInitialize(XSysMon *InstancePtr,
|
||||
XSysMon_Config *ConfigPtr, u32 EffectiveAddr);
|
||||
|
||||
void XSysMon_Reset(XSysMon *InstancePtr);
|
||||
|
||||
u32 XSysMon_GetStatus(XSysMon *InstancePtr);
|
||||
|
||||
u32 XSysMon_GetAlarmOutputStatus(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_StartAdcConversion(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_ResetAdc(XSysMon *InstancePtr);
|
||||
|
||||
u16 XSysMon_GetAdcData(XSysMon *InstancePtr, u8 Channel);
|
||||
|
||||
u16 XSysMon_GetCalibCoefficient(XSysMon *InstancePtr, u8 CoeffType);
|
||||
|
||||
u16 XSysMon_GetMinMaxMeasurement(XSysMon *InstancePtr, u8 MeasurementType);
|
||||
|
||||
void XSysMon_SetAvg(XSysMon *InstancePtr, u8 Average);
|
||||
u8 XSysMon_GetAvg(XSysMon *InstancePtr);
|
||||
|
||||
int XSysMon_SetSingleChParams(XSysMon *InstancePtr, u8 Channel,
|
||||
int IncreaseAcqCycles, int IsEventMode,
|
||||
int IsDifferentialMode);
|
||||
|
||||
void XSysMon_SetAlarmEnables(XSysMon *InstancePtr, u32 AlmEnableMask);
|
||||
u32 XSysMon_GetAlarmEnables(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_SetCalibEnables(XSysMon *InstancePtr, u16 Calibration);
|
||||
u16 XSysMon_GetCalibEnables(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_SetSequencerMode(XSysMon *InstancePtr, u8 SequencerMode);
|
||||
u8 XSysMon_GetSequencerMode(XSysMon *InstancePtr);
|
||||
void XSysMon_SetSequencerEvent(XSysMon *InstancePtr, int IsEventMode);
|
||||
|
||||
void XSysMon_SetExtenalMux(XSysMon *InstancePtr, u8 Channel);
|
||||
|
||||
void XSysMon_SetAdcClkDivisor(XSysMon *InstancePtr, u8 Divisor);
|
||||
u8 XSysMon_GetAdcClkDivisor(XSysMon *InstancePtr);
|
||||
|
||||
int XSysMon_SetSeqChEnables(XSysMon *InstancePtr, u64 ChEnableMask);
|
||||
u64 XSysMon_GetSeqChEnables(XSysMon *InstancePtr);
|
||||
|
||||
int XSysMon_SetSeqAvgEnables(XSysMon *InstancePtr, u64 AvgEnableChMask);
|
||||
u64 XSysMon_GetSeqAvgEnables(XSysMon *InstancePtr);
|
||||
|
||||
int XSysMon_SetSeqInputMode(XSysMon *InstancePtr, u32 InputModeChMask);
|
||||
u32 XSysMon_GetSeqInputMode(XSysMon *InstancePtr);
|
||||
|
||||
int XSysMon_SetSeqAcqTime(XSysMon *InstancePtr, u32 AcqCyclesChMask);
|
||||
u32 XSysMon_GetSeqAcqTime(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_SetAlarmThreshold(XSysMon *InstancePtr, u8 AlarmThrReg, u16 Value);
|
||||
u16 XSysMon_GetAlarmThreshold(XSysMon *InstancePtr, u8 AlarmThrReg);
|
||||
|
||||
void XSysMon_SetOverTemp(XSysMon *InstancePtr, u16 Value);
|
||||
u16 XSysMon_GetOverTemp(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_EnableUserOverTemp(XSysMon *InstancePtr);
|
||||
void XSysMon_DisableUserOverTemp(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_EnableTempUpdate(XSysMon *InstancePtr);
|
||||
void XSysMon_DisableTempUpdate(XSysMon *InstancePtr);
|
||||
void XSysMon_SetTempWaitCycles(XSysMon *InstancePtr, u16 WaitCycles);
|
||||
|
||||
|
||||
/**
|
||||
* Functions in xsysmon_selftest.c
|
||||
*/
|
||||
int XSysMon_SelfTest(XSysMon *InstancePtr);
|
||||
|
||||
/**
|
||||
* Functions in xsysmon_intr.c
|
||||
*/
|
||||
void XSysMon_IntrGlobalEnable(XSysMon *InstancePtr);
|
||||
void XSysMon_IntrGlobalDisable(XSysMon *InstancePtr);
|
||||
|
||||
void XSysMon_IntrEnable(XSysMon *InstancePtr, u32 Mask);
|
||||
void XSysMon_IntrDisable(XSysMon *InstancePtr, u32 Mask);
|
||||
u32 XSysMon_IntrGetEnabled(XSysMon *InstancePtr);
|
||||
|
||||
u32 XSysMon_IntrGetStatus(XSysMon *InstancePtr);
|
||||
void XSysMon_IntrClear(XSysMon *InstancePtr, u32 Mask);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* End of protection macro. */
|
82
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_g.c
Normal file
82
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_g.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_g.c
|
||||
*
|
||||
* This file contains a configuration table that specifies the configuration
|
||||
* of System Monitor/ADC devices in the system.
|
||||
*
|
||||
* See xsysmon.h for more information about this driver.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each System Monitor/ADC
|
||||
* device in the system.
|
||||
*/
|
||||
XSysMon_Config XSysMon_ConfigTable[XPAR_XSYSMON_NUM_INSTANCES] =
|
||||
{
|
||||
{
|
||||
XPAR_SYSMON_0_DEVICE_ID, /**< Unique ID of device */
|
||||
XPAR_SYSMON_0_BASEADDR, /**< Base address of device */
|
||||
XPAR_SYSMON_0_INCLUDE_INTR /**< Include interrupt module */
|
||||
}
|
||||
};
|
683
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_hw.h
Normal file
683
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_hw.h
Normal file
|
@ -0,0 +1,683 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_hw.h
|
||||
*
|
||||
* This header file contains identifiers and basic driver functions (or
|
||||
* macros) that can be used to access the System Monitor/ADC device or XADC.
|
||||
*
|
||||
* Refer to the device specification for more information about this driver.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 2.00a sv 07/07/08 Added bit definitions for new Alarm Interrupts in the
|
||||
* Interrupt Registers.
|
||||
* 3.00a sdm 02/09/09 Added register and bit definitions for V6 SysMon.
|
||||
* 4.00a ktn 10/22/09 The macros have been renamed to remove _m from the name
|
||||
* of the macro.
|
||||
* 5.00a sdm 06/15/11 Added new definitions for XADC.
|
||||
* 5.01a bss 02/15/12 Updated for Zynq.
|
||||
* 5.02a bss 11/23/12 Added macros XSM_CONVST_TEMPUPDT_MASK,
|
||||
* XSM_CONVST_WAITCYCLES_MASK and
|
||||
* XSM_CONVST_WAITCYCLES_SHIFT (CR #679872)
|
||||
* 7.0 bss 7/25/14 To support Ultrascale:
|
||||
* Added XSM_IP_OFFSET macro.
|
||||
* Added Offsets and Masks for VUSER0 to VUSER3 channels.
|
||||
* Added Configuration Register 3 and Sequence Registers
|
||||
* 8 and 9.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef XSYSMON_HW_H /* Prevent circular inclusions */
|
||||
#define XSYSMON_HW_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xil_io.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
#define SYSTEM_MANAGEMENT 1 /* Ultrascale */
|
||||
#define XADC 0 /* 7 Series, Zynq */
|
||||
|
||||
|
||||
#if XPAR_SYSMON_0_IP_TYPE == SYSTEM_MANAGEMENT
|
||||
#define XSM_IP_OFFSET 0x200
|
||||
#else
|
||||
#define XSM_IP_OFFSET 0x00
|
||||
#endif
|
||||
|
||||
|
||||
/**@name Register offsets
|
||||
*
|
||||
* The following constants provide access to each of the registers of the
|
||||
* System Monitor/ADC device.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Local Registers
|
||||
*/
|
||||
#define XSM_SRR_OFFSET 0x00 /**< Software Reset Register */
|
||||
#define XSM_SR_OFFSET 0x04 /**< Status Register */
|
||||
#define XSM_AOR_OFFSET 0x08 /**< Alarm Output Register */
|
||||
#define XSM_CONVST_OFFSET 0x0C /**< ADC Convert Start Register */
|
||||
#define XSM_ARR_OFFSET 0x10 /**< ADC Reset Register */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Interrupt Registers
|
||||
*/
|
||||
#define XSM_GIER_OFFSET 0x5C /**< Global Interrupt Enable */
|
||||
#define XSM_IPISR_OFFSET 0x60 /**< Interrupt Status Register */
|
||||
#define XSM_IPIER_OFFSET 0x68 /**< Interrupt Enable register */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Internal Channel Registers
|
||||
*/
|
||||
#define XSM_TEMP_OFFSET (XSM_IP_OFFSET + 0x200)
|
||||
/**< On-chip Temperature Reg */
|
||||
#define XSM_VCCINT_OFFSET (XSM_IP_OFFSET + 0x204)
|
||||
/**< On-chip VCCINT Data Reg */
|
||||
#define XSM_VCCAUX_OFFSET (XSM_IP_OFFSET + 0x208)
|
||||
/**< On-chip VCCAUX Data Reg */
|
||||
#define XSM_VPVN_OFFSET (XSM_IP_OFFSET + 0x20C)
|
||||
/**< ADC out of VP/VN */
|
||||
#define XSM_VREFP_OFFSET (XSM_IP_OFFSET + 0x210)
|
||||
/**< On-chip VREFP Data Reg */
|
||||
#define XSM_VREFN_OFFSET (XSM_IP_OFFSET + 0x214)
|
||||
/**< On-chip VREFN Data Reg */
|
||||
#define XSM_VBRAM_OFFSET (XSM_IP_OFFSET + 0x218)
|
||||
/**< On-chip VBRAM Data,7-series/Zynq */
|
||||
#define XSM_SUPPLY_CALIB_OFFSET (XSM_IP_OFFSET + 0x220)
|
||||
/**< Supply Offset Data Reg */
|
||||
#define XSM_ADC_CALIB_OFFSET (XSM_IP_OFFSET + 0x224)
|
||||
/**< ADC Offset Data Reg */
|
||||
#define XSM_GAINERR_CALIB_OFFSET (XSM_IP_OFFSET + 0x228)
|
||||
/**< Gain Error Data Reg */
|
||||
#define XSM_VCCPINT_OFFSET (XSM_IP_OFFSET + 0x22C)
|
||||
/**< PS VCCPINT Data Reg - Zynq */
|
||||
#define XSM_VCCPAUX_OFFSET (XSM_IP_OFFSET + 0x230)
|
||||
/**< PS VCCPAUX Data Reg - Zynq */
|
||||
#define XSM_VCCPDRO_OFFSET (XSM_IP_OFFSET + 0x234)
|
||||
/**< PS VCCPDRO Data Reg - Zynq */
|
||||
#define XSM_VUSR0_OFFSET (XSM_IP_OFFSET + 0x400)
|
||||
/**< VUSER0 Supply - Ultrascale */
|
||||
#define XSM_VUSR1_OFFSET (XSM_IP_OFFSET + 0x404)
|
||||
/**< VUSER0 Supply - Ultrascale */
|
||||
#define XSM_VUSR2_OFFSET (XSM_IP_OFFSET + 0x408)
|
||||
/**< VUSER0 Supply - Ultrascale */
|
||||
#define XSM_VUSR3_OFFSET (XSM_IP_OFFSET + 0x40C)
|
||||
/**< VUSER0 Supply - Ultrascale */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC External Channel Registers
|
||||
*/
|
||||
#define XSM_AUX00_OFFSET (XSM_IP_OFFSET + 0x240)
|
||||
/**< ADC out of VAUXP0/VAUXN0 */
|
||||
#define XSM_AUX01_OFFSET (XSM_IP_OFFSET + 0x244)
|
||||
/**< ADC out of VAUXP1/VAUXN1 */
|
||||
#define XSM_AUX02_OFFSET (XSM_IP_OFFSET + 0x248)
|
||||
/**< ADC out of VAUXP2/VAUXN2 */
|
||||
#define XSM_AUX03_OFFSET (XSM_IP_OFFSET + 0x24C)
|
||||
/**< ADC out of VAUXP3/VAUXN3 */
|
||||
#define XSM_AUX04_OFFSET (XSM_IP_OFFSET + 0x250)
|
||||
/**< ADC out of VAUXP4/VAUXN4 */
|
||||
#define XSM_AUX05_OFFSET (XSM_IP_OFFSET + 0x254)
|
||||
/**< ADC out of VAUXP5/VAUXN5 */
|
||||
#define XSM_AUX06_OFFSET (XSM_IP_OFFSET + 0x258)
|
||||
/**< ADC out of VAUXP6/VAUXN6 */
|
||||
#define XSM_AUX07_OFFSET (XSM_IP_OFFSET + 0x25C)
|
||||
/**< ADC out of VAUXP7/VAUXN7 */
|
||||
#define XSM_AUX08_OFFSET (XSM_IP_OFFSET + 0x260)
|
||||
/**< ADC out of VAUXP8/VAUXN8 */
|
||||
#define XSM_AUX09_OFFSET (XSM_IP_OFFSET + 0x264)
|
||||
/**< ADC out of VAUXP9/VAUXN9 */
|
||||
#define XSM_AUX10_OFFSET (XSM_IP_OFFSET + 0x268)
|
||||
/**< ADC out of VAUXP10/VAUXN10 */
|
||||
#define XSM_AUX11_OFFSET (XSM_IP_OFFSET + 0x26C)
|
||||
/**< ADC out of VAUXP11/VAUXN11 */
|
||||
#define XSM_AUX12_OFFSET (XSM_IP_OFFSET + 0x270)
|
||||
/**< ADC out of VAUXP12/VAUXN12 */
|
||||
#define XSM_AUX13_OFFSET (XSM_IP_OFFSET + 0x274)
|
||||
/**< ADC out of VAUXP13/VAUXN13 */
|
||||
#define XSM_AUX14_OFFSET (XSM_IP_OFFSET + 0x278)
|
||||
/**< ADC out of VAUXP14/VAUXN14 */
|
||||
#define XSM_AUX15_OFFSET (XSM_IP_OFFSET + 0x27C)
|
||||
/**< ADC out of VAUXP15/VAUXN15 */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Registers for Maximum/Minimum data captured for the
|
||||
* on chip Temperature/VCCINT/VCCAUX data.
|
||||
*/
|
||||
#define XSM_MAX_TEMP_OFFSET (XSM_IP_OFFSET + 0x280)
|
||||
/**< Maximum Temperature Reg */
|
||||
#define XSM_MAX_VCCINT_OFFSET (XSM_IP_OFFSET + 0x284)
|
||||
/**< Maximum VCCINT Register */
|
||||
#define XSM_MAX_VCCAUX_OFFSET (XSM_IP_OFFSET + 0x288)
|
||||
/**< Maximum VCCAUX Register */
|
||||
#define XSM_MAX_VBRAM_OFFSET (XSM_IP_OFFSET + 0x28C)
|
||||
/**< Maximum VBRAM Reg, 7 Series/Zynq */
|
||||
#define XSM_MIN_TEMP_OFFSET (XSM_IP_OFFSET + 0x290)
|
||||
/**< Minimum Temperature Reg */
|
||||
#define XSM_MIN_VCCINT_OFFSET (XSM_IP_OFFSET + 0x294)
|
||||
/**< Minimum VCCINT Register */
|
||||
#define XSM_MIN_VCCAUX_OFFSET (XSM_IP_OFFSET + 0x298)
|
||||
/**< Minimum VCCAUX Register */
|
||||
#define XSM_MIN_VBRAM_OFFSET (XSM_IP_OFFSET + 0x29C)
|
||||
/**< Maximum VBRAM Reg, 7 Series/Zynq */
|
||||
#define XSM_MAX_VCCPINT_OFFSET (XSM_IP_OFFSET + 0x2A0)
|
||||
/**< Max VCCPINT Register, Zynq */
|
||||
#define XSM_MAX_VCCPAUX_OFFSET (XSM_IP_OFFSET + 0x2A4)
|
||||
/**< Max VCCPAUX Register, Zynq */
|
||||
#define XSM_MAX_VCCPDRO_OFFSET (XSM_IP_OFFSET + 0x2A8)
|
||||
/**< Max VCCPDRO Register, Zynq */
|
||||
#define XSM_MIN_VCCPINT_OFFSET (XSM_IP_OFFSET + 0x2AC)
|
||||
/**< Min VCCPINT Register, Zynq */
|
||||
#define XSM_MIN_VCCPAUX_OFFSET (XSM_IP_OFFSET + 0x2B0)
|
||||
/**< Min VCCPAUX Register, Zynq */
|
||||
#define XSM_MIN_VCCPDRO_OFFSET (XSM_IP_OFFSET + 0x2B4)
|
||||
/**< Min VCCPDRO Register, Zynq */
|
||||
#define XSM_MAX_VUSR0_OFFSET (XSM_IP_OFFSET + 0x480)
|
||||
/**< Maximum VUSER0 Supply Reg */
|
||||
#define XSM_MAX_VUSR1_OFFSET (XSM_IP_OFFSET + 0x484)
|
||||
/**< Maximum VUSER1 Supply Reg */
|
||||
#define XSM_MAX_VUSR2_OFFSET (XSM_IP_OFFSET + 0x488)
|
||||
/**< Maximum VUSER2 Supply Reg */
|
||||
#define XSM_MAX_VUSR3_OFFSET (XSM_IP_OFFSET + 0x48C)
|
||||
/**< Maximum VUSER3 Supply Reg */
|
||||
#define XSM_MIN_VUSR0_OFFSET (XSM_IP_OFFSET + 0x4A0)
|
||||
/**< Minimum VUSER0 Supply Reg */
|
||||
#define XSM_MIN_VUSR1_OFFSET (XSM_IP_OFFSET + 0x4A4)
|
||||
/**< Minimum VUSER1 Supply Reg */
|
||||
#define XSM_MIN_VUSR2_OFFSET (XSM_IP_OFFSET + 0x4A8)
|
||||
/**< Minimum VUSER2 Supply Reg */
|
||||
#define XSM_MIN_VUSR3_OFFSET (XSM_IP_OFFSET + 0x4AC)
|
||||
/**< Minimum VUSER3 Supply Reg */
|
||||
|
||||
|
||||
#define XSM_FLAG_REG_OFFSET (XSM_IP_OFFSET + 0x2FC) /**< General Status */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Configuration Registers
|
||||
*/
|
||||
#define XSM_CFR0_OFFSET (XSM_IP_OFFSET + 0x300)
|
||||
/**< Configuration Register 0 */
|
||||
#define XSM_CFR1_OFFSET (XSM_IP_OFFSET + 0x304)
|
||||
/**< Configuration Register 1 */
|
||||
#define XSM_CFR2_OFFSET (XSM_IP_OFFSET + 0x308)
|
||||
/**< Configuration Register 2 */
|
||||
#define XSM_CFR3_OFFSET (XSM_IP_OFFSET + 0x30C)
|
||||
/**< Configuration Register 2 */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Sequence Registers
|
||||
*/
|
||||
#define XSM_SEQ00_OFFSET (XSM_IP_OFFSET + 0x320)
|
||||
/**< Seq Reg 00 Adc Channel Selection */
|
||||
#define XSM_SEQ01_OFFSET (XSM_IP_OFFSET + 0x324)
|
||||
/**< Seq Reg 01 Adc Channel Selection */
|
||||
#define XSM_SEQ02_OFFSET (XSM_IP_OFFSET + 0x328)
|
||||
/**< Seq Reg 02 Adc Average Enable */
|
||||
#define XSM_SEQ03_OFFSET (XSM_IP_OFFSET + 0x32C)
|
||||
/**< Seq Reg 03 Adc Average Enable */
|
||||
#define XSM_SEQ04_OFFSET (XSM_IP_OFFSET + 0x330)
|
||||
/**< Seq Reg 04 Adc Input Mode Select */
|
||||
#define XSM_SEQ05_OFFSET (XSM_IP_OFFSET + 0x334)
|
||||
/**< Seq Reg 05 Adc Input Mode Select */
|
||||
#define XSM_SEQ06_OFFSET (XSM_IP_OFFSET + 0x338)
|
||||
/**< Seq Reg 06 Adc Acquisition Select */
|
||||
#define XSM_SEQ07_OFFSET (XSM_IP_OFFSET + 0x33C)
|
||||
/**< Seq Reg 07 Adc Acquisition Select */
|
||||
#define XSM_SEQ08_OFFSET (XSM_IP_OFFSET + 0x318)
|
||||
/**< Seq Reg 08 Adc Channel Selection */
|
||||
#define XSM_SEQ09_OFFSET (XSM_IP_OFFSET + 0x31C)
|
||||
/**< Seq Reg 09 Adc Average Enable */
|
||||
|
||||
/*
|
||||
* System Monitor/ADC Alarm Threshold/Limit Registers (ATR)
|
||||
*/
|
||||
#define XSM_ATR_TEMP_UPPER_OFFSET (XSM_IP_OFFSET + 0x340)
|
||||
/**< Temp Upper Alarm Register */
|
||||
#define XSM_ATR_VCCINT_UPPER_OFFSET (XSM_IP_OFFSET + 0x344)
|
||||
/**< VCCINT Upper Alarm Reg */
|
||||
#define XSM_ATR_VCCAUX_UPPER_OFFSET (XSM_IP_OFFSET + 0x348)
|
||||
/**< VCCAUX Upper Alarm Reg */
|
||||
#define XSM_ATR_OT_UPPER_OFFSET (XSM_IP_OFFSET + 0x34C)
|
||||
/**< Over Temp Upper Alarm Reg */
|
||||
#define XSM_ATR_TEMP_LOWER_OFFSET (XSM_IP_OFFSET + 0x350)
|
||||
/**< Temp Lower Alarm Register */
|
||||
#define XSM_ATR_VCCINT_LOWER_OFFSET (XSM_IP_OFFSET + 0x354)
|
||||
/**< VCCINT Lower Alarm Reg */
|
||||
#define XSM_ATR_VCCAUX_LOWER_OFFSET (XSM_IP_OFFSET + 0x358)
|
||||
/**< VCCAUX Lower Alarm Reg */
|
||||
#define XSM_ATR_OT_LOWER_OFFSET (XSM_IP_OFFSET + 0x35C)
|
||||
/**< Over Temp Lower Alarm Reg */
|
||||
#define XSM_ATR_VBRAM_UPPER_OFFSET (XSM_IP_OFFSET + 0x360)
|
||||
/**< VBBAM Upper Alarm,7 Series */
|
||||
#define XSM_ATR_VCCPINT_UPPER_OFFSET (XSM_IP_OFFSET + 0x364)
|
||||
/**< VCCPINT Upper Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPAUX_UPPER_OFFSET (XSM_IP_OFFSET + 0x368)
|
||||
/**< VCCPAUX Upper Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPDRO_UPPER_OFFSET (XSM_IP_OFFSET + 0x36C)
|
||||
/**< VCCPDRO Upper Alarm, Zynq */
|
||||
#define XSM_ATR_VBRAM_LOWER_OFFSET (XSM_IP_OFFSET + 0x370)
|
||||
/**< VRBAM Lower Alarm, 7 Series*/
|
||||
#define XSM_ATR_VCCPINT_LOWER_OFFSET (XSM_IP_OFFSET + 0x374)
|
||||
/**< VCCPINT Lower Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPAUX_LOWER_OFFSET (XSM_IP_OFFSET + 0x378)
|
||||
/**< VCCPAUX Lower Alarm, Zynq */
|
||||
#define XSM_ATR_VCCPDRO_LOWER_OFFSET (XSM_IP_OFFSET + 0x37C)
|
||||
/**< VCCPDRO Lower Alarm, Zynq */
|
||||
#define XSM_ATR_VUSR0_UPPER_OFFSET (XSM_IP_OFFSET + 0x380)
|
||||
/**< VUSER0 Upper Alarm Reg */
|
||||
#define XSM_ATR_VUSR1_UPPER_OFFSET (XSM_IP_OFFSET + 0x384)
|
||||
/**< VUSER1 Upper Alarm Reg */
|
||||
#define XSM_ATR_VUSR2_UPPER_OFFSET (XSM_IP_OFFSET + 0x388)
|
||||
/**< VUSER2 Upper Alarm Reg */
|
||||
#define XSM_ATR_VUSR3_UPPER_OFFSET (XSM_IP_OFFSET + 0x38C)
|
||||
/**< VUSER3 Upper Alarm Reg */
|
||||
#define XSM_ATR_VUSR0_LOWER_OFFSET (XSM_IP_OFFSET + 0x3A0)
|
||||
/**< VUSER0 Lower Alarm Reg */
|
||||
#define XSM_ATR_VUSR1_LOWER_OFFSET (XSM_IP_OFFSET + 0x3A4)
|
||||
/**< VUSER1 Lower Alarm Reg */
|
||||
#define XSM_ATR_VUSR2_LOWER_OFFSET (XSM_IP_OFFSET + 0x3A8)
|
||||
/**< VUSER2 Lower Alarm Reg */
|
||||
#define XSM_ATR_VUSR3_LOWER_OFFSET (XSM_IP_OFFSET + 0x3AC)
|
||||
/**< VUSER3 Lower Alarm Reg */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name System Monitor/ADC Software Reset Register (SRR) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_SRR_IPRST_MASK 0x0000000A /**< Device Reset Mask */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name System Monitor/ADC Status Register (SR) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_SR_JTAG_BUSY_MASK 0x00000400 /**< JTAG is busy */
|
||||
#define XSM_SR_JTAG_MODIFIED_MASK 0x00000200 /**< JTAG Write has occurred */
|
||||
#define XSM_SR_JTAG_LOCKED_MASK 0x00000100 /**< JTAG is locked */
|
||||
#define XSM_SR_BUSY_MASK 0x00000080 /**< ADC is busy in conversion */
|
||||
#define XSM_SR_EOS_MASK 0x00000040 /**< End of Sequence */
|
||||
#define XSM_SR_EOC_MASK 0x00000020 /**< End of Conversion */
|
||||
#define XSM_SR_CH_MASK 0x0000001F /**< Input ADC channel */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name System Monitor/ADC Alarm Output Register (AOR) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_AOR_ALARM_ALL_MASK 0x00001FFF /**< Mask for all Alarms */
|
||||
#define XSM_AOR_VUSR3_MASK 0x00001000 /**< ALM11 - VUSER3 Alarm Mask */
|
||||
#define XSM_AOR_VUSR2_MASK 0x00000800 /**< ALM10 - VUSER2 Alarm Mask */
|
||||
#define XSM_AOR_VUSR1_MASK 0x00000400 /**< ALM9 - VUSER1 Alarm Mask */
|
||||
#define XSM_AOR_VUSR0_MASK 0x00000200 /**< ALM8 - VUSER0 Alarm Mask */
|
||||
#define XSM_AOR_ALL_MASK 0x00000100 /**< ALM7 - All Alarms 0 to 6 */
|
||||
#define XSM_AOR_VCCPDRO_MASK 0x00000080 /**< ALM6 - VCCPDRO Mask, Zynq */
|
||||
#define XSM_AOR_VCCPAUX_MASK 0x00000040 /**< ALM5 - VCCPAUX Mask, Zynq */
|
||||
#define XSM_AOR_VCCPINT_MASK 0x00000020 /**< ALM4 - VCCPINT Mask, Zynq */
|
||||
#define XSM_AOR_VBRAM_MASK 0x00000010 /**< ALM3 - VBRAM Output Mask
|
||||
* - 7 Series and Zynq */
|
||||
#define XSM_AOR_VCCAUX_MASK 0x00000008 /**< ALM2 - VCCAUX Output Mask */
|
||||
#define XSM_AOR_VCCINT_MASK 0x00000004 /**< ALM1 - VCCINT Alarm Mask */
|
||||
#define XSM_AOR_TEMP_MASK 0x00000002 /**< ALM0 - Temp sensor Alarm Mask */
|
||||
#define XSM_AOR_OT_MASK 0x00000001 /**< Over Temp Alarm Output */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name System Monitor/ADC CONVST Register (CONVST) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CONVST_CONVST_MASK 0x00000001
|
||||
/**< Conversion Start Mask */
|
||||
#define XSM_CONVST_TEMPUPDT_MASK 0x00000002
|
||||
/**< Temperature Update
|
||||
Enable Mask */
|
||||
#define XSM_CONVST_WAITCYCLES_SHIFT 2 /**< Wait Cycles Shift */
|
||||
#define XSM_CONVST_WAITCYCLES_MASK 0x0003FFFC /**< Wait Cycles Mask */
|
||||
#define XSM_CONVST_WAITCYCLES_DEFAULT 0x03E8 /**< Wait Cycles
|
||||
default value */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name System Monitor/ADC Reset Register (ARR) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_ARR_RST_MASK 0x00000001 /**< ADC Reset bit mask */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Global Interrupt Enable Register (GIER) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_GIER_GIE_MASK 0x80000000 /**< Global interrupt enable */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name System Monitor/ADC device Interrupt Status/Enable Registers
|
||||
*
|
||||
* <b> Interrupt Status Register (IPISR) </b>
|
||||
*
|
||||
* This register holds the interrupt status flags for the device.
|
||||
*
|
||||
* <b> Interrupt Enable Register (IPIER) </b>
|
||||
*
|
||||
* This register is used to enable interrupt sources for the device.
|
||||
* Writing a '1' to a bit in this register enables the corresponding Interrupt.
|
||||
* Writing a '0' to a bit in this register disables the corresponding Interrupt
|
||||
*
|
||||
* IPISR/IPIER registers have the same bit definitions and are only defined
|
||||
* once.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_IPIXR_VBRAM_MASK 0x00000400 /**< ALM3 - VBRAM Output Mask
|
||||
* - 7 Series and Zynq */
|
||||
#define XSM_IPIXR_TEMP_DEACTIVE_MASK 0x00000200 /**< Alarm 0 DEACTIVE */
|
||||
#define XSM_IPIXR_OT_DEACTIVE_MASK 0x00000100 /**< Over Temp DEACTIVE */
|
||||
#define XSM_IPIXR_JTAG_MODIFIED_MASK 0x00000080 /**< JTAG Modified */
|
||||
#define XSM_IPIXR_JTAG_LOCKED_MASK 0x00000040 /**< JTAG Locked */
|
||||
#define XSM_IPIXR_EOC_MASK 0x00000020 /**< End Of Conversion */
|
||||
#define XSM_IPIXR_EOS_MASK 0x00000010 /**< End Of Sequence */
|
||||
#define XSM_IPIXR_VCCAUX_MASK 0x00000008 /**< Alarm 2 - VCCAUX */
|
||||
#define XSM_IPIXR_VCCINT_MASK 0x00000004 /**< Alarm 1 - VCCINT */
|
||||
#define XSM_IPIXR_TEMP_MASK 0x00000002 /**< Alarm 0 - Temp ACTIVE */
|
||||
#define XSM_IPIXR_OT_MASK 0x00000001 /**< Over Temperature ACTIVE */
|
||||
#define XSM_IPIXR_VUSR0_MASK 0x00004000 /**< Alarm 8 VUSER0 */
|
||||
#define XSM_IPIXR_VUSR1_MASK 0x00008000 /**< Alarm 9 VUSER1 */
|
||||
#define XSM_IPIXR_VUSR2_MASK 0x00010000 /**< Alarm 10 VUSER2 */
|
||||
#define XSM_IPIXR_VUSR3_MASK 0x00020000 /**< Alarm 11 VUSER3 */
|
||||
#define XSM_IPIXR_ALL_MASK 0x0003C7FF /**< Mask of all interrupts */
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Mask for all ADC converted data including Minimum/Maximum Measurements
|
||||
* and Threshold data.
|
||||
* @{
|
||||
*/
|
||||
#define XSM_ADCDATA_MAX_MASK 0x03FF
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Configuration Register 0 (CFR0) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CFR0_CAL_AVG_MASK 0x8000 /**< Averaging enable Mask */
|
||||
#define XSM_CFR0_AVG_VALID_MASK 0x3000 /**< Averaging bit Mask */
|
||||
#define XSM_CFR0_AVG1_MASK 0x0000 /**< No Averaging */
|
||||
#define XSM_CFR0_AVG16_MASK 0x1000 /**< Average 16 samples */
|
||||
#define XSM_CFR0_AVG64_MASK 0x2000 /**< Average 64 samples */
|
||||
#define XSM_CFR0_AVG256_MASK 0x3000 /**< Average 256 samples */
|
||||
#define XSM_CFR0_AVG_SHIFT 12 /**< Shift for the Averaging bits */
|
||||
#define XSM_CFR0_MUX_MASK 0x0800 /**< External Mux Mask Enable
|
||||
* - 7 Series and Zynq */
|
||||
#define XSM_CFR0_DU_MASK 0x0400 /**< Bipolar/Unipolar mode */
|
||||
#define XSM_CFR0_EC_MASK 0x0200 /**< Event driven/Continuous mode */
|
||||
#define XSM_CFR0_ACQ_MASK 0x0100 /**< Add acquisition by 6 ADCCLK */
|
||||
#define XSM_CFR0_CHANNEL_MASK 0x003F /**< Channel number bit Mask */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Configuration Register 1 (CFR1) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CFR1_SEQ_VALID_MASK 0xF000 /**< Sequence bit Mask */
|
||||
#define XSM_CFR1_SEQ_SAFEMODE_MASK 0x0000 /**< Default Safe Mode */
|
||||
#define XSM_CFR1_SEQ_ONEPASS_MASK 0x1000 /**< Onepass through Seq */
|
||||
#define XSM_CFR1_SEQ_CONTINPASS_MASK 0x2000 /**< Continuous Cycling Seq */
|
||||
#define XSM_CFR1_SEQ_SINGCHAN_MASK 0x3000 /**< Single channel - No Seq */
|
||||
#define XSM_CFR1_SEQ_SIMUL_SAMPLING_MASK 0x4000 /**< Simulataneous Sampling
|
||||
* Mask */
|
||||
#define XSM_CFR1_SEQ_INDEPENDENT_MASK 0x8000 /**< Independent Mode */
|
||||
#define XSM_CFR1_SEQ_SHIFT 12 /**< Sequence bit shift */
|
||||
#define XSM_CFR1_ALM_VCCPDRO_MASK 0x0800 /**< Alarm 6 - VCCPDRO, Zynq */
|
||||
#define XSM_CFR1_ALM_VCCPAUX_MASK 0x0400 /**< Alarm 5 - VCCPAUX, Zynq */
|
||||
#define XSM_CFR1_ALM_VCCPINT_MASK 0x0200 /**< Alarm 4 - VCCPINT, Zynq */
|
||||
#define XSM_CFR1_ALM_VBRAM_MASK 0x0100 /**< Alarm 3 - VBRAM Enable
|
||||
* 7 Series and Zynq */
|
||||
#define XSM_CFR1_CAL_VALID_MASK 0x00F0 /**< Valid Calibration Mask */
|
||||
#define XSM_CFR1_CAL_PS_GAIN_OFFSET_MASK 0x0080 /**< Calibration 3 -Power
|
||||
Supply Gain/Offset
|
||||
Enable */
|
||||
#define XSM_CFR1_CAL_PS_OFFSET_MASK 0x0040 /**< Calibration 2 -Power
|
||||
Supply Offset Enable */
|
||||
#define XSM_CFR1_CAL_ADC_GAIN_OFFSET_MASK 0x0020 /**< Calibration 1 -ADC Gain
|
||||
Offset Enable */
|
||||
#define XSM_CFR1_CAL_ADC_OFFSET_MASK 0x0010 /**< Calibration 0 -ADC Offset
|
||||
Enable */
|
||||
#define XSM_CFR1_CAL_DISABLE_MASK 0x0000 /**< No Calibration */
|
||||
#define XSM_CFR1_ALM_ALL_MASK 0x0F0F /**< Mask for all alarms */
|
||||
#define XSM_CFR1_ALM_VCCAUX_MASK 0x0008 /**< Alarm 2 - VCCAUX Enable */
|
||||
#define XSM_CFR1_ALM_VCCINT_MASK 0x0004 /**< Alarm 1 - VCCINT Enable */
|
||||
#define XSM_CFR1_ALM_TEMP_MASK 0x0002 /**< Alarm 0 - Temperature */
|
||||
#define XSM_CFR1_OT_MASK 0x0001 /**< Over Temperature Enable */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Configuration Register 2 (CFR2) mask(s)
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CFR2_CD_VALID_MASK 0xFF00 /**<Clock Divisor bit Mask */
|
||||
#define XSM_CFR2_CD_SHIFT 8 /**<Num of shift on division */
|
||||
#define XSM_CFR2_CD_MIN 8 /**<Minimum value of divisor */
|
||||
#define XSM_CFR2_CD_MAX 255 /**<Maximum value of divisor */
|
||||
|
||||
#define XSM_CFR2_PD_MASK 0x0030 /**<Power Down Mask */
|
||||
#define XSM_CFR2_PD_XADC_MASK 0x0030 /**<Power Down XADC Mask */
|
||||
#define XSM_CFR2_PD_ADC1_MASK 0x0020 /**<Power Down XADC Mask */
|
||||
#define XSM_CFR2_PD_SHIFT 4 /**<Power Down Shift */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Configuration Register 3 (CFR3) mask(s)
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSM_CFR3_ALM_ALL_MASK 0x000F /**< Mask for all alarms */
|
||||
#define XSM_CFR3_ALM_VUSR3_MASK 0x0008 /**< VUSER 0 Supply */
|
||||
#define XSM_CFR3_ALM_VUSR2_MASK 0x0004 /**< VUSER 1 Supply */
|
||||
#define XSM_CFR3_ALM_VUSR1_MASK 0x0002 /**< VUSER 2 Supply */
|
||||
#define XSM_CFR3_ALM_VUSR0_MASK 0x0001 /**< VUSER 3 Supply */
|
||||
|
||||
/* Mask for all Alarms in CFR1 and CFR3 */
|
||||
#define XSM_CFR_ALM_ALL_MASK 0xF0F0F
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Alarm masks for channels in Configuration registers 1 and 3
|
||||
* @{
|
||||
*/
|
||||
#define XSM_CFR_ALM_VUSR3_MASK 0x00080000 /**< VUSER 0 Supply */
|
||||
#define XSM_CFR_ALM_VUSR2_MASK 0x00040000 /**< VUSER 1 Supply */
|
||||
#define XSM_CFR_ALM_VUSR1_MASK 0x00020000 /**< VUSER 2 Supply */
|
||||
#define XSM_CFR_ALM_VUSR0_MASK 0x00010000 /**< VUSER 3 Supply */
|
||||
#define XSM_CFR_ALM_VCCPDRO_MASK 0x0800 /**< Alarm 6 - VCCPDRO, Zynq */
|
||||
#define XSM_CFR_ALM_VCCPAUX_MASK 0x0400 /**< Alarm 5 - VCCPAUX, Zynq */
|
||||
#define XSM_CFR_ALM_VCCPINT_MASK 0x0200 /**< Alarm 4 - VCCPINT, Zynq */
|
||||
#define XSM_CFR_ALM_VBRAM_MASK 0x0100 /**< Alarm 3 - VBRAM Enable
|
||||
* 7 Series and Zynq */
|
||||
#define XSM_CFR_ALM_VCCAUX_MASK 0x0008 /**< Alarm 2 - VCCAUX Enable */
|
||||
#define XSM_CFR_ALM_VCCINT_MASK 0x0004 /**< Alarm 1 - VCCINT Enable */
|
||||
#define XSM_CFR_ALM_TEMP_MASK 0x0002 /**< Alarm 0 - Temperature */
|
||||
#define XSM_CFR_OT_MASK 0x0001 /**< Over Temperature Enable */
|
||||
|
||||
/**
|
||||
* @name Sequence Register (SEQ) Bit Definitions
|
||||
* @{
|
||||
*/
|
||||
#define XSM_SEQ_CH_CALIB 0x00000001 /**< ADC Calibration Channel */
|
||||
#define XSM_SEQ_CH_VCCPINT 0x00000020 /**< VCCPINT, Zynq Only */
|
||||
#define XSM_SEQ_CH_VCCPAUX 0x00000040 /**< VCCPAUX, Zynq Only */
|
||||
#define XSM_SEQ_CH_VCCPDRO 0x00000080 /**< VCCPDRO, Zynq Only */
|
||||
#define XSM_SEQ_CH_TEMP 0x00000100 /**< On Chip Temperature Channel */
|
||||
#define XSM_SEQ_CH_VCCINT 0x00000200 /**< VCCINT Channel */
|
||||
#define XSM_SEQ_CH_VCCAUX 0x00000400 /**< VCCAUX Channel */
|
||||
#define XSM_SEQ_CH_VPVN 0x00000800 /**< VP/VN analog inputs Channel */
|
||||
#define XSM_SEQ_CH_VREFP 0x00001000 /**< VREFP Channel */
|
||||
#define XSM_SEQ_CH_VREFN 0x00002000 /**< VREFN Channel */
|
||||
#define XSM_SEQ_CH_VBRAM 0x00004000 /**< VBRAM Channel, 7 series/Zynq */
|
||||
#define XSM_SEQ_CH_AUX00 0x00010000 /**< 1st Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX01 0x00020000 /**< 2nd Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX02 0x00040000 /**< 3rd Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX03 0x00080000 /**< 4th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX04 0x00100000 /**< 5th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX05 0x00200000 /**< 6th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX06 0x00400000 /**< 7th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX07 0x00800000 /**< 8th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX08 0x01000000 /**< 9th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX09 0x02000000 /**< 10th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX10 0x04000000 /**< 11th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX11 0x08000000 /**< 12th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX12 0x10000000 /**< 13th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX13 0x20000000 /**< 14th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX14 0x40000000 /**< 15th Aux Channel */
|
||||
#define XSM_SEQ_CH_AUX15 0x80000000 /**< 16th Aux Channel */
|
||||
#define XSM_SEQ_CH_VUSR0 0x100000000 /**< VUSER0 Channel */
|
||||
#define XSM_SEQ_CH_VUSR1 0x200000000 /**< VUSER1 Channel */
|
||||
#define XSM_SEQ_CH_VUSR2 0x400000000 /**< VUSER2 Channel */
|
||||
#define XSM_SEQ_CH_VUSR3 0x800000000 /**< VUSER3 Channel */
|
||||
|
||||
#define XSM_SEQ00_CH_VALID_MASK 0x7FE1 /**< Mask for the valid channels */
|
||||
#define XSM_SEQ01_CH_VALID_MASK 0xFFFF /**< Mask for the valid channels */
|
||||
|
||||
#define XSM_SEQ02_CH_VALID_MASK 0x7FE0 /**< Mask for the valid channels */
|
||||
#define XSM_SEQ03_CH_VALID_MASK 0xFFFF /**< Mask for the valid channels */
|
||||
|
||||
#define XSM_SEQ04_CH_VALID_MASK 0x0800 /**< Mask for the valid channels */
|
||||
#define XSM_SEQ05_CH_VALID_MASK 0xFFFF /**< Mask for the valid channels */
|
||||
|
||||
#define XSM_SEQ06_CH_VALID_MASK 0x0800 /**< Mask for the valid channels */
|
||||
#define XSM_SEQ07_CH_VALID_MASK 0xFFFF /**< Mask for the valid channels */
|
||||
|
||||
#define XSM_SEQ08_CH_VALID_MASK 0x000F /**< Mask for the valid channels */
|
||||
#define XSM_SEQ09_CH_VALID_MASK 0x000F /**< Mask for the valid channels */
|
||||
|
||||
#define XSM_SEQ_CH_AUX_SHIFT 16 /**< Shift for the Aux Channel */
|
||||
|
||||
#define XSM_SEQ_CH_VUSR_SHIFT 32 /**< Shift for the Aux Channel */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name OT Upper Alarm Threshold Register Bit Definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSM_ATR_OT_UPPER_ENB_MASK 0x000F /**< Mask for OT enable */
|
||||
#define XSM_ATR_OT_UPPER_VAL_MASK 0xFFF0 /**< Mask for OT value */
|
||||
#define XSM_ATR_OT_UPPER_VAL_SHIFT 4 /**< Shift for OT value */
|
||||
#define XSM_ATR_OT_UPPER_ENB_VAL 0x0003 /**< Value for OT enable */
|
||||
#define XSM_ATR_OT_UPPER_VAL_MAX 0x0FFF /**< Max OT value */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read a register of the System Monitor/ADC device. This macro provides register
|
||||
* access to all registers using the register offsets defined above.
|
||||
*
|
||||
* @param BaseAddress contains the base address of the device.
|
||||
* @param RegOffset is the offset of the register to read.
|
||||
*
|
||||
* @return The contents of the register.
|
||||
*
|
||||
* @note C-style Signature:
|
||||
* u32 XSysMon_ReadReg(u32 BaseAddress, u32 RegOffset);
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XSysMon_ReadReg(BaseAddress, RegOffset) \
|
||||
(Xil_In32((BaseAddress) + (RegOffset)))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write a register of the System Monitor/ADC device. This macro provides
|
||||
* register access to all registers using the register offsets defined above.
|
||||
*
|
||||
* @param BaseAddress contains the base address of the device.
|
||||
* @param RegOffset is the offset of the register to write.
|
||||
* @param Data is the value to write to the register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style Signature:
|
||||
* void XSysMon_WriteReg(u32 BaseAddress,
|
||||
* u32 RegOffset,u32 Data)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XSysMon_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
(Xil_Out32((BaseAddress) + (RegOffset), (Data)))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* End of protection macro. */
|
318
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_intr.c
Normal file
318
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_intr.c
Normal file
|
@ -0,0 +1,318 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_intr.c
|
||||
*
|
||||
* This file contains interrupt handling API functions of the System Monitor/ADC
|
||||
* device.
|
||||
*
|
||||
* The device must be configured at hardware build time to support interrupt
|
||||
* for all the functions in this file to work.
|
||||
*
|
||||
* Refer to xsysmon.h header file and device specification for more information.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Calling the interrupt functions without including the interrupt component will
|
||||
* result in asserts if asserts are enabled, and will result in a unpredictable
|
||||
* behavior if the asserts are not enabled.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 4.00a ktn 10/22/09 Updated the file to use the HAL Processor APIs/macros.
|
||||
* The macros have been renamed to remove _m from the name
|
||||
* of the macro.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function enables the global interrupt in the Global Interrupt Enable
|
||||
* Register (GIER) so that the interrupt output from the System Monitor/ADC
|
||||
* device is enabled. Interrupts enabled using XSysMon_IntrEnable() will not
|
||||
* occur until the global interrupt enable bit is set by using this function.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XSysMon_IntrGlobalEnable(XSysMon *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Enable the Global Interrupt.
|
||||
*/
|
||||
XSysMon_WriteReg(InstancePtr->Config.BaseAddress, XSM_GIER_OFFSET,
|
||||
XSM_GIER_GIE_MASK);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function disables the global interrupt in the Global Interrupt Enable
|
||||
* Register (GIER) so that the interrupt output from the System Monitor/ADC
|
||||
* device is disabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XSysMon_IntrGlobalDisable(XSysMon *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Disable the Global Interrupt.
|
||||
*/
|
||||
XSysMon_WriteReg(InstancePtr->Config.BaseAddress, XSM_GIER_OFFSET, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function enables the specified interrupts in the device.
|
||||
* Interrupts enabled using this function will not occur until the global
|
||||
* interrupt enable bit is set by using the XSysMon_IntrGlobalEnable()function.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
* @param Mask is the bit-mask of the interrupts to be enabled.
|
||||
* Bit positions of 1 will be enabled. Bit positions of 0 will
|
||||
* keep the previous setting. This mask is formed by OR'ing
|
||||
* XSM_IPIXR_* bits defined in xsysmon_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XSysMon_IntrEnable(XSysMon *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 RegValue;
|
||||
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Enable the specified interrupts in the IPIER.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSM_IPIER_OFFSET);
|
||||
RegValue |= (Mask & XSM_IPIXR_ALL_MASK);
|
||||
XSysMon_WriteReg(InstancePtr->Config.BaseAddress, XSM_IPIER_OFFSET,
|
||||
RegValue);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function disables the specified interrupts in the device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
* @param Mask is the bit-mask of the interrupts to be disabled.
|
||||
* Bit positions of 1 will be disabled. Bit positions of 0 will
|
||||
* keep the previous setting. This mask is formed by OR'ing
|
||||
* XSM_IPIXR_* bits defined in xsysmon_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XSysMon_IntrDisable(XSysMon *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 RegValue;
|
||||
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Disable the specified interrupts in the IPIER.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSM_IPIER_OFFSET);
|
||||
RegValue &= ~(Mask & XSM_IPIXR_ALL_MASK);
|
||||
XSysMon_WriteReg(InstancePtr->Config.BaseAddress, XSM_IPIER_OFFSET,
|
||||
RegValue);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the enabled interrupts read from the Interrupt Enable
|
||||
* Register (IPIER). Use the XSM_IPIXR_* constants defined in xsysmon_hw.h to
|
||||
* interpret the returned value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the IPIER.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XSysMon_IntrGetEnabled(XSysMon *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Return the value read from the Interrupt Enable Register.
|
||||
*/
|
||||
return XSysMon_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSM_IPIER_OFFSET) & XSM_IPIXR_ALL_MASK;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the interrupt status read from Interrupt Status
|
||||
* Register(IPISR). Use the XSM_IPIXR_* constants defined in xsysmon_hw.h
|
||||
* to interpret the returned value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the IPISR.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XSysMon_IntrGetStatus(XSysMon *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Return the value read from the Interrupt Status register.
|
||||
*/
|
||||
return XSysMon_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSM_IPISR_OFFSET) & XSM_IPIXR_ALL_MASK;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function clears the specified interrupts in the Interrupt Status
|
||||
* Register (IPISR).
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
* @param Mask is the bit-mask of the interrupts to be cleared.
|
||||
* Bit positions of 1 will be cleared. Bit positions of 0 will not
|
||||
* change the previous interrupt status. This mask is formed by
|
||||
* OR'ing XSM_IPIXR_* bits which are defined in xsysmon_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note The device must be configured at hardware build time to include
|
||||
* interrupt component for this function to work.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XSysMon_IntrClear(XSysMon *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 RegValue;
|
||||
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(InstancePtr->Config.IncludeInterrupt == TRUE);
|
||||
|
||||
/*
|
||||
* Clear the specified interrupts in the Interrupt Status register.
|
||||
*/
|
||||
RegValue = XSysMon_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSM_IPISR_OFFSET);
|
||||
RegValue &= (Mask & XSM_IPIXR_ALL_MASK);
|
||||
XSysMon_WriteReg(InstancePtr->Config.BaseAddress, XSM_IPISR_OFFSET,
|
||||
RegValue);
|
||||
|
||||
}
|
141
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_selftest.c
Normal file
141
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_selftest.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_selftest.c
|
||||
*
|
||||
* This file contains a diagnostic self test function for the XSysMon driver.
|
||||
* The self test function does a simple read/write test of the Alarm Threshold
|
||||
* Register.
|
||||
*
|
||||
* See xsysmon.h for more information.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
* 4.00a ktn 10/22/09 Updated the file to use the HAL APIs/macros.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xsysmon.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* The following constant defines the test value to be written
|
||||
* to the Alarm Threshold Register
|
||||
*/
|
||||
#define XSM_ATR_TEST_VALUE 0x55
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Run a self-test on the driver/device. The test
|
||||
* - Resets the device,
|
||||
* - Writes a value into the Alarm Threshold register and reads it back
|
||||
* for comparison.
|
||||
* - Resets the device again.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSysMon instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the value read from the Alarm Threshold
|
||||
* register is the same as the value written.
|
||||
* - XST_FAILURE Otherwise
|
||||
*
|
||||
* @note This is a destructive test in that resets of the device are
|
||||
* performed. Refer to the device specification for the
|
||||
* device status after the reset operation.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XSysMon_SelfTest(XSysMon *InstancePtr)
|
||||
{
|
||||
int Status;
|
||||
u32 RegValue;
|
||||
|
||||
/*
|
||||
* Assert the argument
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
/*
|
||||
* Reset the device to get it back to its default state
|
||||
*/
|
||||
XSysMon_Reset(InstancePtr);
|
||||
|
||||
/*
|
||||
* Write a value into the Alarm Threshold registers, read it back, and
|
||||
* do the comparison
|
||||
*/
|
||||
XSysMon_SetAlarmThreshold(InstancePtr, XSM_ATR_VCCINT_UPPER,
|
||||
XSM_ATR_TEST_VALUE);
|
||||
RegValue = XSysMon_GetAlarmThreshold(InstancePtr, XSM_ATR_VCCINT_UPPER);
|
||||
|
||||
if (RegValue == XSM_ATR_TEST_VALUE) {
|
||||
Status = XST_SUCCESS;
|
||||
} else {
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the device again to its default state.
|
||||
*/
|
||||
XSysMon_Reset(InstancePtr);
|
||||
|
||||
|
||||
/*
|
||||
* Return the test result.
|
||||
*/
|
||||
return Status;
|
||||
}
|
100
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_sinit.c
Normal file
100
XilinxProcessorIPLib/drivers/sysmon/src/xsysmon_sinit.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsysmon_sinit.c
|
||||
*
|
||||
* This file contains the implementation of the XSysMon driver's static
|
||||
* initialization functionality.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------------
|
||||
* 1.00a xd/sv 05/22/07 First release
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xsysmon.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
extern XSysMon_Config XSysMon_ConfigTable[];
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function looks up the device configuration based on the unique device ID.
|
||||
* The table XSysMon_ConfigTable contains the configuration info for each device
|
||||
* in the system.
|
||||
*
|
||||
* @param DeviceId contains the ID of the device for which the
|
||||
* device configuration pointer is to be returned.
|
||||
*
|
||||
* @return
|
||||
* - A pointer to the configuration found.
|
||||
* - NULL if the specified device ID was not found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XSysMon_Config *XSysMon_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XSysMon_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index=0; Index < XPAR_XSYSMON_NUM_INSTANCES; Index++) {
|
||||
if (XSysMon_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XSysMon_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CfgPtr;
|
||||
}
|
Loading…
Add table
Reference in a new issue