Skip to content
Snippets Groups Projects
Commit 577da5f3 authored by nrs1g15's avatar nrs1g15
Browse files

Added wireless with default pin setup

parent 3fb852ea
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#define SD_FILE_NAME "DATA.BIN" #define SD_FILE_NAME "DATA.BIN"
#define SD_WRITES_BEFORE_FLUSH 2 #define SD_WRITES_BEFORE_FLUSH 2
#define SD_START_TRY_AGAIN_MS 1000
uint8_t sdBegin(); uint8_t sdBegin();
void sdWrite(void *data, uint8_t len); void sdWrite(void *data, uint8_t len);
......
...@@ -5,11 +5,7 @@ ...@@ -5,11 +5,7 @@
#include "ecuCan.h" #include "ecuCan.h"
#include "can.h" #include "can.h"
#include "dashController.h" #include "dashController.h"
#include "wireless.h"
// Watchdog
#include <avr/wdt.h>
#define OPENLOGGER_SERIAL_BUAD_RATE 115200
void setup() void setup()
{ {
...@@ -19,13 +15,15 @@ void setup() ...@@ -19,13 +15,15 @@ void setup()
// Serial port for host pc communications // Serial port for host pc communications
Serial.begin(115200); Serial.begin(115200);
Serial.println("BEGIN"); // Serial.println("BEGIN");
dashBegin(); dashBegin();
sdBegin(); sdBegin();
canBegin(); canBegin();
wirelessBegin();
} }
void loop() void loop()
...@@ -35,9 +33,10 @@ void loop() ...@@ -35,9 +33,10 @@ void loop()
/* /*
* ALL PROCESSES *MUST* BE NON BLOCKING * ALL PROCESSES *MUST* BE NON BLOCKING
*/ */
canProcessRx(); canProcessRx();
dashControllerProcess(); dashControllerProcess();
sdProcess(); sdProcess();
wirelessProcess();
//canProcessTx(); canProcessTx();
} }
\ No newline at end of file
//
// Created by Sil on 30/07/2019.
//
#include "wireless.h"
#include <XBee.h>
#include "buffer.h"
XBee xbee;
XBeeAddress64 xbeeAddress64(XBEE_ADDRESS_UPPER, XBEE_ADDRESS_LOWER);
Tx64Request tx64Request(xbeeAddress64, 0, 0);
uint8_t wirelessTxBuffer[WIRELESS_TX_BUFFER_LEN];
CirBuffer wirelessTxCirBuffer;
uint8_t wirelessBegin()
{
XBEE_SERIAL.begin(XBEE_SERIAL_BAUD_RATE);
xbee.setSerial(XBEE_SERIAL);
pinMode(XBEE_CTS_PIN, INPUT);
pinMode(XBEE_RTS_PIN, OUTPUT);
digitalWrite(XBEE_RTS_PIN, LOW);
return cirBufferBegin(&wirelessTxCirBuffer, wirelessTxBuffer, WIRELESS_TX_BUFFER_LEN, sizeof(uint8_t));
}
void wirelessWrite(void *data, uint8_t len)
{
cirBufferWriteBytes(&wirelessTxCirBuffer, data, len);
}
void wirelessProcess()
{
if (!digitalRead(XBEE_RTS_PIN)) {
if (XBEE_SERIAL.availableForWrite() >= WIRELESS_PAYLOAD_LEN) {
static uint8_t payload[WIRELESS_PAYLOAD_LEN];
tx64Request.setPayload(payload);
tx64Request.setPayloadLength(WIRELESS_PAYLOAD_LEN);
cirBufferReadBytes(&wirelessTxCirBuffer, payload, WIRELESS_PAYLOAD_LEN);
xbee.send(tx64Request);
}
}
}
\ No newline at end of file
//
// Created by Sil on 30/07/2019.
//
#ifndef WIRELESS_H
#define WIRELESS_H
#include "Arduino.h"
#define XBEE_ADDRESS_UPPER 0x0013A200
#define XBEE_ADDRESS_LOWER 0x410AC922
#define XBEE_CTS_PIN 6
#define XBEE_RTS_PIN 7
#define XBEE_SERIAL_BAUD_RATE 115200
#define XBEE_SERIAL Serial1
#define WIRELESS_TX_BUFFER_LEN 256
#define WIRELESS_PAYLOAD_LEN 32
uint8_t wirelessBegin();
void wirelessWrite(void *data, uint8_t len);
void wirelessProcess();
#endif //WIRELESS_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment