Free (GPLv2) TCP/IP stack developed by TASS Belgium

Dependents:   lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more

PicoTCP. Copyright (c) 2013 TASS Belgium NV.

Released under the GNU General Public License, version 2.

Different licensing models may exist, at the sole discretion of the Copyright holders.

Official homepage: http://www.picotcp.com

Bug tracker: https://github.com/tass-belgium/picotcp/issues

Development steps:

  • initial integration with mbed RTOS
  • generic mbed Ethernet driver
  • high performance NXP LPC1768 specific Ethernet driver
  • Multi-threading support for mbed RTOS
  • Berkeley sockets and integration with the New Socket API
  • Fork of the apps running on top of the New Socket API
  • Scheduling optimizations
  • Debugging/benchmarking/testing

Demo application (measuring TCP sender performance):

Import programlpc1768-picotcp-demo

A PicoTCP demo app testing the ethernet throughput on the lpc1768 mbed board.

Committer:
tass
Date:
Thu Sep 19 12:38:53 2013 +0000
Revision:
63:97f481e33cb2
Parent:
51:ab4529a384a6
Update from the master branch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 3:b4047e8a0123 1 /*********************************************************************
daniele 3:b4047e8a0123 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
daniele 3:b4047e8a0123 3 See LICENSE and COPYING for usage.
daniele 3:b4047e8a0123 4
daniele 3:b4047e8a0123 5 *********************************************************************/
daniele 3:b4047e8a0123 6
daniele 3:b4047e8a0123 7 #define DECLARE_HEAP(type, orderby) \
daniele 3:b4047e8a0123 8 struct heap_##type { \
tass 51:ab4529a384a6 9 uint32_t size; \
tass 51:ab4529a384a6 10 uint32_t n; \
tass 51:ab4529a384a6 11 type *top; \
daniele 3:b4047e8a0123 12 }; \
daniele 3:b4047e8a0123 13 typedef struct heap_##type heap_##type; \
daniele 3:b4047e8a0123 14 static inline int heap_insert(struct heap_##type *heap, type *el) \
daniele 3:b4047e8a0123 15 { \
daniele 3:b4047e8a0123 16 int i; \
daniele 3:b4047e8a0123 17 type * newTop; \
tass 51:ab4529a384a6 18 if (++heap->n >= heap->size) { \
daniele 3:b4047e8a0123 19 newTop = pico_zalloc((heap->n + 1) * sizeof(type)); \
daniele 3:b4047e8a0123 20 if(!newTop) \
daniele 3:b4047e8a0123 21 return -1; \
daniele 3:b4047e8a0123 22 if (heap->top) {\
daniele 3:b4047e8a0123 23 memcpy(newTop,heap->top,heap->n*sizeof(type)); \
daniele 3:b4047e8a0123 24 pico_free(heap->top); \
daniele 3:b4047e8a0123 25 } \
tass 51:ab4529a384a6 26 heap->top = newTop; \
tass 51:ab4529a384a6 27 heap->size++; \
tass 51:ab4529a384a6 28 } \
tass 51:ab4529a384a6 29 if (heap->n == 1) { \
tass 51:ab4529a384a6 30 memcpy(&heap->top[1], el, sizeof(type)); \
tass 51:ab4529a384a6 31 return 0; \
tass 51:ab4529a384a6 32 } \
tass 51:ab4529a384a6 33 for (i = heap->n; ((i > 1) && (heap->top[i / 2].orderby > el->orderby)); i /= 2) { \
tass 51:ab4529a384a6 34 memcpy(&heap->top[i], &heap->top[i / 2], sizeof(type)); \
tass 51:ab4529a384a6 35 } \
tass 51:ab4529a384a6 36 memcpy(&heap->top[i], el, sizeof(type)); \
tass 51:ab4529a384a6 37 return 0; \
daniele 3:b4047e8a0123 38 } \
daniele 3:b4047e8a0123 39 static inline int heap_peek(struct heap_##type *heap, type *first) \
daniele 3:b4047e8a0123 40 { \
tass 51:ab4529a384a6 41 type *last; \
tass 63:97f481e33cb2 42 int i, child; \
tass 51:ab4529a384a6 43 if(heap->n == 0) { \
tass 51:ab4529a384a6 44 return -1; \
tass 51:ab4529a384a6 45 } \
tass 51:ab4529a384a6 46 memcpy(first, &heap->top[1], sizeof(type)); \
tass 51:ab4529a384a6 47 last = &heap->top[heap->n--]; \
tass 51:ab4529a384a6 48 for(i = 1; (i * 2) <= heap->n; i = child) { \
tass 51:ab4529a384a6 49 child = 2 * i; \
tass 51:ab4529a384a6 50 if ((child != heap->n) && \
tass 51:ab4529a384a6 51 (heap->top[child + 1]).orderby \
tass 51:ab4529a384a6 52 < (heap->top[child]).orderby) \
tass 51:ab4529a384a6 53 child++; \
tass 51:ab4529a384a6 54 if (last->orderby > \
tass 51:ab4529a384a6 55 heap->top[child].orderby) \
tass 51:ab4529a384a6 56 memcpy(&heap->top[i], &heap->top[child],\
tass 51:ab4529a384a6 57 sizeof(type)); \
tass 51:ab4529a384a6 58 else \
tass 51:ab4529a384a6 59 break; \
tass 51:ab4529a384a6 60 } \
tass 51:ab4529a384a6 61 memcpy(&heap->top[i], last, sizeof(type)); \
tass 51:ab4529a384a6 62 return 0; \
daniele 3:b4047e8a0123 63 } \
daniele 3:b4047e8a0123 64 static inline type *heap_first(heap_##type *heap) \
daniele 3:b4047e8a0123 65 { \
tass 51:ab4529a384a6 66 if (heap->n == 0) \
tass 51:ab4529a384a6 67 return NULL; \
daniele 3:b4047e8a0123 68 return &heap->top[1]; \
daniele 3:b4047e8a0123 69 } \
daniele 3:b4047e8a0123 70 static inline heap_##type *heap_init(void) \
daniele 3:b4047e8a0123 71 { \
daniele 3:b4047e8a0123 72 heap_##type *p = (heap_##type *)pico_zalloc(sizeof(heap_##type)); \
tass 51:ab4529a384a6 73 return p; \
daniele 3:b4047e8a0123 74 } \
daniele 3:b4047e8a0123 75 static inline void heap_destroy(heap_##type *h) \
daniele 3:b4047e8a0123 76 { \
daniele 3:b4047e8a0123 77 pico_free(h->top); \
tass 51:ab4529a384a6 78 pico_free(h); \
daniele 3:b4047e8a0123 79 } \
daniele 3:b4047e8a0123 80
daniele 3:b4047e8a0123 81