CDC/ECM driver for mbed, based on USBDevice by mbed-official. Uses PicoTCP to access Ethernet USB device. License: GPLv2
Fork of USB_Ethernet by
pico_mbed.h
00001 /********************************************************************* 00002 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved. 00003 See LICENSE and COPYING for usage. 00004 Do not redistribute without a written permission by the Copyright 00005 holders. 00006 00007 File: pico_mbed.h 00008 Author: Toon Peters 00009 *********************************************************************/ 00010 00011 #ifndef PICO_SUPPORT_MBED 00012 #define PICO_SUPPORT_MBED 00013 #include <stdio.h> 00014 00015 //#include "mbed.h" 00016 //#include "serial_api.h" 00017 00018 /* 00019 Debug needs initialization: 00020 * void serial_init (serial_t *obj, PinName tx, PinName rx); 00021 * void serial_baud (serial_t *obj, int baudrate); 00022 * void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits); 00023 */ 00024 00025 #define dbg(...) 00026 #define pico_zalloc(x) calloc(x, 1) 00027 #define pico_free(x) free(x) 00028 00029 #ifdef MEMORY_MEASURE // in case, comment out the two defines above me. 00030 extern uint32_t max_mem; 00031 extern uint32_t cur_mem; 00032 00033 static inline void * pico_zalloc(int x) 00034 { 00035 uint32_t *ptr; 00036 if ((cur_mem + x )> (10 * 1024)) 00037 return NULL; 00038 00039 ptr = (uint32_t *)calloc(x + 4, 1); 00040 *ptr = (uint32_t)x; 00041 cur_mem += x; 00042 if (cur_mem > max_mem) { 00043 max_mem = cur_mem; 00044 printf("max mem: %lu\n", max_mem); 00045 } 00046 return (void*)(ptr + 1); 00047 } 00048 00049 static inline void pico_free(void *x) 00050 { 00051 uint32_t *ptr = (uint32_t*)(((uint8_t *)x) - 4); 00052 cur_mem -= *ptr; 00053 free(ptr); 00054 } 00055 #endif 00056 00057 //#define PICO_SUPPORT_MUTEX 00058 extern void *pico_mutex_init(void); 00059 extern void pico_mutex_lock(void*); 00060 extern void pico_mutex_unlock(void*); 00061 00062 00063 extern uint32_t os_time; 00064 00065 static inline unsigned long PICO_TIME(void) 00066 { 00067 return (unsigned long)os_time / 1000; 00068 } 00069 00070 static inline unsigned long PICO_TIME_MS(void) 00071 { 00072 return (unsigned long)os_time; 00073 } 00074 00075 static inline void PICO_IDLE(void) 00076 { 00077 // TODO needs implementation 00078 } 00079 /* 00080 static inline void PICO_DEBUG(const char * formatter, ... ) 00081 { 00082 char buffer[256]; 00083 char *ptr; 00084 va_list args; 00085 va_start(args, formatter); 00086 vsnprintf(buffer, 256, formatter, args); 00087 ptr = buffer; 00088 while(*ptr != '\0') 00089 serial_putc(serial_t *obj, (int) (*(ptr++))); 00090 va_end(args); 00091 //TODO implement serial_t 00092 }*/ 00093 00094 #endif
Generated on Wed Jul 13 2022 02:20:45 by 1.7.2