mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-31 11:29:33 +00:00
avoid switching mode when tx or rx is active.
based on suggestions from Frederik Hermans and some code from Jesper Karlsson.
This commit is contained in:
parent
13b6fe2cd5
commit
e90149b7b4
@ -62,6 +62,8 @@
|
|||||||
#define PRINTF(...)
|
#define PRINTF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SEND_TIMEOUT 10
|
||||||
|
|
||||||
static int cc1020_calibrate(void);
|
static int cc1020_calibrate(void);
|
||||||
static int cc1020_setupTX(int);
|
static int cc1020_setupTX(int);
|
||||||
static int cc1020_setupRX(int);
|
static int cc1020_setupRX(int);
|
||||||
@ -122,6 +124,7 @@ reset_receiver(void)
|
|||||||
cc1020_off();
|
cc1020_off();
|
||||||
} else {
|
} else {
|
||||||
CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING);
|
CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING);
|
||||||
|
cc1020_set_rx();
|
||||||
ENABLE_RX_IRQ();
|
ENABLE_RX_IRQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,6 +236,15 @@ cc1020_send(const void *buf, unsigned short len)
|
|||||||
int normal_header = HDRSIZE + len;
|
int normal_header = HDRSIZE + len;
|
||||||
int i;
|
int i;
|
||||||
uint16_t rxcrc = 0xFFFF; /* For checksum purposes */
|
uint16_t rxcrc = 0xFFFF; /* For checksum purposes */
|
||||||
|
rtimer_clock_t timeout_time;
|
||||||
|
|
||||||
|
timeout_time = RTIMER_NOW() + RTIMER_SECOND / 1000 * SEND_TIMEOUT;
|
||||||
|
while(cc1020_state & CC1020_RX_RECEIVING) {
|
||||||
|
if(RTIMER_CLOCK_LT(timeout_time, RTIMER_NOW())) {
|
||||||
|
PRINTF("cc1020: transmission blocked by reception in progress\n");
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(cc1020_state == CC1020_OFF) {
|
if(cc1020_state == CC1020_OFF) {
|
||||||
return -2;
|
return -2;
|
||||||
|
Loading…
Reference in New Issue
Block a user