mirror of
https://github.com/sascha-hemi/HGD4_reversed.git
synced 2026-03-21 05:06:25 +01:00
@@ -18,5 +18,5 @@ lib_deps =
|
||||
adafruit/Adafruit Unified Sensor@^1.1.15
|
||||
adafruit/Adafruit LIS3DH@^1.3.0
|
||||
sparkfun/SparkFun Ambient Light Sensor Arduino Library@^1.0.4
|
||||
build_unflags = "-DNRF52"
|
||||
build_flags = "-DNRF52840_XXAA"
|
||||
build_unflags = -DNRF52 -DUSE_LFXO
|
||||
build_flags = -DNRF52840_XXAA -DUSE_LFRC
|
||||
@@ -16,70 +16,72 @@ ENS210 ens210;
|
||||
|
||||
Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
|
||||
|
||||
void testallpins();
|
||||
void test1pin(int i,int d);
|
||||
void busscan();
|
||||
void measuretemp();
|
||||
void lightsense();
|
||||
void powerupesp();
|
||||
|
||||
void in1_handler() {
|
||||
digitalWrite(10,HIGH);
|
||||
delay(1);
|
||||
digitalWrite(10,LOW);
|
||||
digitalWrite(DONE,HIGH);
|
||||
delay(1);
|
||||
digitalWrite(DONE,LOW);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
//latch on the main power
|
||||
pinMode(2, OUTPUT);
|
||||
digitalWrite(2, HIGH);
|
||||
pinMode(PWR_LATCH , OUTPUT);
|
||||
digitalWrite(PWR_LATCH , HIGH);
|
||||
//setup watchdog feeding
|
||||
pinMode(10, OUTPUT);
|
||||
pinMode(9, INPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(9), in1_handler, RISING);
|
||||
pinMode(WAKE, INPUT);
|
||||
pinMode(DONE, OUTPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(WAKE), in1_handler, RISING);
|
||||
//setup Serial
|
||||
Serial.begin(115200);
|
||||
//setup I2C bus
|
||||
Wire.begin();
|
||||
//set i2c pins
|
||||
pinMode(15, OUTPUT);
|
||||
pinMode(I2C_SDA, OUTPUT);
|
||||
//needed for some boards
|
||||
in1_handler();
|
||||
//set up leds
|
||||
pinMode(RED_LED,OUTPUT);
|
||||
pinMode(GREEN_LED,OUTPUT);
|
||||
delay(100);
|
||||
digitalWrite(RED_LED,HIGH);
|
||||
digitalWrite(GREEN_LED,HIGH);
|
||||
}
|
||||
|
||||
int ptt = 34;
|
||||
int ptt = 0;
|
||||
|
||||
void loop() {
|
||||
Serial.println("loop");
|
||||
busscan();
|
||||
//powerupesp();
|
||||
//powerupmodem();
|
||||
measuretemp();
|
||||
lightsense();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void powerupesp(){
|
||||
Serial.println("powering up esp");
|
||||
pinMode(29,OUTPUT);
|
||||
digitalWrite(29,HIGH);
|
||||
pinMode(45,OUTPUT);
|
||||
digitalWrite(45,HIGH);
|
||||
delay(600);
|
||||
}
|
||||
|
||||
void powerupmodem(){
|
||||
Serial.println("powering up modem");
|
||||
pinMode(29,OUTPUT);
|
||||
digitalWrite(29,HIGH);
|
||||
delay(600);
|
||||
pinMode(34,OUTPUT);
|
||||
digitalWrite(34,HIGH);
|
||||
delay(600);
|
||||
digitalWrite(34,LOW);
|
||||
delay(600);
|
||||
//testallpins();
|
||||
//measuretemp();
|
||||
//lightsense();
|
||||
//pinMode(ptt,OUTPUT);
|
||||
//digitalWrite(ptt,HIGH);
|
||||
//delay(100);
|
||||
//digitalWrite(ptt,LOW);
|
||||
//delay(100);
|
||||
}
|
||||
|
||||
void test1pin(int i,int d){
|
||||
Serial.println("Testing Pin with number");
|
||||
Serial.println(i);
|
||||
pinMode(i, OUTPUT);
|
||||
for (size_t j = 0; j < 100; j++)
|
||||
{
|
||||
delay(d);
|
||||
digitalWrite(i, HIGH);
|
||||
delay(d);
|
||||
digitalWrite(i, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void lightsense(){
|
||||
@@ -166,20 +168,4 @@ void busscan(){
|
||||
Serial.println("No I2C devices found\n");
|
||||
else
|
||||
Serial.println("done\n");
|
||||
}
|
||||
|
||||
void testallpins(){
|
||||
for (size_t i = 36; i < 64; i++){
|
||||
if(i != 2 && i != 29){
|
||||
Serial.println(String(i));
|
||||
for (size_t j= 0; j < 50; j++)
|
||||
{
|
||||
pinMode(i, OUTPUT);
|
||||
digitalWrite(i, HIGH);
|
||||
delay(50);
|
||||
digitalWrite(i, LOW);
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,31 +35,30 @@ extern "C"
|
||||
#define NUM_ANALOG_INPUTS (6u)
|
||||
#define NUM_ANALOG_OUTPUTS (0u)
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (13) // P0.13
|
||||
#define LED_BUILTIN PIN_LED
|
||||
// PIN setup
|
||||
#define GREEN_LED (0)
|
||||
#define RED_LED (1)
|
||||
#define LED_BUILTIN GREEN_LED
|
||||
#define PWR_LATCH (2)
|
||||
#define WAKE (9)
|
||||
#define DONE (10)
|
||||
#define I2C_SCL (13)
|
||||
#define I2C_SDA (15)
|
||||
|
||||
/*
|
||||
* Analog pins
|
||||
*/
|
||||
#define PIN_A0 (1) // P0.01
|
||||
#define PIN_A1 (2) // P0.02
|
||||
#define PIN_A2 (3) // P0.03
|
||||
#define PIN_A3 (4) // P0.04
|
||||
#define PIN_A4 (5) // P0.05
|
||||
#define PIN_A5 (6) // P0.06
|
||||
|
||||
static const uint8_t A0 = PIN_A0 ;
|
||||
static const uint8_t A1 = PIN_A1 ;
|
||||
static const uint8_t A2 = PIN_A2 ;
|
||||
static const uint8_t A3 = PIN_A3 ;
|
||||
static const uint8_t A4 = PIN_A4 ;
|
||||
static const uint8_t A5 = PIN_A5 ;
|
||||
#if defined(NRF52_SERIES)
|
||||
|
||||
#define ADC_RESOLUTION 14
|
||||
#else
|
||||
#define ADC_RESOLUTION 10
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Serial interfaces
|
||||
@@ -87,8 +86,8 @@ static const uint8_t SCK = PIN_SPI_SCK ;
|
||||
*/
|
||||
#define WIRE_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_WIRE_SDA (15)
|
||||
#define PIN_WIRE_SCL (13)
|
||||
#define PIN_WIRE_SDA (I2C_SDA)
|
||||
#define PIN_WIRE_SCL (I2C_SCL)
|
||||
|
||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||
|
||||
Reference in New Issue
Block a user