config file created

This commit is contained in:
Robin Müller 2020-10-12 23:49:49 +02:00
parent efdb44b759
commit 8c5bb21d70
2 changed files with 22 additions and 5 deletions

8
ArduinoConfig.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef ARDUINOCONFIG_H_
#define ARDUINOCONFIG_H_
#define BAUD_RATE 115200
#define SERIAL_RX_BUFFER_SIZE 256
#define RING_BUFFER_SIZE 100
#endif /* ARDUINOCONFIG_H_ */

View File

@ -1,5 +1,6 @@
#include <Arduino.h> #include <Arduino.h>
#include "ArduinoConfig.h"
#include "helper/SimpleRingBuffer.h" #include "helper/SimpleRingBuffer.h"
#include "helper/DleEncoder.h" #include "helper/DleEncoder.h"
#include "helper/crc_ccitt.h" #include "helper/crc_ccitt.h"
@ -14,9 +15,9 @@
#define CS_PORT PORTC #define CS_PORT PORTC
#define CS_DDR DDRC #define CS_DDR DDRC
#define RING_BUFFER_SIZE 100
#define MAX_PACKET_LENGTH 100 #define MAX_PACKET_LENGTH 100
#define SERIAL_RX_BUFFER_SIZE 256
static const uint8_t COMMAND_TRANSFER_SPI = 1; static const uint8_t COMMAND_TRANSFER_SPI = 1;
@ -91,7 +92,10 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
//check reply: //check reply:
Serial.println("Data response check: "); Serial.println("Data response check: ");
for(size_t i =0; i< packetLen; i++){ for(size_t i =0; i< packetLen; i++){
Serial.print("packet nr ");Serial.print(i);Serial.print(" ");Serial.println(packet[i]); Serial.print("packet nr ");
Serial.print(i);
Serial.print(" ");
Serial.println(packet[i]);
} }
sendData(packet, packetLen); sendData(packet, packetLen);
break; break;
@ -149,7 +153,7 @@ void handleNewData() {
//TODO check if this is thread safe by arduino //TODO check if this is thread safe by arduino
void serialEvent() { void serialEvent() {
//Serial.println(ringBuffer.availableWriteSpace()); //Serial.println(ringBuffer.availableWriteSpace());
uint8_t i = 0; //uint8_t i = 0;
while (Serial.available()>0) { while (Serial.available()>0) {
uint8_t byte = Serial.read(); uint8_t byte = Serial.read();
@ -161,7 +165,12 @@ void serialEvent() {
void setup() { void setup() {
CS_DDR = 0xff; CS_DDR = 0xff;
CS_PORT = 0xff; CS_PORT = 0xff;
Serial.begin(9600); Serial.begin(BAUD_RATE);
Serial.println("Setting up Arduino IO interface board.");
Serial.print("Configured baud rate for serial communication: ");
Serial.println(BAUD_RATE, DEC);
Serial.print("Size of serial receiver buffer: ");
Serial.print(SERIAL_RX_BUFFER_SIZE, DEC);Serial.print(" bytes");
SPI.begin(); SPI.begin();
} }