Skip to content

Commit

Permalink
Added support for diab5.6. Corrected build config for mpc5516it
Browse files Browse the repository at this point in the history
  • Loading branch information
mahi committed Jan 3, 2012
1 parent f290a9b commit cf24d91
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
1 change: 0 additions & 1 deletion boards/mpc5516it/build_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ARCH_MCU=mpc5516

# CFG (y/n) macros
CFG=PPC BOOKE E200Z1 MPC55XX MPC5516 BRD_MPC5516IT
CFG+=VLE

# What buildable modules does this board have,
# default or private
Expand Down
59 changes: 40 additions & 19 deletions include/ppc/Cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@
* -------------------------------- Arctic Core ------------------------------*/









#ifndef CPU_H
#define CPU_H

#include "Std_Types.h"
typedef uint32_t imask_t;
#if defined(__DCC__)
#include <diab/ppcasm.h>
#endif

//#if defined(__DCC__)
//#include <diab/ppcasm.h>
//#endif

// Used if we are running a T32 instruction set simulator
#define SIMULATOR() (SIU.MIDR.R==0)
Expand Down Expand Up @@ -144,9 +138,13 @@ typedef uint32_t imask_t;
* Sets a value to a specific SPR register
*/
#if defined(__DCC__)
#define set_spr(spr_nr, val) (__mtspr(spr_nr,val))
asm void set_spr(uint32 spr_nr, uint32 val)
{
%reg val; con spr_nr
mtspr spr_nr, val
}
#else
#define set_spr(spr_nr, val) \
# define set_spr(spr_nr, val) \
asm volatile (" mtspr " STRINGIFY__(spr_nr) ",%[_val]" : : [_val] "r" (val))
#endif
/**
Expand All @@ -156,7 +154,11 @@ typedef uint32_t imask_t;
*/

#if defined(__DCC__)
#define get_spr(spr_nr) (__mfspr(spr_nr))
asm uint32 get_spr(uint32 spr_nr)
{
% con spr_nr
mfspr r3, spr_nr
}
#else
#define get_spr(spr_nr) CC_EXTENSION \
({\
Expand All @@ -171,7 +173,10 @@ typedef uint32_t imask_t;
* @return
*/
#if defined(__DCC__)
#define get_msr() (__mfmsr())
asm volatile unsigned long get_msr()
{
mfmsr r3
}
#else
static inline unsigned long get_msr() {
uint32_t msr;
Expand All @@ -186,9 +191,12 @@ static inline unsigned long get_msr() {
* @param msr
*/
#if defined(__DCC__)
#define set_msr(msr)\
(__mtmsr(msr));\
(__isync());
asm volatile void set_msr(unsigned long msr)
{
% reg msr
mtmsr msr
isync
}
#else
static inline void set_msr(unsigned long msr) {
asm volatile ("mtmsr %0" : : "r" (msr) );
Expand All @@ -201,7 +209,11 @@ static inline void set_msr(unsigned long msr) {

/* Count the number of consecutive zero bits starting at ppc-bit 0 */
#if defined(__DCC__)
#define cntlzw(val) (__cntlzw(val))
asm volatile unsigned int cntlzw(unsigned int val)
{
% reg val
cntlzw r3, val
}
#else
static inline unsigned int cntlzw(unsigned int val)
{
Expand Down Expand Up @@ -230,14 +242,23 @@ static inline unsigned long _Irq_Disable_save(void)
}

/*-----------------------------------------------------------------*/

static inline void _Irq_Disable_restore(unsigned long flags)
{
set_msr(flags);
}

#if 0
#if defined(__DCC__)
#define _Irq_Disable_restore(flags) (__mtmsr(flags))
#define _Irq_Disable_restore(flags) (set_msr(flags))
#else
static inline void _Irq_Disable_restore(unsigned long flags)
{
set_msr(flags);
asm volatile ("mtmsr %0" : : "r" (flags) );
}
#endif
#endif
/*-----------------------------------------------------------------*/
#if defined(__DCC__)
#else
Expand Down
10 changes: 8 additions & 2 deletions system/EcuM/EcuM.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include "EcuM_Internals.h"
#include "EcuM_Cbk.h"
#include "Mcu.h"
#if defined(USE_DET)
#include "Det.h"
#endif
#include "isr.h"
#if defined(USE_NVM)
#include "NvM.h"
Expand All @@ -33,6 +35,10 @@

EcuM_GlobalType internal_data;

#if !defined(USE_DET) && defined(ECUM_DEV_ERROR_DETECT)
#error EcuM configuration error. DET is not enabled when ECUM_DEV_ERROR_DETECT is set
#endif

void EcuM_Init( void )
{
Std_ReturnType status;
Expand Down Expand Up @@ -111,7 +117,7 @@ void EcuM_StartupTwo(void)
// Start timer to wait for NVM job to complete
tickTimerStatus = GetCounterValue(Os_Arc_OsTickCounter , &tickTimerStart);
if (tickTimerStatus != E_OK) {
Det_ReportError(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR);
DET_REPORTERROR(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR);
}
#endif

Expand All @@ -128,7 +134,7 @@ void EcuM_StartupTwo(void)
tickTimer = tickTimerStart; // Save this because the GetElapsedCounterValue() will destroy it.
tickTimerStatus = GetElapsedCounterValue(Os_Arc_OsTickCounter, &tickTimer, &tickTimerElapsed);
if (tickTimerStatus != E_OK) {
Det_ReportError(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR);
DET_REPORTERROR(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR);
}
} while( (readAllResult == NVM_REQ_PENDING) && (tickTimerElapsed < internal_data.config->EcuMNvramReadAllTimeout) );
#endif
Expand Down

0 comments on commit cf24d91

Please sign in to comment.