-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DA217 sensor.
- Loading branch information
Showing
5 changed files
with
731 additions
and
2 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
libraries/SensorBasic/examples/DA217/da217_steps/da217_steps.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
|
||
#include "Arduino.h" | ||
#include "da217.h" | ||
|
||
#define INT1_PIN GPIO0 | ||
#define INT2_PIN GPIO1 | ||
bool da217_int1_flag,da217_int2_flag; | ||
|
||
DA217 da217; | ||
uint16_t step_num; | ||
da217_step_status_t step_status; | ||
|
||
|
||
void da217_int1_isr(void) | ||
{ | ||
da217_int1_flag =true; | ||
} | ||
void da217_int2_isr(void) | ||
{ | ||
da217_int2_flag =true; | ||
} | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
PINMODE_INPUT_PULLDOWN(INT1_PIN); | ||
PINMODE_INPUT_PULLDOWN(INT2_PIN); | ||
attachInterrupt(INT1_PIN, da217_int1_isr, RISING); | ||
attachInterrupt(INT2_PIN, da217_int2_isr, RISING); | ||
pinMode(Vext,OUTPUT); | ||
digitalWrite(Vext,LOW);//set vext to high | ||
da217.da217_init(); | ||
da217.da217_start_up_step_detect(true,true,5); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
step_num = da217.da217_read_steps(); | ||
step_status = da217.da217_read_step_status(); | ||
Serial.printf("step_num = %d step_status =%d\r\n",step_num,step_status); | ||
if( da217_int1_flag ) | ||
{ | ||
Serial.println("da217_int1_flag"); | ||
da217_int1_flag = false; | ||
} | ||
if(da217_int2_flag) | ||
{ | ||
Serial.println("da217_int2_flag"); | ||
da217_int2_flag = false; | ||
} | ||
delay(3000); | ||
} |
29 changes: 29 additions & 0 deletions
29
libraries/SensorBasic/examples/DA217/da217_xyz/da217_xyz.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
|
||
#include "Arduino.h" | ||
#include "da217.h" | ||
|
||
|
||
DA217 da217; | ||
uint16_t step_num; | ||
uint16_t x_data,y_data,z_data; | ||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
pinMode(Vext,OUTPUT); | ||
digitalWrite(Vext,LOW);//set vext to high | ||
da217.da217_init(); | ||
da217.da217_set_odr_rate(DA217_ODR_500HZ); | ||
da217.da217_set_fifo_mode(FIFO_MODE_FIFO); | ||
da217.da217_set_full_scale(FS_FULL_SCALE_2g); | ||
da217.da217_set_resolution(RESOLUTION_14_BIT); | ||
da217.da217_start_xyz_axis(true,true,true); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
da217.da217_read_xyz_data(&x_data,&y_data,&z_data); | ||
Serial.printf("x_data=%d y_data=%d z_data=%d\r\n",x_data,y_data,z_data); | ||
delay(3000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.