@ -25,6 +25,10 @@
# define CMT2300A_MASK_CHIP_MODE_STA 0x0F
# define CMT2300A_CUS_CMT10 0x09
# define CMT2300A_CUS_TX5 0x59
# define CMT2300A_CUS_TX8 0x5C
# define CMT2300A_CUS_TX9 0x5D
# define CMT2300A_CUS_TX10 0x5E
# define CMT2300A_CUS_MODE_CTL 0x60 // [7] go_switch
// [6] go_tx
@ -153,6 +157,42 @@
# define CMT2300A_MASK_TX_DONE_FLG 0x08
# define CMT2300A_MASK_PKT_OK_FLG 0x01
// this list and the TX5, TX10 registers were compiled from the output of
// HopeRF RFPDK Tool v1.54
static uint8_t paLevelList [ 31 ] [ 2 ] PROGMEM = {
{ 0x17 , 0x01 } , // -10dBm
{ 0x1a , 0x01 } , // -09dBm
{ 0x1d , 0x01 } , // -08dBm
{ 0x21 , 0x01 } , // -07dBm
{ 0x25 , 0x01 } , // -06dBm
{ 0x29 , 0x01 } , // -05dBm
{ 0x2d , 0x01 } , // -04dBm
{ 0x33 , 0x01 } , // -03dBm
{ 0x39 , 0x02 } , // -02dBm
{ 0x41 , 0x02 } , // -01dBm
{ 0x4b , 0x02 } , // 00dBm
{ 0x56 , 0x03 } , // 01dBm
{ 0x63 , 0x03 } , // 02dBm
{ 0x71 , 0x04 } , // 03dBm
{ 0x80 , 0x04 } , // 04dBm
{ 0x22 , 0x01 } , // 05dBm
{ 0x27 , 0x04 } , // 06dBm
{ 0x2c , 0x05 } , // 07dBm
{ 0x31 , 0x06 } , // 08dBm
{ 0x38 , 0x06 } , // 09dBm
{ 0x3f , 0x07 } , // 10dBm
{ 0x48 , 0x08 } , // 11dBm
{ 0x52 , 0x09 } , // 12dBm
{ 0x5d , 0x0b } , // 13dBm
{ 0x6a , 0x0c } , // 14dBm
{ 0x79 , 0x0d } , // 15dBm
{ 0x46 , 0x10 } , // 16dBm
{ 0x51 , 0x10 } , // 17dBm
{ 0x60 , 0x12 } , // 18dBm
{ 0x71 , 0x14 } , // 19dBm
{ 0x8c , 0x1c } // 20dBm
} ;
// default CMT parameters
static uint8_t cmtConfig [ 0x60 ] PROGMEM {
// 0x00 - 0x0f -- RSSI offset +- 0 and 13dBm
@ -168,11 +208,11 @@ static uint8_t cmtConfig[0x60] PROGMEM {
0x10 , 0x00 , 0xB4 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 ,
0x12 , 0x1E , 0x00 , 0xAA , 0x06 , 0x00 , 0x00 , 0x00 ,
// 0x40 - 0x4f
0x00 , 0x48 , 0x5A , 0x48 , 0x4D , 0x01 , 0x1D , 0x00 ,
0x00 , 0x48 , 0x5A , 0x48 , 0x4D , 0x01 , 0x1F , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0xC3 , 0x00 , 0x00 , 0x60 ,
// 0x50 - 0x5f
0xFF , 0x00 , 0x00 , 0x1F , 0x10 , 0x70 , 0x4D , 0x06 ,
0x00 , 0x07 , 0x50 , 0x00 , 0x42 , 0x0C , 0x3F , 0x7F // - TX 13dBm
0x00 , 0x07 , 0x50 , 0x00 , 0x5D , 0x0B , 0x3F , 0x7F // - TX 13dBm
} ;
@ -391,6 +431,26 @@ class Cmt2300a {
return HOY_BASE_FREQ_KHZ + ( mCurCh * FREQ_STEP_KHZ ) ;
}
void setPaLevel ( int8_t level ) {
if ( level < - 10 )
level = - 10 ;
if ( level > 20 )
level = 20 ;
level + = 10 ; // unsigned value
if ( level > = 15 ) {
mSpi . writeReg ( CMT2300A_CUS_TX5 , 0x07 ) ;
mSpi . writeReg ( CMT2300A_CUS_TX10 , 0x3f ) ;
} else {
mSpi . writeReg ( CMT2300A_CUS_TX5 , 0x13 ) ;
mSpi . writeReg ( CMT2300A_CUS_TX10 , 0x18 ) ;
}
mSpi . writeReg ( CMT2300A_CUS_TX8 , paLevelList [ level ] [ 0 ] ) ;
mSpi . writeReg ( CMT2300A_CUS_TX9 , paLevelList [ level ] [ 1 ] ) ;
}
private :
void init ( ) {
mTxPending = false ;