mirror of
https://github.com/aster94/logic-analyzer.git
synced 2026-05-02 08:35:21 +03:00
Integration of all boards
Added a way to every board work with a single one processing code.
This commit is contained in:
@@ -9,12 +9,13 @@
|
||||
|
||||
#define baudrate 115200 // check if it is the same in processing
|
||||
#define samples 200 // the number of samples you want to take
|
||||
#define boardLed PB1
|
||||
#define boardLed PA1
|
||||
|
||||
|
||||
|
||||
uint8_t initial, state, old_state;
|
||||
uint8_t pinChanged[samples];
|
||||
uint16_t initial, state, old_state;
|
||||
uint16_t pinChanged[samples];
|
||||
uint8_t initial1, initial2, pinChanged1, pinChanged2;
|
||||
uint32_t timer[samples];
|
||||
uint16_t event = 0;
|
||||
|
||||
@@ -27,7 +28,18 @@ void setup() {
|
||||
|
||||
pinMode (boardLed, OUTPUT);
|
||||
digitalWrite(boardLed, LOW);
|
||||
|
||||
pinMode(PB0, INPUT_PULLUP);
|
||||
pinMode(PB1, INPUT_PULLUP);
|
||||
pinMode(PB2, INPUT_PULLUP);
|
||||
pinMode(PB3, INPUT_PULLUP);
|
||||
pinMode(PB4, INPUT_PULLUP);
|
||||
pinMode(PB5, INPUT_PULLUP);
|
||||
pinMode(PB6, INPUT_PULLUP);
|
||||
pinMode(PB7, INPUT_PULLUP);
|
||||
pinMode(PB8, INPUT_PULLUP);
|
||||
pinMode(PB9, INPUT_PULLUP);
|
||||
pinMode(PB10, INPUT_PULLUP);
|
||||
pinMode(PB11, INPUT_PULLUP);
|
||||
pinMode(PB12, INPUT_PULLUP);
|
||||
pinMode(PB13, INPUT_PULLUP);
|
||||
pinMode(PB14, INPUT_PULLUP);
|
||||
@@ -45,15 +57,20 @@ void startLA() {
|
||||
digitalWrite(boardLed, HIGH);
|
||||
|
||||
reset_timer();
|
||||
initial = GPIOB->regs->IDR >> 12;
|
||||
initial = GPIOB->regs->IDR;
|
||||
state = initial;
|
||||
for (int i=0; i < samples; i++) {
|
||||
pinChanged[i]=0;
|
||||
//Serial.print(pinChanged1[i]); Serial.print(','); Serial.print(pinChanged2[i]); Serial.print(','); Serial.println(pinChanged3[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
old_state = state;
|
||||
state = GPIOB->regs->IDR >> 12;
|
||||
state = GPIOB->regs->IDR;
|
||||
|
||||
if (old_state != state) {
|
||||
timer[event] = micros();
|
||||
@@ -72,15 +89,27 @@ void sendData() {
|
||||
digitalWrite(boardLed, LOW);
|
||||
|
||||
//initial data
|
||||
initial1=initial;
|
||||
initial2=initial>>8;
|
||||
Serial.println("S");
|
||||
Serial.print(initial); Serial.print(":");
|
||||
Serial.println(samples);
|
||||
|
||||
//data
|
||||
Serial.print(initial1); Serial.print(','); Serial.print(initial2); Serial.print(','); Serial.print(B00000000); Serial.print(":");
|
||||
Serial.println(samples+2);
|
||||
timefix = -timer[0]+timezerooffset;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
Serial.print(pinChanged[i]); Serial.print(":");
|
||||
timer[i]=timer[i]+timefix;
|
||||
}
|
||||
Serial.print(B11111111);Serial.print(','); Serial.print(B11111111); Serial.print(','); Serial.print(B11111111); Serial.print(":");//Este segmento de codigo introduce un cambio en todos los
|
||||
Serial.println(0); //canales, lo que soluciona un error en el codigo en processing
|
||||
//al final se hace un cambio en todos los canales, lo que soluciona //otro pequeño fallo visual.
|
||||
//data
|
||||
for (int i = 0; i < samples; i++) {
|
||||
pinChanged1=pinChanged;
|
||||
pinChanged2=pinChanged>>8;
|
||||
Serial.print(pinChanged1);Serial.print(','); Serial.print(pinChanged2); Serial.print(','); Serial.print(B00000000); Serial.print(":");
|
||||
Serial.println(timer[i]);
|
||||
}
|
||||
Serial.print(B11111111);Serial.print(','); Serial.print(B11111111); Serial.print(','); Serial.print(B11111111); Serial.print(":");
|
||||
Serial.println((timer[samples-1]+400));
|
||||
}
|
||||
|
||||
void reset_timer() {
|
||||
|
||||
Reference in New Issue
Block a user