Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/AutomationCarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "utility/QEI/QEI.h"
#include "utility/ioexpander/TCA6424A.h"

#include "Arduino.h"
#include "mbed.h"

namespace automation {
Expand All @@ -25,12 +26,14 @@ class RTDClass {
}
}

Adafruit_MAX31865 rtd = Adafruit_MAX31865(PA_6);
THERMClass t = THERMClass(7);
Adafruit_MAX31865 rtd = Adafruit_MAX31865(cs_rtd);
THERMClass t = THERMClass(cs_tc);

private:
mbed::DigitalOut ch_sel[3] = { mbed::DigitalOut(PA_0), mbed::DigitalOut(PI_4), mbed::DigitalOut(PJ_9) };
mbed::DigitalOut rtd_th = mbed::DigitalOut(PH_9);
mbed::DigitalOut ch_sel[3] = { mbed::DigitalOut(PA_0), mbed::DigitalOut(PI_4), mbed::DigitalOut(PG_10) };
mbed::DigitalOut rtd_th = mbed::DigitalOut(PC_15);
mbed::DigitalOut cs_tc = mbed::DigitalOut(PI_0);
mbed::DigitalOut cs_rtd = mbed::DigitalOut(PA_6);
};

extern RTDClass temp_probes;
Expand All @@ -46,11 +49,10 @@ class COMMClass {
can_disable = 1;
}

UART _UART4_ = arduino::UART(PA_0, PI_9, PI_10, PI_13);
UART _UART4_ = arduino::UART(PA_0, PI_9, NC, NC);
mbed::CAN& can = _can;

RS485Class rs485 = RS485Class(_UART4_);

RS485Class rs485 = RS485Class(_UART4_,PA_0, PI_13,PI_10);
private:
mbed::DigitalOut can_disable = mbed::DigitalOut(PA_13, 0);

Expand Down Expand Up @@ -192,7 +194,7 @@ class DigitalOutputsClass {
}
private:
mbed::DigitalOut out[8] = {
mbed::DigitalOut(PI_6), mbed::DigitalOut(PC_15), mbed::DigitalOut(PG_10), mbed::DigitalOut(PE_2),
mbed::DigitalOut(PI_6), mbed::DigitalOut(PH_9), mbed::DigitalOut(PJ_9), mbed::DigitalOut(PE_2),
mbed::DigitalOut(PI_3), mbed::DigitalOut(PI_2), mbed::DigitalOut(PD_3), mbed::DigitalOut(PA_14)
};
};
Expand Down
22 changes: 11 additions & 11 deletions src/utility/ArduinoRS485/src/RS485.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "RS485.h"

RS485Class::RS485Class(HardwareSerial& hwSerial, int txPin, int dePin, int rePin) :
RS485Class::RS485Class(HardwareSerial& hwSerial, PinName txPin, PinName dePin, PinName rePin) :
_serial(&hwSerial),
_txPin(txPin),
_dePin(dePin),
Expand All @@ -38,12 +38,12 @@ void RS485Class::begin(unsigned long baudrate, uint16_t config)
_baudrate = baudrate;
_config = config;

if (_dePin > -1) {
if (_dePin != NC) {
pinMode(_dePin, OUTPUT);
digitalWrite(_dePin, LOW);
}

if (_rePin > -1) {
if (_rePin != NC) {
pinMode(_rePin, OUTPUT);
digitalWrite(_rePin, HIGH);
}
Expand All @@ -57,12 +57,12 @@ void RS485Class::end()
{
_serial->end();

if (_rePin > -1) {
if (_rePin != NC) {
digitalWrite(_rePin, LOW);
pinMode(_dePin, INPUT);
}

if (_dePin > -1) {
if (_dePin != NC) {
digitalWrite(_dePin, LOW);
pinMode(_rePin, INPUT);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ void RS485Class::endTransmission()
{
_serial->flush();

if (_dePin > -1) {
if (_dePin != NC) {
delayMicroseconds(50);
digitalWrite(_dePin, LOW);
}
Expand All @@ -127,14 +127,14 @@ void RS485Class::endTransmission()

void RS485Class::receive()
{
if (_rePin > -1) {
if (_rePin != NC) {
digitalWrite(_rePin, LOW);
}
}

void RS485Class::noReceive()
{
if (_rePin > -1) {
if (_rePin != NC) {
digitalWrite(_rePin, HIGH);
}
}
Expand All @@ -143,7 +143,7 @@ void RS485Class::sendBreak(unsigned int duration)
{
_serial->flush();
_serial->end();
if (_txPin > -1) {
if (_txPin != NC) {
pinMode(_txPin, OUTPUT);
digitalWrite(_txPin, LOW);
}
Expand All @@ -155,15 +155,15 @@ void RS485Class::sendBreakMicroseconds(unsigned int duration)
{
_serial->flush();
_serial->end();
if (_txPin > -1) {
if (_txPin != NC) {
pinMode(_txPin, OUTPUT);
digitalWrite(_txPin, LOW);
}
delayMicroseconds(duration);
_serial->begin(_baudrate, _config);
}

void RS485Class::setPins(int txPin, int dePin, int rePin)
void RS485Class::setPins(PinName txPin, PinName dePin, PinName rePin)
{
_txPin = txPin;
_dePin = dePin;
Expand Down
12 changes: 7 additions & 5 deletions src/utility/ArduinoRS485/src/RS485.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <Arduino.h>

#include "mbed.h"

#ifdef PIN_SERIAL1_TX
#define RS485_DEFAULT_TX_PIN PIN_SERIAL1_TX
#else
Expand All @@ -38,7 +40,7 @@

class RS485Class : public Stream {
public:
RS485Class(HardwareSerial& hwSerial, int txPin = -1, int dePin = -1, int rePin = -1);
RS485Class(HardwareSerial& hwSerial, PinName txPin = NC, PinName dePin = NC, PinName rePin = NC);

virtual void begin(unsigned long baudrate);
virtual void begin(unsigned long baudrate, uint16_t config);
Expand All @@ -59,7 +61,7 @@ class RS485Class : public Stream {
void sendBreak(unsigned int duration);
void sendBreakMicroseconds(unsigned int duration);

void setPins(int txPin, int dePin, int rePin);
void setPins(PinName txPin, PinName dePin, PinName rePin);

mbed::DigitalOut half_duplex = mbed::DigitalOut(PA_9);
mbed::DigitalOut sel_485 = mbed::DigitalOut(PA_10);
Expand All @@ -70,9 +72,9 @@ class RS485Class : public Stream {

private:
HardwareSerial* _serial;
int _txPin;
int _dePin = -1;
int _rePin = -1;
PinName _txPin;
PinName _dePin = NC;
PinName _rePin = NC;


bool _transmisionBegun;
Expand Down