Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
90b4da5
fixed packet_timer inconsistencies
oyv Feb 5, 2014
0abe9a7
Added .dep, JLinkLog.txt, .uvgui to .gitignore
oyv Feb 5, 2014
3609d87
Added debug variables to main files. Used with Keil debugger.
oyv Feb 22, 2014
82a4e95
Added Compare0 to IRQHandler
oyv Feb 22, 2014
506e313
Added COMPARE0 -> STOP short to RX packet timer procedure. Also added…
oyv Feb 22, 2014
d0581c0
Increased time until ack timeout (to reduce retransmits)
oyv Feb 22, 2014
90f2997
Added SETUP_INTERRUPTS macro.
oyv Feb 22, 2014
05f8982
Changed variables to be debugger friendly (no static).
oyv Feb 22, 2014
4c2a868
Used PREPARE_* macros instead of 3 lines doing the same.
oyv Feb 22, 2014
b26f29a
Restructured radio_send to be more readable.
oyv Feb 22, 2014
5d82fd4
Fixed on_packet_timeout to correctly handle state transition. Introdu…
oyv Feb 22, 2014
232d33e
Changed ack procedure to send received packet back with ack flag set.
oyv Feb 22, 2014
b558e0c
Added debug variable total_m_tx_attempts.
oyv Feb 22, 2014
1a2532c
Fixed radio_receive_start (added packet_timer_event_start call)
oyv Feb 22, 2014
863fb1b
.bak i .gitignore
oyv Aug 2, 2014
ef12ad1
Amend queues to provide pointers to elements (no copying)
oyv Aug 11, 2014
2a9dd78
Rewrite of radio module:
oyv Aug 11, 2014
7bdaeb1
rewrite rx main.c for new radio module
oyv Aug 11, 2014
50e9724
rewrite tx main.c for new radio module
oyv Aug 11, 2014
006c77b
Remove packet_timer.c and add packet.c to keil project files for tx app
oyv Aug 11, 2014
6867525
Remove packet_timer.c and add packet.c to keil project files for rx app
oyv Aug 11, 2014
cfae166
Fixed Makefiles for my environment
oyv Aug 11, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ tags
*.o
*.d
*.lib
*.dep
JLinkLog.txt
*.uvgui*
tests/all_tests
*.bak


4 changes: 2 additions & 2 deletions app/rx/keil/nrf51-simple-radio-rx.uvopt
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,8 @@
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\lib\packet_timer.c</PathWithFileName>
<FilenameWithoutPath>packet_timer.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\lib\packet.c</PathWithFileName>
<FilenameWithoutPath>packet.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
Expand Down
24 changes: 12 additions & 12 deletions app/rx/keil/nrf51-simple-radio-rx.uvproj
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -910,9 +910,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -1366,9 +1366,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -1822,9 +1822,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -2278,9 +2278,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -2734,9 +2734,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down
16 changes: 11 additions & 5 deletions app/rx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
#include "leds.h"
#include "radio.h"

volatile uint32_t n_packets_received = 0;

void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
volatile uint32_t m_err_code = err_code;
volatile uint32_t m_line_num = line_num;
char * volatile m_file_name = file_name;
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
Expand All @@ -26,6 +31,7 @@ void radio_evt_handler(radio_evt_t * evt)
{
case PACKET_RECEIVED:
led_toggle(LED1);
n_packets_received++;
break;

default:
Expand All @@ -35,17 +41,17 @@ void radio_evt_handler(radio_evt_t * evt)

int main(void)
{
radio_init(radio_evt_handler);

radio_receive_start();
static uint32_t err_code, temp;
err_code = radio_init(radio_evt_handler, 0);
ASSUME_SUCCESS(err_code);

leds_init();
gpio_pins_cfg_out(0, 8);

while (1)
{
err_code = radio_start_rx();
led_on(LED0);
nrf_delay_us(1000);
nrf_delay_us(50000);
led_off(LED0);
nrf_delay_us(100000);
}
Expand Down
8 changes: 4 additions & 4 deletions app/rx/pure-gcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ APPLICATION_LIBS += radio.lib
PROJECT_NAME = $(shell basename "$(realpath ../)")

DEVICE = NRF51
BOARD = BOARD_PCA10000
SEGGER_SERIAL = 480104825
BOARD = BOARD_PCA10001
SEGGER_SERIAL = 480205185

#USE_SOFTDEVICE = S110

SDK_PATH ?= $(HOME)/Projects/nrf51/nrf51822/
TEMPLATE_PATH ?= $(HOME)/Projects/nrf51-pure-gcc-setup/template/
SDK_PATH ?= /usr/lib/nRF51-SDK/nrf51822/
TEMPLATE_PATH ?= $(HOME)/git/nrf51-pure-gcc-setup/template/

LIB_PATH = ../../../lib/

Expand Down
4 changes: 2 additions & 2 deletions app/tx/keil/nrf51-simple-radio-tx.uvopt
Original file line number Diff line number Diff line change
Expand Up @@ -1167,8 +1167,8 @@
<TopLine>25</TopLine>
<CurrentLine>51</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\lib\packet_timer.c</PathWithFileName>
<FilenameWithoutPath>packet_timer.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\lib\packet.c</PathWithFileName>
<FilenameWithoutPath>packet.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
Expand Down
24 changes: 12 additions & 12 deletions app/tx/keil/nrf51-simple-radio-tx.uvproj
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -910,9 +910,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -1366,9 +1366,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -1822,9 +1822,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -2278,9 +2278,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down Expand Up @@ -2734,9 +2734,9 @@
<FilePath>..\..\..\lib\tx_queue.c</FilePath>
</File>
<File>
<FileName>packet_timer.c</FileName>
<FileName>packet.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\lib\packet_timer.c</FilePath>
<FilePath>..\..\..\lib\packet.c</FilePath>
</File>
</Files>
</Group>
Expand Down
24 changes: 17 additions & 7 deletions app/tx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
#include "leds.h"
#include "radio.h"

volatile uint32_t n_packets_sent = 0;
volatile uint32_t n_packets_lost = 0;

void error_handler(uint32_t err_code, uint32_t line_num, char * file_name)
{
volatile uint32_t m_err_code = err_code;
volatile uint32_t m_line_num = line_num;
char * volatile m_file_name = file_name;
while (1)
{
for (uint8_t i = LED_START; i < LED_STOP; i++)
Expand All @@ -27,10 +33,12 @@ void radio_evt_handler(radio_evt_t * evt)
{
case PACKET_SENT:
led_toggle(LED1);
n_packets_sent++;
break;

case PACKET_LOST:
case PACKET_RECEIVED:
led_toggle(LED0);
n_packets_lost++;
break;

default:
Expand All @@ -46,24 +54,26 @@ int main(void)

leds_init();

radio_packet_t initial_packet;
initial_packet.len = 4;

radio_packet_t packet;
packet.len = 4;
packet.flags.ack = 0;

radio_init(radio_evt_handler);
radio_init(radio_evt_handler, &initial_packet);

while (1)
{
packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);

packet.data[0] = i++;
packet.data[1] = 0x12;
err_code = radio_send(&packet);
ASSUME_SUCCESS(err_code);

nrf_delay_us(2000);

radio_stop_rx();

nrf_delay_us(1000000);
}
}
8 changes: 4 additions & 4 deletions app/tx/pure-gcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ APPLICATION_LIBS += radio.lib
PROJECT_NAME = $(shell basename "$(realpath ../)")

DEVICE = NRF51
BOARD = BOARD_PCA10001
SEGGER_SERIAL = 480200976
BOARD = BOARD_PCA10000
SEGGER_SERIAL = 480107090

#USE_SOFTDEVICE = S110

SDK_PATH ?= $(HOME)/Projects/nrf51/nrf51822/
TEMPLATE_PATH ?= $(HOME)/Projects/nrf51-pure-gcc-setup/template/
SDK_PATH ?= /usr/lib/nRF51-SDK/nrf51822/
TEMPLATE_PATH ?= ../../../../nrf51-pure-gcc-setup/template/

LIB_PATH = ../../../lib/

Expand Down
1 change: 1 addition & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RADIO_SRCS += radio.c
RADIO_SRCS += queue.c
RADIO_SRCS += packet.c
RADIO_SRCS += evt_queue.c
RADIO_SRCS += tx_queue.c
RADIO_SRCS += rx_queue.c
Expand Down
20 changes: 20 additions & 0 deletions lib/packet.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "packet.h"
#include "error.h"


uint32_t dummy_packet_get(radio_packet_t ** packet)
{
static radio_packet_t empty_packet =
{
.len = 0,
.flags = 0x80
};

*packet = &empty_packet;
return SUCCESS;
}

bool packet_is_empty(radio_packet_t* packet)
{
return (packet->len == 0);
}
24 changes: 24 additions & 0 deletions lib/packet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef PACKET_H_INCLUDED
#define PACKET_H_INCLUDED
#include <stdint.h>
#include <stdbool.h>

#define RADIO_PACKET_MAX_LEN 64
#define RADIO_PACKET_QUEUE_SIZE 8

typedef struct __attribute__((packed))
{
uint8_t len;
struct __attribute__((packed))
{
uint8_t padding : 8;
//uint8_t ack : 1;
} flags;
uint8_t data[RADIO_PACKET_MAX_LEN];
} radio_packet_t;

uint32_t dummy_packet_get(radio_packet_t ** packet);

bool packet_is_empty(radio_packet_t* packet);

#endif
Loading