switched to standard I2Cdev lib, changed reg 0x44 volume control to remove agc delay
This commit is contained in:
parent
c97b0801d5
commit
28f1ff016c
127
HamShield.cpp
127
HamShield.cpp
|
@ -152,44 +152,86 @@ void HamShield::initialize() {
|
|||
tx_data = 0x03AC; // default is 0x32C
|
||||
I2Cdev::writeWord(devAddr, 0x09, tx_data);
|
||||
|
||||
tx_data = 0x4381;
|
||||
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
|
||||
tx_data = 0x47E0; //0x43A0; // 0x7C20; //
|
||||
I2Cdev::writeWord(devAddr, 0x0A, tx_data); // pga gain [10:6]
|
||||
tx_data = 0xA100;
|
||||
I2Cdev::writeWord(devAddr, 0x13, tx_data);
|
||||
tx_data = 0x5001;
|
||||
I2Cdev::writeWord(devAddr, 0x1F, tx_data);
|
||||
I2Cdev::writeWord(devAddr, 0x1F, tx_data); // GPIO7->VOX, GPIO0->CTC/DCS
|
||||
|
||||
|
||||
tx_data = 0x0031;
|
||||
I2Cdev::writeWord(devAddr, 0x31, tx_data);
|
||||
tx_data = 0x44A5;
|
||||
I2Cdev::writeWord(devAddr, 0x33, tx_data);
|
||||
tx_data = 0x2B87;
|
||||
I2Cdev::writeWord(devAddr, 0x34, tx_data);
|
||||
tx_data = 0x060F;
|
||||
I2Cdev::writeWord(devAddr, 0x41, tx_data);
|
||||
tx_data = 0x0AFF;
|
||||
I2Cdev::writeWord(devAddr, 0x44, tx_data);
|
||||
tx_data = 0x0AF2; //
|
||||
I2Cdev::writeWord(devAddr, 0x33, tx_data); // agc number
|
||||
|
||||
// AGC table
|
||||
tx_data = 0x0001;
|
||||
I2Cdev::writeWord(devAddr, 0x7F, tx_data);
|
||||
tx_data = 0x000C;
|
||||
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;
|
||||
I2Cdev::writeWord(devAddr, 0x47, tx_data);
|
||||
tx_data = 0x2C62;
|
||||
I2Cdev::writeWord(devAddr, 0x4F, tx_data);
|
||||
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;
|
||||
I2Cdev::writeWord(devAddr, 0x54, tx_data);
|
||||
tx_data = 0x0081;
|
||||
I2Cdev::writeWord(devAddr, 0x55, tx_data);
|
||||
tx_data = 0x0B02;
|
||||
I2Cdev::writeWord(devAddr, 0x56, tx_data);
|
||||
tx_data = 0x0B22;
|
||||
I2Cdev::writeWord(devAddr, 0x56, tx_data); // sq detect time
|
||||
tx_data = 0x1C00;
|
||||
I2Cdev::writeWord(devAddr, 0x57, tx_data);
|
||||
tx_data = 0x800D;
|
||||
I2Cdev::writeWord(devAddr, 0x58, tx_data);
|
||||
I2Cdev::writeWord(devAddr, 0x58, tx_data);
|
||||
tx_data = 0x0EDD;
|
||||
I2Cdev::writeWord(devAddr, 0x5A, tx_data);
|
||||
I2Cdev::writeWord(devAddr, 0x5A, tx_data); // sq and noise detect times
|
||||
tx_data = 0x3FFF;
|
||||
I2Cdev::writeWord(devAddr, 0x63, tx_data);
|
||||
|
||||
I2Cdev::writeWord(devAddr, 0x63, tx_data); // pre-emphasis bypass
|
||||
|
||||
// calibration
|
||||
tx_data = 0x00A4;
|
||||
I2Cdev::writeWord(devAddr, 0x30, tx_data);
|
||||
delay(100);
|
||||
|
@ -198,19 +240,26 @@ void HamShield::initialize() {
|
|||
delay(100);
|
||||
tx_data = 0x0006;
|
||||
I2Cdev::writeWord(devAddr, 0x30, tx_data);
|
||||
|
||||
delay(25);
|
||||
|
||||
delay(100);
|
||||
|
||||
|
||||
// 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;
|
||||
I2Cdev::writeWord(devAddr, 0x15, tx_data);
|
||||
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;
|
||||
I2Cdev::writeWord(devAddr, 0x3A, tx_data);
|
||||
I2Cdev::writeWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
|
||||
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;
|
||||
I2Cdev::writeWord(devAddr, 0x3F, tx_data);
|
||||
I2Cdev::writeWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting
|
||||
tx_data = 0x203E;
|
||||
I2Cdev::writeWord(devAddr, 0x48, tx_data);
|
||||
tx_data = 0x1BB7;
|
||||
|
@ -221,34 +270,6 @@ void HamShield::initialize() {
|
|||
I2Cdev::writeWord(devAddr, 0x65, tx_data);
|
||||
tx_data = 0xEB2E;
|
||||
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);
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#ifndef _HAMSHIELD_H_
|
||||
#define _HAMSHIELD_H_
|
||||
|
||||
#include "I2Cdev_rda.h"
|
||||
//#include "I2Cdev_rda.h"
|
||||
#include "I2Cdev.h"
|
||||
#include "SimpleFIFO.h"
|
||||
#include "AFSK.h"
|
||||
#include "DDS.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// I2Cdev library collection - Main I2C device 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:
|
||||
// 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
|
||||
|
||||
#ifdef I2CDEV_IMPLEMENTATION_WARNINGS
|
||||
#if ARDUINO < 100
|
||||
#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 - Repeated starts conditions
|
||||
#warning - Timeout detection (some Wire requests block forever)
|
||||
#elif ARDUINO == 100
|
||||
#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 - Repeated starts conditions
|
||||
#warning - Timeout detection (some Wire requests block forever)
|
||||
#elif ARDUINO > 100
|
||||
#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 Using current Arduino IDE with Wire library is functionally limiting.
|
||||
#warning Arduino IDE v1.6.5+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended.
|
||||
#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
|
||||
|
||||
|
@ -405,8 +405,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
|||
Wire.endTransmission();
|
||||
}
|
||||
#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!
|
||||
|
||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||
|
@ -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)) {
|
||||
Wire.beginTransmission(devAddr);
|
||||
Wire.write(regAddr);
|
||||
Wire.endTransmission(false);
|
||||
// Wire.beginTransmission(devAddr);
|
||||
Wire.endTransmission();
|
||||
Wire.beginTransmission(devAddr);
|
||||
Wire.requestFrom(devAddr, (uint8_t)(length * 2)); // length=words, this wants bytes
|
||||
|
||||
bool msb = true; // starts with MSB, then LSB
|
|
@ -1,8 +1,9 @@
|
|||
// I2Cdev library collection - Main I2C device class header file
|
||||
// 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:
|
||||
// 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-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
|
||||
|
@ -43,14 +44,16 @@ THE SOFTWARE.
|
|||
===============================================
|
||||
*/
|
||||
|
||||
#ifndef _I2CDEV_RDA_H_
|
||||
#define _I2CDEV_RDA_H_
|
||||
#ifndef _I2CDEV_H_
|
||||
#define _I2CDEV_H_
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// I2C interface implementation setting
|
||||
// -----------------------------------------------------------------------------
|
||||
#ifndef I2CDEV_IMPLEMENTATION
|
||||
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
||||
//#define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_FASTWIRE
|
||||
#endif // I2CDEV_IMPLEMENTATION
|
||||
|
||||
// comment this out if you are using a non-optimal IDE/implementation setting
|
||||
// but want the compiler to shut up about it
|
||||
|
@ -76,7 +79,10 @@ THE SOFTWARE.
|
|||
#else
|
||||
#include "Arduino.h"
|
||||
#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>
|
||||
#endif
|
||||
#if I2CDEV_IMPLEMENTATION == I2CDEV_I2CMASTER_LIBRARY
|
||||
|
@ -84,13 +90,19 @@ THE SOFTWARE.
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SPARK
|
||||
#include <spark_wiring_i2c.h>
|
||||
#define ARDUINO 101
|
||||
#endif
|
||||
|
||||
|
||||
// 1000ms default read timeout (modify with "I2Cdev::readTimeout = [ms];")
|
||||
#define I2CDEV_DEFAULT_READ_TIMEOUT 1000
|
||||
|
||||
class I2Cdev {
|
||||
public:
|
||||
I2Cdev();
|
||||
|
||||
|
||||
static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout);
|
||||
static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout);
|
||||
static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout);
|
||||
|
@ -119,7 +131,7 @@ class I2Cdev {
|
|||
// Copyright(C) 2012
|
||||
// Francesco Ferrara
|
||||
//////////////////////
|
||||
|
||||
|
||||
/* Master */
|
||||
#define TW_START 0x08
|
||||
#define TW_REP_START 0x10
|
||||
|
@ -162,24 +174,24 @@ class I2Cdev {
|
|||
// Originally offered to the i2cdevlib project at http://arduino.cc/forum/index.php/topic,68210.30.html
|
||||
|
||||
#define NBWIRE_BUFFER_LENGTH 32
|
||||
|
||||
|
||||
class TwoWire {
|
||||
private:
|
||||
static uint8_t rxBuffer[];
|
||||
static uint8_t rxBufferIndex;
|
||||
static uint8_t rxBufferLength;
|
||||
|
||||
|
||||
static uint8_t txAddress;
|
||||
static uint8_t txBuffer[];
|
||||
static uint8_t txBufferIndex;
|
||||
static uint8_t txBufferLength;
|
||||
|
||||
|
||||
// static uint8_t transmitting;
|
||||
static void (*user_onRequest)(void);
|
||||
static void (*user_onReceive)(int);
|
||||
static void onRequestService(void);
|
||||
static void onReceiveService(uint8_t*, int);
|
||||
|
||||
|
||||
public:
|
||||
TwoWire();
|
||||
void begin();
|
||||
|
@ -201,25 +213,25 @@ class I2Cdev {
|
|||
void onReceive(void (*)(int));
|
||||
void onRequest(void (*)(void));
|
||||
};
|
||||
|
||||
|
||||
#define TWI_READY 0
|
||||
#define TWI_MRX 1
|
||||
#define TWI_MTX 2
|
||||
#define TWI_SRX 3
|
||||
#define TWI_STX 4
|
||||
|
||||
|
||||
#define TW_WRITE 0
|
||||
#define TW_READ 1
|
||||
|
||||
|
||||
#define TW_MT_SLA_NACK 0x20
|
||||
#define TW_MT_DATA_NACK 0x30
|
||||
|
||||
|
||||
#define CPU_FREQ 16000000L
|
||||
#define TWI_FREQ 100000L
|
||||
#define TWI_BUFFER_LENGTH 32
|
||||
|
||||
|
||||
/* TWI Status is in TWSR, in the top 5 bits: TWS7 - TWS3 */
|
||||
|
||||
|
||||
#define TW_STATUS_MASK (_BV(TWS7)|_BV(TWS6)|_BV(TWS5)|_BV(TWS4)|_BV(TWS3))
|
||||
#define TW_STATUS (TWSR & TW_STATUS_MASK)
|
||||
#define TW_START 0x08
|
||||
|
@ -250,20 +262,20 @@ class I2Cdev {
|
|||
#define TW_SR_STOP 0xA0
|
||||
#define TW_NO_INFO 0xF8
|
||||
#define TW_BUS_ERROR 0x00
|
||||
|
||||
|
||||
//#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))
|
||||
//#define _SFR_BYTE(sfr) _MMIO_BYTE(_SFR_ADDR(sfr))
|
||||
|
||||
|
||||
#ifndef sbi // set bit
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif // sbi
|
||||
|
||||
|
||||
#ifndef cbi // clear bit
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif // cbi
|
||||
|
||||
|
||||
extern TwoWire Wire;
|
||||
|
||||
#endif // I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_NBWIRE
|
||||
|
||||
#endif /* _I2CDEV_RDA_H_ */
|
||||
#endif /* _I2CDEV_H_ */
|
Loading…
Reference in New Issue