Skip to content

Commit

Permalink
#32 Moving the US ON Timer start inside the PPI function and removing…
Browse files Browse the repository at this point in the history
… the new lines
  • Loading branch information
trifuns committed Jun 21, 2022
1 parent 7546b2e commit a540d33
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions bsp/nrf52833/hc_sr04.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @copyright Inria, 2022
*/


#include <nrf.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -19,11 +18,11 @@

//=========================== define ==========================================

// GPIOTE for turning ON US sensor and receiving the range measurement
#define US_ON_PORT 1UL // output port number
#define US_ON_PIN 10UL // output pin number
#define US_READ_PORT 1UL
#define US_READ_PIN 6UL
// GPIOTE for turning ON US sensor and READING the range measurement
#define US_ON_PORT 1UL // output port number
#define US_ON_PIN 10UL // output pin number
#define US_READ_PORT 1UL
#define US_READ_PIN 6UL

#define US_ON_CH 0UL
#define US_READ_CH_LoToHi 1UL
Expand All @@ -43,22 +42,20 @@ void hc_sr04_on_set_trigger(double duration_ms, double offset_ms);

typedef struct {

us_callback_t us_callback; // Function pointer, stores the callback to use in the GPIOTE_IRQn handler.
timer_callback_t timer_callback; // Function pointer, stores the callback to use in the GPIOTE_IRQn handler.
NRF_TIMER_Type *us_on_timer; // Pointer to the TIMER structure used for triggering US sensor
NRF_TIMER_Type *us_read_timer; // Pointer to the TIMER structure used for reading the range on the US sensor
us_callback_t us_callback; // Function pointer, stores the callback to use in the GPIOTE_IRQn handler.
timer_callback_t timer_callback; // Function pointer, stores the callback to use in the GPIOTE_IRQn handler.

NRF_TIMER_Type *us_on_timer; // Pointer to the TIMER structure used for triggering US sensor
NRF_TIMER_Type *us_read_timer; // Pointer to the TIMER structure used for reading the range on the US sensor

volatile uint32_t us_reading; // Variable to store pulse duration of the US echo pin
volatile uint32_t us_reading; // Variable to store pulse duration of the US echo pin

} us_vars_t;

static us_vars_t us_vars;


//=========================== public ==========================================


/**
* @brief Function for initializing variables and calling private functions for using the hc_sr04 US sensor
*/
Expand Down

0 comments on commit a540d33

Please sign in to comment.