Skip to content

Commit

Permalink
Unify all Cortex-M targets in picotcp/include/arch
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vincent committed Mar 24, 2015
1 parent 41e4da7 commit 6d9a8c5
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 587 deletions.
85 changes: 15 additions & 70 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-include ../../config.mk
-include ../../tools/kconfig/.config

CC:=$(CROSS_COMPILE)gcc
LD:=$(CROSS_COMPILE)ld
AR:=$(CROSS_COMPILE)ar
Expand Down Expand Up @@ -48,6 +51,7 @@ TAP?=0
IPV6?=1

EXTRA_CFLAGS+=-DPICO_COMPILE_TIME=`date +%s`
EXTRA_CFLAGS+=$(PLATFORM_CFLAGS)

CFLAGS=-I$(PREFIX)/include -Iinclude -Imodules -Wall -Wdeclaration-after-statement -W -Wextra -Wshadow -Wcast-qual -Wwrite-strings -Wmissing-field-initializers -Wunused-variable -Wundef -Wunused-function $(EXTRA_CFLAGS)
# extra flags recommanded by TIOBE TICS framework to score an A on compiler warnings
Expand Down Expand Up @@ -92,22 +96,20 @@ ifneq ($(RTOS),0)
OPTIONS+=-DPICO_SUPPORT_RTOS
endif

ifeq ($(ARCH),stm32f4xx)
CFLAGS+=-mcpu=cortex-m4 \
-mthumb -mlittle-endian -mfpu=fpv4-sp-d16 \
-mfloat-abi=hard -mthumb-interwork -fsingle-precision-constant -DSTM32
ifeq ($(ARCH),cortexm4-hardfloat)
CFLAGS+=-DCORTEX_M4_HARDFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork -fsingle-precision-constant
endif

ifeq ($(ARCH),cortexm4-softfloat)
CFLAGS+=-DCORTEX_M4_SOFTFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfloat-abi=soft -mthumb-interwork
endif

ifeq ($(ARCH),stm32)
CFLAGS+=-mcpu=cortex-m4 \
-mthumb -mlittle-endian -mfpu=fpv4-sp-d16 \
-mfloat-abi=hard -mthumb-interwork -fsingle-precision-constant -DSTM32
ifeq ($(ARCH),cortexm3)
CFLAGS+=DCORTEX_M3 -mcpu=cortex-m3 -mthumb -mlittle-endian -mthumb-interwork
endif

ifeq ($(ARCH),stm32_gc)
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16
CFLAGS_CORTEX_M4 += -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS+= $(CFLAGS_CORTEX_M4) -mlittle-endian -DSTM32_GC
ifeq ($(ARCH),arm9)
CFLAGS+=-DARM9 -mcpu=arm9e -march=armv5te -gdwarf-2 -Wall -marm -mthumb-interwork -fpack-struct
endif

ifeq ($(ARCH),faulty)
Expand All @@ -117,65 +119,12 @@ ifeq ($(ARCH),faulty)
DUMMY_EXTRA+=test/pico_faulty.o
endif

ifeq ($(ARCH),stm32-softfloat)
CFLAGS+=-mcpu=cortex-m3 \
-mthumb -mlittle-endian \
-mfloat-abi=soft -mthumb-interwork \
-DSTM32
endif


ifeq ($(ARCH),stm32f1xx)
CFLAGS+=-mcpu=cortex-m3 \
-mthumb -mlittle-endian \
-mthumb-interwork \
-DSTM32F1
endif


ifeq ($(ARCH),msp430)
CFLAGS+=-DMSP430
endif

ifeq ($(ARCH),esp8266)
CFLAGS += -DESP8266 \
-g \
-Wpointer-arith \
-Wundef \
-Wl,-EL \
-fno-inline-functions \
-nostdlib \
-mlongcalls \
-mtext-section-literals
endif

ifeq ($(ARCH),stellaris)
CFLAGS+=-mthumb -DSTELLARIS
endif

ifeq ($(ARCH),lpc)
CFLAGS+=-fmessage-length=0 -fno-builtin \
-ffunction-sections -fdata-sections -mlittle-endian \
-mcpu=cortex-m3 -mthumb -MMD -MP -DLPC
endif

ifeq ($(ARCH),lpc18xx)
CFLAGS+=-fmessage-length=0 -fno-builtin \
-ffunction-sections -fdata-sections -mlittle-endian \
-mcpu=cortex-m3 -mthumb -MMD -MP -DLPC18XX
endif

ifeq ($(ARCH),lpc17xx)
CFLAGS+=-fmessage-length=0 -fno-builtin \
-ffunction-sections -fdata-sections -mlittle-endian \
-mcpu=cortex-m3 -mthumb -MMD -MP -DLPC17XX
endif

ifeq ($(ARCH),lpc43xx)
CFLAGS+=-fmessage-length=0 -fno-builtin \
-ffunction-sections -fdata-sections -mlittle-endian \
-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-fsingle-precision-constant -mthumb -MMD -MP -DLPC43XX
CFLAGS+=-DESP8266 -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals
endif

ifeq ($(ARCH),pic24)
Expand All @@ -187,10 +136,6 @@ ifeq ($(ARCH),atmega128)
CFLAGS+=-Wall -mmcu=atmega128 -DAVR
endif

ifeq ($(ARCH),str9)
CFLAGS+=-DSTR9 -mcpu=arm9e -march=armv5te -gdwarf-2 -Wall -marm -mthumb-interwork -fpack-struct
endif

ifeq ($(ARCH),none)
CFLAGS+=-DARCHNONE
endif
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions include/arch/pico_cortex_m.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*********************************************************************
PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
See LICENSE and COPYING for usage.
*********************************************************************/
#ifndef _INCLUDE_PICO_CORTEX_M
#define _INCLUDE_PICO_CORTEX_M

#include "pico_generic_gcc.h"

#endif /* PICO_CORTEX_M */

97 changes: 97 additions & 0 deletions include/arch/pico_generic_gcc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*********************************************************************
PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
See LICENSE and COPYING for usage.
*********************************************************************/
#ifndef _INCLUDE_PICO_GCC
#define _INCLUDE_PICO_GCC

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "pico_constants.h"

/* monotonically increasing tick,
* typically incremented every millisecond in a systick interrupt */
extern volatile unsigned int tassTick;

#define dbg(...)

#ifdef PICO_SUPPORT_RTOS
#define PICO_SUPPORT_MUTEX

extern void *pico_mutex_init(void);
extern void pico_mutex_lock(void*);
extern void pico_mutex_unlock(void*);
extern void *pvPortMalloc( size_t xSize );
extern void vPortFree( void *pv );

#define pico_free(x) vPortFree(x)
#define free(x) vPortFree(x)

static inline void *pico_zalloc(size_t size)
{
void *ptr = pvPortMalloc(size);

if(ptr)
memset(ptr, 0u, size);

return ptr;
}

static inline pico_time PICO_TIME_MS()
{
return tassTick;
}

static inline pico_time PICO_TIME()
{
return tassTick / 1000;
}

static inline void PICO_IDLE(void)
{
uint32_t now = PICO_TIME_MS();
while(now == PICO_TIME_MS()) ;
}

#else /* NO RTOS SUPPORT */

#ifdef MEM_MEAS
/* These functions should be implemented elsewhere */
extern void * memmeas_zalloc(size_t size);
extern void memmeas_free(void *);
#define pico_free(x) memmeas_free(x)
#define pico_zalloc(x) memmeas_zalloc(x)
#else
/* Use plain C-lib malloc and free */
#define pico_free(x) free(x)
static inline void *pico_zalloc(size_t size)
{
void *ptr = malloc(size);
if(ptr)
memset(ptr, 0u, size);
return ptr;
}
#endif

static inline pico_time PICO_TIME_MS(void)
{
return tassTick;
}

static inline pico_time PICO_TIME(void)
{
return PICO_TIME_MS() / 1000;
}

static inline void PICO_IDLE(void)
{
unsigned int now = tassTick;
while(now == tassTick) ;
}

#endif /* IFNDEF RTOS */

#endif /* PICO_GCC */

83 changes: 0 additions & 83 deletions include/arch/pico_lpc17xx.h

This file was deleted.

Loading

0 comments on commit 6d9a8c5

Please sign in to comment.