TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers platform.h Source File

platform.h

Go to the documentation of this file.
00001 /**
00002  * \file platform.h
00003  *
00004  * \brief mbed TLS Platform abstraction layer
00005  *
00006  *  Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
00007  *
00008  *  This file is part of mbed TLS (https://tls.mbed.org)
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License along
00021  *  with this program; if not, write to the Free Software Foundation, Inc.,
00022  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00023  */
00024 #ifndef POLARSSL_PLATFORM_H
00025 #define POLARSSL_PLATFORM_H
00026 
00027 #if !defined(POLARSSL_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include POLARSSL_CONFIG_FILE
00031 #endif
00032 
00033 /* Temporary compatibility hack for to keep MEMORY_C working */
00034 #if defined(POLARSSL_MEMORY_C) && !defined(POLARSSL_PLATFORM_MEMORY)
00035 #define POLARSSL_PLATFORM_MEMORY
00036 #endif
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 /**
00043  * \name SECTION: Module settings
00044  *
00045  * The configuration options you can set for this module are in this section.
00046  * Either change them in config.h or define them on the compiler command line.
00047  * \{
00048  */
00049 
00050 #if !defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS)
00051 #include <stdio.h>
00052 #include <stdlib.h>
00053 #if !defined(POLARSSL_PLATFORM_STD_SNPRINTF)
00054 #define POLARSSL_PLATFORM_STD_SNPRINTF   snprintf /**< Default snprintf to use  */
00055 #endif
00056 #if !defined(POLARSSL_PLATFORM_STD_PRINTF)
00057 #define POLARSSL_PLATFORM_STD_PRINTF   printf /**< Default printf to use  */
00058 #endif
00059 #if !defined(POLARSSL_PLATFORM_STD_FPRINTF)
00060 #define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
00061 #endif
00062 #if !defined(POLARSSL_PLATFORM_STD_MALLOC)
00063 #define POLARSSL_PLATFORM_STD_MALLOC   malloc /**< Default allocator to use */
00064 #endif
00065 #if !defined(POLARSSL_PLATFORM_STD_FREE)
00066 #define POLARSSL_PLATFORM_STD_FREE       free /**< Default free to use */
00067 #endif
00068 #if !defined(POLARSSL_PLATFORM_STD_EXIT)
00069 #define POLARSSL_PLATFORM_STD_EXIT      exit /**< Default free to use */
00070 #endif
00071 #else /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
00072 #if defined(POLARSSL_PLATFORM_STD_MEM_HDR)
00073 #include POLARSSL_PLATFORM_STD_MEM_HDR
00074 #endif
00075 #endif /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
00076 
00077 /* \} name SECTION: Module settings */
00078 
00079 /*
00080  * The function pointers for malloc and free
00081  */
00082 #if defined(POLARSSL_PLATFORM_MEMORY)
00083 #if defined(POLARSSL_PLATFORM_FREE_MACRO) && \
00084     defined(POLARSSL_PLATFORM_MALLOC_MACRO)
00085 #define polarssl_free       POLARSSL_PLATFORM_FREE_MACRO
00086 #define polarssl_malloc     POLARSSL_PLATFORM_MALLOC_MACRO
00087 #else
00088 /* For size_t */
00089 #include <stddef.h>
00090 extern void * (*polarssl_malloc)( size_t len );
00091 extern void (*polarssl_free)( void *ptr );
00092 
00093 /**
00094  * \brief   Set your own memory implementation function pointers
00095  *
00096  * \param malloc_func   the malloc function implementation
00097  * \param free_func     the free function implementation
00098  *
00099  * \return              0 if successful
00100  */
00101 int platform_set_malloc_free( void * (*malloc_func)( size_t ),
00102                               void (*free_func)( void * ) );
00103 #endif /* POLARSSL_PLATFORM_FREE_MACRO && POLARSSL_PLATFORM_MALLOC_MACRO */
00104 #else /* !POLARSSL_PLATFORM_MEMORY */
00105 #define polarssl_free       free
00106 #define polarssl_malloc     malloc
00107 #endif /* POLARSSL_PLATFORM_MEMORY && !POLARSSL_PLATFORM_{FREE,MALLOC}_MACRO */
00108 
00109 /*
00110  * The function pointers for fprintf
00111  */
00112 #if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
00113 /* We need FILE * */
00114 #include <stdio.h>
00115 extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... );
00116 
00117 /**
00118  * \brief   Set your own fprintf function pointer
00119  *
00120  * \param fprintf_func   the fprintf function implementation
00121  *
00122  * \return              0
00123  */
00124 int platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
00125                                                ... ) );
00126 #else
00127 #if defined(POLARSSL_PLATFORM_FPRINTF_MACRO)
00128 #define polarssl_fprintf    POLARSSL_PLATFORM_FPRINTF_MACRO
00129 #else
00130 #define polarssl_fprintf    fprintf
00131 #endif /* POLARSSL_PLATFORM_FPRINTF_MACRO */
00132 #endif /* POLARSSL_PLATFORM_FPRINTF_ALT */
00133 
00134 /*
00135  * The function pointers for printf
00136  */
00137 #if defined(POLARSSL_PLATFORM_PRINTF_ALT)
00138 extern int (*polarssl_printf)( const char *format, ... );
00139 
00140 /**
00141  * \brief   Set your own printf function pointer
00142  *
00143  * \param printf_func   the printf function implementation
00144  *
00145  * \return              0
00146  */
00147 int platform_set_printf( int (*printf_func)( const char *, ... ) );
00148 #else /* !POLARSSL_PLATFORM_PRINTF_ALT */
00149 #if defined(POLARSSL_PLATFORM_PRINTF_MACRO)
00150 #define polarssl_printf     POLARSSL_PLATFORM_PRINTF_MACRO
00151 #else
00152 #define polarssl_printf     printf
00153 #endif /* POLARSSL_PLATFORM_PRINTF_MACRO */
00154 #endif /* POLARSSL_PLATFORM_PRINTF_ALT */
00155 
00156 /*
00157  * The function pointers for snprintf
00158  */
00159 #if defined(POLARSSL_PLATFORM_SNPRINTF_ALT)
00160 extern int (*polarssl_snprintf)( char * s, size_t n, const char * format, ... );
00161 
00162 /**
00163  * \brief   Set your own snprintf function pointer
00164  *
00165  * \param snprintf_func   the snprintf function implementation
00166  *
00167  * \return              0
00168  */
00169 int platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
00170                                                  const char * format, ... ) );
00171 #else /* POLARSSL_PLATFORM_SNPRINTF_ALT */
00172 #if defined(POLARSSL_PLATFORM_SNPRINTF_MACRO)
00173 #define polarssl_snprintf   POLARSSL_PLATFORM_SNPRINTF_MACRO
00174 #else
00175 #define polarssl_snprintf   snprintf
00176 #endif /* POLARSSL_PLATFORM_SNPRINTF_MACRO */
00177 #endif /* POLARSSL_PLATFORM_SNPRINTF_ALT */
00178 
00179 /*
00180  * The function pointers for exit
00181  */
00182 #if defined(POLARSSL_PLATFORM_EXIT_ALT)
00183 extern void (*polarssl_exit)( int status );
00184 
00185 /**
00186  * \brief   Set your own exit function pointer
00187  *
00188  * \param exit_func   the exit function implementation
00189  *
00190  * \return              0
00191  */
00192 int platform_set_exit( void (*exit_func)( int status ) );
00193 #else
00194 #if defined(POLARSSL_PLATFORM_EXIT_MACRO)
00195 #define polarssl_exit   POLARSSL_PLATFORM_EXIT_MACRO
00196 #else
00197 #define polarssl_exit   exit
00198 #endif /* POLARSSL_PLATFORM_EXIT_MACRO */
00199 #endif /* POLARSSL_PLATFORM_EXIT_ALT */
00200 
00201 #ifdef __cplusplus
00202 }
00203 #endif
00204 
00205 #endif /* platform.h */
00206