Esempio n. 1
0
/*******************************************************************************
 * Writes an array of bytes into inte the MiRF registers.                      *
 ******************************************************************************/
void mirf_write_register(uint8_t reg, uint8_t * value, uint8_t len)
{
    mirf_CSN_lo;
    spi_fast_shift(W_REGISTER | (REGISTER_MASK & reg));
    spi_transmit_sync(value,len);
    mirf_CSN_hi;
}
Esempio n. 2
0
/*******************************************************************************
 * Sends a data package to the default address. Be sure to send the correct    *
 * amount of bytes as configured as payload on the receiver                    *
 ******************************************************************************/
void mirf_send(uint8_t * value, uint8_t len)
{
    while (PTX) {}                  // Wait until last paket is send

    mirf_CE_lo;

    PTX = 1;                        // Set to transmitter mode
    TX_POWERUP;                     // Power up

    mirf_CSN_lo;                    // Pull down chip select
    spi_fast_shift( FLUSH_TX );     // Write cmd to flush tx fifo
    mirf_CSN_hi;                    // Pull up chip select

    mirf_CSN_lo;                    // Pull down chip select
    spi_fast_shift( W_TX_PAYLOAD ); // Write cmd to write payload
    spi_transmit_sync(value,len);   // Write payload
    mirf_CSN_hi;                    // Pull up chip select

    mirf_CE_hi;                     // Start transmission

    while(mirf_is_sending());

	mirf_CE_lo;                     // Deactivate transreceiver
	RX_POWERUP;                     // Power up in receiving mode

	mirf_CE_hi;                     // Listening for pakets
	PTX = 0;                        // Set to receiving mode

	// Reset status register for further interaction
	mirf_config_register(STATUS,(1<<TX_DS)|(1<<MAX_RT));

	//mirf_CE_lo;

	POWERDOWN;
}
Esempio n. 3
0
void NRF24L01_LOW_write_register(uint8_t regaddr, uint8_t* data, uint8_t len)
{
	NRF24L01_CSN_LOW;
	spi_fast_shift(NRF24L01_CMD_W_REGISTER | regaddr);
	spi_transmit_sync(data, len);
	NRF24L01_CSN_HIGH;
}
Esempio n. 4
0
void nrf_send(uint8_t * value) 
// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
{
    CE_LOW

    TX_POWERUP                     // Power up NRF
    
    nrf_config_register(STATUS,(1<<TX_DS)|(1<<MAX_RT)); // clear status register, write 1 to clear bit.
	
	
	CSN_LOW                    // Pull down chip select
    spi_fast_shift( FLUSH_TX );     // Write cmd to flush tx fifo
    CSN_HIGH                    // Pull up chip select
    
    CSN_LOW                    // Pull down chip select
    spi_fast_shift( W_TX_PAYLOAD ); // Write cmd to write payload
    spi_transmit_sync(value,PAYLOAD_WIDTH);   // Write payload
    CSN_HIGH                    // Pull up chip select
    
    CE_HIGH                     // Start transmission
	_delay_loop_1(4);			// Short Delay to make sure CE is High for at least 10us
	CE_LOW
										// Wait until data is sent or MAX_RT flag
	while(!(nrf_send_completed()));		// This function return 1 if data was transmitted or after MAX_RT.
										
}
Esempio n. 5
0
void NRF24L01_write_ack_payload(uint8_t pipe, uint8_t* data, uint8_t len)
{
	NRF24L01_CSN_LOW;
	spi_fast_shift(NRF24L01_CMD_W_ACK_PAYLOAD | pipe);
	spi_transmit_sync(data, len);
	NRF24L01_CSN_HIGH;
}
Esempio n. 6
0
void mirf_write_register(uint8_t reg, uint8_t * value, uint8_t len) 
// Writes an array of bytes into inte the MiRF registers.
{
    mirf_CSN_lo;
    spi_fast_shift(W_REGISTER | (REGISTER_MASK & reg));
    spi_transmit_sync(value,len);
    mirf_CSN_hi;
}
Esempio n. 7
0
void nrf_write_register(uint8_t reg, uint8_t * value, uint8_t len) 
// Writes an array of bytes into into NRF24L01+ registers.
{
	CSN_LOW
    spi_fast_shift(W_REGISTER | (REGISTER_MASK & reg));
    spi_transmit_sync(value,len);
    CSN_HIGH
}
Esempio n. 8
0
///Initializes data transmission. Automatically sets the NRF24L01 to TX mode
extern void NRF24L01_send_data(uint8_t* data, uint8_t len)
{
	NRF24L01_CE_LOW;
	NRF24L01_set_tx();
	NRF24L01_CSN_LOW;
	spi_fast_shift(NRF24L01_CMD_FLUSH_TX);
	NRF24L01_CSN_HIGH;
	NRF24L01_CSN_LOW;
	spi_fast_shift(NRF24L01_CMD_W_TX_PAYLOAD);
	spi_transmit_sync(data, len);
	NRF24L01_CSN_HIGH;
	NRF24L01_CE_HIGH;
	_delay_us(10);
	NRF24L01_CE_LOW;
}
Esempio n. 9
0
// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
void mirf_send(uint8_t *value, uint8_t len) {
  PMODE = TXMODE; // Set to transmitter mode
  TX_POWERUP; // Power up

  mirf_CSN_lo; // Pull down chip select
  spi_fast_shift(FLUSH_TX);  // Write cmd to flush tx fifo
  mirf_CSN_hi; // Pull up chip select

  mirf_CSN_lo;  // Pull down chip select
  spi_fast_shift(W_TX_PAYLOAD); // Write cmd to write payload
  spi_transmit_sync(value, len); // Write payload
  mirf_CSN_hi; // Pull up chip select

  mirf_CE_hi; // Start transmission
  _delay_us(15);
  mirf_CE_lo;
}
Esempio n. 10
0
extern void NRF24L01_send_data(uint8_t* data, uint8_t len)
{
	NRF24L01_CE_LOW;
	nrf24l01_config_t* config = malloc(sizeof(nrf24l01_config_t));
	config->value = NRF24L01_LOW_get_register(NRF24L01_REG_CONFIG);
	config->prim_rx = 0;
	config->pwr_up = 1;
	NRF24L01_LOW_set_register(NRF24L01_REG_CONFIG, config->value);
	free(config);
	NRF24L01_CSN_LOW;
	spi_fast_shift(NRF24L01_CMD_FLUSH_TX);
	NRF24L01_CSN_HIGH;
	NRF24L01_CSN_LOW;
	spi_fast_shift(NRF24L01_CMD_W_TX_PAYLOAD);
	spi_transmit_sync(data, len);
	NRF24L01_CSN_HIGH;
	NRF24L01_CE_HIGH;
	_delay_us(10);
	NRF24L01_CE_LOW;
}
Esempio n. 11
0
void mirf_send(uint8_t * value, uint8_t len) 
// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
{
    while (PTX) {}                  // Wait until last paket is send

    mirf_CE_lo;

    PTX = 1;                        // Set to transmitter mode
    TX_POWERUP;                     // Power up
    
    mirf_CSN_lo;                    // Pull down chip select
    spi_fast_shift( FLUSH_TX );     // Write cmd to flush tx fifo
    mirf_CSN_hi;                    // Pull up chip select
    
    mirf_CSN_lo;                    // Pull down chip select
    spi_fast_shift( W_TX_PAYLOAD ); // Write cmd to write payload
    spi_transmit_sync(value,len);   // Write payload
    mirf_CSN_hi;                    // Pull up chip select
    
    mirf_CE_hi;                     // Start transmission
}