Example #1
0
/** @brief Function for main application entry.
 */
int main(void)
{
    // This function contains workaround for PAN_028 rev2.0A anomalies 28, 29,30 and 31.
    int32_t volatile temp;

    nrf_temp_init();

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));

    while (true)
    {
        NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */

        /* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
        /*lint -e{845} // A zero has been given as right argument to operator '|'" */
        while (NRF_TEMP->EVENTS_DATARDY == 0)
        {
            // Do nothing.
        }
        NRF_TEMP->EVENTS_DATARDY = 0;

        /**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */
        temp = (nrf_temp_read() / 4);

        /**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
        NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */

        NRF_LOG_INFO("Actual temperature: %d\r\n", (int)temp);
        nrf_delay_ms(500);

        NRF_LOG_FLUSH();
    }
}
Example #2
0
void nrf5TempInit(void)
{
#if !SOFTDEVICE_PRESENT
    nrf_temp_init();

    NRF_TEMP->TASKS_START = 1;
#endif
}
Example #3
0
// the temperature from the internal temperature sensor
JsVarFloat jshReadTemperature() {
  nrf_temp_init();

  NRF_TEMP->TASKS_START = 1;
  while (NRF_TEMP->EVENTS_DATARDY == 0) ;// Do nothing...
  NRF_TEMP->EVENTS_DATARDY = 0;
  int32_t nrf_temp = nrf_temp_read();
  NRF_TEMP->TASKS_STOP = 1;

  return nrf_temp / 4.0;
}
Example #4
0
/** @brief Function for main application entry.
 */
int main(void)
{
    // This function contains workaround for PAN_028 rev2.0A anomalies 28, 29,30 and 31.
    int32_t volatile temp;

    nrf_temp_init();
    uint32_t err_code;
    APP_GPIOTE_INIT(1);
    const app_uart_comm_params_t comm_params =
     {
         RX_PIN_NUMBER,
         TX_PIN_NUMBER,
         RTS_PIN_NUMBER,
         CTS_PIN_NUMBER,
         APP_UART_FLOW_CONTROL_ENABLED,
         false,
         UART_BAUDRATE_BAUDRATE_Baud38400
     };

    APP_UART_FIFO_INIT(&comm_params,
                    UART_RX_BUF_SIZE,
                    UART_TX_BUF_SIZE,
                    uart_error_handle,
                    APP_IRQ_PRIORITY_LOW,
                    err_code);

    APP_ERROR_CHECK(err_code);

    while (true)
    {
        NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */

        /* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
        /*lint -e{845} // A zero has been given as right argument to operator '|'" */
        while (NRF_TEMP->EVENTS_DATARDY == 0)
        {
            // Do nothing.
        }
        NRF_TEMP->EVENTS_DATARDY = 0;

        /**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */
        temp = (nrf_temp_read() / 4);

        /**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
        NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */

        printf("Actual temperature: %d\n\r", (int)temp);
        nrf_delay_ms(500);
    }
}
Example #5
0
uint32_t nrf_utils_read_temperature(void) {
  
  nrf_temp_init();

  int32_t volatile nrf_temp;

  NRF_TEMP->TASKS_START = 1;
  while (NRF_TEMP->EVENTS_DATARDY == 0)
  {
    // Do nothing...
  }
  NRF_TEMP->EVENTS_DATARDY = 0;

  nrf_temp = (nrf_temp_read() / 4);

  NRF_TEMP->TASKS_STOP = 1;

  return (uint32_t) nrf_temp;

}
Example #6
0
/*====================================================================================================*/
void TEMP_Config( void )
{
  nrf_temp_init();
}
Example #7
0
void nrf5TempInit(void)
{
    nrf_temp_init();
}
Example #8
0
// the temperature from the internal temperature sensor
JsVarFloat jshReadTemperature() {
  nrf_temp_init();

  return nrf_temp_read() / 4.0;
}