projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Force telemetry rate to 38400 when ao_force_freq is set
[fw/altos]
/
src
/
drivers
/
ao_packet_master.c
diff --git
a/src/drivers/ao_packet_master.c
b/src/drivers/ao_packet_master.c
index 023c788ba86c4be6c0d8d0efcc548f5e8df973e3..e63771e55dd406569be34d44a858787a7e6856c5 100644
(file)
--- a/
src/drivers/ao_packet_master.c
+++ b/
src/drivers/ao_packet_master.c
@@
-3,7
+3,8
@@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-17,11
+18,16
@@
#include "ao.h"
#include "ao.h"
-static
char
+static
int
ao_packet_getchar(void)
{
int c;
ao_packet_getchar(void)
{
int c;
- while ((c = ao_packet_pollchar()) == AO_READ_AGAIN) {
+
+ /* No need to block interrupts in this function as
+ * all packet variables are only modified from task
+ * context, not an interrupt handler
+ */
+ while ((c = _ao_packet_pollchar()) == AO_READ_AGAIN) {
if (!ao_packet_enable)
break;
if (ao_packet_master_sleeping)
if (!ao_packet_enable)
break;
if (ao_packet_master_sleeping)
@@
-52,6
+58,12
@@
static __xdata uint16_t ao_packet_master_time;
#define AO_PACKET_MASTER_DELAY_LONG AO_MS_TO_TICKS(1000)
#define AO_PACKET_MASTER_DELAY_TIMEOUT AO_MS_TO_TICKS(2000)
#define AO_PACKET_MASTER_DELAY_LONG AO_MS_TO_TICKS(1000)
#define AO_PACKET_MASTER_DELAY_TIMEOUT AO_MS_TO_TICKS(2000)
+#if HAS_RADIO_RATE
+#define AO_PACKET_MASTER_RECV_DELAY AO_MS_TO_TICKS(100) << (ao_config.radio_rate << 1)
+#else
+#define AO_PACKET_MASTER_RECV_DELAY AO_MS_TO_TICKS(100)
+#endif
+
static void
ao_packet_master_busy(void)
{
static void
ao_packet_master_busy(void)
{
@@
-86,9
+98,7
@@
ao_packet_master(void)
if (ao_tx_packet.len)
ao_packet_master_busy();
ao_packet_master_check_busy();
if (ao_tx_packet.len)
ao_packet_master_busy();
ao_packet_master_check_busy();
- ao_alarm(ao_packet_master_delay);
- r = ao_packet_recv();
- ao_clear_alarm();
+ r = ao_packet_recv(AO_PACKET_MASTER_RECV_DELAY);
if (r) {
/* if we can transmit data, do so */
if (ao_packet_tx_used && ao_tx_packet.len == 0)
if (r) {
/* if we can transmit data, do so */
if (ao_packet_tx_used && ao_tx_packet.len == 0)
@@
-96,9
+106,7
@@
ao_packet_master(void)
if (ao_rx_packet.packet.len)
ao_packet_master_busy();
ao_packet_master_sleeping = 1;
if (ao_rx_packet.packet.len)
ao_packet_master_busy();
ao_packet_master_sleeping = 1;
- ao_alarm(ao_packet_master_delay);
- ao_sleep(&ao_packet_master_sleeping);
- ao_clear_alarm();
+ ao_sleep_for(&ao_packet_master_sleeping, ao_packet_master_delay);
ao_packet_master_sleeping = 0;
}
}
ao_packet_master_sleeping = 0;
}
}
@@
-110,6
+118,7
@@
ao_packet_forward(void) __reentrant
{
char c;
ao_packet_enable = 1;
{
char c;
ao_packet_enable = 1;
+ ao_packet_tx_used = 0;
ao_cmd_white();
flush();
ao_cmd_white();
flush();
@@
-140,7
+149,7
@@
ao_packet_forward(void) __reentrant
static void
ao_packet_signal(void)
{
static void
ao_packet_signal(void)
{
- printf ("RSSI: %d\n",
AO_RSSI_FROM_RADIO(ao_packet_last_rssi)
);
+ printf ("RSSI: %d\n",
ao_radio_rssi
);
}
__code struct ao_cmds ao_packet_master_cmds[] = {
}
__code struct ao_cmds ao_packet_master_cmds[] = {