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:
Tue Nov 12 13:31:02 2013 +0000
Revision:
117:b853bfe76990
Parent:
113:f2f9b678d3fe
Child:
118:da0e49d8eb56
merge branches, disabled memory tools and prescaler by default

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 29:1a47b7151851 1 /*********************************************************************
daniele 29:1a47b7151851 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
daniele 29:1a47b7151851 3 See LICENSE and COPYING for usage.
daniele 29:1a47b7151851 4 Do not redistribute without a written permission by the Copyright
daniele 29:1a47b7151851 5 holders.
daniele 29:1a47b7151851 6
daniele 29:1a47b7151851 7 File: pico_mbed.h
daniele 29:1a47b7151851 8 Author: Toon Peters
daniele 29:1a47b7151851 9 *********************************************************************/
daniele 29:1a47b7151851 10
daniele 29:1a47b7151851 11 #ifndef PICO_SUPPORT_MBED
daniele 29:1a47b7151851 12 #define PICO_SUPPORT_MBED
daniele 29:1a47b7151851 13 #include <stdio.h>
daniele 29:1a47b7151851 14
daniele 29:1a47b7151851 15 //#include "mbed.h"
daniele 29:1a47b7151851 16 //#include "serial_api.h"
daniele 29:1a47b7151851 17
tass 117:b853bfe76990 18 //#define TIME_PRESCALE
tass 117:b853bfe76990 19 //#define PICO_MEASURE_STACK
tass 117:b853bfe76990 20 //#define MEMORY_MEASURE
daniele 29:1a47b7151851 21 /*
daniele 29:1a47b7151851 22 Debug needs initialization:
daniele 29:1a47b7151851 23 * void serial_init (serial_t *obj, PinName tx, PinName rx);
daniele 29:1a47b7151851 24 * void serial_baud (serial_t *obj, int baudrate);
daniele 29:1a47b7151851 25 * void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
daniele 29:1a47b7151851 26 */
daniele 29:1a47b7151851 27
daniele 29:1a47b7151851 28 #define dbg(...)
tass 89:49ca05d9a19e 29
tass 89:49ca05d9a19e 30 #ifdef PICO_MEASURE_STACK
tass 89:49ca05d9a19e 31
tass 89:49ca05d9a19e 32 extern int freeStack;
tass 89:49ca05d9a19e 33 #define STACK_TOTAL_WORDS 1000u
tass 89:49ca05d9a19e 34 #define STACK_PATTERN (0xC0CAC01A)
tass 89:49ca05d9a19e 35
tass 89:49ca05d9a19e 36 void stack_fill_pattern(void *ptr);
tass 89:49ca05d9a19e 37 void stack_count_free_words(void *ptr);
tass 89:49ca05d9a19e 38 int stack_get_free_words(void);
tass 89:49ca05d9a19e 39
tass 89:49ca05d9a19e 40 #endif
tass 89:49ca05d9a19e 41
daniele 29:1a47b7151851 42 #ifdef MEMORY_MEASURE // in case, comment out the two defines above me.
daniele 29:1a47b7151851 43 extern uint32_t max_mem;
daniele 29:1a47b7151851 44 extern uint32_t cur_mem;
daniele 29:1a47b7151851 45
daniele 29:1a47b7151851 46 static inline void * pico_zalloc(int x)
daniele 29:1a47b7151851 47 {
daniele 29:1a47b7151851 48 uint32_t *ptr;
daniele 29:1a47b7151851 49 if ((cur_mem + x )> (10 * 1024))
daniele 29:1a47b7151851 50 return NULL;
daniele 29:1a47b7151851 51
daniele 29:1a47b7151851 52 ptr = (uint32_t *)calloc(x + 4, 1);
daniele 29:1a47b7151851 53 *ptr = (uint32_t)x;
daniele 29:1a47b7151851 54 cur_mem += x;
daniele 29:1a47b7151851 55 if (cur_mem > max_mem) {
daniele 29:1a47b7151851 56 max_mem = cur_mem;
tass 89:49ca05d9a19e 57 // printf("max mem: %lu\n", max_mem);
daniele 29:1a47b7151851 58 }
daniele 29:1a47b7151851 59 return (void*)(ptr + 1);
daniele 29:1a47b7151851 60 }
daniele 29:1a47b7151851 61
daniele 29:1a47b7151851 62 static inline void pico_free(void *x)
daniele 29:1a47b7151851 63 {
daniele 29:1a47b7151851 64 uint32_t *ptr = (uint32_t*)(((uint8_t *)x) - 4);
daniele 29:1a47b7151851 65 cur_mem -= *ptr;
daniele 29:1a47b7151851 66 free(ptr);
daniele 29:1a47b7151851 67 }
tass 113:f2f9b678d3fe 68 #else
tass 113:f2f9b678d3fe 69
tass 113:f2f9b678d3fe 70 #define pico_zalloc(x) calloc(x, 1)
tass 113:f2f9b678d3fe 71 #define pico_free(x) free(x)
tass 113:f2f9b678d3fe 72
daniele 29:1a47b7151851 73 #endif
daniele 29:1a47b7151851 74
daniele 29:1a47b7151851 75 #define PICO_SUPPORT_MUTEX
daniele 29:1a47b7151851 76 extern void *pico_mutex_init(void);
daniele 29:1a47b7151851 77 extern void pico_mutex_lock(void*);
daniele 29:1a47b7151851 78 extern void pico_mutex_unlock(void*);
daniele 29:1a47b7151851 79
daniele 29:1a47b7151851 80 extern uint32_t os_time;
daniele 3:b4047e8a0123 81
tass 83:d4e1dcd97346 82 #ifdef TIME_PRESCALE
tass 83:d4e1dcd97346 83 extern int32_t prescale_time;
tass 83:d4e1dcd97346 84 #endif
tass 87:d45bc027b06d 85 extern uint32_t os_time;
tass 87:d45bc027b06d 86
daniele 29:1a47b7151851 87
daniele 29:1a47b7151851 88 static inline unsigned long PICO_TIME(void)
daniele 29:1a47b7151851 89 {
tass 83:d4e1dcd97346 90 #ifdef TIME_PRESCALE
tass 83:d4e1dcd97346 91 return (prescale_time < 0) ? (unsigned long)(os_time / 1000 << (-prescale_time)) : \
tass 83:d4e1dcd97346 92 (unsigned long)(os_time / 1000 >> prescale_time);
tass 83:d4e1dcd97346 93 #else
tass 83:d4e1dcd97346 94 return (unsigned long)(os_time / 1000);
tass 83:d4e1dcd97346 95 #endif
daniele 29:1a47b7151851 96 }
daniele 29:1a47b7151851 97
daniele 29:1a47b7151851 98 static inline unsigned long PICO_TIME_MS(void)
daniele 29:1a47b7151851 99 {
tass 83:d4e1dcd97346 100 #ifdef TIME_PRESCALE
tass 83:d4e1dcd97346 101 return (prescale_time < 0) ? (unsigned long)(os_time << (-prescale_time)) : \
tass 83:d4e1dcd97346 102 (unsigned long)(os_time >> prescale_time);
tass 83:d4e1dcd97346 103 #else
daniele 3:b4047e8a0123 104 return (unsigned long)os_time;
tass 83:d4e1dcd97346 105 #endif
daniele 29:1a47b7151851 106 }
daniele 29:1a47b7151851 107
daniele 29:1a47b7151851 108 static inline void PICO_IDLE(void)
daniele 29:1a47b7151851 109 {
daniele 29:1a47b7151851 110 // TODO needs implementation
daniele 29:1a47b7151851 111 }
daniele 29:1a47b7151851 112 /*
daniele 29:1a47b7151851 113 static inline void PICO_DEBUG(const char * formatter, ... )
daniele 29:1a47b7151851 114 {
daniele 29:1a47b7151851 115 char buffer[256];
daniele 29:1a47b7151851 116 char *ptr;
daniele 29:1a47b7151851 117 va_list args;
daniele 29:1a47b7151851 118 va_start(args, formatter);
daniele 29:1a47b7151851 119 vsnprintf(buffer, 256, formatter, args);
daniele 29:1a47b7151851 120 ptr = buffer;
daniele 29:1a47b7151851 121 while(*ptr != '\0')
daniele 29:1a47b7151851 122 serial_putc(serial_t *obj, (int) (*(ptr++)));
daniele 29:1a47b7151851 123 va_end(args);
daniele 29:1a47b7151851 124 //TODO implement serial_t
daniele 29:1a47b7151851 125 }*/
daniele 29:1a47b7151851 126
daniele 29:1a47b7151851 127 #endif