Skip to content

Commit

Permalink
v1.0.7
Browse files Browse the repository at this point in the history
* Updated documentation.
  • Loading branch information
vishnumaiea committed Jul 25, 2023
1 parent 5ca2b37 commit aa8f651
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.~*.insyncdl
5 changes: 5 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
:repository-owner: CIRCUITSTATE
:repository-name: CSE_ArduinoRS485
:repository-version: 1.0.7

= {repository-name} Library for Arduino =

image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml/badge.svg["Check Arduino status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml"]
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml/badge.svg["Compile Examples status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml"]
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml/badge.svg["Spell Check status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml"]

This Arduino library allows you to send and receive data using the **RS-485** interface standard. Supported by all Arduino-compatible boards such as ESP32, STM32, RP2040, AVR, SAMD, ESP8266, etc. You can use both hardware and software serial ports. This library supports the Maxim Integrated MAX485 and equivalent chipsets.

Three examples are included with this library:
Expand Down
143 changes: 46 additions & 97 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@

## Methods

### `begin()`
### `RS485Class()`

Initializes the RS485 object communication speed.
Creates a new CSE_ArduinoRS485 object. If you are using a hardware serial port, you can simply send its name as a parameter. If you are using software serial, you must include the SoftwareSerial library first and create a new object of that type. Then send the name of the object as a parameter.

#### Syntax

```cpp
RS485Class RS485 (serial, dePin, rePin, txPin);
```
RS485.begin(baudrate)
#### Parameters
* _serial_: Name of the serial port to use. Can be hardware serial or software serial.
* _dePin_: Drive enable pin.
* _rePin_: Receive enable pin. Optional. Default: -1.
* _txPin_: Serial transmit pin (used to send break signals). Optional. Default: -1.
### `begin()`
Initializes the RS485 object communication speed. The baudrate can be left empty to make it 0. This will prevent the serial port from being initialized by the RS485 library. But then you have to manually initialize the serial port before calling any RS485 library function.
#### Syntax
```cpp
RS485.begin (baudrate)
```

#### Parameters
Expand Down Expand Up @@ -38,11 +55,11 @@ None.

### `end()`

Disables RS485 communication.
Disables RS485 communication. This will close the serial port and reset the DE and RE pins to INPUT mode.

#### Syntax

```
```cpp
RS485.end()
```

Expand Down Expand Up @@ -76,7 +93,7 @@ Get the number of bytes (characters) available for reading from the RS485 port.

#### Syntax

```
```cpp
RS485.available()
```

Expand Down Expand Up @@ -110,7 +127,7 @@ Returns the next byte (character) of the incoming serial data without removing i

#### Syntax

```
```cpp
RS485.peek()
```

Expand Down Expand Up @@ -144,7 +161,7 @@ Reads incoming serial data.

#### Syntax

```
```cpp
RS485.read()
```

Expand Down Expand Up @@ -178,8 +195,8 @@ Writes binary data to the serial port. This data is sent as a byte or series of

#### Syntax

```
RS485.write(uint8_t b)
```cpp
RS485.write (uint8_t b)
```

#### Parameters
Expand Down Expand Up @@ -212,7 +229,7 @@ Waits for the transmission of outgoing serial data to complete.

#### Syntax

```
```cpp
RS485.flush()
```

Expand Down Expand Up @@ -242,11 +259,11 @@ None.

### `beginTransmission()`

Enables RS-485 transmission.
Enables RS-485 transmission. This will assert the DE pin and the RE pin is not modified (since DE has priority over RE).

#### Syntax

```
```cpp
RS485.beginTransmission()
```

Expand All @@ -258,29 +275,6 @@ None.

None.

#### Example

```
#include <ArduinoRS485.h>
int counter = 0;
void setup() {
RS485.begin(9600);
}
void loop() {
RS485.beginTransmission();
RS485.print("Counter: ");
RS485.println(counter);
RS485.endTransmission();
counter++;
delay(1000);
}
```

#### See also

* [begin()](#begin)
Expand All @@ -299,11 +293,11 @@ void loop() {

### `endTransmission()`

Disables RS-485 transmission.
Disables RS-485 transmission. This deasserts the DE pin and the RE pin is not modified (since DE has priority over RE).

#### Syntax

```
```cpp
RS485.endTransmission()
```

Expand All @@ -315,29 +309,6 @@ None.

None.

#### Example

```
#include <ArduinoRS485.h>
int counter = 0;
void setup() {
RS485.begin(9600);
}
void loop() {
RS485.beginTransmission();
RS485.print("Counter: ");
RS485.println(counter);
RS485.endTransmission();
counter++;
delay(1000);
}
```

#### See also

* [begin()](#begin)
Expand All @@ -356,11 +327,11 @@ void loop() {

### `receive()`

Enables reception.
Enables reception. This asserts the RE pin. The state of the DE pins should be set to LOW before calling this function.

#### Syntax

```
```cpp
RS485.receive()
```

Expand All @@ -372,28 +343,6 @@ None.

None.

#### Example

```
#include <ArduinoRS485.h>
void setup() {
Serial.begin(9600);
while (!Serial);
RS485.begin(9600);
// Enable data reception
RS485.receive();
}
void loop() {
if (RS485.available()) {
Serial.write(RS485.read());
}
}
```

#### See also

* [begin()](#begin)
Expand All @@ -412,11 +361,11 @@ void loop() {

### `noReceive()`

Disables reception.
Disables reception. This deasserts the RE pin. If the DE pin is also deasserted (LOW), then the transceiver enters a high-impedance state.

#### Syntax

```
```cpp
RS485.noReceive()
```

Expand Down Expand Up @@ -446,12 +395,12 @@ None.

### `sendBreak()`

Sends a serial break signal for the specified duration in milliseconds.
Sends a serial break signal for the specified duration in milliseconds. This function will only work if the TX pin is specified in the constructor. The serial port will be reinitialized only if the baudrate is greater than 0.

#### Syntax

```
RS485.sendBreak(unsigned int duration)
```cpp
RS485.sendBreak (unsigned int duration)
```

#### Parameters
Expand Down Expand Up @@ -480,12 +429,12 @@ None.

### `sendBreakMicroseconds()`

Sends a serial break signal for the specified duration in microseconds.
Sends a serial break signal for the specified duration in microseconds. This function will only work if the TX pin is specified in the constructor. The serial port will be reinitialized only if the baudrate is greater than 0.

#### Syntax

```
RS485.sendBreak(unsigned int duration)
```cpp
RS485.sendBreak (unsigned int duration)
```

#### Parameters
Expand Down Expand Up @@ -514,19 +463,19 @@ None.

### `setPins()`

Modify the pins used to communicate with the MAX3157 chipset. By default the library uses pin 14 for TX, pin A6 for drive output enable, and pin A5 for receiver output enable.
Modify the pins used to communicate with the RS-485 transceiver.

#### Syntax

```
RS485.setPins(int txPin, int dePin, int rePin)
```cpp
RS485.setPins (int dePin, int rePin, int txPin)
```

#### Parameters

* _txPin_: transmission pin (used to send break signals).
* _dePin_: drive output enable pin.
* _rePin_: receiver output enable pin.
* _txPin_: transmission pin (used to send break signals).

#### Returns

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"url": "https://github.com/CIRCUITSTATE",
"maintainer": true
},
"version": "1.0.6",
"version": "1.0.7",
"license": "LGPL-2.1",
"frameworks": "arduino",
"platforms": "*"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CSE_ArduinoRS485
version=1.0.6
version=1.0.7
author=CIRCUITSTATE
maintainer=CIRCUITSTATE <@circuitstate>
sentence=Allows sending and receiving data through the RS-485 interface, using any Arduino-compatible boards.
Expand Down
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions src/CSE_RS485.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
//===================================================================================//

// Version: 1.0.6
// Last modified: +05:30 19:18:39 PM 25-07-2023, Tuesday
// Version: 1.0.7
// Last modified: +05:30 20:29:06 PM 25-07-2023, Tuesday
// Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485

//===================================================================================//
Expand Down
4 changes: 2 additions & 2 deletions src/CSE_RS485.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
//===================================================================================//

// Version: 1.0.6
// Last modified: +05:30 19:20:17 PM 25-07-2023, Tuesday
// Version: 1.0.7
// Last modified: +05:30 20:29:01 PM 25-07-2023, Tuesday
// Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485

//===================================================================================//
Expand Down

0 comments on commit aa8f651

Please sign in to comment.