Skip to content

Commit

Permalink
[udp] convert udp to generic device API
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Nov 4, 2014
1 parent cea822f commit b7ea8e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Expand Up @@ -8,11 +8,14 @@ MODEM_PORT_OUT ?= 4242
MODEM_PORT_IN ?= 4243
MODEM_BROADCAST ?= TRUE

UDP_MODEM_PORT_LOWER=$(shell echo $(MODEM_DEV) | tr A-Z a-z)


MODEM_CFLAGS = -DUSE_$(MODEM_DEV) -D$(MODEM_DEV)_PORT_OUT=$(MODEM_PORT_OUT) -D$(MODEM_DEV)_PORT_IN=$(MODEM_PORT_IN)
MODEM_CFLAGS += -D$(MODEM_DEV)_BROADCAST=$(MODEM_BROADCAST) -D$(MODEM_DEV)_HOST=$(MODEM_HOST)

TELEM_CFLAGS = -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(MODEM_DEV) -DPPRZ_UART=$(MODEM_DEV)
TELEM_CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ -DDefaultPeriodic='&telemetry_Main'
TELEM_CFLAGS = -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=$(UDP_MODEM_PORT_LOWER) -DPPRZ_UART=$(MODEM_DEV)
TELEM_CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -DDefaultPeriodic='&telemetry_Main'


ap.CFLAGS += $(MODEM_CFLAGS) $(TELEM_CFLAGS)
Expand Down
4 changes: 4 additions & 0 deletions sw/airborne/mcu_periph/udp.c
Expand Up @@ -32,6 +32,10 @@ void udp_periph_init(struct udp_periph* p, char* host, int port_out, int port_in
p->rx_insert_idx = 0;
p->rx_extract_idx = 0;
p->tx_insert_idx = 0;
p->device.periph = (void *)p;
p->device.check_free_space = (check_free_space_t) udp_check_free_space;
p->device.transmit = (transmit_t) udp_transmit;
p->device.send_message = (send_message_t) udp_send_message;

// Arch dependent initialization
udp_arch_periph_init(p, host, port_out, port_in, broadcast);
Expand Down
3 changes: 3 additions & 0 deletions sw/airborne/mcu_periph/udp.h
Expand Up @@ -30,6 +30,7 @@

#include "std.h"
#include "mcu_periph/udp_arch.h"
#include "mcu_periph/device.h"

#define UDP_RX_BUFFER_SIZE 256
#define UDP_TX_BUFFER_SIZE 256
Expand All @@ -44,6 +45,8 @@ struct udp_periph {
uint16_t tx_insert_idx;
/** UDP network */
void* network;
/** Generic device interface */
struct device device;
};

extern void udp_periph_init(struct udp_periph* p, char* host, int port_out, int port_in, bool_t broadcast);
Expand Down

0 comments on commit b7ea8e1

Please sign in to comment.