root/PlatformSupport/CustomPeripherals/drivers/radio_controller_v1_09_a/src/radio_prototypes.c

Revision 737, 6.4 kB (checked in by murphpo, 10 months ago)

changing a default register vlaue

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
87unsigned int clkRatio = 0x00000001;
88
89
90/***************************** Functions ******************************/
91
92// slv_reg8 is the transmit register where the value to be transmitted is to be stored.
93// The last 4 bits of the transmitted value should be the register that needs to be set while
94// the first 14 bits are the numbers that need to be set in that register.
95// slv_reg5 is the Control Register. 0x00003412 is the startup value to be set for the system.
96// 0x00003512 lets the core know to transmit the value in the transmit register.
97// slv_reg6 is the Divider Register. The startup value that needs to be set is 0x00000000.
98// slv_reg7 is the Slave Select Register. This decides which of the radios recieve the transmitted
99// value. Daughtercard slot 1 is 0x00000001. Slot 2 is 0x00000002. Slot 3 is 0x00000004.
100// Slot 4 is 0x00000008. Multiple slots can also be selected at the same time.
101
102/**
103 * @brief Send information via SPI interface.
104 *
105 * Function used to send values to the radio. Waits until the controller is done transmitting
106 * before it returning. Slave select must be correctly set before being used.
107 *
108 * @param val Value to be sent to the radio.
109 */
110void transmit(int val) {
111
112        RADIO_CONTROLLER_mWriteSlaveReg8((volatile)radio_controller_baseaddr, val);                                     // Set the transmit register to the value that should be transmitted.
113
114        RADIO_CONTROLLER_mWriteSlaveReg5((volatile)radio_controller_baseaddr, 0x3512);                          // Sets the GO_BSY to high so it starts transmitting.
115
116        while(RADIO_CONTROLLER_mReadSlaveReg5((volatile)radio_controller_baseaddr) == 0x3512) {         // Wait for the controller to finish transmitting.
117        }
118
119}
120
121
122/**
123 * @brief Send data to a subset of radios via SPI
124 *
125 * Using transmit() it sends data to radio but also allows for temporarily changing the slave select
126 * to apply to some of the radios and not all.
127 *
128 * @param ssval Slave select input
129 * @param val Value to be sent
130 */
131void transRadio(int ssval, unsigned int val) {
132
133        unsigned int temp = RADIO_CONTROLLER_mReadSlaveReg7((volatile)radio_controller_baseaddr);       // Store the current value of the Slave Select. Needed as this function is
134                                                                                                                                                                // used when calling the function for a single radio but still using more
135        RADIO_CONTROLLER_mWriteSlaveReg7((volatile)radio_controller_baseaddr, ssval);                           // Set the Slave Select to the new value.
136        transmit(val);                                                                                  // Transmit the new value
137        RADIO_CONTROLLER_mWriteSlaveReg7((volatile)radio_controller_baseaddr, temp);                                    // Return the Slave Select to its initial value.
138
139}
140
141/**
142 * @brief Send information to the DAC registers.
143 *
144 * Use to send information to DAC registers. Waits until the controller is done transmitting
145 * before it returning. Slave select must be correctly set before being used.
146 *
147 * @param val Value to be sent. 16 bits wide, first 8 register number, last 8 data for that register.
148 */
149void transmitdac(int val) {
150
151        RADIO_CONTROLLER_mWriteSlaveReg8((volatile)radio_controller_baseaddr, val);
152
153        RADIO_CONTROLLER_mWriteSlaveReg5((volatile)radio_controller_baseaddr, 0x3510);
154
155        while(RADIO_CONTROLLER_mReadSlaveReg5((volatile)radio_controller_baseaddr) == 0x3510) {
156        }
157
158}
Note: See TracBrowser for help on using the browser.