void osSuspendAllTasks(void)
{
#if !defined(osCMSIS_RTX)
   //Make sure the operating system is running
   if(osKernelRunning())
   {
      //Suspend all tasks
      osThreadSuspendAll();
   }
#endif
}
Beispiel #2
0
/*******************************************************************************
* º¯ÊýÃû  : ADS1222_AdRead
* Ãè  Êö  : »ñÈ¡ADS1222£®Ò»´ÎÍêÕûµÄÊý¾Ý´«ÊäΪ24bit£¬¸ßλÏȳö
* Êä  Èë  : chipId: ads1222оƬ±àºÅ
*           channel: ads1222оƬͨµÀºÅ 
* Êä  ³ö  : ÎÞ
* ·µ »Ø Öµ: ¶ÁÈ¡24bit ԭʼADÖµ
*******************************************************************************/
Ads1222Err ADS1222_AdRead(u32* data_a, u32* data_b, u32* data_c, u32* data_d)
{
    u8 i = 0;

    ADS1222_DOUT_IPU(0x0f);

    // enter critical section
    // first will disable global interrupt
    // then will suspend all threads
    // taskENTER_CRITICAL();
    osThreadSuspendAll();

    *data_a = 0;
    *data_b = 0;
    *data_c = 0;
    *data_d = 0;

    for(i=0; i<24; i++)
    {
        // shift data
        *data_a = *data_a << 1;
        *data_b = *data_b << 1;
        *data_c = *data_c << 1;
        *data_d = *data_d << 1;

        // sclk put high
        ADS1222_A_SCLK_HIGH();
        ADS1222_B_SCLK_HIGH();
        ADS1222_C_SCLK_HIGH();
        ADS1222_D_SCLK_HIGH();

        delay_us(1);

        // sclk put low
        ADS1222_A_SCLK_LOW();
        ADS1222_B_SCLK_LOW();
        ADS1222_C_SCLK_LOW();
        ADS1222_D_SCLK_LOW();

        delay_us(1);

        // read bit
        if (ADS1222_A_DOUT_IN() == GPIO_PIN_SET)
        {
            *data_a |= 0x00000001;  //or adValue+=1;     
        }
        if (ADS1222_B_DOUT_IN() == GPIO_PIN_SET)
        {
            *data_b |= 0x00000001;  //or adValue+=1;     
        }
        if (ADS1222_C_DOUT_IN() == GPIO_PIN_SET)
        {
            *data_c |= 0x00000001;  //or adValue+=1;     
        }
        if (ADS1222_D_DOUT_IN() == GPIO_PIN_SET)
        {
            *data_d |= 0x00000001;  //or adValue+=1;     
        }
    }

    // sclk put high
    ADS1222_A_SCLK_HIGH();
    ADS1222_B_SCLK_HIGH();
    ADS1222_C_SCLK_HIGH();
    ADS1222_D_SCLK_HIGH();

    delay_us(1);

    // sclk put low
    ADS1222_A_SCLK_LOW();
    ADS1222_B_SCLK_LOW();
    ADS1222_C_SCLK_LOW();
    ADS1222_D_SCLK_LOW();

    delay_us(1);

    // exit critical section
    // first will resume all threads
    // then will re-enable global interrupt
    osThreadResumeAll();
    // taskEXIT_CRITICAL();

    return Ads1222Err_NoErr;
}