-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54886cc
commit 7f3dc9f
Showing
88 changed files
with
12,570 additions
and
5,787 deletions.
There are no files selected for viewing
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,156 @@ | ||
#include "Arduino.h" | ||
#include "utilities.h" | ||
|
||
bool reply = false; | ||
|
||
/** | ||
* After first time power on, some register of this pin will be written then | ||
* it will lose shutdown function, so it is recommended to use PWRKEY to power | ||
* on the module and RESET key only used as reset function. | ||
*/ | ||
void A7682E_reset(void) | ||
{ | ||
pinMode(BOARD_A7682E_RST, OUTPUT); | ||
digitalWrite(BOARD_A7682E_RST, HIGH); | ||
delay(100); | ||
digitalWrite(BOARD_A7682E_RST, LOW); | ||
delay(2500); // Pull down for at least 2 seconds to reset | ||
digitalWrite(BOARD_A7682E_RST, HIGH); | ||
} | ||
/** | ||
* | ||
*/ | ||
void A7682E_power_on(void) | ||
{ | ||
digitalWrite(BOARD_A7682E_PWRKEY, LOW); | ||
delay(10); | ||
digitalWrite(BOARD_A7682E_PWRKEY, HIGH); | ||
delay(50); | ||
digitalWrite(BOARD_A7682E_PWRKEY, LOW); | ||
delay(10); | ||
} | ||
/** | ||
* | ||
*/ | ||
void A7682E_power_off(void) | ||
{ | ||
digitalWrite(BOARD_A7682E_PWRKEY, LOW); | ||
delay(10); | ||
digitalWrite(BOARD_A7682E_PWRKEY, HIGH); | ||
delay(3000); | ||
digitalWrite(BOARD_A7682E_PWRKEY, LOW); | ||
delay(10); | ||
} | ||
|
||
void setup(void) | ||
{ | ||
// enable A7682 module power | ||
pinMode(BOARD_A7682E_POWER_EN, OUTPUT); | ||
digitalWrite(BOARD_A7682E_POWER_EN, HIGH); | ||
|
||
SerialMon.begin(115200); | ||
SerialAT.begin(115200, SERIAL_8N1, BOARD_A7682E_TXD, BOARD_A7682E_RXD); | ||
|
||
// Power on the modem PWRKEY | ||
pinMode(BOARD_A7682E_PWRKEY, OUTPUT); | ||
digitalWrite(BOARD_A7682E_PWRKEY, HIGH); | ||
|
||
delay(2000); | ||
|
||
#ifdef BOARD_A7682E_RST | ||
// Release reset GPIO hold | ||
gpio_hold_dis((gpio_num_t)BOARD_A7682E_RST); | ||
|
||
// Set modem reset pin ,reset modem | ||
// The module will also be started during reset. | ||
Serial.println("Set Reset Pin."); | ||
A7682E_reset(); | ||
#endif | ||
|
||
// A7682 Power on | ||
Serial.println("Power on the modem PWRKEY."); | ||
A7682E_power_on(); | ||
|
||
// UART is ready to exit from the sleep mode if DTR pin is pulled down | ||
pinMode(BOARD_A7682E_DTR, OUTPUT); | ||
digitalWrite(BOARD_A7682E_DTR, LOW); | ||
|
||
int i = 10; | ||
Serial.println("\nTesting Modem Response...\n"); | ||
Serial.println("****"); | ||
while (i) | ||
{ | ||
SerialAT.println("AT"); | ||
delay(500); | ||
if (SerialAT.available()) | ||
{ | ||
String r = SerialAT.readString(); | ||
SerialAT.println(r); | ||
if (r.indexOf("OK") >= 0) | ||
{ | ||
reply = true; | ||
break; | ||
} | ||
} | ||
delay(500); | ||
i--; | ||
} | ||
Serial.println("****\n"); | ||
|
||
if (reply) | ||
{ | ||
Serial.println(F("***********************************************************")); | ||
Serial.println(F(" You can now send AT commands")); | ||
Serial.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\"")); | ||
Serial.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor")); | ||
Serial.println(F(" DISCLAIMER: Entering AT commands without knowing what they do")); | ||
Serial.println(F(" can have undesired consiquinces...")); | ||
Serial.println(F("***********************************************************\n")); | ||
} | ||
else | ||
{ | ||
Serial.println(F("***********************************************************")); | ||
Serial.println(F(" Failed to connect to the modem! Check the baud and try again.")); | ||
Serial.println(F("***********************************************************\n")); | ||
} | ||
} | ||
|
||
void loop(void) | ||
{ | ||
// while (SerialAT.available()) | ||
// { | ||
// SerialMon.write(SerialAT.read()); | ||
// } | ||
// while (SerialMon.available()) | ||
// { | ||
// SerialAT.write(SerialMon.read()); | ||
// } | ||
|
||
// 检查是否有可读取的串口数据 | ||
if (Serial.available() > 0) | ||
{ | ||
char inputChar = Serial.read(); // 读取一个字符 | ||
Serial.print("recvice commend:"); | ||
Serial.println(inputChar); | ||
|
||
// 根据输入的字符输出不同的消息 | ||
switch (inputChar) | ||
{ | ||
case 'o': | ||
Serial.println("A7682 Power on"); | ||
A7682E_power_on(); | ||
break; | ||
case 'f': | ||
Serial.println("A7682 Power off"); | ||
A7682E_power_off(); | ||
break; | ||
case 'r': | ||
Serial.println("A7682 reset"); | ||
A7682E_reset(); | ||
break; | ||
default: | ||
Serial.println("input 'o', 'f' or 'r'"); | ||
break; | ||
} | ||
} | ||
} |
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,14 @@ | ||
#pragma once | ||
|
||
|
||
#define SerialMon Serial | ||
#define SerialAT Serial1 | ||
|
||
// A7682E Modem | ||
#define BOARD_A7682E_POWER_EN 41 // enable 7682 module | ||
#define BOARD_A7682E_RI 7 | ||
#define BOARD_A7682E_DTR 8 | ||
#define BOARD_A7682E_RST 9 | ||
#define BOARD_A7682E_RXD 10 | ||
#define BOARD_A7682E_TXD 11 | ||
#define BOARD_A7682E_PWRKEY 40 |
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,38 @@ | ||
## Some AT command test | ||
|
||
| command | explain | Response | | ||
| ------------ | ------------------------------------ | ------------ | | ||
| AT | AT test instruction | OK | | ||
| ATI | version information | | | ||
| AT+CPIN? | Example Query the SIM card status | +CPIN: READY | | ||
| AT+CGREG? | Network Registration Status | +CGREG: 0,1 | | ||
| AT+CSQ | Network signal quality query | | | ||
| AT+COPS? | Querying current Carrier Information | | | ||
|
||
Refer to the T-A7670X instruction manual for more [AT instructions](../../../hardware/A76XX_series/A76XX_Series_AT_Command_Manual_V1.09.pdf) | ||
|
||
|
||
## File System | ||
|
||
|
||
## Audio AT test | ||
|
||
1. `AT+CTTSPARAM=1,3,0,1,1` : TTS parameters setting | ||
2. `AT+CTTS=2,"1234567890"`:synth and play ASCII text | ||
|
||
AT+CTTSPARAM=1,3,0,1,1,1 | ||
AT+CTTS=2,"1234567890" | ||
|
||
|
||
AT+CCMXPLAY="c:/iPhone_Ring.mp3",0,255 | ||
AT+CCMXSTOP | ||
|
||
More audio application references [A76XX Series_Audio_Application Note](../../../hardware/A76XX_series/A76XX%20Series_Audio_Application%20Note_V1.03.pdf) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,14 @@ | ||
#pragma once | ||
|
||
|
||
#define SerialMon Serial | ||
#define SerialAT Serial1 | ||
|
||
// A7682E Modem | ||
#define BOARD_A7682E_POWER_EN 41 // enable 7682 module | ||
#define BOARD_A7682E_RI 7 | ||
#define BOARD_A7682E_DTR 8 | ||
#define BOARD_A7682E_RST 9 | ||
#define BOARD_A7682E_RXD 10 | ||
#define BOARD_A7682E_TXD 11 | ||
#define BOARD_A7682E_PWRKEY 40 |
Empty file.
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,123 @@ | ||
|
||
#include <Wire.h> | ||
#include <SPI.h> | ||
#include <Arduino.h> | ||
#include "SensorBHI260AP.hpp" | ||
#include "utilities.h" | ||
#include "peripheral.h" | ||
|
||
SensorBHI260AP bhy; | ||
struct bhy2_data_xyz accel_data; | ||
struct bhy2_data_xyz gyro_data; | ||
struct bhy2_data_xyz magn_data; | ||
|
||
float accel_factor; | ||
float gyro_factor; | ||
float magn_factor; | ||
|
||
void accel_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp) | ||
{ | ||
accel_factor = get_sensor_default_scaling(sensor_id); | ||
bhy2_parse_xyz(data_ptr, &accel_data); | ||
// Serial.print(bhy.getSensorName(sensor_id)); | ||
// Serial.print(":"); | ||
// Serial.printf("x: %f, y: %f, z: %f;\r\n", | ||
// accel_data.x * accel_factor, | ||
// accel_data.y * accel_factor, | ||
// accel_data.z * accel_factor | ||
// ); | ||
} | ||
|
||
void gyro_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp) | ||
{ | ||
gyro_factor = get_sensor_default_scaling(sensor_id); | ||
bhy2_parse_xyz(data_ptr, &gyro_data); | ||
// Serial.print(bhy.getSensorName(sensor_id)); | ||
// Serial.print(":"); | ||
// Serial.printf("x: %f, y: %f, z: %f;\r\n", | ||
// gyro_data.x * gyro_factor, | ||
// gyro_data.y * gyro_factor, | ||
// gyro_data.z * gyro_factor | ||
// ); | ||
} | ||
|
||
void magn_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp) | ||
{ | ||
magn_factor = get_sensor_default_scaling(sensor_id); | ||
bhy2_parse_xyz(data_ptr, &magn_data); | ||
Serial.print(bhy.getSensorName(sensor_id)); | ||
// Serial.print(":"); | ||
// Serial.printf("x: %f, y: %f, z: %f;\r\n", | ||
// magn_data.x * magn_factor, | ||
// magn_data.y * magn_factor, | ||
// magn_data.z * magn_factor | ||
// ); | ||
} | ||
|
||
/** | ||
* int val_type | ||
* 1 --- acceleration | ||
* 2 --- gyroscope | ||
* 3 --- Magnetometer | ||
*/ | ||
void BHI260AP_get_val(int val_type, float *x, float *y, float *z) | ||
{ | ||
bhy.update(); | ||
|
||
switch (val_type) { | ||
case 1: | ||
*x = accel_data.x * accel_factor; | ||
*y = accel_data.y * accel_factor; | ||
*z = accel_data.z * accel_factor; | ||
break; | ||
case 2 : | ||
*x = gyro_data.x * gyro_factor; | ||
*y = gyro_data.y * gyro_factor; | ||
*z = gyro_data.z * gyro_factor; | ||
break; | ||
case 3: | ||
*x = magn_data.x * magn_factor; | ||
*y = magn_data.y * magn_factor; | ||
*z = magn_data.z * magn_factor; | ||
break; | ||
default: | ||
*x = 0; | ||
*y = 0; | ||
*z = 0; | ||
break; | ||
} | ||
} | ||
|
||
bool BHI260AP_init(void) | ||
{ | ||
// Set the reset pin and interrupt pin, if any | ||
bhy.setPins(BOARD_GYROSCOPDE_RST, BOARD_GYROSCOPDE_INT); | ||
|
||
if (!bhy.init(Wire, BOARD_I2C_SDA, BOARD_I2C_SCL, BHI260AP_SLAVE_ADDRESS_L)) { | ||
Serial.print("Failed to init BHI260AP - "); | ||
Serial.println(bhy.getError()); | ||
return false; | ||
} | ||
|
||
// Output all available sensors to Serial | ||
// bhy.printSensors(Serial); | ||
|
||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */ | ||
uint32_t report_latency_ms = 0; /* Report immediately */ | ||
|
||
// Enable acceleration | ||
bhy.configure(SENSOR_ID_ACC_PASS, sample_rate, report_latency_ms); | ||
// Enable gyroscope | ||
bhy.configure(SENSOR_ID_GYRO_PASS, sample_rate, report_latency_ms); | ||
|
||
// Set the acceleration sensor result callback function | ||
bhy.onResultEvent(SENSOR_ID_ACC_PASS, accel_process_callback); | ||
|
||
// Set the gyroscope sensor result callback function | ||
bhy.onResultEvent(SENSOR_ID_GYRO_PASS, gyro_process_callback); | ||
|
||
// Set the Magnetometer sensor result callback function | ||
bhy.onResultEvent(SENSOR_ID_MAG_PASS, magn_process_callback); | ||
|
||
return true; | ||
} |
Oops, something went wrong.