switched to standard I2Cdev lib, changed reg 0x44 volume control to remove agc delay
This commit is contained in:
parent
c97b0801d5
commit
28f1ff016c
121
HamShield.cpp
121
HamShield.cpp
|
@ -152,44 +152,86 @@ void HamShield::initialize() {
|
||||||
tx_data = 0x03AC; // default is 0x32C
|
tx_data = 0x03AC; // default is 0x32C
|
||||||
I2Cdev::writeWord(devAddr, 0x09, tx_data);
|
I2Cdev::writeWord(devAddr, 0x09, tx_data);
|
||||||
|
|
||||||
tx_data = 0x4381;
|
tx_data = 0x47E0; //0x43A0; // 0x7C20; //
|
||||||
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
|
I2Cdev::writeWord(devAddr, 0x0A, tx_data); // pga gain [10:6]
|
||||||
tx_data = 0xA100;
|
tx_data = 0xA100;
|
||||||
I2Cdev::writeWord(devAddr, 0x13, tx_data);
|
I2Cdev::writeWord(devAddr, 0x13, tx_data);
|
||||||
tx_data = 0x5001;
|
tx_data = 0x5001;
|
||||||
I2Cdev::writeWord(devAddr, 0x1F, tx_data);
|
I2Cdev::writeWord(devAddr, 0x1F, tx_data); // GPIO7->VOX, GPIO0->CTC/DCS
|
||||||
|
|
||||||
|
|
||||||
tx_data = 0x0031;
|
tx_data = 0x0031;
|
||||||
I2Cdev::writeWord(devAddr, 0x31, tx_data);
|
I2Cdev::writeWord(devAddr, 0x31, tx_data);
|
||||||
tx_data = 0x44A5;
|
tx_data = 0x0AF2; //
|
||||||
I2Cdev::writeWord(devAddr, 0x33, tx_data);
|
I2Cdev::writeWord(devAddr, 0x33, tx_data); // agc number
|
||||||
tx_data = 0x2B87;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x34, tx_data);
|
// AGC table
|
||||||
tx_data = 0x060F;
|
tx_data = 0x0001;
|
||||||
I2Cdev::writeWord(devAddr, 0x41, tx_data);
|
I2Cdev::writeWord(devAddr, 0x7F, tx_data);
|
||||||
tx_data = 0x0AFF;
|
tx_data = 0x000C;
|
||||||
I2Cdev::writeWord(devAddr, 0x44, tx_data);
|
I2Cdev::writeWord(devAddr, 0x05, tx_data);
|
||||||
|
tx_data = 0x020C;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x06, tx_data);
|
||||||
|
tx_data = 0x030C;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x07, tx_data);
|
||||||
|
tx_data = 0x0324;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x08, tx_data);
|
||||||
|
tx_data = 0x1344;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x09, tx_data);
|
||||||
|
tx_data = 0x3F44;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
|
||||||
|
tx_data = 0x3F44;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x0B, tx_data);
|
||||||
|
tx_data = 0x3F44;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x0C, tx_data);
|
||||||
|
tx_data = 0x3F44;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x0D, tx_data);
|
||||||
|
tx_data = 0x3F44;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x0E, tx_data);
|
||||||
|
tx_data = 0x3F44;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x0F, tx_data);
|
||||||
|
tx_data = 0xE0ED;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x12, tx_data);
|
||||||
|
tx_data = 0xF2FE;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x13, tx_data);
|
||||||
|
tx_data = 0x0A16;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x14, tx_data);
|
||||||
|
tx_data = 0x2424;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x15, tx_data);
|
||||||
|
tx_data = 0x2424;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x16, tx_data);
|
||||||
|
tx_data = 0x2424;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x17, tx_data);
|
||||||
|
tx_data = 0x0000;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x7F, tx_data);
|
||||||
|
// end AGC table
|
||||||
|
|
||||||
|
tx_data = 0x067F; //0x0601; //0x470F;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x41, tx_data); // voice gain tx [6:0]
|
||||||
|
tx_data = 0x02FF; // using 0x04FF to avoid tx voice delay
|
||||||
|
I2Cdev::writeWord(devAddr, 0x44, tx_data); // tx gain [11:8]
|
||||||
tx_data = 0x7F2F;
|
tx_data = 0x7F2F;
|
||||||
I2Cdev::writeWord(devAddr, 0x47, tx_data);
|
I2Cdev::writeWord(devAddr, 0x47, tx_data);
|
||||||
tx_data = 0x2C62;
|
tx_data = 0x2C62;
|
||||||
I2Cdev::writeWord(devAddr, 0x4F, tx_data);
|
I2Cdev::writeWord(devAddr, 0x4F, tx_data);
|
||||||
tx_data = 0x0094;
|
tx_data = 0x0094;
|
||||||
I2Cdev::writeWord(devAddr, 0x53, tx_data);
|
I2Cdev::writeWord(devAddr, 0x53, tx_data); // compressor update time (bits 6:0, 5.12ms per unit)
|
||||||
tx_data = 0x2A18;
|
tx_data = 0x2A18;
|
||||||
I2Cdev::writeWord(devAddr, 0x54, tx_data);
|
I2Cdev::writeWord(devAddr, 0x54, tx_data);
|
||||||
tx_data = 0x0081;
|
tx_data = 0x0081;
|
||||||
I2Cdev::writeWord(devAddr, 0x55, tx_data);
|
I2Cdev::writeWord(devAddr, 0x55, tx_data);
|
||||||
tx_data = 0x0B02;
|
tx_data = 0x0B22;
|
||||||
I2Cdev::writeWord(devAddr, 0x56, tx_data);
|
I2Cdev::writeWord(devAddr, 0x56, tx_data); // sq detect time
|
||||||
tx_data = 0x1C00;
|
tx_data = 0x1C00;
|
||||||
I2Cdev::writeWord(devAddr, 0x57, tx_data);
|
I2Cdev::writeWord(devAddr, 0x57, tx_data);
|
||||||
tx_data = 0x800D;
|
tx_data = 0x800D;
|
||||||
I2Cdev::writeWord(devAddr, 0x58, tx_data);
|
I2Cdev::writeWord(devAddr, 0x58, tx_data);
|
||||||
tx_data = 0x0EDD;
|
tx_data = 0x0EDD;
|
||||||
I2Cdev::writeWord(devAddr, 0x5A, tx_data);
|
I2Cdev::writeWord(devAddr, 0x5A, tx_data); // sq and noise detect times
|
||||||
tx_data = 0x3FFF;
|
tx_data = 0x3FFF;
|
||||||
I2Cdev::writeWord(devAddr, 0x63, tx_data);
|
I2Cdev::writeWord(devAddr, 0x63, tx_data); // pre-emphasis bypass
|
||||||
|
|
||||||
|
|
||||||
|
// calibration
|
||||||
tx_data = 0x00A4;
|
tx_data = 0x00A4;
|
||||||
I2Cdev::writeWord(devAddr, 0x30, tx_data);
|
I2Cdev::writeWord(devAddr, 0x30, tx_data);
|
||||||
delay(100);
|
delay(100);
|
||||||
|
@ -198,19 +240,26 @@ void HamShield::initialize() {
|
||||||
delay(100);
|
delay(100);
|
||||||
tx_data = 0x0006;
|
tx_data = 0x0006;
|
||||||
I2Cdev::writeWord(devAddr, 0x30, tx_data);
|
I2Cdev::writeWord(devAddr, 0x30, tx_data);
|
||||||
|
delay(100);
|
||||||
|
|
||||||
delay(25);
|
|
||||||
|
|
||||||
|
// setup for 12.5kHz channel width
|
||||||
|
tx_data = 0x3D37;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x11, tx_data);
|
||||||
|
tx_data = 0x0100;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x12, tx_data);
|
||||||
tx_data = 0x1100;
|
tx_data = 0x1100;
|
||||||
I2Cdev::writeWord(devAddr, 0x15, tx_data);
|
I2Cdev::writeWord(devAddr, 0x15, tx_data);
|
||||||
tx_data = 0x4495;
|
tx_data = 0x4495;
|
||||||
I2Cdev::writeWord(devAddr, 0x32, tx_data);
|
I2Cdev::writeWord(devAddr, 0x32, tx_data); // agc target power [11:6]
|
||||||
|
tx_data = 0x2B8E;
|
||||||
|
I2Cdev::writeWord(devAddr, 0x34, tx_data);
|
||||||
tx_data = 0x40C3;
|
tx_data = 0x40C3;
|
||||||
I2Cdev::writeWord(devAddr, 0x3A, tx_data);
|
I2Cdev::writeWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
|
||||||
tx_data = 0x0407;
|
tx_data = 0x0407;
|
||||||
I2Cdev::writeWord(devAddr, 0x3C, tx_data);
|
I2Cdev::writeWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7]
|
||||||
tx_data = 0x28D0;
|
tx_data = 0x28D0;
|
||||||
I2Cdev::writeWord(devAddr, 0x3F, tx_data);
|
I2Cdev::writeWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting
|
||||||
tx_data = 0x203E;
|
tx_data = 0x203E;
|
||||||
I2Cdev::writeWord(devAddr, 0x48, tx_data);
|
I2Cdev::writeWord(devAddr, 0x48, tx_data);
|
||||||
tx_data = 0x1BB7;
|
tx_data = 0x1BB7;
|
||||||
|
@ -222,34 +271,6 @@ void HamShield::initialize() {
|
||||||
tx_data = 0xEB2E;
|
tx_data = 0xEB2E;
|
||||||
I2Cdev::writeWord(devAddr, 0x66, tx_data);
|
I2Cdev::writeWord(devAddr, 0x66, tx_data);
|
||||||
|
|
||||||
// AGC table
|
|
||||||
tx_data = 0x0001;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x7F, tx_data);
|
|
||||||
tx_data = 0x0014;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x06, tx_data);
|
|
||||||
tx_data = 0x020C;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x07, tx_data);
|
|
||||||
tx_data = 0x0214;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x08, tx_data);
|
|
||||||
tx_data = 0x030C;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x09, tx_data);
|
|
||||||
tx_data = 0x0314;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
|
|
||||||
tx_data = 0x0324;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x0B, tx_data);
|
|
||||||
tx_data = 0x0344;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x0C, tx_data);
|
|
||||||
tx_data = 0x1344;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x0D, tx_data);
|
|
||||||
tx_data = 0x1B44;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x0E, tx_data);
|
|
||||||
tx_data = 0x3F44;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x0F, tx_data);
|
|
||||||
tx_data = 0x0EEB;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x12, tx_data);
|
|
||||||
tx_data = 0x0000;
|
|
||||||
I2Cdev::writeWord(devAddr, 0x7F, tx_data);
|
|
||||||
|
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
// setup default values
|
// setup default values
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
#ifndef _HAMSHIELD_H_
|
#ifndef _HAMSHIELD_H_
|
||||||
#define _HAMSHIELD_H_
|
#define _HAMSHIELD_H_
|
||||||
|
|
||||||
#include "I2Cdev_rda.h"
|
//#include "I2Cdev_rda.h"
|
||||||
|
#include "I2Cdev.h"
|
||||||
#include "SimpleFIFO.h"
|
#include "SimpleFIFO.h"
|
||||||
#include "AFSK.h"
|
#include "AFSK.h"
|
||||||
#include "DDS.h"
|
#include "DDS.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// I2Cdev library collection - Main I2C device class
|
// I2Cdev library collection - Main I2C device class
|
||||||
// Abstracts bit and byte I2C R/W functions into a convenient class
|
// Abstracts bit and byte I2C R/W functions into a convenient class
|
||||||
// 6/9/2012 by Jeff Rowberg <jeff@rowberg.net>
|
// 2013-06-05 by Jeff Rowberg <jeff@rowberg.net>
|
||||||
//
|
//
|
||||||
// Changelog:
|
// Changelog:
|
||||||
// 2013-05-06 - add Francesco Ferrara's Fastwire v0.24 implementation with small modifications
|
// 2013-05-06 - add Francesco Ferrara's Fastwire v0.24 implementation with small modifications
|
||||||
|
@ -43,28 +43,28 @@ THE SOFTWARE.
|
||||||
===============================================
|
===============================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "I2Cdev_rda.h"
|
#include "I2Cdev.h"
|
||||||
|
|
||||||
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
||||||
|
|
||||||
#ifdef I2CDEV_IMPLEMENTATION_WARNINGS
|
#ifdef I2CDEV_IMPLEMENTATION_WARNINGS
|
||||||
#if ARDUINO < 100
|
#if ARDUINO < 100
|
||||||
#warning Using outdated Arduino IDE with Wire library is functionally limiting.
|
#warning Using outdated Arduino IDE with Wire library is functionally limiting.
|
||||||
#warning Arduino IDE v1.0.1+ with I2Cdev Fastwire implementation is recommended.
|
#warning Arduino IDE v1.6.5+ with I2Cdev Fastwire implementation is recommended.
|
||||||
#warning This I2Cdev implementation does not support:
|
#warning This I2Cdev implementation does not support:
|
||||||
#warning - Repeated starts conditions
|
#warning - Repeated starts conditions
|
||||||
#warning - Timeout detection (some Wire requests block forever)
|
#warning - Timeout detection (some Wire requests block forever)
|
||||||
#elif ARDUINO == 100
|
#elif ARDUINO == 100
|
||||||
#warning Using outdated Arduino IDE with Wire library is functionally limiting.
|
#warning Using outdated Arduino IDE with Wire library is functionally limiting.
|
||||||
#warning Arduino IDE v1.0.1+ with I2Cdev Fastwire implementation is recommended.
|
#warning Arduino IDE v1.6.5+ with I2Cdev Fastwire implementation is recommended.
|
||||||
#warning This I2Cdev implementation does not support:
|
#warning This I2Cdev implementation does not support:
|
||||||
#warning - Repeated starts conditions
|
#warning - Repeated starts conditions
|
||||||
#warning - Timeout detection (some Wire requests block forever)
|
#warning - Timeout detection (some Wire requests block forever)
|
||||||
#elif ARDUINO > 100
|
#elif ARDUINO > 100
|
||||||
#warning Using current Arduino IDE with Wire library is functionally limiting.
|
/*#warning Using current Arduino IDE with Wire library is functionally limiting.
|
||||||
#warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended.
|
#warning Arduino IDE v1.6.5+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended.
|
||||||
#warning This I2Cdev implementation does not support:
|
#warning This I2Cdev implementation does not support:
|
||||||
#warning - Timeout detection (some Wire requests block forever)
|
#warning - Timeout detection (some Wire requests block forever)*/
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -405,7 +405,6 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
#elif (ARDUINO > 100)
|
#elif (ARDUINO > 100)
|
||||||
//Serial.println("wires");
|
|
||||||
// Arduino v1.0.1+, Wire library
|
// Arduino v1.0.1+, Wire library
|
||||||
// Adds official support for repeated start condition, yay!
|
// Adds official support for repeated start condition, yay!
|
||||||
|
|
||||||
|
@ -415,8 +414,8 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
||||||
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.write(regAddr);
|
Wire.write(regAddr);
|
||||||
Wire.endTransmission(false);
|
Wire.endTransmission();
|
||||||
// Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
Wire.requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
||||||
|
|
||||||
bool msb = true; // starts with MSB, then LSB
|
bool msb = true; // starts with MSB, then LSB
|
|
@ -1,8 +1,9 @@
|
||||||
// I2Cdev library collection - Main I2C device class header file
|
// I2Cdev library collection - Main I2C device class header file
|
||||||
// Abstracts bit and byte I2C R/W functions into a convenient class
|
// Abstracts bit and byte I2C R/W functions into a convenient class
|
||||||
// 6/9/2012 by Jeff Rowberg <jeff@rowberg.net>
|
// 2013-06-05 by Jeff Rowberg <jeff@rowberg.net>
|
||||||
//
|
//
|
||||||
// Changelog:
|
// Changelog:
|
||||||
|
// 2015-10-30 - simondlevy : support i2c_t3 for Teensy3.1
|
||||||
// 2013-05-06 - add Francesco Ferrara's Fastwire v0.24 implementation with small modifications
|
// 2013-05-06 - add Francesco Ferrara's Fastwire v0.24 implementation with small modifications
|
||||||
// 2013-05-05 - fix issue with writing bit values to words (Sasquatch/Farzanegan)
|
// 2013-05-05 - fix issue with writing bit values to words (Sasquatch/Farzanegan)
|
||||||
// 2012-06-09 - fix major issue with reading > 32 bytes at a time with Arduino Wire
|
// 2012-06-09 - fix major issue with reading > 32 bytes at a time with Arduino Wire
|
||||||
|
@ -43,14 +44,16 @@ THE SOFTWARE.
|
||||||
===============================================
|
===============================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _I2CDEV_RDA_H_
|
#ifndef _I2CDEV_H_
|
||||||
#define _I2CDEV_RDA_H_
|
#define _I2CDEV_H_
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// I2C interface implementation setting
|
// I2C interface implementation setting
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
#ifndef I2CDEV_IMPLEMENTATION
|
||||||
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
||||||
//#define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_FASTWIRE
|
//#define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_FASTWIRE
|
||||||
|
#endif // I2CDEV_IMPLEMENTATION
|
||||||
|
|
||||||
// comment this out if you are using a non-optimal IDE/implementation setting
|
// comment this out if you are using a non-optimal IDE/implementation setting
|
||||||
// but want the compiler to shut up about it
|
// but want the compiler to shut up about it
|
||||||
|
@ -76,7 +79,10 @@ THE SOFTWARE.
|
||||||
#else
|
#else
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#endif
|
#endif
|
||||||
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
#if defined(CORE_TEENSY) && defined(__MK20DX256__)
|
||||||
|
#include <i2c_t3.h>
|
||||||
|
#define BUFFER_LENGTH 32
|
||||||
|
#elif I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#endif
|
#endif
|
||||||
#if I2CDEV_IMPLEMENTATION == I2CDEV_I2CMASTER_LIBRARY
|
#if I2CDEV_IMPLEMENTATION == I2CDEV_I2CMASTER_LIBRARY
|
||||||
|
@ -84,6 +90,12 @@ THE SOFTWARE.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SPARK
|
||||||
|
#include <spark_wiring_i2c.h>
|
||||||
|
#define ARDUINO 101
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// 1000ms default read timeout (modify with "I2Cdev::readTimeout = [ms];")
|
// 1000ms default read timeout (modify with "I2Cdev::readTimeout = [ms];")
|
||||||
#define I2CDEV_DEFAULT_READ_TIMEOUT 1000
|
#define I2CDEV_DEFAULT_READ_TIMEOUT 1000
|
||||||
|
|
||||||
|
@ -266,4 +278,4 @@ class I2Cdev {
|
||||||
|
|
||||||
#endif // I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_NBWIRE
|
#endif // I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_NBWIRE
|
||||||
|
|
||||||
#endif /* _I2CDEV_RDA_H_ */
|
#endif /* _I2CDEV_H_ */
|
Loading…
Reference in New Issue