forked from mohr/ArduinoIO
config file created
This commit is contained in:
parent
efdb44b759
commit
8c5bb21d70
8
ArduinoConfig.h
Normal file
8
ArduinoConfig.h
Normal 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_ */
|
19
main.cpp
19
main.cpp
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user