/*!
 * @brief main function
 */
int main(void)
{
#if FSL_FEATURE_ADC16_HAS_CALIBRATION
    adc16_calibration_param_t tempSnseCalibraitionParam;
#endif

    hardware_init();
    GPIO_DRV_Init(NULL, ledPins);

    // Configure the power mode protection
    SMC_HAL_SetProtection(SMC_BASE_PTR, kAllowPowerModeVlp);

    ADC16_DRV_StructInitUserConfigDefault(&tempSnseAdcConfig);
#if (FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16)
    tempSnseAdcConfig.resolution = kAdc16ResolutionBitOf16;
#endif

#if BOARD_ADC_USE_ALT_VREF
    tempSnseAdcConfig.refVoltSrc = kAdc16RefVoltSrcOfValt;
#endif
    // Init ADC
    ADC16_DRV_Init(ADC_INSTANCE, &tempSnseAdcConfig);
    // Calibrate VDD and ADCR_TEMP25
#if FSL_FEATURE_ADC16_HAS_CALIBRATION
    // Auto calibraion
    ADC16_DRV_GetAutoCalibrationParam(ADC_INSTANCE, &tempSnseCalibraitionParam);
    ADC16_DRV_SetCalibrationParam(ADC_INSTANCE, &tempSnseCalibraitionParam);
#endif // FSL_FEATURE_ADC16_HAS_CALIBRATION
    calibrateParams();

    // get cpu uid low value for slave
    gSlaveId = SIM_UIDL_UID(SIM_BASE_PTR);

    PRINTF("i2c_rtos_slave_bm demo\r\n");

    // task list initialize
    OSA_Init();

    // create task(in BM: only the first registered task can be executed)
    OSA_TaskCreate(task_slave,
                   (uint8_t *)"slave",
                   512,
                   task_slave_stack,
                   0,
                   (void *)0,
                   false,
                   &task_slave_task_handler);

    OSA_Start();

    return 0;
}
示例#2
0
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */
   uint32_t      currentCounter = 0;
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  hw_average_config.hwAverageCountMode = kAdc16HwAverageCountOf32;      //enable hardware average.
  ADC16_DRV_ConfigHwAverage(FSL_ADCONV1,&hw_average_config);
  ADC16_DRV_GetAutoCalibrationParam(FSL_ADCONV1,&calibration_param);

  calibrateParams();
  //ADC16_DRV_Init(FSL_ADCONV1, &adConv1_InitConfig0);

  LPTMR_DRV_SetTimerPeriodUs(FSL_LPTMR1,1000000);  // Set lptmr period
  printf("\r\nLPTMR is running!!\r\n");
  LPTMR_DRV_Start(FSL_LPTMR1);
  /* Write your code here */
  /* For example: for(;;) { } */
  while(1)
  {
      if(currentCounter != lptmrCounter)
      {
          currentCounter = lptmrCounter;
          printf("\r\nLPTMR interrupt No.%d \r\n",currentCounter);
          GPIO_DRV_TogglePinOutput(LEDRGB_GREEN);
      }
  }

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/