summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2015-02-19 02:26:06 (GMT)
committerChristian Pointner <equinox@mur.at>2015-02-19 02:26:06 (GMT)
commit45c7f7013877485c369c32c9b230ed5c9b8da677 (patch)
tree9de3dc0144c05d77f3a7555cb0c3677cdeba9899
parentd031f9e63d53cff9f8a50735a1c5ada9e3027637 (diff)
hhd70: cc1101 register getter
-rw-r--r--software/avr.lib/cc1101.c117
-rw-r--r--software/avr.lib/cc1101.h4
2 files changed, 80 insertions, 41 deletions
diff --git a/software/avr.lib/cc1101.c b/software/avr.lib/cc1101.c
index 7ad87ea..f57395d 100644
--- a/software/avr.lib/cc1101.c
+++ b/software/avr.lib/cc1101.c
@@ -218,7 +218,7 @@ cc1101_state_t cc1101_get_state(void)
uint8_t cc1101_get_iocfg0(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_IOCFG0);
}
void cc1101_set_iocfg0(uint8_t iocfg)
@@ -227,7 +227,7 @@ void cc1101_set_iocfg0(uint8_t iocfg)
uint8_t cc1101_get_iocfg1(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_IOCFG1);
}
void cc1101_set_iocfg1(uint8_t iocfg)
@@ -236,7 +236,7 @@ void cc1101_set_iocfg1(uint8_t iocfg)
uint8_t cc1101_get_iocfg2(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_IOCFG2);
}
void cc1101_set_iocfg2(uint8_t iocfg)
@@ -246,7 +246,7 @@ void cc1101_set_iocfg2(uint8_t iocfg)
uint8_t cc1101_get_fifothr(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_FIFOTHR);
}
void cc1101_set_fifothr(uint8_t fifothr)
@@ -256,7 +256,10 @@ void cc1101_set_fifothr(uint8_t fifothr)
uint16_t cc1101_get_sync(void)
{
- return 0xFFFF;
+ uint16_t s = cc1101_spi_read_register(CC1101_REG_RW_SYNC1);
+ s = s << 8;
+ s |= cc1101_spi_read_register(CC1101_REG_RW_SYNC0);
+ return s;
}
void cc1101_set_sync(uint16_t sync)
@@ -265,7 +268,7 @@ void cc1101_set_sync(uint16_t sync)
uint8_t cc1101_get_pktlen(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_PKTLEN);
}
void cc1101_set_pktlen(uint8_t len)
@@ -274,7 +277,10 @@ void cc1101_set_pktlen(uint8_t len)
uint16_t cc1101_get_pktctrl(void)
{
- return 0xFF;
+ uint16_t p = cc1101_spi_read_register(CC1101_REG_RW_PKTCTRL1);
+ p = p << 8;
+ p |= cc1101_spi_read_register(CC1101_REG_RW_PKTCTRL0);
+ return p;
}
void cc1101_set_pktctrl(uint16_t ctrl)
@@ -283,7 +289,7 @@ void cc1101_set_pktctrl(uint16_t ctrl)
uint8_t cc1101_get_addr(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_ADDR);
}
void cc1101_set_addr(uint8_t addr)
@@ -293,7 +299,7 @@ void cc1101_set_addr(uint8_t addr)
uint8_t cc1101_get_channr(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_CHANNR);
}
void cc1101_set_channr(uint8_t nr)
@@ -302,7 +308,7 @@ void cc1101_set_channr(uint8_t nr)
uint8_t cc1101_get_iffreq(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_FSCTRL1);
}
void cc1101_set_iffreq(uint8_t iffreq)
@@ -311,7 +317,7 @@ void cc1101_set_iffreq(uint8_t iffreq)
uint8_t cc1101_get_freq_offset(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_FSCTRL0);
}
void cc1101_set_freq_offset(uint8_t freqoff)
@@ -320,7 +326,12 @@ void cc1101_set_freq_offset(uint8_t freqoff)
uint32_t cc1101_get_freq(void)
{
- return 0x3FFFFF;
+ uint32_t f = cc1101_spi_read_register(CC1101_REG_RW_FREQ2) & 0x3F;
+ f = f << 8;
+ f |= cc1101_spi_read_register(CC1101_REG_RW_FREQ1);
+ f = f << 8;
+ f |= cc1101_spi_read_register(CC1101_REG_RW_FREQ0);
+ return f;
}
void cc1101_set_freq(uint32_t freq)
@@ -329,7 +340,7 @@ void cc1101_set_freq(uint32_t freq)
uint8_t cc1101_get_deviatn(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_DEVIATN);
}
void cc1101_set_deviatn(uint8_t dev)
@@ -338,7 +349,16 @@ void cc1101_set_deviatn(uint8_t dev)
uint64_t cc1101_get_modemcfg(void)
{
- return 0xFFFFFFFFFFFFFFFF;
+ uint64_t m = cc1101_spi_read_register(CC1101_REG_RW_MDMCFG4);
+ m = m << 8;
+ m |= cc1101_spi_read_register(CC1101_REG_RW_MDMCFG3);
+ m = m << 8;
+ m |= cc1101_spi_read_register(CC1101_REG_RW_MDMCFG2);
+ m = m << 8;
+ m |= cc1101_spi_read_register(CC1101_REG_RW_MDMCFG1);
+ m = m << 8;
+ m |= cc1101_spi_read_register(CC1101_REG_RW_MDMCFG0);
+ return m;
}
void cc1101_set_modemcfg(uint64_t cfg)
@@ -348,7 +368,12 @@ void cc1101_set_modemcfg(uint64_t cfg)
uint32_t cc1101_get_mcsm(void)
{
- return 0xFFFFFFFF;
+ uint32_t m = cc1101_spi_read_register(CC1101_REG_RW_MCSM2);
+ m = m << 8;
+ m |= cc1101_spi_read_register(CC1101_REG_RW_MCSM1);
+ m = m << 8;
+ m |= cc1101_spi_read_register(CC1101_REG_RW_MCSM0);
+ return m;
}
void cc1101_set_mcsm(uint32_t cfg)
@@ -358,7 +383,7 @@ void cc1101_set_mcsm(uint32_t cfg)
uint8_t cc1101_get_foccfg(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_FOCCFG);
}
void cc1101_set_foccfg(uint8_t cfg)
@@ -367,7 +392,7 @@ void cc1101_set_foccfg(uint8_t cfg)
uint8_t cc1101_get_bscfg(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_BSCFG);
}
void cc1101_set_bscfg(uint8_t cfg)
@@ -376,7 +401,12 @@ void cc1101_set_bscfg(uint8_t cfg)
uint32_t cc1101_get_agcctrl(void)
{
- return 0xFFFFFFFF;
+ uint32_t b = cc1101_spi_read_register(CC1101_REG_RW_AGCCTRL2);
+ b = b << 8;
+ b |= cc1101_spi_read_register(CC1101_REG_RW_AGCCTRL1);
+ b = b << 8;
+ b |= cc1101_spi_read_register(CC1101_REG_RW_AGCCTRL0);
+ return b;
}
void cc1101_set_agcctrl(uint32_t ctrl)
@@ -385,7 +415,10 @@ void cc1101_set_agcctrl(uint32_t ctrl)
uint16_t cc1101_get_worevt(void)
{
- return 0xFFFF;
+ uint16_t w = cc1101_spi_read_register(CC1101_REG_RW_WOREVT1);
+ w = w << 8;
+ w |= cc1101_spi_read_register(CC1101_REG_RW_WOREVT0);
+ return w;
}
void cc1101_set_worevt(uint16_t timeout)
@@ -394,7 +427,7 @@ void cc1101_set_worevt(uint16_t timeout)
uint8_t cc1101_get_worctrl(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_WORCTRL);
}
void cc1101_set_worctrl(uint8_t ctrl)
@@ -404,7 +437,10 @@ void cc1101_set_worctrl(uint8_t ctrl)
uint16_t cc1101_get_frend(void)
{
- return 0xFFFF;
+ uint16_t f = cc1101_spi_read_register(CC1101_REG_RW_FREND1);
+ f = f << 8;
+ f |= cc1101_spi_read_register(CC1101_REG_RW_FREND0);
+ return f;
}
void cc1101_set_frend(uint16_t cfg)
@@ -413,7 +449,14 @@ void cc1101_set_frend(uint16_t cfg)
uint32_t cc1101_get_fscal(void)
{
- return 0xFFFFFFFF;
+ uint32_t f = cc1101_spi_read_register(CC1101_REG_RW_FSCAL3);
+ f = f << 8;
+ f = cc1101_spi_read_register(CC1101_REG_RW_FSCAL2);
+ f = f << 8;
+ f |= cc1101_spi_read_register(CC1101_REG_RW_FSCAL1);
+ f = f << 8;
+ f |= cc1101_spi_read_register(CC1101_REG_RW_FSCAL0);
+ return f;
}
void cc1101_set_fscal(uint32_t cal)
@@ -422,7 +465,10 @@ void cc1101_set_fscal(uint32_t cal)
uint16_t cc1101_get_rcctrl(void)
{
- return 0xFFFF;
+ uint16_t r = cc1101_spi_read_register(CC1101_REG_RW_RCCTRL1);
+ r = r << 8;
+ r |= cc1101_spi_read_register(CC1101_REG_RW_RCCTRL0);
+ return r;
}
void cc1101_set_rcctrl(uint16_t ctrl)
@@ -432,25 +478,25 @@ void cc1101_set_rcctrl(uint16_t ctrl)
uint8_t cc1101_get_fstest(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_FSTEST);
}
void cc1101_set_fstest(uint8_t test)
{
}
-uint8_t cc1101_get_pstest(void)
+uint8_t cc1101_get_ptest(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_PTEST);
}
-void cc1101_set_pstest(uint8_t test)
+void cc1101_set_ptest(uint8_t test)
{
}
uint8_t cc1101_get_agctest(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_AGCTEST);
}
void cc1101_set_agctest(uint8_t test)
@@ -459,7 +505,7 @@ void cc1101_set_agctest(uint8_t test)
uint8_t cc1101_get_test0(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_TEST0);
}
void cc1101_set_test0(uint8_t test)
@@ -468,7 +514,7 @@ void cc1101_set_test0(uint8_t test)
uint8_t cc1101_get_test1(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_TEST1);
}
void cc1101_set_test1(uint8_t test)
@@ -477,7 +523,7 @@ void cc1101_set_test1(uint8_t test)
uint8_t cc1101_get_test2(void)
{
- return 0xFF;
+ return cc1101_spi_read_register(CC1101_REG_RW_TEST2);
}
void cc1101_set_test2(uint8_t test)
@@ -631,14 +677,7 @@ void cc1101_dump_register(void)
uint32_t cc1101_get_freq_hz(void)
{
- uint32_t freq = 0;
- freq = cc1101_spi_read_register(CC1101_REG_RW_FREQ2) & 0x3F;
- freq = freq << 8;
- freq |= cc1101_spi_read_register(CC1101_REG_RW_FREQ1);
- freq = freq << 8;
- freq |= cc1101_spi_read_register(CC1101_REG_RW_FREQ0);
-
- return (uint32_t)((float)freq * drv.freq_corr);
+ return (uint32_t)((float)(cc1101_get_freq()) * drv.freq_corr);
}
void cc1101_set_freq_hz(uint32_t hz)
diff --git a/software/avr.lib/cc1101.h b/software/avr.lib/cc1101.h
index ec676e4..af7c0b3 100644
--- a/software/avr.lib/cc1101.h
+++ b/software/avr.lib/cc1101.h
@@ -107,8 +107,8 @@ void cc1101_set_rcctrl(uint16_t ctrl);
uint8_t cc1101_get_fstest(void);
void cc1101_set_fstest(uint8_t test);
-uint8_t cc1101_get_pstest(void);
-void cc1101_set_pstest(uint8_t test);
+uint8_t cc1101_get_ptest(void);
+void cc1101_set_ptest(uint8_t test);
uint8_t cc1101_get_agctest(void);
void cc1101_set_agctest(uint8_t test);
uint8_t cc1101_get_test0(void);