Skip to content

Commit f4b93e4

Browse files
committed
Merge pull request #26 from ps2/dev
Version 0.7
2 parents 02f7164 + 83d6b0b commit f4b93e4

File tree

17 files changed

+98
-18
lines changed

17 files changed

+98
-18
lines changed

Makefile.srfstick

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
SERIAL_TYPE := usb_ep0
2+
SERIAL_PARAMS := -DSRF_STICK
3+
4+
BOARD_TYPE := SRF_STICK
5+
BOARD_PARAMS := -DSRF_STICK
6+
7+
TARGET_DEVICE := CC1111
8+
9+
10+
SRC = \
11+
hal.c \
12+
usb.c \
13+
usb_descriptors.c
14+
15+
ADB=$(SRC:.c=.adb)
16+
ASM=$(SRC:.c=.asm)
17+
LNK=$(SRC:.c=.lnk)
18+
LST=$(SRC:.c=.lst)
19+
REL=$(SRC:.c=.rel)
20+
RST=$(SRC:.c=.rst)
21+
SYM=$(SRC:.c=.sym)
22+
23+
PCDB=$(PROGS:.hex=.cdb)
24+
PLNK=$(PROGS:.hex=.lnk)
25+
PMAP=$(PROGS:.hex=.map)
26+
PMEM=$(PROGS:.hex=.mem)
27+
PAOM=$(PROGS:.hex=)
28+
include common.mk
29+
30+
hal.rel: ${SERIAL_TYPE}/hal.c
31+
$(CC) $(CFLAGS) -o output/${TARGET_BUILD}/$@ -c $<
32+
33+
usb_descriptors.rel: ${SERIAL_TYPE}/usb_descriptors.c
34+
$(CC) $(CFLAGS) -o output/${TARGET_BUILD}/$@ -c $<
35+
usb.rel: ${SERIAL_TYPE}/usb.c
36+
$(CC) $(CFLAGS) -o output/${TARGET_BUILD}/$@ -c $<

commands.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ CommandHandler handlers[] = {
2222

2323
void cmd_get_packet() {
2424
uint8_t channel;
25-
uint16_t timeout_ms;
25+
uint32_t timeout_ms;
2626
uint8_t result;
2727
channel = serial_rx_byte();
28-
timeout_ms = serial_rx_word();
28+
timeout_ms = serial_rx_long();
2929
result = get_packet_and_write_to_serial(channel, timeout_ms);
3030
if (result != 0) {
3131
serial_tx_byte(result);
@@ -38,7 +38,7 @@ void cmd_get_state() {
3838
}
3939

4040
void cmd_get_version() {
41-
serial_tx_str("subg_rfspy 0.6");
41+
serial_tx_str("subg_rfspy 0.7");
4242
}
4343

4444
void do_cmd(uint8_t cmd) {
@@ -74,15 +74,15 @@ void cmd_send_and_listen() {
7474
uint8_t repeat_count;
7575
uint8_t delay_ms;
7676
uint8_t listen_channel;
77-
uint16_t timeout_ms;
77+
uint32_t timeout_ms;
7878
uint8_t retry_count;
7979
uint8_t result;
8080

8181
send_channel = serial_rx_byte();
8282
repeat_count = serial_rx_byte();
8383
delay_ms = serial_rx_byte();
8484
listen_channel = serial_rx_byte();
85-
timeout_ms = serial_rx_word();
85+
timeout_ms = serial_rx_long();
8686
retry_count = serial_rx_byte();
8787

8888
send_packet_from_serial(send_channel, repeat_count, delay_ms);

hardware.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
#define GREEN_LED P1_7
3333
#define BLUE_LED P1_7
3434
#define SYSTEM_CLOCK_MHZ 24
35+
#elif SRF_STICK
36+
#define HARDWARE_FLOW_CONTROL_CONFIG 0x02; /* 8N1, NO flow control, high stop bit */
37+
#define HARDWARE_LED_INIT P1DIR |= BIT7;
38+
#define GREEN_LED P1_7
39+
#define BLUE_LED P1_6
40+
#define SYSTEM_CLOCK_MHZ 24
3541
#endif
3642

3743

main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void rx1_isr(void) __interrupt URX1_VECTOR;
1717
void tx1_isr(void) __interrupt UTX1_VECTOR;
1818
#endif
1919

20-
#ifdef TI_DONGLE
20+
#if TI_DONGLE || SRF_STICK
2121
void usb_isr() __interrupt 6;
2222
#endif
2323
int main(void)
@@ -49,4 +49,3 @@ int main(void)
4949
get_command();
5050
}
5151
}
52-

radio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void resend_from_tx_buf(uint8_t channel) {
204204
while(MARCSTATE!=MARC_STATE_IDLE);
205205
}
206206

207-
uint8_t get_packet_and_write_to_serial(uint8_t channel, uint16_t timeout_ms) {
207+
uint8_t get_packet_and_write_to_serial(uint8_t channel, uint32_t timeout_ms) {
208208

209209
uint8_t read_idx = 0;
210210
uint8_t d_byte = 0;

radio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void configure_radio();
77
// 0 = timed out
88
// 1 = got packet
99
// 2 = rx interrupted by serial
10-
uint8_t get_packet_and_write_to_serial(uint8_t channel, uint16_t timeout_ms);
10+
uint8_t get_packet_and_write_to_serial(uint8_t channel, uint32_t timeout_ms);
1111

1212
void send_packet_from_serial(uint8_t channel, uint8_t repeat_count, uint8_t delay_ms);
1313

spi1_alt2/serial.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ volatile uint8_t output_size = 0;
1616
volatile uint8_t output_head_idx = 0;
1717
volatile uint8_t output_tail_idx = 0;
1818

19+
volatile uint8_t ready_to_send = 0;
20+
1921
volatile uint8_t serial_data_available;
2022

2123
#define SPI_MODE_WAIT 0
2224
#define SPI_MODE_SIZE 1
2325
#define SPI_MODE_XFER 2
2426
volatile uint8_t spi_mode;
2527

26-
volatile uint8_t master_send_size;
27-
volatile uint8_t slave_send_size;
28+
volatile uint8_t master_send_size = 0;
29+
volatile uint8_t slave_send_size = 0;
2830

2931

3032
/***************************************************************************
@@ -96,7 +98,12 @@ void rx1_isr(void) __interrupt URX1_VECTOR {
9698
value = U1DBUF;
9799

98100
if (spi_mode == SPI_MODE_WAIT && value == 0x99) {
99-
slave_send_size = output_size;
101+
if (ready_to_send) {
102+
slave_send_size = output_size;
103+
ready_to_send = 0;
104+
} else {
105+
slave_send_size = 0;
106+
}
100107
spi_mode = SPI_MODE_SIZE;
101108
U1DBUF = slave_send_size;
102109
return;
@@ -172,6 +179,10 @@ uint16_t serial_rx_word() {
172179
return (serial_rx_byte() << 8) + serial_rx_byte();
173180
}
174181

182+
uint32_t serial_rx_long() {
183+
return ((uint32_t)serial_rx_word() << 16) + serial_rx_word();
184+
}
185+
175186
void serial_tx_byte(uint8_t tx_byte) {
176187
if (output_size >= SPI_BUF_LEN) {
177188
// drop oldest byte
@@ -182,6 +193,9 @@ void serial_tx_byte(uint8_t tx_byte) {
182193
}
183194
}
184195
spi_output_buf[output_head_idx] = tx_byte;
196+
if (tx_byte == 0) {
197+
ready_to_send = 1;
198+
}
185199
output_head_idx++;
186200
if (output_head_idx >= SPI_BUF_LEN) {
187201
output_head_idx = 0;

spi1_alt2/serial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ void configure_serial();
99
void serial_tx_byte(uint8_t);
1010
void serial_tx_str(const char *str);
1111
uint8_t serial_rx_byte();
12-
uint16_t serial_rx_word();
12+
uint32_t serial_rx_long();
1313

1414
#endif

timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdint.h>
33
#include "hardware.h"
44

5-
volatile uint16_t timerCounter = 0;
5+
volatile uint32_t timerCounter = 0;
66

77
void init_timer() {
88
union {

timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef TIMER_H
22
#define TIMER_H
33

4-
volatile extern uint16_t timerCounter;
4+
volatile extern uint32_t timerCounter;
55

66
void init_timer();
77
void reset_timer();

0 commit comments

Comments
 (0)