sort out the length details.
This commit is contained in:
parent
fb922c0ab9
commit
d3f6ef07f2
|
@ -1,22 +1,23 @@
|
||||||
#ifndef PACKET_H
|
#ifndef PACKET_H
|
||||||
#define PACKET_H
|
#define PACKET_H
|
||||||
|
|
||||||
#ifndef MAX_PACKET_SIZE
|
/* does not include 2 byte FCS checksum */
|
||||||
#define MAX_PACKET_SIZE 127
|
#ifndef MAX_PAYLOAD_SIZE
|
||||||
|
#define MAX_PAYLOAD_SIZE 125
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef uint16_t short_addr_t;
|
typedef uint16_t short_addr_t;
|
||||||
|
|
||||||
struct packet {
|
struct packet {
|
||||||
short_addr_t addr;
|
short_addr_t addr;
|
||||||
uint8_t length;
|
uint8_t length; /* does not include FCS checksum */
|
||||||
volatile struct packet * left;
|
volatile struct packet * left;
|
||||||
volatile struct packet * right;
|
volatile struct packet * right;
|
||||||
/* offset into data for first byte of the packet payload */
|
/* offset into data for first byte of the packet payload */
|
||||||
/* On TX this should be 0 */
|
/* On TX this should be 0 */
|
||||||
/* On RX this should be 1 since the maca puts the length as the first byte*/
|
/* On RX this should be 1 since the maca puts the length as the first byte*/
|
||||||
uint8_t offset;
|
uint8_t offset;
|
||||||
uint8_t data[MAX_PACKET_SIZE+1]; /* + 1 since maca returns the length as the first byte */
|
uint8_t data[MAX_PAYLOAD_SIZE+2+1]; /* +2 for FCS; + 1 since maca returns the length as the first byte */
|
||||||
};
|
};
|
||||||
typedef struct packet packet_t;
|
typedef struct packet packet_t;
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,10 @@
|
||||||
#define CLK_PER_BYTE 8
|
#define CLK_PER_BYTE 8
|
||||||
|
|
||||||
#ifndef RECV_SOFTIMEOUT
|
#ifndef RECV_SOFTIMEOUT
|
||||||
#define RECV_SOFTIMEOUT 4*128*CLK_PER_BYTE /* 4 128 byte packets */
|
#define RECV_SOFTIMEOUT (8*128*CLK_PER_BYTE) /* 4 128 byte packets */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MAX_PACKET_SIZE (MAX_PAYLOAD_SIZE + 2) /* packet includes 2 bytes of checksum */
|
||||||
|
|
||||||
#define reg(x) (*(volatile uint32_t *)(x))
|
#define reg(x) (*(volatile uint32_t *)(x))
|
||||||
|
|
||||||
|
@ -345,7 +346,7 @@ void maca_isr(void) {
|
||||||
|
|
||||||
if (data_indication_irq()) {
|
if (data_indication_irq()) {
|
||||||
*MACA_CLRIRQ = (1 << maca_irq_di);
|
*MACA_CLRIRQ = (1 << maca_irq_di);
|
||||||
dma_rx->length = *MACA_GETRXLVL - 2;
|
dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */
|
||||||
// PRINTF("maca data ind %x %d\n\r", dma_rx, dma_rx->length);
|
// PRINTF("maca data ind %x %d\n\r", dma_rx, dma_rx->length);
|
||||||
add_to_rx(dma_rx);
|
add_to_rx(dma_rx);
|
||||||
dma_rx = 0;
|
dma_rx = 0;
|
||||||
|
|
|
@ -35,7 +35,7 @@ void print_packet(volatile packet_t *p) {
|
||||||
for(j=0, k=0; j <= ((p->length)%PER_ROW); j++) {
|
for(j=0, k=0; j <= ((p->length)%PER_ROW); j++) {
|
||||||
printf("\n\r");
|
printf("\n\r");
|
||||||
for(i=0; i < PER_ROW; i++, k++) {
|
for(i=0; i < PER_ROW; i++, k++) {
|
||||||
if(k >= (p->length + 1) ) { /* + 1 since first byte is len+2 */
|
if(k >= p->length ) {
|
||||||
printf("\n\r");
|
printf("\n\r");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue