Пример #1
0
static void
finish_setup (CEPageDcb *self, gpointer user_data)
{
	CEPage *parent = CE_PAGE (self);
	CEPageDcbPrivate *priv = CE_PAGE_DCB_GET_PRIVATE (self);
	NMSettingDcb *s_dcb = nm_connection_get_setting_dcb (parent->connection);
	guint i;

	gtk_toggle_button_set_active (priv->enabled, priv->initial_have_dcb);
	g_signal_connect (priv->enabled, "toggled", G_CALLBACK (enable_toggled), self);
	gtk_widget_set_sensitive (GTK_WIDGET (priv->box), priv->initial_have_dcb);

	for (i = 0; i < G_N_ELEMENTS (features); i++)
		feature_setup (self, s_dcb, &features[i]);
}
Пример #2
0
void cNRF24L01::init(HAL *_hal, dir_t dir, uint8_t addr, uint8_t channel, hal_spi_c *_SPI)
{
    hal = _hal;
	address_width_t addr_width = RF24_ADDR_5_BYTES;
	
    this->channel = channel;
	this->addr_size = addr_width + 2;
	this->addr = BASE_ADDR + addr;
	this->payload_size = 10;
	this->dynamic_payload = 1;
	this->dir = dir;

	/*PWR_.init(&hw_conf.pwr);
	IRQ.init(&hw_conf.irq);
	CE.init(&hw_conf.ce);*/
    hal->gpio->init(SPI1_PINS_RCC, SPI1_PINS_PORT, SPI1_PWR, GPIO_Mode_OUT);
    hal->gpio->init(SPI1_CE_PIN_RCC, SPI1_CE_PIN_PORT, SPI1_CE, GPIO_Mode_OUT);        
    hal->gpio->init(SPI1_PINS_RCC, SPI1_PINS_PORT, SPI1_IRQ, GPIO_Mode_IN);
	init_registers(_SPI);

	// Turn on RF24 - defaults, standby-I mode
    hal->gpio->set(SPI1_PINS_PORT, SPI1_PWR, PIN_HIGH);
    hal->gpio->set(SPI1_CE_PIN_PORT, SPI1_CE, PIN_LOW);
	//PWR_.set(PIN_HIGH);
	//CE.set(PIN_LOW);
	// XXX fixme delay(5, msec_1);
	power_mode_set(RF24_PWR_DOWN, RF24_DIR_TX);

//#define RF_DEBUG_INIT
#ifdef RF_DEBUG_INIT
    volatile uint64_t tmp = 0;
#endif
    // Enable CRC
	CRC_len_set(RF24_CRC_16);
#ifdef RF_DEBUG_INIT
	tmp = config.read();// CONFIG = 0x0C
#endif
	// Answer if msg recieved on P0 addr
    auto_ack_enable(RF24_AUTO_ACK_P0);
#ifdef RF_DEBUG_INIT
    tmp = en_aa.read(); // EN_AA = 0x01
#endif
    // Enable P0 addr for RX
    enable_rx_address(RF24_AUTO_ACK_P0);
#ifdef RF_DEBUG_INIT
    tmp = en_rxaddr.read(); //RX_ADDR = 0x01
#endif
    // Addressing width 4 bytes
    address_width_set(addr_width);
#ifdef RF_DEBUG_INIT
    tmp = setup_aw.read(); //SETUP_AW = 0x02 - 4 bytes
#endif
    // Set retries
    retry_mode_set(RF24_RETR_COUNT_5, RF24_RETR_DELAY_500);
#ifdef RF_DEBUG_INIT
    tmp = setup_retr.read(); //SETUP_RETR = 0x2A
#endif
    // Default channel #2, set 1 !!!
    channel_set((rf_channel_t)this->channel);
#ifdef RF_DEBUG_INIT
    tmp = rf_ch.read(); // 0x02
#endif
    rf_setup_set(RF24_1MBPS, RF24_PA_MAX);
#ifdef RF_DEBUG_INIT
    tmp = rf_setup.read(); // RF_SETUP = 0x07
#endif
    tx_addr_set(addr);
#ifdef RF_DEBUG_INIT
    tx_addr.read((uint8_t*)(&tmp), this->addr_size);
#endif
    rx_addr_set(addr, RF24_AUTO_ACK_P0);
#ifdef RF_DEBUG_INIT
    rx_addr_p0.read((uint8_t*)(&tmp), this->addr_size);
#endif
			payload_size_set(this->payload_size);
#ifdef RF_DEBUG_INIT
    tmp = rx_pw_p0.read();
#endif
    if (!this->dynamic_payload)
    {
    	dyn_pd.write(0);
    	feature.write(0);
    }
		else
    {
        feature_setup();
		}
    // Reset current IRQ status
    irq_status_reset();

    // Flush buffers
    config.flush(RX_BUFF);
    config.flush(TX_BUFF);
}