source: PlatformSupport/CustomPeripherals/pcores/radio_controller_v1_30_a/src/radio_prototypes.c

Last change on this file was 891, checked in by murphpo, 16 years ago

updated radio controller 1.20 for better compatibility with faster PLB46

File size: 6.4 KB
Line 
1// Copyright (c) 2006 Rice University
2// All Rights Reserved
3// This code is covered by the Rice-WARP license
4// See http://warp.rice.edu/license/ for details
5
6/**
7 * \file radio_prototypes.c
8 * \brief Initializes the registers to their default values.
9 *
10 * @version 1.09
11 * @author Siddharth Gupta
12 *
13 */
14
15// This file initializes the local copies of the radio registers.
16
17/***************************** Include Files *******************************/
18
19#include "radio_prototypes.h"
20
21/************************ Variable Initializations *************************/
22
23// These are local copies of the registers in the chip on WARP Radio Board
24// daughtercard. These are modified on every command sent to the radio by
25// all the radio libraries.
26
27// RADIO 1
28unsigned short REG_RAD1_REGISTER_0 = 0x1140;
29unsigned short REG_RAD1_REGISTER_1 = 0x00CA;
30unsigned short REG_RAD1_STANDBY = 0x1007;
31unsigned short REG_RAD1_INTEGER_DIVIDER_RATIO = 0x30A2;
32unsigned short REG_RAD1_FRACTIONAL_DIVIDER_RATIO = 0x1DDD;
33unsigned short REG_RAD1_BAND_SELECT = 0x1824;
34unsigned short REG_RAD1_CALIBRATION = 0x1C00;
35unsigned short REG_RAD1_LOWPASS_FILTER = 0x002A;
36unsigned short REG_RAD1_RX_CONTROL = 0x0025;
37unsigned short REG_RAD1_TX_LINEARITY = 0x03CF;
38unsigned short REG_RAD1_PA_BIAS_DAC = 0x03C0;
39unsigned short REG_RAD1_RX_GAIN = 0x007F;
40unsigned short REG_RAD1_TX_VGA_GAIN = 0x0000;
41
42// RADIO 2
43unsigned short REG_RAD2_REGISTER_0 = 0x1140;
44unsigned short REG_RAD2_REGISTER_1 = 0x00CA;
45unsigned short REG_RAD2_STANDBY = 0x1007;
46unsigned short REG_RAD2_INTEGER_DIVIDER_RATIO = 0x30A2;
47unsigned short REG_RAD2_FRACTIONAL_DIVIDER_RATIO = 0x1DDD;
48unsigned short REG_RAD2_BAND_SELECT = 0x1824;
49unsigned short REG_RAD2_CALIBRATION = 0x1C00;
50unsigned short REG_RAD2_LOWPASS_FILTER = 0x002A;
51unsigned short REG_RAD2_RX_CONTROL = 0x0025;
52unsigned short REG_RAD2_TX_LINEARITY = 0x03CF;
53unsigned short REG_RAD2_PA_BIAS_DAC = 0x03C0;
54unsigned short REG_RAD2_RX_GAIN = 0x007F;
55unsigned short REG_RAD2_TX_VGA_GAIN = 0x0000;
56
57// RADIO 3
58unsigned short REG_RAD3_REGISTER_0 = 0x1140;
59unsigned short REG_RAD3_REGISTER_1 = 0x00CA;
60unsigned short REG_RAD3_STANDBY = 0x1007;
61unsigned short REG_RAD3_INTEGER_DIVIDER_RATIO = 0x30A2;
62unsigned short REG_RAD3_FRACTIONAL_DIVIDER_RATIO = 0x1DDD;
63unsigned short REG_RAD3_BAND_SELECT = 0x1824;
64unsigned short REG_RAD3_CALIBRATION = 0x1C00;
65unsigned short REG_RAD3_LOWPASS_FILTER = 0x002A;
66unsigned short REG_RAD3_RX_CONTROL = 0x0025;
67unsigned short REG_RAD3_TX_LINEARITY = 0x03CF;
68unsigned short REG_RAD3_PA_BIAS_DAC = 0x03C0;
69unsigned short REG_RAD3_RX_GAIN = 0x007F;
70unsigned short REG_RAD3_TX_VGA_GAIN = 0x0000;
71
72// RADIO 4
73unsigned short REG_RAD4_REGISTER_0 = 0x1140;
74unsigned short REG_RAD4_REGISTER_1 = 0x00CA;
75unsigned short REG_RAD4_STANDBY = 0x1007;
76unsigned short REG_RAD4_INTEGER_DIVIDER_RATIO = 0x30A2;
77unsigned short REG_RAD4_FRACTIONAL_DIVIDER_RATIO = 0x1DDD;
78unsigned short REG_RAD4_BAND_SELECT = 0x1824;
79unsigned short REG_RAD4_CALIBRATION = 0x1C00;
80unsigned short REG_RAD4_LOWPASS_FILTER = 0x002A;
81unsigned short REG_RAD4_RX_CONTROL = 0x0025;
82unsigned short REG_RAD4_TX_LINEARITY = 0x03CF;
83unsigned short REG_RAD4_PA_BIAS_DAC = 0x03C0;
84unsigned short REG_RAD4_RX_GAIN = 0x007F;
85unsigned short REG_RAD4_TX_VGA_GAIN = 0x0000;
86
87
88/***************************** Functions ******************************/
89
90// slv_reg8 is the transmit register where the value to be transmitted is to be stored.
91// The last 4 bits of the transmitted value should be the register that needs to be set while
92// the first 14 bits are the numbers that need to be set in that register.
93// slv_reg5 is the Control Register. 0x00003412 is the startup value to be set for the system.
94// 0x00003512 lets the core know to transmit the value in the transmit register.
95// slv_reg6 is the Divider Register. The startup value that needs to be set is 0x00000000.
96// slv_reg7 is the Slave Select Register. This decides which of the radios recieve the transmitted
97// value. Daughtercard slot 1 is 0x00000001. Slot 2 is 0x00000002. Slot 3 is 0x00000004.
98// Slot 4 is 0x00000008. Multiple slots can also be selected at the same time.
99
100/**
101 * @brief Send information via SPI interface.
102 *
103 * Function used to send values to the radio. Waits until the controller is done transmitting
104 * before it returning. Slave select must be correctly set before being used.
105 *
106 * @param val Value to be sent to the radio.
107 */
108void transmit(int val) {
109
110    RADIO_CONTROLLER_mWriteSlaveReg8((volatile)radio_controller_baseaddr, val);                 // Set the transmit register to the value that should be transmitted.
111
112    RADIO_CONTROLLER_mWriteSlaveReg5((volatile)radio_controller_baseaddr, 0x3512);              // Sets the GO_BSY to high so it starts transmitting.
113
114    while(RADIO_CONTROLLER_mReadSlaveReg5((volatile)radio_controller_baseaddr) == 0x3512) {     // Wait for the controller to finish transmitting.
115    }
116
117}
118
119
120/**
121 * @brief Send data to a subset of radios via SPI
122 *
123 * Using transmit() it sends data to radio but also allows for temporarily changing the slave select
124 * to apply to some of the radios and not all.
125 *
126 * @param ssval Slave select input
127 * @param val Value to be sent
128 */
129void transRadio(int ssval, unsigned int val) {
130
131    unsigned int temp = RADIO_CONTROLLER_mReadSlaveReg7((volatile)radio_controller_baseaddr);   // Store the current value of the Slave Select. Needed as this function is
132                                                                                // used when calling the function for a single radio but still using more
133    RADIO_CONTROLLER_mWriteSlaveReg7((volatile)radio_controller_baseaddr, ssval);               // Set the Slave Select to the new value.
134    transmit(val);                                          // Transmit the new value
135    RADIO_CONTROLLER_mWriteSlaveReg7((volatile)radio_controller_baseaddr, temp);                    // Return the Slave Select to its initial value.
136
137}
138
139/**
140 * @brief Send information to the DAC registers.
141 *
142 * Use to send information to DAC registers. Waits until the controller is done transmitting
143 * before it returning. Slave select must be correctly set before being used.
144 *
145 * @param val Value to be sent. 16 bits wide, first 8 register number, last 8 data for that register.
146 */
147void transmitdac(int val) {
148
149    RADIO_CONTROLLER_mWriteSlaveReg8((volatile)radio_controller_baseaddr, val);
150
151    RADIO_CONTROLLER_mWriteSlaveReg5((volatile)radio_controller_baseaddr, 0x3510);
152
153    while(RADIO_CONTROLLER_mReadSlaveReg5((volatile)radio_controller_baseaddr) == 0x3510) {
154    }
155
156}
157
Note: See TracBrowser for help on using the repository browser.