\r
\r
Can_ReturnType Can_SetControllerMode( uint8 controller, Can_StateTransitionType transition ) {\r
+ imask_t state;
CAN_HW_t *canHw;\r
Can_ReturnType rv = CAN_OK;\r
VALIDATE( (controller < GET_CONTROLLER_CNT()), 0x3, CAN_E_PARAM_CONTROLLER );\r
{\r
case CAN_T_START:\r
canUnit->state = CANIF_CS_STARTED;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (canUnit->lock_cnt == 0){ // REQ CAN196\r
Can_EnableControllerInterrupts(controller);
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);
break;\r
case CAN_T_WAKEUP:
VALIDATE(canUnit->state == CANIF_CS_SLEEP, 0x3, CAN_E_TRANSITION);
\r
void Can_DisableControllerInterrupts( uint8 controller )\r
{\r
+ imask_t state;
Can_UnitType *canUnit;\r
CAN_HW_t *canHw;\r
\r
\r
VALIDATE_NO_RV( (canUnit->state!=CANIF_CS_UNINIT), 0x4, CAN_E_UNINIT );\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);
if(canUnit->lock_cnt > 0 )\r
{\r
// Interrupts already disabled\r
canUnit->lock_cnt++;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);
return;\r
}\r
canUnit->lock_cnt++;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);
\r
/* Don't try to be intelligent, turn everything off */\r
canHw = GetController(controller);\r
CAN_ITConfig(canHw, CAN_IT_FMP0 | CAN_IT_BOF | CAN_IT_ERR | CAN_IT_WKU, DISABLE);
}\r
\r
-void Can_EnableControllerInterrupts( uint8 controller ) {\r
+void Can_EnableControllerInterrupts( uint8 controller ) {
+ imask_t state;\r
Can_UnitType *canUnit;\r
CAN_HW_t *canHw;\r
const Can_ControllerConfigType *canHwConfig;\r
\r
VALIDATE_NO_RV( (canUnit->state!=CANIF_CS_UNINIT), 0x5, CAN_E_UNINIT );\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);
if( canUnit->lock_cnt > 1 )\r
{\r
// IRQ should still be disabled so just decrement counter\r
canUnit->lock_cnt--;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);
return;\r
} else if (canUnit->lock_cnt == 1)\r
{\r
canUnit->lock_cnt = 0;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);
\r
canHw = GetController(controller);\r
\r
const Can_HardwareObjectType *hohObj;\r
const Can_ControllerConfigType *canHwConfig;
uint32 controller;\r
- uint32 oldMsr;\r
+ imask_t state;\r
VALIDATE( (Can_Global.initRun == CAN_READY), 0x6, CAN_E_UNINIT );\r
VALIDATE( (pduInfo != NULL), 0x6, CAN_E_PARAM_POINTER );\r
Can_UnitType *canUnit = GET_PRIVATE_DATA(controller);\r
\r
canHw = GetController(controller);\r
- oldMsr = McuE_EnterCriticalSection();\r
+ Irq_Save(state);
CanTxMsg TxMessage;
} else {\r
rv = CAN_BUSY;\r
}\r
- McuE_ExitCriticalSection(oldMsr);\r
+ Irq_Restore(state);
\r
return rv;\r
}\r
return f_sys;\r
}\r
\r
-imask_t McuE_EnterCriticalSection()\r
-{\r
- uint32_t val;\r
- Irq_Save(val);\r
- return val;\r
-}\r
-\r
-void McuE_ExitCriticalSection(uint32_t old_state)\r
-{\r
- Irq_Restore(old_state);\r
-}\r
-\r
/**\r
* Get the peripheral clock in Hz for a specific device\r
*/\r
{\r
\r
}\r
-\r
-void McuE_EnableInterrupts(void)\r
-{\r
- Irq_Enable();\r
-}\r
-\r
-void McuE_DisableInterrupts(void)\r
-{\r
- Irq_Disable();\r
-}\r
bl Os_Isr_cm3\r
IRQ_ENABLE()\r
\r
-/* bl Irq_Entry */\r
mov sp, r6 // pop from returned stack\r
\r
/* Do a normal exception return */\r
#define ICSR_VECTACTIVE 0x1ff
-/**
- * Get Active ISR number field.
- * You can subtract 16 from the VECTACTIVE field to index into the Interrupt
- * Clear/Set Enable, Interrupt Clear Pending/SetPending and Interrupt Priority
- * Registers. INTISR[0] has vector number 16.
- *
- */
-#if 0
-static uint32_t NVIC_GetActiveVector( void) {
- return (SCB->ICSR & ICSR_VECTACTIVE);
-}
-#endif
-
-
-#if 0
-/**
- *
- * @param stack_p Ptr to the current stack.
- *
- * The stack holds C, NVGPR, VGPR and the EXC frame.
- *
- */
-void *Irq_Entry( void *stack_p ){
- uint32_t vector = 0;
-
- Irq_Disable();
-
- /* 0. Set the default handler here....
- * 1. Grab the vector from the interrupt controller
- * INT_CTRL_ST[VECTACTIVE]
- * 2. Irq_VectorTable[vector] is odd -> ISR1
- * Irq_VectorTable[vector] is even-> ISR2
- */
-
-
- vector = NVIC_GetActiveVector();
-
- Os_Isr_cm3((void *)Irq_VectorTable[vector]);
- Irq_Enable();
-
- return stack_p;
-}
-#endif
-
/**
* NVIC prio have priority 0-31, 0-highest priority.
uint8 MsgNr;\r
uint32 ErrCounter;\r
uint32 Eob;\r
+ imask_t state;\r
\r
/* DET Error Check */\r
#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
}\r
#endif \r
\r
- imask_t i_state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
\r
// TODO This should be used instead of other variables in the Can_Lcfg file.\r
CurConfig = Config;\r
ModuleState = CAN_READY;\r
#endif\r
\r
- McuE_ExitCriticalSection(i_state);\r
+ Irq_Restore(state);\r
\r
}\r
\r
{\r
uint8 MsgNr;\r
uint32 ErrCounter;\r
+ imask_t state;\r
\r
#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
if(Config == NULL)\r
}\r
#endif \r
\r
- imask_t i_state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
\r
ErrCounter = CAN_TIMEOUT_DURATION;\r
\r
/* Clear CCE Bit */\r
CanRegs[Controller]->CTL &= ~0x00000040;\r
\r
- McuE_ExitCriticalSection(i_state);\r
+ Irq_Restore(state);\r
}\r
\r
\r
Can_PduType *CurPduArrayPtr;\r
uint8 *CurCancelRqstPtr;\r
uint8 *CurTxRqstPtr;\r
+ imask_t state;\r
\r
CurSduPtr = PduInfo->sdu;\r
\r
DCAN_WAIT_UNTIL_NOT_BUSY(ControllerId, IfRegId);\r
\r
// We cannot allow an interrupt or other task to play with the COM, MC and ARB registers here.\r
- imask_t i_state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
\r
\r
/* Set NewDat, TxIE (dep on ControllerConfig), TxRqst, EoB and DLC */\r
\r
IfRegId ^= 1;\r
\r
- McuE_ExitCriticalSection(i_state);\r
+ Irq_Restore(state);\r
return CAN_OK;\r
}\r
\r
return f_sys;\r
}\r
\r
-imask_t McuE_EnterCriticalSection()\r
-{\r
- imask_t state;\r
- Irq_Save(state);\r
- return state;\r
-}\r
-\r
-void McuE_ExitCriticalSection(uint32_t old_state)\r
-{\r
- Irq_Restore(old_state);\r
-}\r
-\r
/**\r
* Get the peripheral clock in Hz for a specific device\r
*/\r
\r
-#include "McuExtensions.h"\r
-\r
-imask_t McuE_EnterCriticalSection(void) {\r
- return 0;\r
-}\r
-\r
-void McuE_ExitCriticalSection(imask_t old_state) {\r
- (void)old_state; // Nothing to be done. This is just to avoid PC-Lint warning.\r
-}\r
\r
\r
Can_ReturnType Can_SetControllerMode( uint8 controller, Can_StateTransitionType transition ) {\r
+ imask_t state;\r
CAN_HW_t *canHw;\r
Can_ReturnType rv = CAN_OK;\r
VALIDATE( (controller < GET_CONTROLLER_CNT()), 0x3, CAN_E_PARAM_CONTROLLER );\r
{\r
case CAN_T_START:\r
canUnit->state = CANIF_CS_STARTED;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (canUnit->lock_cnt == 0){ // REQ CAN196\r
Can_EnableControllerInterrupts(controller);\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
break;\r
case CAN_T_WAKEUP:\r
VALIDATE(canUnit->state == CANIF_CS_SLEEP, 0x3, CAN_E_TRANSITION);\r
\r
void Can_DisableControllerInterrupts( uint8 controller )\r
{\r
+ imask_t state;\r
Can_UnitType *canUnit;\r
CAN_HW_t *canHw;\r
\r
\r
VALIDATE_NO_RV( (canUnit->state!=CANIF_CS_UNINIT), 0x4, CAN_E_UNINIT );\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if(canUnit->lock_cnt > 0 )\r
{\r
// Interrupts already disabled\r
canUnit->lock_cnt++;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return;\r
}\r
canUnit->lock_cnt++;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
\r
/* Don't try to be intelligent, turn everything off */\r
canHw = GetController(controller);\r
}\r
\r
void Can_EnableControllerInterrupts( uint8 controller ) {\r
+ imask_t state;\r
Can_UnitType *canUnit;\r
CAN_HW_t *canHw;\r
const Can_ControllerConfigType *canHwConfig;\r
\r
VALIDATE_NO_RV( (canUnit->state!=CANIF_CS_UNINIT), 0x5, CAN_E_UNINIT );\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if( canUnit->lock_cnt > 1 )\r
{\r
// IRQ should still be disabled so just decrement counter\r
canUnit->lock_cnt--;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return;\r
} else if (canUnit->lock_cnt == 1)\r
{\r
canUnit->lock_cnt = 0;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
\r
canHw = GetController(controller);\r
\r
const Can_HardwareObjectType *hohObj;\r
const Can_ControllerConfigType *canHwConfig;\r
uint32 controller;\r
- uint32 oldMsr;\r
+ imask_t state;\r
IdrType idr;\r
\r
VALIDATE( (Can_Global.initRun == CAN_READY), 0x6, CAN_E_UNINIT );\r
Can_UnitType *canUnit = GET_PRIVATE_DATA(controller);\r
\r
canHw = GetController(controller);\r
- oldMsr = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
\r
// check for any free box\r
if((canHw->TFLG & BM_TX0) == BM_TX0) {\r
} else {\r
rv = CAN_BUSY;\r
}\r
- McuE_ExitCriticalSection(oldMsr);\r
+ Irq_Restore(state);\r
\r
return rv;\r
}\r
return f_sys;\r
}\r
\r
-imask_t McuE_EnterCriticalSection()\r
-{\r
-#if 0\r
- uint32_t msr = get_msr();\r
- Irq_Disable();\r
- return msr;\r
-#endif\r
- return 0;\r
-}\r
-\r
-void McuE_ExitCriticalSection(uint32_t old_state)\r
-{\r
-#if 0\r
- set_msr(old_state);\r
-#endif\r
-}\r
-\r
-\r
-\r
-\r
/**\r
* Function to setup the internal flash for optimal performance\r
*/\r
\r
Can_ReturnType Can_SetControllerMode( uint8 controller, Can_StateTransitionType transition ) {\r
flexcan_t *canHw;\r
+ imask_t state;\r
Can_ReturnType rv = CAN_OK;\r
VALIDATE( (controller < GET_CONTROLLER_CNT()), 0x3, CAN_E_PARAM_CONTROLLER );\r
\r
canHw->MCR.B.FRZ = 0;\r
canHw->MCR.B.HALT = 0;\r
canUnit->state = CANIF_CS_STARTED;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (canUnit->lock_cnt == 0) // REQ CAN196\r
{\r
Can_EnableControllerInterrupts(controller);\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
break;\r
case CAN_T_WAKEUP: //CAN267\r
case CAN_T_SLEEP: //CAN258, CAN290\r
{\r
Can_UnitType *canUnit;\r
flexcan_t *canHw;\r
+ imask_t state;\r
\r
VALIDATE_NO_RV( (controller < GET_CONTROLLER_CNT()), 0x4, CAN_E_PARAM_CONTROLLER );\r
\r
\r
VALIDATE_NO_RV( (canUnit->state!=CANIF_CS_UNINIT), 0x4, CAN_E_UNINIT );\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if(canUnit->lock_cnt > 0 )\r
{\r
// Interrupts already disabled\r
canUnit->lock_cnt++;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return;\r
}\r
canUnit->lock_cnt++;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
\r
/* Don't try to be intelligent, turn everything off */\r
canHw = GET_CONTROLLER(controller);\r
void Can_EnableControllerInterrupts( uint8 controller ) {\r
Can_UnitType *canUnit;\r
flexcan_t *canHw;\r
+ imask_t state;\r
const Can_ControllerConfigType *canHwConfig;\r
VALIDATE_NO_RV( (controller < GET_CONTROLLER_CNT()), 0x5, CAN_E_PARAM_CONTROLLER );\r
\r
\r
VALIDATE_NO_RV( (canUnit->state!=CANIF_CS_UNINIT), 0x5, CAN_E_UNINIT );\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if( canUnit->lock_cnt > 1 )\r
{\r
// IRQ should still be disabled so just decrement counter\r
canUnit->lock_cnt--;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return;\r
} else if (canUnit->lock_cnt == 1)\r
{\r
canUnit->lock_cnt = 0;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
\r
canHw = GET_CONTROLLER(controller);\r
\r
flexcan_t *canHw;\r
const Can_HardwareObjectType *hohObj;\r
uint32 controller;\r
- uint32 oldMsr;\r
+ imask_t state;\r
\r
VALIDATE( (Can_Global.initRun == CAN_READY), 0x6, CAN_E_UNINIT );\r
VALIDATE( (pduInfo != NULL), 0x6, CAN_E_PARAM_POINTER );\r
Can_UnitType *canUnit = GET_PRIVATE_DATA(controller);\r
\r
canHw = GET_CONTROLLER(controller);\r
- oldMsr = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
iflag = canHw->IFRL.R & canUnit->Can_Arc_TxMbMask;\r
\r
// check for any free box\r
} else {\r
rv = CAN_BUSY;\r
}\r
- McuE_ExitCriticalSection(oldMsr);\r
+ Irq_Restore(state);\r
\r
return rv;\r
}\r
\r
Std_ReturnType Lin_SendHeader( uint8 Channel, Lin_PduType* PduInfoPtr )\r
{\r
- LinSRtype tmp;\r
- LinLTRType tmpLtr;\r
+ LinSRtype tmp;\r
+ LinLTRType tmpLtr;\r
volatile struct ESCI_tag * esciHw = ESCI(Channel);\r
+ imask_t state;\r
\r
// LIN021\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if(LinChannelStatus[Channel] == LIN_TX_BUSY || LinChannelStatus[Channel] == LIN_TX_ERROR ||\r
LinChannelStatus[Channel] == LIN_RX_BUSY || LinChannelStatus[Channel] == LIN_RX_ERROR){\r
LinChannelStatus[Channel]=LIN_CH_OPERATIONAL;\r
// Clear flags\r
esciHw->SR.R=0xffffffff;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
\r
\r
VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_SEND_HEADER_SERVICE_ID, LIN_E_UNINIT, E_NOT_OK);\r
\r
Lin_StatusType Lin_GetStatus( uint8 Channel, uint8** Lin_SduPtr )\r
{\r
+ imask_t state;\r
VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_GETSTATUS_SERVICE_ID, LIN_E_UNINIT, E_NOT_OK);\r
VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_UNINIT), LIN_GETSTATUS_SERVICE_ID, LIN_E_CHANNEL_UNINIT, E_NOT_OK);\r
VALIDATE_W_RV( (Channel < LIN_CONTROLLER_CNT), LIN_GETSTATUS_SERVICE_ID, LIN_E_INVALID_CHANNEL, E_NOT_OK);\r
VALIDATE_W_RV( (Lin_SduPtr!=NULL), LIN_GETSTATUS_SERVICE_ID, LIN_E_INVALID_POINTER, E_NOT_OK);\r
\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
Lin_StatusType res = LinChannelStatus[Channel];\r
// We can only check for valid sdu ptr when LIN_RX_OK\r
if(LinChannelStatus[Channel] == LIN_RX_OK || LinChannelStatus[Channel] == LIN_RX_ERROR){\r
} else if(LinChannelStatus[Channel] == LIN_TX_OK || LinChannelStatus[Channel] == LIN_TX_ERROR){\r
LinChannelStatus[Channel]=LIN_CH_OPERATIONAL;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return res;\r
}\r
\r
return f_sys;\r
}\r
\r
-imask_t McuE_EnterCriticalSection()\r
-{\r
- uint32_t msr = get_msr();\r
- Irq_Disable();\r
- return msr;\r
-}\r
-\r
-void McuE_ExitCriticalSection(uint32_t old_state)\r
-{\r
- set_msr(old_state);\r
-}\r
\r
/**\r
* Get the peripheral clock in Hz for a specific device\r
#endif\r
}\r
\r
-void McuE_EnableInterrupts(void)\r
-{\r
- Irq_Enable();\r
-}\r
-\r
-void McuE_DisableInterrupts(void)\r
-{\r
- Irq_Disable();\r
-}\r
VALIDATE_PARAM_PIN(pin, PORT_SET_PIN_DIRECTION_ID);\r
unsigned long state;\r
\r
+ Irq_Save(state); // Lock interrupts\r
if (direction==PORT_PIN_IN)\r
{\r
- state = _Irq_Disable_save(); // Lock interrupts\r
SIU.PCR[pin].B.IBE = 1;\r
SIU.PCR[pin].B.OBE = 0;\r
- _Irq_Disable_restore(state); // Restore interrupts\r
}\r
else\r
{\r
- state = _Irq_Disable_save(); // Lock interrupts\r
SIU.PCR[pin].B.IBE = 0;\r
SIU.PCR[pin].B.OBE = 1;\r
- _Irq_Disable_restore(state); // Restore interrupts\r
}\r
+ Irq_Restore(state); // Restore interrupts\r
return;\r
}\r
#endif\r
unsigned long state;\r
for (i=0; i < sizeof(SIU.PCR)/sizeof(SIU.PCR[0]); i++)\r
{\r
- state = _Irq_Disable_save(); // Lock interrupts\r
+ Irq_Save(state); // Lock interrupts\r
*pcrPtr = (*pcrPtr & ~bitMask) | (*padCfgPtr & bitMask);\r
- _Irq_Disable_restore(state); // Restore interrups\r
+ Irq_Restore(state); // Restore interrupts\r
pcrPtr++;\r
padCfgPtr++;\r
if(98 == i)\r
/* This function services the internal Watchdog timer */\r
void Wdg_Trigger (void)\r
{\r
- uint32 tmp;\r
+ imask_t state;\r
\r
- tmp = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
\r
// According to MPC55xx manual:\r
// To prevent the watchdog timer from interrupting or resetting\r
MCM.SWTSR.R = 0xAA;\r
#endif\r
\r
- McuE_ExitCriticalSection(tmp);\r
+ Irq_Restore(state);\r
}\r
\r
# Needed by us\r
MOD_USE=\r
-\r
-# Stubs\r
-obj-y += McuExtensionsStub.o
\ No newline at end of file
\r
void Sleep(uint32_t nofTicks, TaskType TaskID, EventMaskType Mask )\r
{\r
- uint32 pval = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
if(nofTicks == 0){\r
nofTicks=1;\r
}\r
/* Error */\r
ErrorHook(E_OS_LIMIT);\r
}\r
- McuE_ExitCriticalSection(pval);\r
+ Irq_Restore(state);\r
}\r
\r
\r
#include "debug.h"\r
#include "PduR.h"\r
#include "Det.h"\r
-#include "McuExtensions.h"\r
\r
\r
uint8 Com_SendSignal(Com_SignalIdType SignalId, const void *SignalDataPtr) {\r
// Is the IPdu ready for transmission?\r
if (Arc_IPdu->Com_Arc_TxIPduTimers.ComTxIPduMinimumDelayTimer == 0) {\r
\r
- imask_t mask = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+\r
+ Irq_Save(state);\r
// Check callout status\r
if (IPdu->ComIPduCallout != NULL) {\r
if (!IPdu->ComIPduCallout(ComTxPduId, Arc_IPdu->ComIPduDataPtr)) {\r
// TODO Report error to DET.\r
// Det_ReportError();\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
return;\r
}\r
}\r
}\r
}\r
}\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
\r
// Reset miminum delay timer.\r
Arc_IPdu->Com_Arc_TxIPduTimers.ComTxIPduMinimumDelayTimer = IPdu->ComTxIPdu.ComTxIPduMinimumDelayFactor;\r
#include "Dem.h"\r
#endif\r
#include "PduR.h"\r
-#include "McuExtensions.h"\r
#include "debug.h"\r
\r
/*\r
}\r
\r
void PduR_BufferQueue(PduRTxBuffer_type *Buffer, const uint8 * SduPtr) {\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
if (PduR_BufferIsFull(Buffer)) { // Buffer is full\r
PduR_BufferFlush(Buffer);\r
DEBUG(DEBUG_LOW,"\tBuffer %d: Queued data %d. Status: NrItems %d, First %d, Last %d\n", Buffer->BufferId, *SduPtr, Buffer->NrItems, *Buffer->First, *Buffer->Last);\r
\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
void PduR_BufferDeQueue(PduRTxBuffer_type *Buffer, uint8 *SduPtr) {\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
if (Buffer->NrItems > 0) {\r
memcpy(SduPtr, Buffer->First, sizeof(uint8) * Buffer->Length);\r
} else {\r
DEBUG(DEBUG_LOW,"\tBuffer %d: Buffer is empty, nothing to dequeue!\n", Buffer->BufferId);\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
void PduR_BufferFlush(PduRTxBuffer_type *Buffer) {\r
DEBUG(DEBUG_LOW,"\tBuffer %d: Flushing!\n", Buffer->BufferId);\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
Buffer->NrItems = 0;\r
Buffer->First = Buffer->Buffer;\r
Buffer->Last = Buffer->Buffer;\r
Buffer->TxConfP = 0;\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
uint8 PduR_BufferIsFull(PduRTxBuffer_type *Buffer) {\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
uint8 rv = 0;\r
if (Buffer->NrItems < Buffer->Depth) {\r
rv = 0;\r
} else {\r
rv = 1;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return rv;\r
}\r
*/\r
//#include "ComM_Dcm.h"\r
#include "PduR_Dcm.h"\r
#include "ComStack_Types.h"\r
-#include "McuExtensions.h"\r
\r
// State variable\r
typedef enum\r
\r
\r
#include <string.h>\r
-#include "McuExtensions.h"\r
#include "Dcm.h"\r
#include "Dcm_Internal.h"\r
#include "MemMap.h"\r
DEBUG( DEBUG_MEDIUM, "DslDsdProcessingDone rxPduIdRef=%d\n", rxPduIdRef);\r
\r
if (findRxPduIdParentConfigurationLeafs(rxPduIdRef, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
switch (responseResult) {\r
case DSD_TX_RESPONSE_READY:\r
runtime->externalTxBufferStatus = DSD_PENDING_RESPONSE_SIGNALED; /** @req DCM114 */\r
DEBUG( DEBUG_MEDIUM, "Unknown response result from DslDsdProcessingDone!\n");\r
break;\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
}\r
\r
const Dcm_DslProtocolRowType *protocolRow = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
Std_ReturnType transmitResult;\r
+ imask_t state;\r
\r
+ Irq_Save(state);\r
/** @req DCM119 */\r
- imask_t state = McuE_EnterCriticalSection();\r
if (findRxPduIdParentConfigurationLeafs(protocol->DslRunTimeProtocolParameters->diagReqestRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
runtime->localTxBuffer.status = PROVIDED_TO_DSD;\r
}\r
}\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
// - - - - - - - - - - -\r
const Dcm_DslConnectionType *connection = NULL;\r
const Dcm_DslProtocolRowType *protocolRow = NULL;\r
Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
+ imask_t state;\r
\r
DEBUG( DEBUG_MEDIUM, "DslProvideRxBufferToPdur(dcmRxPduId=%d) called!\n", dcmRxPduId);\r
- imask_t state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (findRxPduIdParentConfigurationLeafs(dcmRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
const Dcm_DslBufferType *externalRxBuffer = protocolRow->DslProtocolRxBufferID;\r
if (externalRxBuffer->pduInfo.SduLength >= tpSduLength) { /** @req DCM443 */\r
stopS3SessionTimer(runtime); /** @req DCM141 */\r
}\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
return ret;\r
}\r
\r
// We need to find out in what buffer we can find our Rx data (it can\r
// be either in the normal RX-buffer or the 'extra' buffer for implementing\r
// the Concurrent "Test Present" functionality.\r
- state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (runtime->externalRxBufferStatus == PROVIDED_TO_PDUR) {\r
if ( result == NTFRSLT_OK ) { /** @req DCM111 */\r
if (isTesterPresentCommand(&(protocolRow->DslProtocolRxBufferID->pduInfo))) {\r
runtime->localRxBuffer.status = NOT_IN_USE;\r
}\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
}\r
\r
boolean externalBufferReleased = FALSE;\r
\r
// Free the buffer and free the Pdu runtime data buffer.\r
- state = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
switch (runtime->externalTxBufferStatus) { // ### EXTERNAL TX BUFFER ###\r
case PROVIDED_TO_PDUR: {\r
#if defined(USE_COMM)\r
break;\r
}\r
}\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
}\r
\r
//#include "Nvm.h"\r
//#include "SchM_Dem.h"\r
#include "MemMap.h"\r
-#include "McuExtensions.h"\r
\r
/*\r
* Local defines\r
static void updateEventStatusRec(const Dem_EventParameterType *eventParam, Dem_EventStatusType eventStatus, boolean createIfNotExist, EventStatusRecType *eventStatusRec)\r
{\r
EventStatusRecType *eventStatusRecPtr;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
// Lookup event ID\r
lookupEventStatusRec(eventParam->EventID, &eventStatusRecPtr);\r
eventStatusRec->errorStatusChanged = FALSE;\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
\r
static void mergeEventStatusRec(const EventRecType *eventRec)\r
{\r
EventStatusRecType *eventStatusRecPtr;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
// Lookup event ID\r
lookupEventStatusRec(eventRec->eventId, &eventStatusRecPtr);\r
}\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
\r
static void deleteEventStatusRec(const Dem_EventParameterType *eventParam)\r
{\r
EventStatusRecType *eventStatusRecPtr;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
// Lookup event ID\r
lookupEventStatusRec(eventParam->EventID, &eventStatusRecPtr);\r
memset(eventStatusRecPtr, 0, sizeof(EventStatusRecType));\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
\r
boolean eventIdFound = FALSE;\r
boolean eventIdFreePositionFound=FALSE;\r
uint16 i;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
// Check if already stored\r
for (i = 0; (i<DEM_MAX_NUMBER_EXT_DATA_PRE_INIT) && (!eventIdFound); i++){\r
}\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
/*\r
boolean eventIdFound = FALSE;\r
boolean eventIdFreePositionFound=FALSE;\r
uint16 i;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
(void)*eventParam; // Currently not used, do this to avoid warning\r
\r
}\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
/*\r
{\r
boolean eventIdFound = FALSE;\r
uint16 i;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
\r
// Lookup event ID\r
memset(&priMemEventBuffer[i-1], 0, sizeof(EventRecType));\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
/*\r
boolean eventIdFound = FALSE;\r
boolean eventIdFreePositionFound=FALSE;\r
uint16 i;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
// Check if already stored\r
for (i = 0; (i<DEM_MAX_NUMBER_EXT_DATA_PRI_MEM) && (!eventIdFound); i++){\r
}\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
/*\r
{\r
boolean eventIdFound = FALSE;\r
uint16 i;\r
- imask_t state = McuE_EnterCriticalSection();\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
// Check if already stored\r
for (i = 0;(i<DEM_MAX_NUMBER_EXT_DATA_PRI_MEM) && (!eventIdFound); i++){\r
memset(&priMemExtDataBuffer[i-1], 0, sizeof(ExtDataRecType));\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
/*\r
*/\r
static void resetEventStatus(Dem_EventIdType eventId)\r
{\r
- imask_t state = McuE_EnterCriticalSection();\r
EventStatusRecType *eventStatusRecPtr;\r
+ imask_t state;\r
+ Irq_Save(state);\r
\r
lookupEventStatusRec(eventId, &eventStatusRecPtr);\r
if (eventStatusRecPtr != NULL) {\r
eventStatusRecPtr->eventStatusExtended &= (Dem_EventStatusExtendedType)~DEM_TEST_FAILED; /** @req DEM187 */\r
}\r
\r
- McuE_ExitCriticalSection(state);\r
+ Irq_Restore(state);\r
}\r
\r
\r
#if defined(CFG_MPC55XX) || defined(CFG_ARM_CR4)\r
uint32_t McuE_GetPeripheralClock( McuE_PeriperalClock_t type );\r
#endif\r
-#include "McuExtensions.h"\r
-\r
-\r
\r
#endif /*MCU_H_*/\r
/** @} */\r
+++ /dev/null
-/* -------------------------------- Arctic Core ------------------------------\r
- * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
- *\r
- * Copyright (C) 2009 ArcCore AB <contact@arccore.com>\r
- *\r
- * This source code is free software; you can redistribute it and/or modify it\r
- * under the terms of the GNU General Public License version 2 as published by the\r
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
- *\r
- * This program is distributed in the hope that it will be useful, but\r
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\r
- * for more details.\r
- * -------------------------------- Arctic Core ------------------------------*/\r
-\r
-\r
-\r
-#ifndef MCU_EXTENSIONS_H\r
-#define MCU_EXTENSIONS_H\r
-\r
-#include "Std_Types.h"\r
-typedef uint32_t imask_t;\r
-\r
-imask_t McuE_EnterCriticalSection(void);\r
-void McuE_ExitCriticalSection(imask_t old_state);\r
-\r
-#endif\r
#include "core_cr4.h"
#endif
+#include "Std_Types.h"
+typedef uint32_t imask_t;
+
/* Call architecture specific code */
#define Irq_Disable() __disable_irq()
#define Irq_Enable() __enable_irq()
#define CPU_H\r
\r
#include "Std_Types.h"\r
+typedef uint32_t imask_t;\r
\r
#define Irq_Save(flags) ((flags) = 0) // Dummy assignment to avoid compiler warnings\r
#define Irq_Restore(flags) (void)(flags)\r
#ifndef CPU_H_\r
#define CPU_H_\r
\r
+#include "Std_Types.h"\r
+typedef uint32_t imask_t;\r
+\r
#define Irq_Disable() asm volatile (" sei");\r
#define Irq_Enable() asm volatile (" cli");\r
\r
#define CPU_H\r
\r
#include "Std_Types.h"\r
+typedef uint32_t imask_t;\r
\r
// Used if we are running a T32 instruction set simulator\r
#define SIMULATOR() (SIU.MIDR.R==0)\r
{\r
uint16 BlockIndex;\r
const Ea_BlockConfigType *EaBlockCon;\r
+ imask_t state;\r
\r
/*@req <EA130> */\r
if (E_OK != Ea_ValidateInitialized(EA_READ_ID))\r
\r
/*@req <EA137> */\r
/* Lock down the module to ourself */\r
- imask_t mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (Ea_Global.ModuleStatus != MEMIF_IDLE)\r
{\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
return E_NOT_OK;\r
}\r
/*set current state is internal busy*/\r
Ea_Global.ModuleStatus = MEMIF_BUSY_INTERNAL;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
\r
BlockIndex = EA_GET_BLOCK(BlockNumber);\r
\r
uint16 BlockIndex;\r
const Ea_BlockConfigType *EaBlockCon;\r
Ea_AdminBlock* adminBlock;\r
+ imask_t state;\r
\r
/*@req <EA131> */\r
if (E_OK != Ea_ValidateInitialized(EA_WRITE_ID))\r
/*@req <EA137>\r
*/\r
/* Lock down the module to ourself */\r
- imask_t mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (Ea_Global.ModuleStatus != MEMIF_IDLE)\r
{\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
return E_NOT_OK;\r
}\r
/*set current state is internal busy*/\r
Ea_Global.ModuleStatus = MEMIF_BUSY_INTERNAL;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
\r
BlockIndex = EA_GET_BLOCK(BlockNumber);\r
\r
const Ea_BlockConfigType *EaBlockCon;\r
Ea_AdminBlock* adminBlock;\r
Std_ReturnType result;\r
+ imask_t state;\r
\r
/*@req <EA135> */\r
if (E_OK != Ea_ValidateInitialized(EA_INVALIDATEBLOCK_ID))\r
/*@req <EA137>\r
*/\r
/* Lock down the module to ourself */\r
- imask_t mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (Ea_Global.ModuleStatus != MEMIF_IDLE)\r
{\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
return E_NOT_OK;\r
}\r
/*set current state is internal busy*/\r
Ea_Global.ModuleStatus = MEMIF_BUSY_INTERNAL;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
\r
BlockIndex = EA_GET_BLOCK(BlockNumber);\r
\r
result = Eep_Write(Ea_Global.EepAddress, (const uint8*) Ea_TempBuffer, sizeof(Ea_AdminBlock));\r
if (E_OK == result)\r
{\r
- mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
MemIf_StatusType status = Eep_GetStatus();\r
if ((status == MEMIF_BUSY) || (status == MEMIF_BUSY_INTERNAL))\r
Ea_Global.JobStatus = EA_PENDING_ADMIN_WRITE;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
}\r
else\r
{\r
{\r
uint16 BlockIndex;\r
const Ea_BlockConfigType *EaBlockCon;\r
+ imask_t state;\r
\r
/*@req <EA136> */\r
if (E_OK != Ea_ValidateInitialized(EA_ERASEIMMEDIATEBLOCK_ID))\r
/*@req <EA137>\r
*/\r
/* Lock down the module to ourself */\r
- imask_t mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
if (Ea_Global.ModuleStatus != MEMIF_IDLE)\r
{\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
return E_NOT_OK;\r
}\r
/*set current state is internal busy*/\r
Ea_Global.ModuleStatus = MEMIF_BUSY_INTERNAL;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
\r
BlockIndex = EA_GET_BLOCK(BlockNumber);\r
\r
void Ea_MainFunction(void)\r
{\r
Std_ReturnType result;\r
- imask_t mask;\r
+ imask_t state;\r
\r
if ((MEMIF_JOB_PENDING == Ea_Global.JobResult) && (Ea_Global.JobStatus == EA_PENDING_NONE))\r
{\r
result = Eep_Write(Ea_Global.EepAddress, (const uint8*) Ea_TempBuffer, Ea_Global.Length);\r
if (E_OK == result)\r
{\r
- mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
MemIf_StatusType status = Eep_GetStatus();\r
if ((status == MEMIF_BUSY) || (status == MEMIF_BUSY_INTERNAL))\r
Ea_Global.JobStatus = EA_PENDING_WRITE;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
}\r
}\r
break;\r
result = Eep_Read(Ea_Global.EepAddress, (uint8*) Ea_TempBuffer, Ea_Global.Length);\r
if (E_OK == result)\r
{\r
- mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
MemIf_StatusType status = Eep_GetStatus();\r
if ((status == MEMIF_BUSY) || (status == MEMIF_BUSY_INTERNAL))\r
Ea_Global.JobStatus = EA_PENDING_READ;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
}\r
}\r
break;\r
result = Eep_Erase(Ea_Global.EepAddress, Ea_Global.Length);\r
if (E_OK == result)\r
{\r
- mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
MemIf_StatusType status = Eep_GetStatus();\r
if ((status == MEMIF_BUSY) || (status == MEMIF_BUSY_INTERNAL))\r
Ea_Global.JobStatus = EA_PENDING_ERASE;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
}\r
}\r
break;\r
{\r
Ea_AdminBlock* adminBlock;\r
Std_ReturnType result;\r
- imask_t mask;\r
+ imask_t state;\r
\r
if (Ea_Global.JobResult == MEMIF_JOB_OK)\r
{\r
result = Eep_Write(Ea_Global.EepAddress, (const uint8*) Ea_TempBuffer, sizeof(Ea_AdminBlock));\r
if (E_OK == result)\r
{\r
- mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
MemIf_StatusType status = Eep_GetStatus();\r
if ((status == MEMIF_BUSY) || (status == MEMIF_BUSY_INTERNAL))\r
Ea_Global.JobStatus = EA_PENDING_ADMIN_WRITE;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
} else\r
{\r
Ea_Global.JobResult = MEMIF_JOB_FAILED;\r
{\r
Ea_AdminBlock* adminBlock;\r
Std_ReturnType result;\r
- imask_t mask;\r
+ imask_t state;\r
\r
if (Ea_Global.JobResult == MEMIF_JOB_OK)\r
{\r
result = Eep_Write(Ea_Global.EepAddress, (const uint8*) Ea_TempBuffer, sizeof(Ea_AdminBlock));\r
if (E_OK == result)\r
{\r
- mask = McuE_EnterCriticalSection();\r
+ Irq_Save(state);\r
MemIf_StatusType status = Eep_GetStatus();\r
if ((status == MEMIF_BUSY) || (status == MEMIF_BUSY_INTERNAL))\r
Ea_Global.JobStatus = EA_PENDING_ADMIN_WRITE;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
} else\r
{\r
Ea_Global.JobResult = MEMIF_JOB_FAILED;\r
/*@req <EA102> */\r
void Ea_JobErrorNotification(void)\r
{\r
- imask_t mask = McuE_EnterCriticalSection();\r
- /*@req EA154*/\r
+ imask_t state;\r
+ Irq_Save(state);\r
+\r
+ /*@req EA154*/\r
if (Ea_Global.JobResult == MEMIF_JOB_PENDING)\r
Ea_Global.JobResult = MEMIF_JOB_FAILED;\r
\r
Ea_Global.JobType = EA_JOB_NONE;\r
Ea_Global.JobStatus = EA_PENDING_NONE;\r
Ea_Global.ModuleStatus = MEMIF_IDLE;\r
- McuE_ExitCriticalSection(mask);\r
+ Irq_Restore(state);\r
\r
/*@req <EA055> */\r
/*@req <EA144> */\r
\r
OsTaskVarType *curr_pcb = Os_SysTaskGetCurr();\r
StatusType rv = E_OK;\r
+ imask_t state;\r
\r
OS_DEBUG(D_EVENT,"# WaitEvent %s\n",Os_SysTaskGetCurr()->name);\r
\r
}\r
\r
/* Remove from ready queue */\r
- Irq_Disable();\r
+ Irq_Save(state);\r
\r
// OSEK/VDX footnote 5. The call of WaitEvent does not lead to a waiting state if one of the events passed in the event mask to\r
// WaitEvent is already set. In this case WaitEvent does not lead to a rescheduling.\r
}\r
}\r
\r
- Irq_Enable();\r
+ Irq_Restore(state);\r
\r
// The following line disables the unused label warning. Remove when\r
// proper error handling is implemented.\r