示例#1
0
/**
 *******************************************************************************
 * @brief      Initialize before Flash Programming/Erase Functions 
 * @param[in]  baseAddr     Flash device base address.
 * @param[in]  clk     			Flash program clock.
 * @param[in]  operateFuc   Init for what operation
 														(FLASH_OPT_ERASECHIP/FLASH_OPT_ERASESECTORS/FLASH_OPT_PROGRAMPAGE/
 														 FLASH_OPT_VERIFY/ FLASH_OPT_BLANKCHECK).
 * @param[out] None  
 * @retval     0   					All is OK.
 * @retval     others       Some error occurs.		 
 *
 * @par Description
 * @details    This function is called before flash programming/erase. 
 * @note 
 *******************************************************************************
 */
int FlashInit (unsigned long baseAddr,unsigned long clk, unsigned long operateFuc)
{
  //
  // disable interrupts on the processor 
  //
  CPUcpsid();
  
  //
  // Check which flash key the MCU is set to use
  //
  if(HWREG(FLASH_BOOTCFG) & FLASH_BOOTCFG_KEY)
  {
	WRKEY = 0xA4420000;
  }
  else
  {
	WRKEY = 0x71D50000;
  }
  
  //
  // Clear the BA bit in RMCTL to set the Flash memory at address 0x0)
  //
  HWREG(FLASH_RMCTL)  = FLASH_RMCTL_BA;
  
  return (0);
}
示例#2
0
文件: interrupt.c 项目: 0x00f/Energia
//*****************************************************************************
//
//! Disables the processor interrupt.
//!
//! This function prevents the processor from receiving interrupts.  This
//! function does not affect the set of interrupts enabled in the interrupt
//! controller; it just gates the single interrupt from the controller to the
//! processor.
//!
//! \note Previously, this function had no return value.  As such, it was
//! possible to include <tt>interrupt.h</tt> and call this function without
//! having included <tt>hw_types.h</tt>.  Now that the return is a
//! <tt>tBoolean</tt>, a compiler error occurs in this case.  The solution
//! is to include <tt>hw_types.h</tt> before including <tt>interrupt.h</tt>.
//!
//! \return Returns \b true if interrupts were already disabled when the
//! function was called or \b false if they were initially enabled.
//
//*****************************************************************************
tBoolean
IntMasterDisable(void)
{
    //
    // Disable processor interrupts.
    //
    return(CPUcpsid());
}
示例#3
0
/* Disable system / global interrupt. ref counted for use by nested calls */
u32 disable_system_irq(void)
{
        u32 primask;
        /* Disable the interrupts */
        primask = CPUcpsid();
        intr_ref_cnt++;

        return(primask);
}
示例#4
0
/* Disable system / global interrupt. ref counted for use by nested calls */
void cc_dsbl_sys_irq(void)
{
        u32 primask;
        /* Disable the interrupts */
        primask = CPUcpsid();
        cc_pm_ctrl.intr_ref_cnt++;

        UNUSED(primask);
        return;
}
示例#5
0
文件: adi.c 项目: BadgeWiz/TR16Badge
//*****************************************************************************
//
// SafeHapiAuxAdiSelect()
// Common wrapper function for the Hapi functions needing the "bus arbitration
// issue" workaround.
//
//*****************************************************************************
void SafeHapiAuxAdiSelect( FPTR_VOID_UINT8_T fPtr, uint8_t ut8Signal )
{
    bool bIrqEnabled = ( ! CPUcpsid() );
    while ( ! HWREG( AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 ));
    fPtr( ut8Signal );
    HWREG( AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 ) = 1;
    if ( bIrqEnabled ) {
        CPUcpsie();
    }
}
示例#6
0
//*****************************************************************************
//
// SafeHapiVoid() and SafeHapiAuxAdiSelect()
// Common wrapper functions for the Hapi functions needing the "bus arbitration
// issue" workaround.
//
//*****************************************************************************
void SafeHapiVoid( FPTR_VOID_VOID_T fPtr )
{
    bool bIrqEnabled = ( ! CPUcpsid() );
    while ( ! HWREG( AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 ));
    fPtr();
    HWREG( AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 ) = 1;
    if ( bIrqEnabled ) {
        CPUcpsie();
    }
}
/*
 *  ======== PowerCC3200_sleepPolicy ========
 */
void PowerCC3200_sleepPolicy()
{
    bool returnFromSleep = FALSE;
    uint32_t constraintMask;
    uint32_t ticks;
    uint64_t time;
    uint64_t match;
    uint64_t curr;
    uint64_t remain;
    uint32_t taskKey;
    uint32_t swiKey;

    /* disable interrupts */
    CPUcpsid();

    /* disable Swi and Task scheduling */
    swiKey = Swi_disable();
    taskKey = Task_disable();

    /* query the declared constraints */
    constraintMask = Power_getConstraintMask();

    /*
     *  Do not go into LPDS if not allowed into DEEPSLEEP.
     *  Check to see if we can go into LPDS (lowest level sleep).
     *  If not allowed, then attempt to go into DEEPSLEEP.
     *  If not allowed in DEEPSLEEP then just SLEEP.
     */

     /* check if we are allowed to go to LPDS */
    if ((constraintMask &
        ((1 << PowerCC3200_DISALLOW_LPDS) |
        (1 << PowerCC3200_DISALLOW_DEEPSLEEP))) == 0) {
        /*
         * Check how many ticks until the next scheduled wakeup.  A value of
         * zero indicates a wakeup will occur as the current Clock tick period
         * expires; a very large value indicates a very large number of Clock
         * tick periods will occur before the next scheduled wakeup.
         */
        /* Get the time remaining for the RTC timer to expire */
        ticks = Clock_getTicksUntilInterrupt();

        /* convert ticks to microseconds */
        time = ticks * Clock_tickPeriod;

        /* check if can go to LPDS */
        if (time > Power_getTransitionLatency(PowerCC3200_LPDS, Power_TOTAL)) {
            /* get the current and match values for RTC */
            match = MAP_PRCMSlowClkCtrMatchGet();
            curr = MAP_PRCMSlowClkCtrGet();
            remain = match - curr -
                (((uint64_t)PowerCC3200_TOTALTIMELPDS * 32768) / 1000000);

            /* set the LPDS wakeup time interval */
            MAP_PRCMLPDSIntervalSet(remain);

            /* enable the wake source to be timer */
            MAP_PRCMLPDSWakeupSourceEnable(PRCM_LPDS_TIMER);

            /* go to LPDS mode */
            Power_sleep(PowerCC3200_LPDS);

            /* set 'returnFromSleep' to TRUE*/
            returnFromSleep = TRUE;
        }
    }

    /* check if we are allowed to go to DEEPSLEEP */
    if ((constraintMask & (1 << PowerCC3200_DISALLOW_DEEPSLEEP) == 0) &&
        (!returnFromSleep)) {
        /*
         * Check how many ticks until the next scheduled wakeup.  A value of
         * zero indicates a wakeup will occur as the current Clock tick period
         * expires; a very large value indicates a very large number of Clock
         * tick periods will occur before the next scheduled wakeup.
         */
        ticks = Clock_getTicksUntilInterrupt();

        /* convert ticks to microseconds */
        time = ticks * Clock_tickPeriod;

        /* check if can go to DEEPSLEEP */
        if (time > Power_getTransitionLatency(PowerCC3200_DEEPSLEEP,
            Power_TOTAL)) {
            /* schedule the wakeup event */
            ticks -= PowerCC3200_RESUMETIMEDEEPSLEEP / Clock_tickPeriod;
            Clock_setTimeout(Clock_handle(&clockObj), ticks);
            Clock_start(Clock_handle(&clockObj));

            /* go to DEEPSLEEP mode */
            Power_sleep(PowerCC3200_DEEPSLEEP);
            Clock_stop(Clock_handle(&clockObj));

            /* set 'returnFromSleep' to TRUE so we don't go to sleep (below) */
            returnFromSleep = TRUE;
        }
    }

    /* re-enable interrupts */
    CPUcpsie();

    /* restore Swi scheduling */
    Swi_restore(swiKey);

    /* restore Task scheduling */
    Task_restore(taskKey);

    /* sleep only if we are not returning from one of the sleep modes above */
    if (!(returnFromSleep)) {
        MAP_PRCMSleepEnter();
    }
}
示例#8
0
/**
  *  global interrupt disable
  */
void hwDisableInterrupts(){
    CPUcpsid();
}