コード例 #1
0
/* ===================================================================*/
LDD_TDeviceData* SystemTimer1_Init(LDD_TUserData *UserDataPtr)
{
  /* Allocate device structure */
  SystemTimer1_TDeviceData *DeviceDataPrv;
  /* {MQXLite RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
  DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC;
  DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */
  /* Interrupt vector(s) allocation */
  /* {MQXLite RTOS Adapter} Save old and set new interrupt vector (function handler and ISR parameter) */
  /* Note: Exception handler for interrupt is not saved, because it is not modified */
  DeviceDataPrv->SavedISRSettings_TUInterrupt.isrData = _int_get_isr_data(LDD_ivIndex_INT_SysTick);
  DeviceDataPrv->SavedISRSettings_TUInterrupt.isrFunction = _int_install_isr(LDD_ivIndex_INT_SysTick, SystemTimer1_Interrupt, DeviceDataPrv);
  /* SYST_CSR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,COUNTFLAG=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CLKSOURCE=0,TICKINT=0,ENABLE=0 */
  SYST_CSR = 0x00U;                    /* Clear control register */
  /* SYST_RVR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,RELOAD=0x0003A97F */
  SYST_RVR = SysTick_RVR_RELOAD(0x0003A97F); /* Setup reload value */
  /* SYST_CVR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CURRENT=0 */
  SYST_CVR = SysTick_CVR_CURRENT(0x00); /* Clear current value */
  /* SCB_SHPR3: PRI_15=0x80 */
  SCB_SHPR3 = (uint32_t)((SCB_SHPR3 & (uint32_t)~(uint32_t)(
               SCB_SHPR3_PRI_15(0x7F)
              )) | (uint32_t)(
               SCB_SHPR3_PRI_15(0x80)
              ));
  /* SYST_CSR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,COUNTFLAG=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CLKSOURCE=1,TICKINT=1,ENABLE=0 */
  SYST_CSR = (SysTick_CSR_CLKSOURCE_MASK | SysTick_CSR_TICKINT_MASK); /* Set up control register */
  /* Registration of the device structure */
  PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_SystemTimer1_ID,DeviceDataPrv);
  return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the device data structure */
}
コード例 #2
0
ファイル: schedInit.c プロジェクト: hellertime/manos
void schedInit(int quantumMillis, uint8_t priority) {
    SCB_SHPR3 = (SCB_SHPR3 & ~(SCB_SHPR3_PRI_14_MASK & SCB_SHPR3_PRI_15_MASK)) /* clear the old priority for SysTick and PendSV */
              | SCB_SHPR3_PRI_14(priority << 4)                                /* set the high bits of the PendSV interrupt */
              | SCB_SHPR3_PRI_15(priority << 4);                               /* set the high bits of the SysTick interrupt */

    SYST_CSR |= SysTick_CSR_TICKINT_MASK | SysTick_CSR_CLKSOURCE_MASK;         /* enable the SysTick clock source to use the processor clock (120MHz) */
    SYST_RVR = SysTick_RVR_RELOAD(quantumMillis * MANOS_ARCH_K70_CYCLES_PER_MILLIS - 1); /* setup the SysTick quantum scaled to to cycle count of 8 1/3 nanos - counting starts at 1 */
}
コード例 #3
0
ファイル: SysTick.c プロジェクト: EmanuelVF/Seguidor-De-Luz
void SysTick_init(void) 
{
  SYST_CSR = 0x00;
  SYST_RVR = SysTick_RVR_RELOAD(274999U); // 0.5ms 
  SYST_CVR = SysTick_CVR_CURRENT(0);
  SYST_CSR = SysTick_CSR_CLKSOURCE_MASK |
		     SysTick_CSR_TICKINT_MASK |
		     SysTick_CSR_ENABLE_MASK;
}