altos: Start making cc1120 radio work
authorKeith Packard <keithp@keithp.com>
Sat, 16 Jun 2012 05:40:30 +0000 (22:40 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 16 Jun 2012 05:40:30 +0000 (22:40 -0700)
RDF tones and radio calibration work now.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_cc1120.c
src/drivers/ao_cc1120.h
src/drivers/ao_cc1120_CC1120.h
src/megametrum-v0.1/Makefile
src/megametrum-v0.1/ao_megametrum.c
src/megametrum-v0.1/ao_pins.h

index 68f7e7363ca1a7ff4d3c0a6f131b58060a246aae..a1d78d9ca13aa331ca07ac061686415f2fc2509e 100644 (file)
@@ -106,7 +106,7 @@ ao_radio_strobe(uint8_t addr)
        ao_radio_duplex(&addr, &in, 1);
        ao_radio_deselect();
 #if CC1120_DEBUG
-       printf("%02x\n", in);
+       printf("%02x\n", in); flush();
 #endif
        return in;
 }
@@ -254,15 +254,33 @@ ao_radio_rdf(uint8_t len)
        ao_radio_abort = 0;
        for (i = 0; i < sizeof (rdf_setup) / sizeof (rdf_setup[0]); i += 2)
                ao_radio_reg_write(rdf_setup[i], rdf_setup[i+1]);
-       ao_radio_reg_write(CC1120_PKT_LEN, len);
+
+#if 0
        int_pin ("Before CFG");
        ao_radio_reg_write(CC1120_IOCFG2, CC1120_IOCFG_GPIO_CFG_RX0TX1_CFG);
        int_pin ("After CFG");
+#endif
+
+       ao_radio_fifo_write_fixed(ao_radio_rdf_value, len);
+
+       ao_radio_reg_write(CC1120_PKT_LEN, len);
+
+       printf ("packet length: %d\n", ao_radio_reg_read(CC1120_PKT_LEN));
+
        ao_radio_strobe(CC1120_STX);
+
+       for (i = 0; i < 20; i++) {
+               printf ("%d ", i); flush();
+               printf ("Status %02x ", ao_radio_status()); flush();
+               printf ("num_tx_bytes %d ", ao_radio_reg_read(CC1120_NUM_TXBYTES)); flush();
+               printf ("marc status %x\n", ao_radio_marc_status()); flush();
+               ao_delay(AO_MS_TO_TICKS(50));
+       }
+
+#if 0
        ao_exti_enable(&AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);
        int_pin ("After strobe");
        ao_delay(AO_MS_TO_TICKS(100));
-       ao_radio_fifo_write_fixed(ao_radio_rdf_value, len);
        int_pin ("After delay");
        cli();
        for (i = 0; i < 20; i++) {
@@ -278,11 +296,14 @@ ao_radio_rdf(uint8_t len)
 #endif
        }
        sei();
+#endif
        printf ("num_tx_bytes %d marc status %x\n",
                ao_radio_reg_read(CC1120_NUM_TXBYTES),
                ao_radio_marc_status());
+#if 0
        if (!ao_radio_tx_done())
                ao_radio_idle();
+#endif
        ao_radio_set_packet();
        ao_radio_put();
 }
@@ -488,8 +509,8 @@ ao_radio_setup(void)
        ao_radio_reg_write(CC1120_IOCFG2, CC1120_IOCFG_GPIO_CFG_MARC_MCU_WAKEUP);
 
        /* Enable the EXTI interrupt for the appropriate pin */
-       ao_enable_port(AO_CC1120_INT_PORT);
-       ao_exti_setup(&AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, AO_EXTI_MODE_FALLING, ao_radio_isr);
+//     ao_enable_port(AO_CC1120_INT_PORT);
+//     ao_exti_setup(&AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, AO_EXTI_MODE_FALLING, ao_radio_isr);
 
        ao_radio_set_packet();
        ao_radio_configured = 1;
index 0f03f2c7c74dea874ba976e640f2c8cf070b4455..5822a21a32ad880a531d54e14d32e74a25815b84 100644 (file)
 #define  CC1120_PKT_CFG1_APPEND_STATUS 0
 
 #define CC1120_PKT_CFG0                0x28
+#define  CC1120_PKT_CFG0_RESERVED7     7
 #define  CC1120_PKT_CFG0_LENGTH_CONFIG 5
 #define  CC1120_PKT_CFG0_LENGTH_CONFIG_FIXED           0
 #define  CC1120_PKT_CFG0_LENGTH_CONFIG_VARIABLE                1
index 1799c2748ffc5023de7c1d3513f0479f33ea132d..f86fd3846462d3d42cd8555ee6b7511f6fac2920 100644 (file)
@@ -68,7 +68,7 @@
         CC1120_PKT_CFG2,                       0x04,       /* Packet Configuration, Reg 2 */\r
         CC1120_PKT_CFG1,                       0x45,       /* Packet Configuration, Reg 1 */\r
 #endif\r
-        CC1120_PKT_CFG0,                       0x20,       /* Packet Configuration, Reg 0 */\r
+        CC1120_PKT_CFG0,                       0x00,       /* Packet Configuration, Reg 0 */\r
         CC1120_RFEND_CFG1,                     0x0f,       /* RFEND Configuration, Reg 1 */\r
         CC1120_RFEND_CFG0,                     0x00,       /* RFEND Configuration, Reg 0 */\r
         CC1120_PA_CFG2,                        0x3f,       /* Power Amplifier Configuration, Reg 2 */\r
@@ -87,9 +87,6 @@
         CC1120_RCCAL_OFFSET,                   0x00,       /* RC Oscillator Calibration Clock Offset */\r
         CC1120_FREQOFF1,                       0x00,       /* Frequency Offset (MSB) */\r
         CC1120_FREQOFF0,                       0x00,       /* Frequency Offset (LSB) */\r
-        CC1120_FREQ2,                          0x6c,       /* Frequency Configuration [23:16] */\r
-        CC1120_FREQ1,                          0xa3,       /* Frequency Configuration [15:8] */\r
-        CC1120_FREQ0,                          0x33,       /* Frequency Configuration [7:0] */\r
         CC1120_IF_ADC2,                        0x02,       /* Analog to Digital Converter Configuration, Reg 2 */\r
         CC1120_IF_ADC1,                        0xa6,       /* Analog to Digital Converter Configuration, Reg 1 */\r
         CC1120_IF_ADC0,                        0x04,       /* Analog to Digital Converter Configuration, Reg 0 */\r
index a07b25eeeab06eee19f53df24200416d7eb9cfe9..5761fed751a32c020c49af9337e9d41941b96fa4 100644 (file)
@@ -24,7 +24,6 @@ INC = \
 # Common AltOS sources
 #
 
-#      ao_cc1120.c \
 #      ao_packet.c \
 #      ao_packet_slave.c \
 
@@ -45,6 +44,7 @@ ALTOS_SRC = \
        ao_freq.c \
        ao_dma_stm.c \
        ao_spi_stm.c \
+       ao_cc1120.c \
        ao_ms5607.c \
        ao_adc_stm.c \
        ao_beep_stm.c \
index 19746d378d2d63ccf230d79bd751ad336d4fb871..628c55387120ead3c659a1c23287cd9660cf8d8a 100644 (file)
 #include <ao_log.h>
 #include <ao_exti.h>
 
-void
-beep(void)
-{
-       ao_beep(AO_BEEP_MID);
-       printf ("Hit a character to stop..."); flush();
-       getchar();
-       putchar('\n');
-       ao_beep(0);
-}
-
-const struct ao_cmds ao_mm_cmds[] = {
-       { beep, "b\0Beep" },
-       { 0, NULL },
-};
-
 int
 main(void)
 {
@@ -55,7 +40,7 @@ main(void)
        ao_storage_init();
        ao_usb_init();
        ao_exti_init();
-//     ao_radio_init();
+       ao_radio_init();
        ao_i2c_init();
        ao_hmc5883_init();
        ao_mpu6000_init();
@@ -64,7 +49,6 @@ main(void)
        ao_report_init();
        ao_config_init();
        
-       ao_cmd_register(&ao_mm_cmds[0]);
        ao_start_scheduler();
        return 0;
 }
index d6394d9b86e1aabd90ebdaf6bd2a1cb38f86238d..5121ad58a906e94e2a1b544f9636daa0048063fc 100644 (file)
@@ -65,6 +65,7 @@
 #define USE_INTERNAL_FLASH     0
 #define HAS_USB                        1
 #define HAS_BEEP               1
+#define HAS_RADIO              1
 
 #define HAS_SPI_1              1
 #define SPI_1_PA5_PA6_PA7      1
 #define HAS_SPI_2              1
 #define SPI_2_PB13_PB14_PB15   1
 #define SPI_2_PD1_PD3_PD4      0
+#define SPI_2_GPIO             stm_gpiob
+#define SPI_2_SCK              13
+#define SPI_2_MISO             14
+#define SPI_2_MOSI             15
 
 #define HAS_I2C_1              1
 #define I2C_1_PB8_PB9          1
@@ -81,7 +86,7 @@
 #define HAS_I2C_2              1
 #define I2C_2_PB10_PB11                1
 
-#define PACKET_HAS_SLAVE       1
+#define PACKET_HAS_SLAVE       0
 
 #define LOW_LEVEL_DEBUG                1
 
@@ -251,4 +256,6 @@ struct ao_adc {
 
 #define HAS_HIGHG_ACCEL                1
 
+#define NUM_CMDS               16
+
 #endif /* _AO_PINS_H_ */