Skip to content
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
48 changes: 48 additions & 0 deletions sblib/inc/sblib/eib/bcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,48 @@ class BCU
*/
void begin(int manufacturer, int deviceType, int version);

/**
* Set RxPin of board, must be called before begin method
* @param rxPin pin definition
*/
void setRxPin(int rxPin) {
bus.rxPin=rxPin;
}
/**
* Set TxPin of board, must be called before begin method
* @param txPin pin definition
*/
void setTxPin(int txPin) {
bus.txPin=txPin;
}
/**
* Set timer class, must be called before begin method
* @param timer
*/
void setTimer(Timer& timer) {
bus.timer=timer;
}
/**
* Set capture channel of processor, must be called before begin method
* @param capture channel definition of processor
*/
void setCaptureChannel(TimerCapture captureChannel) {
bus.captureChannel=captureChannel;
}
/**
* Set ProgPin of board, must be called before begin method
* @param progPin Pin definition
*/
void setProgPin(int prgPin) {
progPin=prgPin;
}
/**
* Set ProgPin output inverted, must be called before begin method
* @param progPin output inverted
*/
void setProgPinInverted(int prgPinInv) {
progPinInv=prgPinInv;
}
/**
* End using the EIB bus coupling unit.
*/
Expand Down Expand Up @@ -125,6 +167,12 @@ class BCU
*/
int progPin;

/**
* Programming LED output inverted: If set to 1 the programming LED output is
* being inverted
*/
int progPinInv;

protected:
/**
* Process a unicast connection control telegram with our physical address as
Expand Down
12 changes: 12 additions & 0 deletions sblib/inc/sblib/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ class Serial: public BufferedStream
*/
Serial(int rxPin, int txPin);

/**
* Set rx pin for serial communication.
*
* @param rxPin - the pin to use for RXD: PIO1_6, PIO2_7, PIO3_1, or PIO3_4
*/
void setRxPin(int rxPin);
/**
* Set tx pin for serial communication.
*
* @param txPin - the pin to use for TXD: PIO1_7, PIO2_8, PIO3_0, or PIO3_5
*/
void setTxPin(int txPin);
/**
* Begin using the serial port with the specified baud rate and 8 data bits,
* no parity bit, and 1 stop bit (SERIAL_8N1).
Expand Down
5 changes: 3 additions & 2 deletions sblib/src/eib/bcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ BCU::BCU()
:progButtonDebouncer()
{
progPin = DEFAULT_PROG_PIN;
progPinInv = true;
enabled = false;
}

Expand Down Expand Up @@ -164,14 +165,14 @@ void BCU::loop()
if (bcu.progPin)
{
// Detect the falling edge of pressing the prog button
pinMode(bcu.progPin, INPUT);
pinMode(bcu.progPin, INPUT|PULL_UP);
int oldValue = progButtonDebouncer.value();
if (!progButtonDebouncer.debounce(digitalRead(bcu.progPin), 50) && oldValue)
{
userRam.status ^= 0x81; // toggle programming mode and checksum bit
}
pinMode(bcu.progPin, OUTPUT);
digitalWrite(bcu.progPin, !(userRam.status & BCU_STATUS_PROG));
digitalWrite(bcu.progPin, (userRam.status & BCU_STATUS_PROG)^progPinInv);
}

if (userEeprom.isModified() && bus.idle() && bus.telegramLen == 0 && connectedAddr == 0)
Expand Down
10 changes: 10 additions & 0 deletions sblib/src/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,18 @@


Serial::Serial(int rxPin, int txPin)
{
setRxPin(rxPin);
setTxPin(txPin);
}

void Serial::setRxPin(int rxPin)
{
pinMode(rxPin, SERIAL_RXD);
}

void Serial::setTxPin(int txPin)
{
pinMode(txPin, SERIAL_TXD);
}

Expand Down