1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/drivers/at86rf231/at86rf231_spi.c

66 lines
1.5 KiB
C
Raw Normal View History

2013-12-16 17:54:58 +01:00
#include "at86rf231_spi.h"
#include "at86rf231_arch.h"
#include "at86rf231.h"
void at86rf231_reg_write(uint8_t addr, uint8_t value)
{
2013-08-15 19:13:00 +02:00
// Start the SPI transfer
at86rf231_spi_select();
2013-08-15 19:13:00 +02:00
// Send first byte being the command and address
at86rf231_spi_transfer_byte(AT86RF231_ACCESS_REG | AT86RF231_ACCESS_WRITE | addr);
2013-08-15 19:13:00 +02:00
// Send value
at86rf231_spi_transfer_byte(value);
2013-08-15 19:13:00 +02:00
// End the SPI transfer
at86rf231_spi_unselect();
}
uint8_t at86rf231_reg_read(uint8_t addr)
{
2013-08-15 19:13:00 +02:00
uint8_t value;
2013-08-15 19:13:00 +02:00
// Start the SPI transfer
at86rf231_spi_select();
2013-08-15 19:13:00 +02:00
// Send first byte being the command and address
at86rf231_spi_transfer_byte(AT86RF231_ACCESS_REG | AT86RF231_ACCESS_READ | addr);
2013-08-15 19:13:00 +02:00
// Send value
value = at86rf231_spi_transfer_byte(0);
2013-08-15 19:13:00 +02:00
// End the SPI transfer
at86rf231_spi_unselect();
2013-08-15 19:13:00 +02:00
return value;
}
2013-08-15 19:13:00 +02:00
void at86rf231_read_fifo(uint8_t *data, uint8_t length)
{
2013-08-15 19:13:00 +02:00
// Start the SPI transfer
at86rf231_spi_select();
2013-08-15 19:13:00 +02:00
// Send Frame Buffer Write access
at86rf231_spi_transfer_byte(AT86RF231_ACCESS_FRAMEBUFFER | AT86RF231_ACCESS_READ);
2013-08-15 19:13:00 +02:00
at86rf231_spi_transfer(0, data, length);
2013-08-15 19:13:00 +02:00
// End the SPI transfer
at86rf231_spi_unselect();
}
2013-08-15 19:13:00 +02:00
void at86rf231_write_fifo(const uint8_t *data, uint8_t length)
{
2013-08-15 19:13:00 +02:00
// Start the SPI transfer
at86rf231_spi_select();
2013-08-15 19:13:00 +02:00
// Send Frame Buffer Write access
at86rf231_spi_transfer_byte(AT86RF231_ACCESS_FRAMEBUFFER | AT86RF231_ACCESS_WRITE);
2013-08-15 19:13:00 +02:00
at86rf231_spi_transfer(data, 0, length);
2013-08-15 19:13:00 +02:00
// End the SPI transfer
at86rf231_spi_unselect();
}