Merge pull request #1375 from OlegHahm/radio_packet_length

Radio packet length
dev/timer
Oleg Hahm 9 years ago
commit 4e2640f9de

@ -44,7 +44,7 @@ uint8_t at86rf231_reg_read(uint8_t addr)
return value;
}
void at86rf231_read_fifo(uint8_t *data, uint8_t length)
void at86rf231_read_fifo(uint8_t *data, radio_packet_length_t length)
{
// Start the SPI transfer
at86rf231_spi_select();
@ -58,7 +58,7 @@ void at86rf231_read_fifo(uint8_t *data, uint8_t length)
at86rf231_spi_unselect();
}
void at86rf231_write_fifo(const uint8_t *data, uint8_t length)
void at86rf231_write_fifo(const uint8_t *data, radio_packet_length_t length)
{
// Start the SPI transfer
at86rf231_spi_select();

@ -10,7 +10,7 @@
#include "at86rf231_arch.h"
#include "at86rf231_spi.h"
static void at86rf231_xmit(uint8_t *data, uint8_t length);
static void at86rf231_xmit(uint8_t *data, radio_packet_length_t length);
static void at86rf231_gen_pkt(uint8_t *buf, at86rf231_packet_t *packet);
static uint8_t sequenz_nr;
@ -66,7 +66,7 @@ int16_t at86rf231_send(at86rf231_packet_t *packet)
return packet->length;
}
static void at86rf231_xmit(uint8_t *data, uint8_t length)
static void at86rf231_xmit(uint8_t *data, radio_packet_length_t length)
{
// Go to state PLL_ON
at86rf231_reg_write(AT86RF231_REG__TRX_STATE, AT86RF231_TRX_STATE__PLL_ON);

@ -13,7 +13,7 @@ uint8_t at86rf231_get_status(void);
void at86rf231_spi_select(void);
void at86rf231_spi_unselect(void);
void at86rf231_spi_transfer(const uint8_t *data_out, uint8_t *data_in, uint16_t length);
void at86rf231_spi_transfer(const uint8_t *data_out, uint8_t *data_in, radio_packet_length_t length);
uint8_t at86rf231_spi_transfer_byte(uint8_t byte);
void at86rf231_init_interrupts(void);

@ -3,9 +3,11 @@
#include <stdint.h>
#include "board.h"
uint8_t at86rf231_reg_read(uint8_t addr);
void at86rf231_reg_write(uint8_t addr, uint8_t value);
void at86rf231_read_fifo(uint8_t *data, uint8_t length);
void at86rf231_write_fifo(const uint8_t *data, uint8_t length);
void at86rf231_read_fifo(uint8_t *data, radio_packet_length_t length);
void at86rf231_write_fifo(const uint8_t *data, radio_packet_length_t length);
#endif

@ -60,7 +60,7 @@ static void cs_timeout_cb(void *ptr)
}
/*---------------------------------------------------------------------------*/
int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priority, char *payload, int payload_len)
int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priority, char *payload, radio_packet_length_t payload_len)
{
uint16_t min_window_size;
uint16_t max_window_size;

@ -165,7 +165,7 @@ void cc110x_gdo2_irq(void)
// of RX FIFO (don't call when in WOR mode)
/*---------------------------------------------------------------------------*/
static bool spi_receive_packet_variable(uint8_t *rxBuffer, uint8_t length)
static bool spi_receive_packet_variable(uint8_t *rxBuffer, radio_packet_length_t length)
{
/* Needed here for statistics */
extern cc1100_statistic_t cc1100_statistic;
@ -215,7 +215,7 @@ static bool spi_receive_packet_variable(uint8_t *rxBuffer, uint8_t length)
}
}
bool cc1100_spi_receive_packet(uint8_t *rxBuffer, uint8_t length)
bool cc1100_spi_receive_packet(uint8_t *rxBuffer, radio_packet_length_t length)
{
uint8_t pkt_len_cfg = cc1100_spi_read_reg(CC1100_PKTCTRL0) & PKT_LENGTH_CONFIG;

@ -245,7 +245,7 @@ void cc1100_gdo2_irq(void);
* @return true if operation succeeded; false otherwise (e.g. no data
* available, buffer to small or CRC check failed).
*/
bool cc1100_spi_receive_packet(uint8_t *rxBuffer, uint8_t length);
bool cc1100_spi_receive_packet(uint8_t *rxBuffer, radio_packet_length_t length);
/**
* @brief Sends raw data.

@ -507,7 +507,7 @@ static bool send_burst(cc1100_packet_layer0_t *packet, uint8_t retries, uint8_t
return true;
}
int cc1100_send(radio_address_t addr, protocol_t protocol, int priority, char *payload, int payload_len)
int cc1100_send(radio_address_t addr, protocol_t protocol, int priority, char *payload, radio_packet_length_t payload_len)
{
(void) priority;

@ -63,6 +63,7 @@ Notes:
for each new packet and kept for packet retransmissions.
*/
typedef struct __attribute__((packed)) cc1100_packet_layer0_t {
radio_packet_length_t length; ///< Length of the packet (without length byte)
uint8_t length; ///< Length of the packet (without length byte)
uint8_t address; ///< Destination address
uint8_t phy_src; ///< Source address (physical source)

@ -36,8 +36,8 @@ radio_address_t ignored_addr[IGN_MAX];
static uint8_t is_ignored(radio_address_t addr);
#endif
static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length);
static uint8_t receive_packet(uint8_t *rxBuffer, uint8_t length);
static uint8_t receive_packet_variable(uint8_t *rxBuffer, radio_packet_length_t length);
static uint8_t receive_packet(uint8_t *rxBuffer, radio_packet_length_t length);
rx_buffer_t cc110x_rx_buffer[RX_BUF_SIZE]; ///< RX buffer
volatile uint8_t rx_buffer_next; ///< Next packet in RX queue
@ -127,7 +127,7 @@ void cc110x_rx_handler(void)
}
static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length)
static uint8_t receive_packet_variable(uint8_t *rxBuffer, radio_packet_length_t length)
{
uint8_t status[2];
uint8_t packetLength = 0;
@ -177,7 +177,7 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length)
}
}
static uint8_t receive_packet(uint8_t *rxBuffer, uint8_t length)
static uint8_t receive_packet(uint8_t *rxBuffer, radio_packet_length_t length)
{
uint8_t pkt_len_cfg = cc110x_read_reg(CC1100_PKTCTRL0) & PKT_LENGTH_CONFIG;

@ -48,8 +48,8 @@ uint8_t cc2420_strobe(uint8_t c) {
}
/* ram */
uint16_t cc2420_read_ram(uint16_t addr, uint8_t* buffer, uint16_t len) {
uint16_t i;
radio_packet_length_t cc2420_read_ram(uint16_t addr, uint8_t* buffer, radio_packet_length_t len) {
radio_packet_length_t i;
unsigned int cpsr = disableIRQ();
cc2420_spi_select();
cc2420_txrx(CC2420_RAM_ACCESS | (addr & 0x7F));
@ -62,8 +62,8 @@ uint16_t cc2420_read_ram(uint16_t addr, uint8_t* buffer, uint16_t len) {
return i;
}
uint16_t cc2420_write_ram(uint16_t addr, uint8_t* buffer, uint16_t len) {
uint16_t i;
radio_packet_length_t cc2420_write_ram(uint16_t addr, uint8_t* buffer, radio_packet_length_t len) {
radio_packet_length_t i;
unsigned int cpsr = disableIRQ();
cc2420_spi_select();
cc2420_txrx(CC2420_RAM_ACCESS | (addr & 0x7F));
@ -78,8 +78,8 @@ uint16_t cc2420_write_ram(uint16_t addr, uint8_t* buffer, uint16_t len) {
/* fifo */
uint16_t cc2420_write_fifo(uint8_t* data, uint16_t data_length) {
uint16_t i;
radio_packet_length_t cc2420_write_fifo(uint8_t* data, radio_packet_length_t data_length) {
radio_packet_length_t i;
unsigned int cpsr = disableIRQ();
cc2420_spi_select();
cc2420_txrx(CC2420_REG_TXFIFO | CC2420_WRITE_ACCESS);
@ -91,8 +91,8 @@ uint16_t cc2420_write_fifo(uint8_t* data, uint16_t data_length) {
return i;
}
uint16_t cc2420_read_fifo(uint8_t* data, uint16_t data_length) {
uint16_t i;
radio_packet_length_t cc2420_read_fifo(uint8_t* data, radio_packet_length_t data_length) {
radio_packet_length_t i;
unsigned int cpsr = disableIRQ();
cc2420_spi_select();
cc2420_txrx(CC2420_REG_RXFIFO | CC2420_READ_ACCESS);

@ -19,6 +19,7 @@
#define CC2420_SPI_H
#include <stdio.h>
#include "board.h"
/**
* @brief Writes a byte to the cc2420 register.
@ -56,7 +57,7 @@ uint8_t cc2420_strobe(uint8_t c);
*
* @return The number of bytes read.
*/
uint16_t cc2420_read_ram(uint16_t addr, uint8_t* buffer, uint16_t len);
radio_packet_length_t cc2420_read_ram(uint16_t addr, uint8_t* buffer, radio_packet_length_t len);
/**
* @brief Writes multiple bytes to the cc2420 ram.
@ -67,7 +68,7 @@ uint16_t cc2420_read_ram(uint16_t addr, uint8_t* buffer, uint16_t len);
*
* @return The number of bytes written.
*/
uint16_t cc2420_write_ram(uint16_t addr, uint8_t* buffer, uint16_t len);
radio_packet_length_t cc2420_write_ram(uint16_t addr, uint8_t* buffer, radio_packet_length_t len);
/**
* @brief Writes multiple bytes to the cc2420 fifo.
@ -77,7 +78,7 @@ uint16_t cc2420_write_ram(uint16_t addr, uint8_t* buffer, uint16_t len);
*
* @return The number of bytes written.
*/
uint16_t cc2420_write_fifo(uint8_t* data, uint16_t data_length);
radio_packet_length_t cc2420_write_fifo(uint8_t* data, radio_packet_length_t data_length);
/**
* @brief Reads multiple bytes from the cc2420 fifo.
@ -87,6 +88,6 @@ uint16_t cc2420_write_fifo(uint8_t* data, uint16_t data_length);
*
* @return The number of bytes read.
*/
uint16_t cc2420_read_fifo(uint8_t* data, uint16_t data_length);
radio_packet_length_t cc2420_read_fifo(uint8_t* data, radio_packet_length_t data_length);
#endif

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdint.h>
#include "board.h"
#include "radio/types.h"
#include "ieee802154_frame.h"
@ -19,7 +20,7 @@
typedef struct __attribute__((packed))
{
/* @{ */
uint8_t length; /** < the length of the frame of the frame including fcs*/
uint8_t length; /** < the length of the frame of the frame including fcs*/
ieee802154_frame_t frame; /** < the ieee802154 frame */
int8_t rssi; /** < the rssi value */
uint8_t crc; /** < 1 if crc was successfull, 0 otherwise */

@ -176,7 +176,7 @@ int cc1100_set_packet_handler(protocol_t protocol, packet_handler_t handler);
*
* @return A negative value if operation failed; if operation succeeded (ACK received) the number of transmitted bytes.
*/
int cc1100_send(radio_address_t addr, protocol_t protocol, int priority, char *payload, int payload_len);
int cc1100_send(radio_address_t addr, protocol_t protocol, int priority, char *payload, radio_packet_length_t payload_len);
/**
* @brief Send data to given destination address with acknowledgment and CSMA/CA.
@ -191,7 +191,7 @@ int cc1100_send(radio_address_t addr, protocol_t protocol, int priority, char *p
*
* @return A negative value if operation failed; if operation succeeded (ACK received) else the number of transmitted bytes.
*/
int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priority, char *payload, int payload_len);
int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priority, char *payload, radio_packet_length_t payload_len);
/**
* @brief Print current radio configuration.

@ -89,10 +89,10 @@ Notes:
*/
typedef struct __attribute__((packed))
{
uint8_t length; ///< Length of the packet (without length byte)
uint8_t address; ///< Destination address
uint8_t phy_src; ///< Source address (physical source)
uint8_t flags; ///< Flags
uint8_t length; ///< Length of the packet (without length byte)
uint8_t address; ///< Destination address
uint8_t phy_src; ///< Source address (physical source)
uint8_t flags; ///< Flags
uint8_t data[CC1100_MAX_DATA_LENGTH]; ///< Data (high layer protocol)
}
cc110x_packet_t;

Loading…
Cancel
Save