센서보드 RF IRQ 테스트 중
Fork of stm-spirit1-rf-driver by
Revision 48:373e1b7e424f, committed 2017-01-12
- Comitter:
- Wolfgang Betz
- Date:
- Thu Jan 12 08:20:43 2017 +0100
- Parent:
- 47:3a30b960a8c2
- Child:
- 49:d017830c0c67
- Commit message:
- Insert 'MAX_PACKET_LEN' checks when receiving
Changed in this revision
| source/SimpleSpirit1.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/SimpleSpirit1.cpp Thu Dec 22 08:25:22 2016 +0100
+++ b/source/SimpleSpirit1.cpp Thu Jan 12 08:20:43 2017 +0100
@@ -525,10 +525,10 @@
spirit_rx_len = pkt_basic_get_received_pkt_length();
#ifdef DEBUG_IRQ
- debug_if(!(spirit_rx_len <= MAX_PACKET_LEN), "\n\rAssert failed in: %s (%d)\n\r", __func__, __LINE__);
+ debug_if(!(spirit_rx_len <= MAX_PACKET_LEN), "\n\r%s (%d): irq=%x\n\r", __func__, __LINE__, *tmp);
#endif
- for(; _spirit_rx_pos < spirit_rx_len;) {
+ if(spirit_rx_len <= MAX_PACKET_LEN) {
uint8_t to_receive = spirit_rx_len - _spirit_rx_pos;
if(to_receive > 0) {
spi_read_linear_fifo(to_receive, &spirit_rx_buf[_spirit_rx_pos]);
@@ -542,7 +542,7 @@
last_sqi = qi_get_sqi(); //MGR
/* call user callback */
- if(_current_irq_callback) {
+ if((_spirit_rx_pos == spirit_rx_len) && _current_irq_callback) {
_current_irq_callback(RX_DONE);
}
@@ -564,8 +564,14 @@
#endif
} else {
uint8_t fifo_available = linear_fifo_read_num_elements_rx_fifo();
- spi_read_linear_fifo(fifo_available, &spirit_rx_buf[_spirit_rx_pos]);
- _spirit_rx_pos += fifo_available;
+ if((fifo_available + _spirit_rx_pos) <= MAX_PACKET_LEN) {
+ spi_read_linear_fifo(fifo_available, &spirit_rx_buf[_spirit_rx_pos]);
+ _spirit_rx_pos += fifo_available;
+ } else {
+#ifdef DEBUG_IRQ
+ debug("\n\r%s (%d): irq=%x\n\r", __func__, __LINE__, *tmp);
+#endif
+ }
}
}
#endif // !RX_FIFO_THR_WA
