Commit e5c1876a authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

adding scripts to generate simple helloworld app

parent 7c61268c
To generate FSBL, PMUFW and helloworld application follow these steps:
1. Copy your *.xsa file exported from Vivado to hardware/
2. Execute: xsct gen_platform.tcl
the_ROM_image:
{
[bootloader, destination_cpu = a53-0] xsct_ws/diot_fsbl/Release/diot_fsbl.elf
[destination_cpu = pmu] xsct_ws/diot_pmufw/Release/diot_pmufw.elf
[destination_device = pl] xsct_ws/diot_wr_platform/hw/diot_wr_mpsoc.bit
[destination_cpu = a53-0] xsct_ws/hello_world/Release/hello_world.elf
}
setws xsct_ws
platform create -name diot_wr_platform -hw hardware/diot_wr_mpsoc.xsa -no-boot-bsp
# create domain for FSBL
domain create -name "fsbl_domain" -os standalone -proc psu_cortexa53_0
bsp setlib xilffs
bsp setlib xilsecure
bsp setlib xilpm
bsp config zynqmp_fsbl_bsp true
# create domain for PMU firmware
domain create -name "pmufw_domain" -os standalone -proc psu_pmu_0
bsp setlib xilfpga
bsp setlib xilsecure
bsp setlib xilskey
# create standalone sw domain
domain create -name "standalone_domain" -os standalone -proc psu_cortexa53_0
# generate platform
platform generate
# Generate FSBL APP
app create -name diot_fsbl -template {Zynq MP FSBL} -platform diot_wr_platform -domain fsbl_domain -sysproj diot_wr_system
# Generate PMU FW APP
app create -name diot_pmufw -template {ZynqMP PMU Firmware} -platform diot_wr_platform -domain pmufw_domain -sysproj diot_wr_system
# Generate Hello World APP
app create -name hello_world -template {Hello World} -platform diot_wr_platform -domain standalone_domain -sysproj diot_wr_system
# Configure applications
app config -name diot_fsbl build-config release
app config -name diot_pmufw build-config release
app config -name hello_world build-config release
exec cp my_src/helloworld.c xsct_ws/hello_world/src/
exec cp my_src/Si5341-RevD-diot_sb-Registers.h xsct_ws/hello_world/src/
# Building all apps
app build -name diot_fsbl
app build -name diot_pmufw
app build -name hello_world
# Generate BOOT.BIN
exec bootgen -image bootgen.bif -arch zynqmp -w -o BOOT.bin
/*
* Si5341 Rev D Configuration Register Export Header File
*
* This file represents a series of Silicon Labs Si5341 Rev D
* register writes that can be performed to load a single configuration
* on a device. It was created by a Silicon Labs ClockBuilder Pro
* export tool.
*
* Part: Si5341 Rev D
* Design ID: diot_sb
* Includes Pre/Post Download Control Register Writes: Yes
* Created By: ClockBuilder Pro v3.3 [2021-04-08]
* Timestamp: 2021-05-04 10:10:01 GMT+02:00
*
* A complete design report corresponding to this export is included at the end
* of this header file.
*
*/
#ifndef SI5341_REVD_REG_CONFIG_HEADER
#define SI5341_REVD_REG_CONFIG_HEADER
#define SI5341_REVD_REG_CONFIG_NUM_REGS 387
typedef struct
{
unsigned int address; /* 16-bit register address */
unsigned char value; /* 8-bit register data */
} si5341_revd_register_t;
si5341_revd_register_t const si5341_revd_registers[SI5341_REVD_REG_CONFIG_NUM_REGS] =
{
/* Start configuration preamble */
{ 0x0B24, 0xC0 },
{ 0x0B25, 0x00 },
/* Rev D stuck divider fix */
{ 0x0502, 0x01 },
{ 0x0505, 0x03 },
{ 0x0957, 0x17 },
{ 0x0B4E, 0x1A },
/* End configuration preamble */
/* Delay 300 msec */
/* Delay is worst case time for device to complete any calibration */
/* that is running due to device state change previous to this script */
/* being processed. */
/* Start configuration registers */
{ 0x0006, 0x00 },
{ 0x0007, 0x00 },
{ 0x0008, 0x00 },
{ 0x000B, 0x74 },
{ 0x0017, 0xFA },
{ 0x0018, 0xF6 },
{ 0x0021, 0x09 },
{ 0x0022, 0x00 },
{ 0x002B, 0x02 },
{ 0x002C, 0x39 },
{ 0x002D, 0x41 },
{ 0x002E, 0x8D },
{ 0x002F, 0x00 },
{ 0x0030, 0x00 },
{ 0x0031, 0x00 },
{ 0x0032, 0x00 },
{ 0x0033, 0x00 },
{ 0x0034, 0x8D },
{ 0x0035, 0x00 },
{ 0x0036, 0x8D },
{ 0x0037, 0x00 },
{ 0x0038, 0x00 },
{ 0x0039, 0x00 },
{ 0x003A, 0x00 },
{ 0x003B, 0x00 },
{ 0x003C, 0x8D },
{ 0x003D, 0x00 },
{ 0x0041, 0x04 },
{ 0x0042, 0x00 },
{ 0x0043, 0x00 },
{ 0x0044, 0x04 },
{ 0x009E, 0x00 },
{ 0x0102, 0x01 },
{ 0x0108, 0x02 },
{ 0x0109, 0x09 },
{ 0x010A, 0x3E },
{ 0x010B, 0x18 },
{ 0x010D, 0x02 },
{ 0x010E, 0x09 },
{ 0x010F, 0x3E },
{ 0x0110, 0x18 },
{ 0x0112, 0x02 },
{ 0x0113, 0x09 },
{ 0x0114, 0x3E },
{ 0x0115, 0x18 },
{ 0x0117, 0x02 },
{ 0x0118, 0x09 },
{ 0x0119, 0x3E },
{ 0x011A, 0x18 },
{ 0x011C, 0x02 },
{ 0x011D, 0x09 },
{ 0x011E, 0x3E },
{ 0x011F, 0x18 },
{ 0x0121, 0x02 },
{ 0x0122, 0x09 },
{ 0x0123, 0x3E },
{ 0x0124, 0x18 },
{ 0x0126, 0x02 },
{ 0x0127, 0x09 },
{ 0x0128, 0x3E },
{ 0x0129, 0x18 },
{ 0x012B, 0x02 },
{ 0x012C, 0x09 },
{ 0x012D, 0x3E },
{ 0x012E, 0x18 },
{ 0x0130, 0x02 },
{ 0x0131, 0x09 },
{ 0x0132, 0x3E },
{ 0x0133, 0x18 },
{ 0x013A, 0x02 },
{ 0x013B, 0x09 },
{ 0x013C, 0x3E },
{ 0x013D, 0x18 },
{ 0x013F, 0x00 },
{ 0x0140, 0x08 },
{ 0x0141, 0x40 },
{ 0x0206, 0x00 },
{ 0x0208, 0x01 },
{ 0x0209, 0x00 },
{ 0x020A, 0x00 },
{ 0x020B, 0x00 },
{ 0x020C, 0x00 },
{ 0x020D, 0x00 },
{ 0x020E, 0x01 },
{ 0x020F, 0x00 },
{ 0x0210, 0x00 },
{ 0x0211, 0x00 },
{ 0x0212, 0x00 },
{ 0x0213, 0x00 },
{ 0x0214, 0x00 },
{ 0x0215, 0x00 },
{ 0x0216, 0x00 },
{ 0x0217, 0x00 },
{ 0x0218, 0x00 },
{ 0x0219, 0x00 },
{ 0x021A, 0x00 },
{ 0x021B, 0x00 },
{ 0x021C, 0x00 },
{ 0x021D, 0x00 },
{ 0x021E, 0x00 },
{ 0x021F, 0x00 },
{ 0x0220, 0x00 },
{ 0x0221, 0x00 },
{ 0x0222, 0x00 },
{ 0x0223, 0x00 },
{ 0x0224, 0x00 },
{ 0x0225, 0x00 },
{ 0x0226, 0x01 },
{ 0x0227, 0x00 },
{ 0x0228, 0x00 },
{ 0x0229, 0x00 },
{ 0x022A, 0x00 },
{ 0x022B, 0x00 },
{ 0x022C, 0x01 },
{ 0x022D, 0x00 },
{ 0x022E, 0x00 },
{ 0x022F, 0x00 },
{ 0x0235, 0x00 },
{ 0x0236, 0x00 },
{ 0x0237, 0x00 },
{ 0x0238, 0x00 },
{ 0x0239, 0x13 },
{ 0x023A, 0x01 },
{ 0x023B, 0x00 },
{ 0x023C, 0x00 },
{ 0x023D, 0x00 },
{ 0x023E, 0x80 },
{ 0x024A, 0x04 },
{ 0x024B, 0x00 },
{ 0x024C, 0x00 },
{ 0x024D, 0x03 },
{ 0x024E, 0x00 },
{ 0x024F, 0x00 },
{ 0x0250, 0x04 },
{ 0x0251, 0x00 },
{ 0x0252, 0x00 },
{ 0x0253, 0x04 },
{ 0x0254, 0x00 },
{ 0x0255, 0x00 },
{ 0x0256, 0x04 },
{ 0x0257, 0x00 },
{ 0x0258, 0x00 },
{ 0x0259, 0x04 },
{ 0x025A, 0x00 },
{ 0x025B, 0x00 },
{ 0x025C, 0x09 },
{ 0x025D, 0x00 },
{ 0x025E, 0x00 },
{ 0x025F, 0x04 },
{ 0x0260, 0x00 },
{ 0x0261, 0x00 },
{ 0x0262, 0x04 },
{ 0x0263, 0x00 },
{ 0x0264, 0x00 },
{ 0x0268, 0x18 },
{ 0x0269, 0x00 },
{ 0x026A, 0x00 },
{ 0x026B, 0x64 },
{ 0x026C, 0x69 },
{ 0x026D, 0x6F },
{ 0x026E, 0x74 },
{ 0x026F, 0x5F },
{ 0x0270, 0x73 },
{ 0x0271, 0x62 },
{ 0x0272, 0x00 },
{ 0x0302, 0x00 },
{ 0x0303, 0x00 },
{ 0x0304, 0x00 },
{ 0x0305, 0x80 },
{ 0x0306, 0x05 },
{ 0x0307, 0x00 },
{ 0x0308, 0x00 },
{ 0x0309, 0x00 },
{ 0x030A, 0x00 },
{ 0x030B, 0x80 },
{ 0x030C, 0x00 },
{ 0x030D, 0x00 },
{ 0x030E, 0x00 },
{ 0x030F, 0x00 },
{ 0x0310, 0x00 },
{ 0x0311, 0x00 },
{ 0x0312, 0x00 },
{ 0x0313, 0x00 },
{ 0x0314, 0x00 },
{ 0x0315, 0x00 },
{ 0x0316, 0x00 },
{ 0x0317, 0x00 },
{ 0x0318, 0x00 },
{ 0x0319, 0x00 },
{ 0x031A, 0x00 },
{ 0x031B, 0x00 },
{ 0x031C, 0x00 },
{ 0x031D, 0x00 },
{ 0x031E, 0x00 },
{ 0x031F, 0x00 },
{ 0x0320, 0x00 },
{ 0x0321, 0x00 },
{ 0x0322, 0x00 },
{ 0x0323, 0x00 },
{ 0x0324, 0x00 },
{ 0x0325, 0x00 },
{ 0x0326, 0x00 },
{ 0x0327, 0x00 },
{ 0x0328, 0x00 },
{ 0x0329, 0x00 },
{ 0x032A, 0x00 },
{ 0x032B, 0x00 },
{ 0x032C, 0x00 },
{ 0x032D, 0x00 },
{ 0x032E, 0x00 },
{ 0x032F, 0x00 },
{ 0x0330, 0x00 },
{ 0x0331, 0x00 },
{ 0x0332, 0x00 },
{ 0x0333, 0x00 },
{ 0x0334, 0x00 },
{ 0x0335, 0x00 },
{ 0x0336, 0x00 },
{ 0x0337, 0x00 },
{ 0x0338, 0x00 },
{ 0x0339, 0x1F },
{ 0x033B, 0x00 },
{ 0x033C, 0x00 },
{ 0x033D, 0x00 },
{ 0x033E, 0x00 },
{ 0x033F, 0x00 },
{ 0x0340, 0x00 },
{ 0x0341, 0x00 },
{ 0x0342, 0x00 },
{ 0x0343, 0x00 },
{ 0x0344, 0x00 },
{ 0x0345, 0x00 },
{ 0x0346, 0x00 },
{ 0x0347, 0x00 },
{ 0x0348, 0x00 },
{ 0x0349, 0x00 },
{ 0x034A, 0x00 },
{ 0x034B, 0x00 },
{ 0x034C, 0x00 },
{ 0x034D, 0x00 },
{ 0x034E, 0x00 },
{ 0x034F, 0x00 },
{ 0x0350, 0x00 },
{ 0x0351, 0x00 },
{ 0x0352, 0x00 },
{ 0x0353, 0x00 },
{ 0x0354, 0x00 },
{ 0x0355, 0x00 },
{ 0x0356, 0x00 },
{ 0x0357, 0x00 },
{ 0x0358, 0x00 },
{ 0x0359, 0x00 },
{ 0x035A, 0x00 },
{ 0x035B, 0x00 },
{ 0x035C, 0x00 },
{ 0x035D, 0x00 },
{ 0x035E, 0x00 },
{ 0x035F, 0x00 },
{ 0x0360, 0x00 },
{ 0x0361, 0x00 },
{ 0x0362, 0x00 },
{ 0x0802, 0x00 },
{ 0x0803, 0x00 },
{ 0x0804, 0x00 },
{ 0x0805, 0x00 },
{ 0x0806, 0x00 },
{ 0x0807, 0x00 },
{ 0x0808, 0x00 },
{ 0x0809, 0x00 },
{ 0x080A, 0x00 },
{ 0x080B, 0x00 },
{ 0x080C, 0x00 },
{ 0x080D, 0x00 },
{ 0x080E, 0x00 },
{ 0x080F, 0x00 },
{ 0x0810, 0x00 },
{ 0x0811, 0x00 },
{ 0x0812, 0x00 },
{ 0x0813, 0x00 },
{ 0x0814, 0x00 },
{ 0x0815, 0x00 },
{ 0x0816, 0x00 },
{ 0x0817, 0x00 },
{ 0x0818, 0x00 },
{ 0x0819, 0x00 },
{ 0x081A, 0x00 },
{ 0x081B, 0x00 },
{ 0x081C, 0x00 },
{ 0x081D, 0x00 },
{ 0x081E, 0x00 },
{ 0x081F, 0x00 },
{ 0x0820, 0x00 },
{ 0x0821, 0x00 },
{ 0x0822, 0x00 },
{ 0x0823, 0x00 },
{ 0x0824, 0x00 },
{ 0x0825, 0x00 },
{ 0x0826, 0x00 },
{ 0x0827, 0x00 },
{ 0x0828, 0x00 },
{ 0x0829, 0x00 },
{ 0x082A, 0x00 },
{ 0x082B, 0x00 },
{ 0x082C, 0x00 },
{ 0x082D, 0x00 },
{ 0x082E, 0x00 },
{ 0x082F, 0x00 },
{ 0x0830, 0x00 },
{ 0x0831, 0x00 },
{ 0x0832, 0x00 },
{ 0x0833, 0x00 },
{ 0x0834, 0x00 },
{ 0x0835, 0x00 },
{ 0x0836, 0x00 },
{ 0x0837, 0x00 },
{ 0x0838, 0x00 },
{ 0x0839, 0x00 },
{ 0x083A, 0x00 },
{ 0x083B, 0x00 },
{ 0x083C, 0x00 },
{ 0x083D, 0x00 },
{ 0x083E, 0x00 },
{ 0x083F, 0x00 },
{ 0x0840, 0x00 },
{ 0x0841, 0x00 },
{ 0x0842, 0x00 },
{ 0x0843, 0x00 },
{ 0x0844, 0x00 },
{ 0x0845, 0x00 },
{ 0x0846, 0x00 },
{ 0x0847, 0x00 },
{ 0x0848, 0x00 },
{ 0x0849, 0x00 },
{ 0x084A, 0x00 },
{ 0x084B, 0x00 },
{ 0x084C, 0x00 },
{ 0x084D, 0x00 },
{ 0x084E, 0x00 },
{ 0x084F, 0x00 },
{ 0x0850, 0x00 },
{ 0x0851, 0x00 },
{ 0x0852, 0x00 },
{ 0x0853, 0x00 },
{ 0x0854, 0x00 },
{ 0x0855, 0x00 },
{ 0x0856, 0x00 },
{ 0x0857, 0x00 },
{ 0x0858, 0x00 },
{ 0x0859, 0x00 },
{ 0x085A, 0x00 },
{ 0x085B, 0x00 },
{ 0x085C, 0x00 },
{ 0x085D, 0x00 },
{ 0x085E, 0x00 },
{ 0x085F, 0x00 },
{ 0x0860, 0x00 },
{ 0x0861, 0x00 },
{ 0x090E, 0x00 },
{ 0x091C, 0x03 },
{ 0x0943, 0x01 },
{ 0x0949, 0x09 },
{ 0x094A, 0x90 },
{ 0x094E, 0x49 },
{ 0x094F, 0x02 },
{ 0x095E, 0x00 },
{ 0x0A02, 0x00 },
{ 0x0A03, 0x01 },
{ 0x0A04, 0x01 },
{ 0x0A05, 0x01 },
{ 0x0A14, 0x00 },
{ 0x0A1A, 0x00 },
{ 0x0A20, 0x00 },
{ 0x0A26, 0x00 },
{ 0x0A2C, 0x00 },
{ 0x0B44, 0x0F },
{ 0x0B4A, 0x1E },
{ 0x0B57, 0x06 },
{ 0x0B58, 0x02 },
/* End configuration registers */
/* Start configuration postamble */
{ 0x001C, 0x01 },
{ 0x0B24, 0xC3 },
{ 0x0B25, 0x02 },
/* End configuration postamble */
};
/*
* Design Report
*
* Overview
* ========
* Part: Si5341ABCD Rev D
* Project File: C:\Users\gdaniluk\cernbox\Documents\DIOT\Designs\non-rad_SB\Si5341\Si5341-RevD-diot_sb-Project.slabtimeproj
* Design ID: diot_sb
* Created By: ClockBuilder Pro v3.3 [2021-04-08]
* Timestamp: 2021-05-04 10:10:00 GMT+02:00
*
* Design Rule Check
* =================
* Errors:
* - No errors
*
* Warnings:
* - No warnings
*
* Device Grade
* ============
* Maximum Output Frequency: 156.25 MHz
* Frequency Synthesis Mode: Integer
* Frequency Plan Grade: D
* Minimum Base OPN: Si5341D*
*
* Base Output Clock Supported Frequency Synthesis Modes
* OPN Grade Frequency Range (Typical Jitter)
* --------- ------------------- --------------------------------------------
* Si5341A 100 Hz to 1.028 GHz Integer (< 100 fs) and fractional (< 150 fs)
* Si5341B 100 Hz to 350 MHz "
* Si5341C 100 Hz to 1.028 GHz Integer only (< 100 fs)
* Si5341D* 100 Hz to 350 MHz "
*
* * Based on your calculated frequency plan, a Si5341D grade device is
* sufficient for your design. For more in-system configuration flexibility
* (higher frequencies and/or to enable fractional synthesis), consider
* selecting device grade Si5341A when specifying an ordering part number (OPN)
* for your application. See the datasheet Ordering Guide for more information.
*
* Design
* ======
* Host Interface:
* I/O Power Supply: VDDA (3.3V)
* SPI Mode: 4-Wire
* I2C Address Range: 116d to 119d / 0x74 to 0x77 (selected via A0/A1 pins)
*
* Inputs:
* XAXB: Unused
* IN0: 25 MHz
* Standard
* IN1: Unused
* IN2: Unused
* FB_IN: 25 MHz
* Standard
*
* Outputs:
* OUT0: 125 MHz
* Enabled, LVDS 1.8 V
* OUT1: 156.25 MHz
* Enabled, LVDS 1.8 V
* OUT2: 125 MHz
* Enabled, LVDS 1.8 V
* OUT3: 125 MHz
* Enabled, LVDS 1.8 V
* OUT4: 125 MHz
* Enabled, LVDS 1.8 V
* OUT5: 125 MHz
* Enabled, LVDS 1.8 V
* OUT6: 62.5 MHz
* Enabled, LVDS 1.8 V
* OUT7: 125 MHz
* Enabled, LVDS 1.8 V
* OUT8: 125 MHz
* Enabled, LVDS 1.8 V
* OUT9: ZDM - 25 MHz
* Enabled, LVDS 1.8 V
*
* Frequency Plan
* ==============
* Priority: maximize the number of low jitter outputs
*
* Fpfd = 25 MHz
* Fvco = 13.75 GHz
* Fms0 = 1.25 GHz
*
* P dividers:
* P0 = 1
* P1 = Unused
* P2 = Unused
* P3 = 1
* Pxaxb = Unused
*
* M = 550
* N dividers:
* N0 (Zero Delay):
* Value: 11
* OUT0: 125 MHz
* OUT1: 156.25 MHz [ 156 + 1/4 MHz ]
* OUT2: 125 MHz
* OUT3: 125 MHz
* OUT4: 125 MHz
* OUT5: 125 MHz
* OUT6: 62.5 MHz [ 62 + 1/2 MHz ]
* OUT7: 125 MHz
* OUT8: 125 MHz
* OUT9: 25 MHz
* N1:
* Unused
* N2:
* Unused
* N3:
* Unused
* N4:
* Unused
*
* R dividers:
* R0 = 10
* R1 = 8
* R2 = 10
* R3 = 10
* R4 = 10
* R5 = 10
* R6 = 20
* R7 = 10
* R8 = 10
* R9 = 50
*
* Dividers listed above show effective values. These values are translated to register settings by ClockBuilder Pro. For the actual register values, see below. Refer to the Family Reference Manual for information on registers related to frequency plan.
*
* Digitally Controlled Oscillator (DCO)
* =====================================
* Mode: Register Direct Write
*
* N0: DCO Disabled
*
* N1: DCO Disabled
*
* N2: DCO Disabled
*
* N3: DCO Disabled
*
* N4: DCO Disabled
*
* Estimated Power & Junction Temperature
* ======================================
* Assumptions:
*
* Revision: D
* VDD: 1.8 V
* Ta: 25 C
* Theta-JA: 18.3 C/W
* Airflow: 2 m/s
*
* Total Power: 897 mW, On Chip Power: 837 mW, Tj: 40 C
*
* Frequency Format Voltage Current Power
* ---------- ------ -------- -------- --------
* VDD 1.8 V 135.1 mA 243 mW
* VDDA 3.3 V 113.7 mA 375 mW
* VDDO0 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO1 156.25 MHz LVDS 1.8 V 15.7 mA 28 mW
* VDDO2 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO3 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO4 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO5 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO6 62.5 MHz LVDS 1.8 V 15.3 mA 28 mW
* VDDO7 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO8 125 MHz LVDS 1.8 V 15.6 mA 28 mW
* VDDO9 25 MHz LVDS 1.8 V 15.1 mA 27 mW
* -------- --------
* Total 403.9 mA 897 mW
*
* Note:
*
* -Tj is junction temperature. Tj must be less than 125 C (on Si5341 Revision D) for device to comply with datasheet specifications. Tj = Ta + Theta_JA*On_Chip_Power.
* -Overall power includes on-chip power dissipation and adds differential load power dissipation to estimate total power requirements.
* -Above are estimates only: power and temperature should be measured on your PCB.
* -Selection of appropriate Theta-JA is required for most accurate estimate. Ideally, select 'User Specified Theta-JA' and enter a Theta-JA value based on the thermal properties of your PCB.
*
* Settings
* ========
*
* Location Setting Name Decimal Value Hex Value
* ------------ ------------------- ----------------- -----------------
* 0x0006[23:0] TOOL_VERSION 0 0x000000
* 0x000B[6:0] I2C_ADDR 116 0x74
* 0x0017[0] SYSINCAL_INTR_MSK 0 0x0
* 0x0017[1] LOSXAXB_INTR_MSK 1 0x1
* 0x0017[2] LOSREF_INTR_MSK 0 0x0
* 0x0017[3] LOL_INTR_MSK 1 0x1
* 0x0017[5] SMB_TMOUT_INTR_MSK 1 0x1
* 0x0018[3:0] LOSIN_INTR_MSK 6 0x6
* 0x0021[0] IN_SEL_REGCTRL 1 0x1
* 0x0021[2:1] IN_SEL 0 0x0
* 0x0022[1] OE 0 0x0
* 0x002B[3] SPI_3WIRE 0 0x0
* 0x002B[5] AUTO_NDIV_UPDATE 0 0x0
* 0x002C[3:0] LOS_EN 9 0x9
* 0x002C[4] LOSXAXB_DIS 1 0x1
* 0x002D[1:0] LOS0_VAL_TIME 1 0x1
* 0x002D[3:2] LOS1_VAL_TIME 0 0x0
* 0x002D[5:4] LOS2_VAL_TIME 0 0x0
* 0x002D[7:6] LOS3_VAL_TIME 1 0x1
* 0x002E[15:0] LOS0_TRG_THR 141 0x008D
* 0x0030[15:0] LOS1_TRG_THR 0 0x0000
* 0x0032[15:0] LOS2_TRG_THR 0 0x0000
* 0x0034[15:0] LOS3_TRG_THR 141 0x008D
* 0x0036[15:0] LOS0_CLR_THR 141 0x008D
* 0x0038[15:0] LOS1_CLR_THR 0 0x0000
* 0x003A[15:0] LOS2_CLR_THR 0 0x0000
* 0x003C[15:0] LOS3_CLR_THR 141 0x008D
* 0x0041[4:0] LOS0_DIV_SEL 4 0x04
* 0x0042[4:0] LOS1_DIV_SEL 0 0x00
* 0x0043[4:0] LOS2_DIV_SEL 0 0x00
* 0x0044[4:0] LOS3_DIV_SEL 4 0x04
* 0x009E[7:4] LOL_SET_THR 0 0x0
* 0x0102[0] OUTALL_DISABLE_LOW 1 0x1
* 0x0108[0] OUT0_PDN 0 0x0
* 0x0108[1] OUT0_OE 1 0x1
* 0x0108[2] OUT0_RDIV_FORCE2 0 0x0
* 0x0109[2:0] OUT0_FORMAT 1 0x1
* 0x0109[3] OUT0_SYNC_EN 1 0x1
* 0x0109[5:4] OUT0_DIS_STATE 0 0x0
* 0x0109[7:6] OUT0_CMOS_DRV 0 0x0
* 0x010A[3:0] OUT0_CM 14 0xE
* 0x010A[6:4] OUT0_AMPL 3 0x3
* 0x010B[2:0] OUT0_MUX_SEL 0 0x0
* 0x010B[5:4] OUT0_VDD_SEL 1 0x1
* 0x010B[3] OUT0_VDD_SEL_EN 1 0x1
* 0x010B[7:6] OUT0_INV 0 0x0
* 0x010D[0] OUT1_PDN 0 0x0
* 0x010D[1] OUT1_OE 1 0x1
* 0x010D[2] OUT1_RDIV_FORCE2 0 0x0
* 0x010E[2:0] OUT1_FORMAT 1 0x1
* 0x010E[3] OUT1_SYNC_EN 1 0x1
* 0x010E[5:4] OUT1_DIS_STATE 0 0x0
* 0x010E[7:6] OUT1_CMOS_DRV 0 0x0
* 0x010F[3:0] OUT1_CM 14 0xE
* 0x010F[6:4] OUT1_AMPL 3 0x3
* 0x0110[2:0] OUT1_MUX_SEL 0 0x0
* 0x0110[5:4] OUT1_VDD_SEL 1 0x1
* 0x0110[3] OUT1_VDD_SEL_EN 1 0x1
* 0x0110[7:6] OUT1_INV 0 0x0
* 0x0112[0] OUT2_PDN 0 0x0
* 0x0112[1] OUT2_OE 1 0x1
* 0x0112[2] OUT2_RDIV_FORCE2 0 0x0
* 0x0113[2:0] OUT2_FORMAT 1 0x1
* 0x0113[3] OUT2_SYNC_EN 1 0x1
* 0x0113[5:4] OUT2_DIS_STATE 0 0x0
* 0x0113[7:6] OUT2_CMOS_DRV 0 0x0
* 0x0114[3:0] OUT2_CM 14 0xE
* 0x0114[6:4] OUT2_AMPL 3 0x3
* 0x0115[2:0] OUT2_MUX_SEL 0 0x0
* 0x0115[5:4] OUT2_VDD_SEL 1 0x1
* 0x0115[3] OUT2_VDD_SEL_EN 1 0x1
* 0x0115[7:6] OUT2_INV 0 0x0
* 0x0117[0] OUT3_PDN 0 0x0
* 0x0117[1] OUT3_OE 1 0x1
* 0x0117[2] OUT3_RDIV_FORCE2 0 0x0
* 0x0118[2:0] OUT3_FORMAT 1 0x1
* 0x0118[3] OUT3_SYNC_EN 1 0x1
* 0x0118[5:4] OUT3_DIS_STATE 0 0x0
* 0x0118[7:6] OUT3_CMOS_DRV 0 0x0
* 0x0119[3:0] OUT3_CM 14 0xE
* 0x0119[6:4] OUT3_AMPL 3 0x3
* 0x011A[2:0] OUT3_MUX_SEL 0 0x0
* 0x011A[5:4] OUT3_VDD_SEL 1 0x1
* 0x011A[3] OUT3_VDD_SEL_EN 1 0x1
* 0x011A[7:6] OUT3_INV 0 0x0
* 0x011C[0] OUT4_PDN 0 0x0
* 0x011C[1] OUT4_OE 1 0x1
* 0x011C[2] OUT4_RDIV_FORCE2 0 0x0
* 0x011D[2:0] OUT4_FORMAT 1 0x1
* 0x011D[3] OUT4_SYNC_EN 1 0x1
* 0x011D[5:4] OUT4_DIS_STATE 0 0x0
* 0x011D[7:6] OUT4_CMOS_DRV 0 0x0
* 0x011E[3:0] OUT4_CM 14 0xE
* 0x011E[6:4] OUT4_AMPL 3 0x3
* 0x011F[2:0] OUT4_MUX_SEL 0 0x0
* 0x011F[5:4] OUT4_VDD_SEL 1 0x1
* 0x011F[3] OUT4_VDD_SEL_EN 1 0x1
* 0x011F[7:6] OUT4_INV 0 0x0
* 0x0121[0] OUT5_PDN 0 0x0
* 0x0121[1] OUT5_OE 1 0x1
* 0x0121[2] OUT5_RDIV_FORCE2 0 0x0
* 0x0122[2:0] OUT5_FORMAT 1 0x1
* 0x0122[3] OUT5_SYNC_EN 1 0x1
* 0x0122[5:4] OUT5_DIS_STATE 0 0x0
* 0x0122[7:6] OUT5_CMOS_DRV 0 0x0
* 0x0123[3:0] OUT5_CM 14 0xE
* 0x0123[6:4] OUT5_AMPL 3 0x3
* 0x0124[2:0] OUT5_MUX_SEL 0 0x0
* 0x0124[5:4] OUT5_VDD_SEL 1 0x1
* 0x0124[3] OUT5_VDD_SEL_EN 1 0x1
* 0x0124[7:6] OUT5_INV 0 0x0
* 0x0126[0] OUT6_PDN 0 0x0
* 0x0126[1] OUT6_OE 1 0x1
* 0x0126[2] OUT6_RDIV_FORCE2 0 0x0
* 0x0127[2:0] OUT6_FORMAT 1 0x1
* 0x0127[3] OUT6_SYNC_EN 1 0x1
* 0x0127[5:4] OUT6_DIS_STATE 0 0x0
* 0x0127[7:6] OUT6_CMOS_DRV 0 0x0
* 0x0128[3:0] OUT6_CM 14 0xE
* 0x0128[6:4] OUT6_AMPL 3 0x3
* 0x0129[2:0] OUT6_MUX_SEL 0 0x0
* 0x0129[5:4] OUT6_VDD_SEL 1 0x1
* 0x0129[3] OUT6_VDD_SEL_EN 1 0x1
* 0x0129[7:6] OUT6_INV 0 0x0
* 0x012B[0] OUT7_PDN 0 0x0
* 0x012B[1] OUT7_OE 1 0x1
* 0x012B[2] OUT7_RDIV_FORCE2 0 0x0
* 0x012C[2:0] OUT7_FORMAT 1 0x1
* 0x012C[3] OUT7_SYNC_EN 1 0x1
* 0x012C[5:4] OUT7_DIS_STATE 0 0x0
* 0x012C[7:6] OUT7_CMOS_DRV 0 0x0
* 0x012D[3:0] OUT7_CM 14 0xE
* 0x012D[6:4] OUT7_AMPL 3 0x3
* 0x012E[2:0] OUT7_MUX_SEL 0 0x0
* 0x012E[5:4] OUT7_VDD_SEL 1 0x1
* 0x012E[3] OUT7_VDD_SEL_EN 1 0x1
* 0x012E[7:6] OUT7_INV 0 0x0
* 0x0130[0] OUT8_PDN 0 0x0
* 0x0130[1] OUT8_OE 1 0x1
* 0x0130[2] OUT8_RDIV_FORCE2 0 0x0
* 0x0131[2:0] OUT8_FORMAT 1 0x1
* 0x0131[3] OUT8_SYNC_EN 1 0x1
* 0x0131[5:4] OUT8_DIS_STATE 0 0x0
* 0x0131[7:6] OUT8_CMOS_DRV 0 0x0
* 0x0132[3:0] OUT8_CM 14 0xE
* 0x0132[6:4] OUT8_AMPL 3 0x3
* 0x0133[2:0] OUT8_MUX_SEL 0 0x0
* 0x0133[5:4] OUT8_VDD_SEL 1 0x1
* 0x0133[3] OUT8_VDD_SEL_EN 1 0x1
* 0x0133[7:6] OUT8_INV 0 0x0
* 0x013A[0] OUT9_PDN 0 0x0
* 0x013A[1] OUT9_OE 1 0x1
* 0x013A[2] OUT9_RDIV_FORCE2 0 0x0
* 0x013B[2:0] OUT9_FORMAT 1 0x1
* 0x013B[3] OUT9_SYNC_EN 1 0x1
* 0x013B[5:4] OUT9_DIS_STATE 0 0x0
* 0x013B[7:6] OUT9_CMOS_DRV 0 0x0
* 0x013C[3:0] OUT9_CM 14 0xE
* 0x013C[6:4] OUT9_AMPL 3 0x3
* 0x013D[2:0] OUT9_MUX_SEL 0 0x0
* 0x013D[5:4] OUT9_VDD_SEL 1 0x1
* 0x013D[3] OUT9_VDD_SEL_EN 1 0x1
* 0x013D[7:6] OUT9_INV 0 0x0
* 0x013F[11:0] OUTX_ALWAYS_ON 2048 0x800
* 0x0141[5] OUT_DIS_LOL_MSK 0 0x0
* 0x0141[7] OUT_DIS_MSK_LOS_PFD 0 0x0
* 0x0206[1:0] PXAXB 0 0x0
* 0x0208[47:0] P0 1 0x000000000001
* 0x020E[31:0] P0_SET 1 0x00000001
* 0x0212[47:0] P1 0 0x000000000000
* 0x0218[31:0] P1_SET 0 0x00000000
* 0x021C[47:0] P2 0 0x000000000000
* 0x0222[31:0] P2_SET 0 0x00000000
* 0x0226[47:0] P3 1 0x000000000001
* 0x022C[31:0] P3_SET 1 0x00000001
* 0x0235[43:0] M_NUM 1181116006400 0x11300000000
* 0x023B[31:0] M_DEN 2147483648 0x80000000
* 0x024A[23:0] R0_REG 4 0x000004
* 0x024D[23:0] R1_REG 3 0x000003
* 0x0250[23:0] R2_REG 4 0x000004
* 0x0253[23:0] R3_REG 4 0x000004
* 0x0256[23:0] R4_REG 4 0x000004
* 0x0259[23:0] R5_REG 4 0x000004
* 0x025C[23:0] R6_REG 9 0x000009
* 0x025F[23:0] R7_REG 4 0x000004
* 0x0262[23:0] R8_REG 4 0x000004
* 0x0268[23:0] R9_REG 24 0x000018
* 0x026B[7:0] DESIGN_ID0 100 0x64
* 0x026C[7:0] DESIGN_ID1 105 0x69
* 0x026D[7:0] DESIGN_ID2 111 0x6F
* 0x026E[7:0] DESIGN_ID3 116 0x74
* 0x026F[7:0] DESIGN_ID4 95 0x5F
* 0x0270[7:0] DESIGN_ID5 115 0x73
* 0x0271[7:0] DESIGN_ID6 98 0x62
* 0x0272[7:0] DESIGN_ID7 0 0x00
* 0x0302[43:0] N0_NUM 23622320128 0x00580000000
* 0x0308[31:0] N0_DEN 2147483648 0x80000000
* 0x030C[0] N0_UPDATE 0 0x0
* 0x030D[43:0] N1_NUM 0 0x00000000000
* 0x0313[31:0] N1_DEN 0 0x00000000
* 0x0317[0] N1_UPDATE 0 0x0
* 0x0318[43:0] N2_NUM 0 0x00000000000
* 0x031E[31:0] N2_DEN 0 0x00000000
* 0x0322[0] N2_UPDATE 0 0x0
* 0x0323[43:0] N3_NUM 0 0x00000000000
* 0x0329[31:0] N3_DEN 0 0x00000000
* 0x032D[0] N3_UPDATE 0 0x0
* 0x032E[43:0] N4_NUM 0 0x00000000000
* 0x0334[31:0] N4_DEN 0 0x00000000
* 0x0338[0] N4_UPDATE 0 0x0
* 0x0338[1] N_UPDATE 0 0x0
* 0x0339[4:0] N_FSTEP_MSK 31 0x1F
* 0x033B[43:0] N0_FSTEPW 0 0x00000000000
* 0x0341[43:0] N1_FSTEPW 0 0x00000000000
* 0x0347[43:0] N2_FSTEPW 0 0x00000000000
* 0x034D[43:0] N3_FSTEPW 0 0x00000000000
* 0x0353[43:0] N4_FSTEPW 0 0x00000000000
* 0x0359[15:0] N0_DELAY 0 0x0000
* 0x035B[15:0] N1_DELAY 0 0x0000
* 0x035D[15:0] N2_DELAY 0 0x0000
* 0x035F[15:0] N3_DELAY 0 0x0000
* 0x0361[15:0] N4_DELAY 0 0x0000
* 0x0802[15:0] FIXREGSA0 0 0x0000
* 0x0804[7:0] FIXREGSD0 0 0x00
* 0x0805[15:0] FIXREGSA1 0 0x0000
* 0x0807[7:0] FIXREGSD1 0 0x00
* 0x0808[15:0] FIXREGSA2 0 0x0000
* 0x080A[7:0] FIXREGSD2 0 0x00
* 0x080B[15:0] FIXREGSA3 0 0x0000
* 0x080D[7:0] FIXREGSD3 0 0x00
* 0x080E[15:0] FIXREGSA4 0 0x0000
* 0x0810[7:0] FIXREGSD4 0 0x00
* 0x0811[15:0] FIXREGSA5 0 0x0000
* 0x0813[7:0] FIXREGSD5 0 0x00
* 0x0814[15:0] FIXREGSA6 0 0x0000
* 0x0816[7:0] FIXREGSD6 0 0x00
* 0x0817[15:0] FIXREGSA7 0 0x0000
* 0x0819[7:0] FIXREGSD7 0 0x00
* 0x081A[15:0] FIXREGSA8 0 0x0000
* 0x081C[7:0] FIXREGSD8 0 0x00
* 0x081D[15:0] FIXREGSA9 0 0x0000
* 0x081F[7:0] FIXREGSD9 0 0x00
* 0x0820[15:0] FIXREGSA10 0 0x0000
* 0x0822[7:0] FIXREGSD10 0 0x00
* 0x0823[15:0] FIXREGSA11 0 0x0000
* 0x0825[7:0] FIXREGSD11 0 0x00
* 0x0826[15:0] FIXREGSA12 0 0x0000
* 0x0828[7:0] FIXREGSD12 0 0x00
* 0x0829[15:0] FIXREGSA13 0 0x0000
* 0x082B[7:0] FIXREGSD13 0 0x00
* 0x082C[15:0] FIXREGSA14 0 0x0000
* 0x082E[7:0] FIXREGSD14 0 0x00
* 0x082F[15:0] FIXREGSA15 0 0x0000
* 0x0831[7:0] FIXREGSD15 0 0x00
* 0x0832[15:0] FIXREGSA16 0 0x0000
* 0x0834[7:0] FIXREGSD16 0 0x00
* 0x0835[15:0] FIXREGSA17 0 0x0000
* 0x0837[7:0] FIXREGSD17 0 0x00
* 0x0838[15:0] FIXREGSA18 0 0x0000
* 0x083A[7:0] FIXREGSD18 0 0x00
* 0x083B[15:0] FIXREGSA19 0 0x0000
* 0x083D[7:0] FIXREGSD19 0 0x00
* 0x083E[15:0] FIXREGSA20 0 0x0000
* 0x0840[7:0] FIXREGSD20 0 0x00
* 0x0841[15:0] FIXREGSA21 0 0x0000
* 0x0843[7:0] FIXREGSD21 0 0x00
* 0x0844[15:0] FIXREGSA22 0 0x0000
* 0x0846[7:0] FIXREGSD22 0 0x00
* 0x0847[15:0] FIXREGSA23 0 0x0000
* 0x0849[7:0] FIXREGSD23 0 0x00
* 0x084A[15:0] FIXREGSA24 0 0x0000
* 0x084C[7:0] FIXREGSD24 0 0x00
* 0x084D[15:0] FIXREGSA25 0 0x0000
* 0x084F[7:0] FIXREGSD25 0 0x00
* 0x0850[15:0] FIXREGSA26 0 0x0000
* 0x0852[7:0] FIXREGSD26 0 0x00
* 0x0853[15:0] FIXREGSA27 0 0x0000
* 0x0855[7:0] FIXREGSD27 0 0x00
* 0x0856[15:0] FIXREGSA28 0 0x0000
* 0x0858[7:0] FIXREGSD28 0 0x00
* 0x0859[15:0] FIXREGSA29 0 0x0000
* 0x085B[7:0] FIXREGSD29 0 0x00
* 0x085C[15:0] FIXREGSA30 0 0x0000
* 0x085E[7:0] FIXREGSD30 0 0x00
* 0x085F[15:0] FIXREGSA31 0 0x0000
* 0x0861[7:0] FIXREGSD31 0 0x00
* 0x090E[0] XAXB_EXTCLK_EN 0 0x0
* 0x090E[1] XAXB_PDNB 0 0x0
* 0x091C[2:0] ZDM_EN 3 0x3
* 0x0943[0] IO_VDD_SEL 1 0x1
* 0x0949[3:0] IN_EN 9 0x9
* 0x0949[7:4] IN_PULSED_CMOS_EN 0 0x0
* 0x094A[7:4] INX_TO_PFD_EN 9 0x9
* 0x094E[11:0] REFCLK_HYS_SEL 585 0x249
* 0x095E[0] M_INTEGER 0 0x0
* 0x0A02[4:0] N_ADD_0P5 0 0x00
* 0x0A03[4:0] N_CLK_TO_OUTX_EN 1 0x01
* 0x0A04[4:0] N_PIBYP 1 0x01
* 0x0A05[4:0] N_PDNB 1 0x01
* 0x0A14[3] N0_HIGH_FREQ 0 0x0
* 0x0A1A[3] N1_HIGH_FREQ 0 0x0
* 0x0A20[3] N2_HIGH_FREQ 0 0x0
* 0x0A26[3] N3_HIGH_FREQ 0 0x0
* 0x0A2C[3] N4_HIGH_FREQ 0 0x0
* 0x0B44[3:0] PDIV_ENB 15 0xF
* 0x0B4A[4:0] N_CLK_DIS 30 0x1E
* 0x0B57[11:0] VCO_RESET_CALCODE 518 0x206
*
*
*/
#endif
\ No newline at end of file
/******************************************************************************
*
* Copyright (C) 2009 - 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
* XILINX 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.
*
******************************************************************************/
/*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/
#include <stdio.h>
#include <string.h>
#include "platform.h"
#include "xil_printf.h"
#include "xgpiops.h"
#include "xparameters.h"
#include <xil_types.h>
#include <xiicps.h>
#include <xiicps_hw.h>
#include <xuartps_hw.h>
#include "Si5341-RevD-diot_sb-Registers.h"
#define IIC_DEVICE_ID XPAR_PSU_I2C_1_DEVICE_ID
#define IIC_SCLK_RATE 100000
#define I2C_MUX_ADDR 0x70
#define I2C_MUX_CH_SI5341 2
#define I2C_MUX_CH_SFP 5
#define I2C_SI5341_ADDR 0x76
#define LED_DELAY 50000000
#define LED_MAX_BLINK 0x10
#define UART_BASEADDR XPAR_XUARTPS_0_BASEADDR
#define UART_DEVICE_ID XPAR_XUARTPS_0_DEVICE_ID
static int reset_pl(void);
static int i2c(void);
static int shell(void);
static int pwr_cycle(void);
int main()
{
int ret;
init_platform();
xil_printf("Hello World\n\r");
i2c();
xil_printf("Si5341 config done\n\r");
reset_pl();
xil_printf("PL reset done\n\r");
shell();
xil_printf("Exiting\n\r");
cleanup_platform();
return 0;
}
static s32 IicPsSlaveMonitor(XIicPs *InstancePtr, u16 Address) {
u32 Index, IntrStatusReg;
XIicPs *IicPtr;
IicPtr = InstancePtr;
XIicPs_EnableSlaveMonitor(InstancePtr, Address);
Index = 0;
/*
* Wait for the Slave Monitor Status
*/
while (Index < 0x00FFFFFF) {
Index++;
/*
* Read the Interrupt status register.
*/
IntrStatusReg = XIicPs_ReadReg(IicPtr->Config.BaseAddress,
(u32)XIICPS_ISR_OFFSET);
if (0U != (IntrStatusReg & XIICPS_IXR_SLV_RDY_MASK)) {
XIicPs_DisableSlaveMonitor(InstancePtr);
XIicPs_WriteReg(IicPtr->Config.BaseAddress, (u32)XIICPS_ISR_OFFSET,
IntrStatusReg);
return XST_SUCCESS;
}
}
XIicPs_DisableSlaveMonitor(InstancePtr);
return XST_FAILURE;
}
void i2cmux_set_channel(XIicPs *InstancePtr, uint8_t channel) {
uint8_t buffer[4];
buffer[0] = 1 << channel;
XIicPs_MasterSendPolled(InstancePtr, buffer, 1, I2C_MUX_ADDR);
while (XIicPs_BusIsBusy(InstancePtr))
;
}
void si5341_i2c_write(XIicPs *InstancePtr, uint16_t addr, uint8_t data) {
uint8_t buffer[4];
buffer[0] = 0x01;
buffer[1] = (0xFF00 & addr) >> 8;
buffer[2] = (0x00FF & addr);
buffer[3] = data;
XIicPs_MasterSendPolled(InstancePtr, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(InstancePtr, &buffer[2], 2, I2C_SI5341_ADDR);
}
void si5341_dev_ready(XIicPs *InstancePtr)
{
uint8_t buffer[4];
buffer[0] = 0x01;
buffer[1] = 0;
buffer[2] = 0xFE; //DEVICE_READY reg
XIicPs_MasterSendPolled(InstancePtr, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(InstancePtr, &buffer[2], 1, I2C_SI5341_ADDR);
do {
buffer[0] = 0;
XIicPs_MasterRecvPolled(InstancePtr, buffer, 1, I2C_SI5341_ADDR);
} while (*buffer != 0xF);
}
void si5341_soft_rst(XIicPs *InstancePtr)
{
uint8_t buffer[4];
buffer[0] = 0x01;
buffer[1] = 0;
buffer[2] = 0x1C; //SOFT_RST
buffer[3] = 1;
XIicPs_MasterSendPolled(InstancePtr, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(InstancePtr, &buffer[2], 2, I2C_SI5341_ADDR);
}
void si5341_i2c_write_nvm(XIicPs *iic) {
uint8_t buffer[4];
// see p13 of the reference manual Si5341-40-D-RM
xil_printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\r");
xil_printf("Si5341: wiriting to NVM!!!\n\r");
// write 0xC7 to NVM_WRITE register
buffer[0] = 0x01;
buffer[1] = 0;
buffer[2] = 0xE3;
buffer[3] = 0xC7;
XIicPs_MasterSendPolled(iic, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(iic, &buffer[2], 2, I2C_SI5341_ADDR);
// wait until DEVICE_READY = 0x0F
buffer[0] = 0x01;
buffer[1] = 0;
buffer[2] = 0xFE;
XIicPs_MasterSendPolled(iic, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(iic, &buffer[2], 1, I2C_SI5341_ADDR);
do {
buffer[0] = 0;
XIicPs_MasterRecvPolled(iic, buffer, 1, I2C_SI5341_ADDR);
} while (*buffer != 0xF);
// Set NVM_READ_BANK 0x00E4[0] = 1
buffer[0] = 0x01;
buffer[1] = 0;
buffer[2] = 0xE4;
buffer[4] = 1;
XIicPs_MasterSendPolled(iic, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(iic, &buffer[2], 2,
I2C_SI5341_ADDR);
// wait until DEVICE_READY = 0x0F
buffer[0] = 0x01;
buffer[1] = 0;
buffer[2] = 0xFE;
XIicPs_MasterSendPolled(iic, buffer, 2, I2C_SI5341_ADDR);
XIicPs_MasterSendPolled(iic, &buffer[2], 1,
I2C_SI5341_ADDR);
do {
buffer[0] = 0;
XIicPs_MasterRecvPolled(iic, buffer, 1, I2C_SI5341_ADDR);
} while (*buffer != 0xF);
xil_printf("Si5341: wiriting to NVM DONE!!!\n\r");
xil_printf("////////////////////////////////\n\r");
}
static int i2c(void)
{
XIicPs iic;
XIicPs_Config *iic_config;
int32_t status;
/* Initialize the IIC0 driver so that it is ready to use */
iic_config = XIicPs_LookupConfig(IIC_DEVICE_ID);
if (iic_config == NULL) {
xil_printf("XIicPs_LookupConfig error\r\n");
return -1;
}
status = XIicPs_CfgInitialize(&iic, iic_config, iic_config->BaseAddress);
if (status != XST_SUCCESS) {
xil_printf("XIicPs_CfgInitialize error\r\n");
return -1;
}
/* Set the IIC serial clock rate */
status = XIicPs_SetSClk(&iic, IIC_SCLK_RATE);
if (status != XST_SUCCESS) {
xil_printf("XIicPs_SetSClk error\r\n");
return -1;
}
// check if mux is alive
//status = IicPsSlaveMonitor(&iic, I2C_MUX_ADDR);
//if (status == XST_SUCCESS) {
// xil_printf("I2C mux alive\r\n");
//} else {
// xil_printf("I2C mux not alive\r\n");
// return -1;
//}
//SI i2cmux_set_channel(&iic, I2C_MUX_CH_SI5341);
//SI
//SI // send preamble
//SI for (int i = 0; i < 6; i++) {
//SI si5341_i2c_write(&iic, si5341_revd_registers[i].address,
//SI si5341_revd_registers[i].value);
//SI }
//SI
//SI xil_printf("Si5341: preamble sent\n\r");
//SI
//SI /* Delay 300 msec */
//SI usleep(300000);
//SI
//SI for (int i = 6; i < SI5341_REVD_REG_CONFIG_NUM_REGS; i++) {
//SI si5341_i2c_write(&iic, si5341_revd_registers[i].address,
//SI si5341_revd_registers[i].value);
//SI }
//SI xil_printf("Si5341: config sent\n\r");
//SI
//SI /* Wait until bus is idle */
//SI while (XIicPs_BusIsBusy(&iic) > 0)
//SI ;
//SI
//SI /* Soft reset */
//SI si5341_soft_rst(&iic);
//SI usleep(300000);
//SI
//SI /* Wait for dev ready */
//SI si5341_dev_ready(&iic);
/* Configure I2C Mux to SFP */
i2cmux_set_channel(&iic, I2C_MUX_CH_SFP);
//GD xil_printf("Si5341: Completed!\n\r");
}
static int shell(void)
{
int active;
u32 reg;
u8 dat;
u8 buf[80];
//UPS XUartPs_Config *uart_cfg;
//UPS XUartPs uart;
int status;
xil_printf("Shell starting\n\r");
reg = XUartPs_ReadReg(UART_BASEADDR, XUARTPS_CR_OFFSET);
XUartPs_WriteReg(UART_BASEADDR, XUARTPS_CR_OFFSET,
((reg & ~XUARTPS_CR_EN_DIS_MASK) |
XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN));
//UPS uart_cfg = XUartPs_LookupConfig(UART_DEVICE_ID);
//UPS if (uart_cfg == NULL)
//UPS return XST_FAILURE;
//UPS status = XUartPs_CfgInitialize(&uart, uart_cfg, uart_cfg->BaseAddress);
//UPS if (status != XST_SUCCESS)
//UPS return XST_FAILURE;
//UPS //XUartPs_SetOperMode(&uart, XUARTPS_OPER_MODE_LOCAL_LOOP);
//UPS XUartPs_SetOperMode(&uart, XUARTPS_OPER_MODE_NORMAL);
//UPS //memcpy(buf, "Test UART\n\r", 12);
//UPS //XUartPs_Send(&uart, buf, 12);
//UPS while (XUartPs_IsSending(&uart)) {}
//UPS active = TRUE;
//UPS while (active) {
//UPS XUartPs_Recv(&uart, &dat, 1);
//UPS switch (dat) {
//UPS case 'q':
//UPS active = FALSE;
//UPS break;
//UPS default:
//UPS xil_printf("RECEIVED:");
//UPS dat += 1;
//UPS XUartPs_Send(&uart, &dat, 1);
//UPS break;
//UPS }
//UPS }
active = TRUE;
while (active) {
while (!XUartPs_IsReceiveData(UART_BASEADDR));
dat = XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET);
switch (dat) {
case 'p':
pwr_cycle();
break;
case 'q':
active = FALSE;
break;
default:
XUartPs_WriteReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET, dat + 1);
break;
}
}
return XST_SUCCESS;
}
static int pwr_cycle(void)
{
XGpioPs_Config *ConfigPtr;
XGpioPs Gpio; /* The driver instance for GPIO Device. */
int status, i;
u32 emio_led = 30;
u32 emio_pwr = 79;
u32 emio_pwr_str = 80;
xil_printf("Power-cycling DI/OT crate\n\r");
ConfigPtr = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr,
ConfigPtr->BaseAddr);
if (status != XST_SUCCESS) {
xil_printf("pwr_cycle: Init failed\n\r");
return XST_FAILURE;
}
XGpioPs_SetDirectionPin(&Gpio, emio_led, 1);
XGpioPs_SetDirectionPin(&Gpio, emio_pwr, 1);
XGpioPs_SetDirectionPin(&Gpio, emio_pwr_str, 1);
XGpioPs_SetOutputEnablePin(&Gpio, emio_led, 1);
XGpioPs_SetOutputEnablePin(&Gpio, emio_pwr, 1);
XGpioPs_SetOutputEnablePin(&Gpio, emio_pwr, 1);
XGpioPs_WritePin(&Gpio, emio_pwr, 0x1);
XGpioPs_WritePin(&Gpio, emio_pwr_str, 0x0);
XGpioPs_WritePin(&Gpio, emio_pwr_str, 0x1);
usleep(1000);
XGpioPs_WritePin(&Gpio, emio_pwr_str, 0x0);
XGpioPs_WritePin(&Gpio, emio_pwr, 0x0);
XGpioPs_WritePin(&Gpio, emio_pwr_str, 0x1);
usleep(1000);
XGpioPs_WritePin(&Gpio, emio_pwr_str, 0x0);
usleep(500000);
xil_printf("Done?\n\r");
for (i=0; i<10; ++i) {
XGpioPs_WritePin(&Gpio, emio_led, 0x1);
usleep(500000);
XGpioPs_WritePin(&Gpio, emio_led, 0x0);
usleep(500000);
}
return XST_SUCCESS;
}
//////////////////////////////////////////////////////////////////////////
#undef GPIO_MASK_DATA_5_MSW_OFFSET
#define GPIO_MASK_DATA_5_MSW_OFFSET 0XFF0A002C
#undef GPIO_DIRM_5_OFFSET
#define GPIO_DIRM_5_OFFSET 0XFF0A0344
#undef GPIO_OEN_5_OFFSET
#define GPIO_OEN_5_OFFSET 0XFF0A0348
#undef GPIO_DATA_5_OFFSET
#define GPIO_DATA_5_OFFSET 0XFF0A0054
static
void PSU_Mask_Write(unsigned long offset, unsigned long mask,
unsigned long val)
{
unsigned long RegVal = 0x0;
RegVal = Xil_In32(offset);
RegVal &= ~(mask);
RegVal |= (val & mask);
Xil_Out32(offset, RegVal);
}
static int reset_pl(void)
{
XGpioPs_Config *ConfigPtr;
XGpioPs Gpio; /* The driver instance for GPIO Device. */
//u32 user_led = 78+95;
u32 mio_sfp_disable = 29;
u32 emio_rst_n = 78;
u32 emio_led = 80;
int status;
int i;
u32 Data;
volatile int Delay;
ConfigPtr = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr,
ConfigPtr->BaseAddr);
if (status != XST_SUCCESS) {
print("Reset_PL: Init failed\n\r");
return XST_FAILURE;
}
XGpioPs_SetDirectionPin(&Gpio, emio_rst_n, 1);
XGpioPs_SetDirectionPin(&Gpio, emio_led, 1);
XGpioPs_SetDirectionPin(&Gpio, mio_sfp_disable, 1);
XGpioPs_SetOutputEnablePin(&Gpio, emio_rst_n, 1);
XGpioPs_SetOutputEnablePin(&Gpio, emio_led, 1);
XGpioPs_SetOutputEnablePin(&Gpio, mio_sfp_disable, 1);
/* Reset PL */
XGpioPs_WritePin(&Gpio, emio_rst_n, 0x0);
Data = XGpioPs_ReadPin(&Gpio, emio_rst_n);
if (Data != 0 ) {
print("Reset_PL: fail set 0\n\r");
return XST_FAILURE;
}
usleep(1);
//XGpioPs_WritePin(&Gpio, emio_rst_n, 0x1);
//Data = XGpioPs_ReadPin(&Gpio, emio_rst_n);
//if (Data != 1 ) {
// print("Reset_PL: fail reset\n\r");
// return XST_FAILURE;
//}
//usleep(1);
/* Turn on SFP */
XGpioPs_WritePin(&Gpio, mio_sfp_disable, 0x0);
Data = XGpioPs_ReadPin(&Gpio, mio_sfp_disable);
if (Data != 0 ) {
print("SFP Enable: fail\n\r");
return XST_FAILURE;
}
/* blink LED a bit */
//for (i=0; i<10; ++i) {
// XGpioPs_WritePin(&Gpio, emio_led, 0x1);
// usleep(500000);
// XGpioPs_WritePin(&Gpio, emio_led, 0x0);
// usleep(500000);
//}
//PSU_Mask_Write(GPIO_MASK_DATA_5_MSW_OFFSET, 0xFFFF0000U, 0x80000000U);
//PSU_Mask_Write(GPIO_DIRM_5_OFFSET, 0xFFFFFFFFU, 0x80000000U);
//PSU_Mask_Write(GPIO_OEN_5_OFFSET, 0xFFFFFFFFU, 0x80000000U);
//PSU_Mask_Write(GPIO_DATA_5_OFFSET, 0xFFFFFFFFU, 0x80000000U);
//usleep(1);
//PSU_Mask_Write(GPIO_DATA_5_OFFSET, 0xFFFFFFFFU, 0x00000000U);
//usleep(1);
//PSU_Mask_Write(GPIO_DATA_5_OFFSET, 0xFFFFFFFFU, 0x80000000U);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment