Skip to content

Commit

Permalink
Added EnableRs485 function
Browse files Browse the repository at this point in the history
  • Loading branch information
nopnop2002 committed Jan 11, 2022
1 parent ffe3766 commit b425c94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Arduino & ESP8266/SC16IS752.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,21 @@ int SC16IS752::ReadByte(uint8_t channel)

}

void SC16IS752::EnableRs485(uint8_t channel, uint8_t invert)
{
uint8_t temp_efcr;
temp_efcr = ReadRegister(channel, SC16IS750_REG_EFCR);
if ( invert == 0) {
temp_efcr |= 0x20;
} else {
temp_efcr |= 0x30;
}
WriteRegister(channel, SC16IS750_REG_EFCR,temp_efcr);

return;
}


void SC16IS752::EnableTransmit(uint8_t channel, uint8_t tx_enable)
{
uint8_t temp_efcr;
Expand Down
6 changes: 4 additions & 2 deletions Arduino & ESP8266/SC16IS752.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class SC16IS752
void InterruptControl(uint8_t channel, uint8_t int_ena);
void ModemPin(uint8_t gpio); //gpio == 0, gpio[7:4] are modem pins, gpio == 1 gpio[7:4] are gpios
void GPIOLatch(uint8_t latch);

void EnableRs485(uint8_t channel, uint8_t invert);
void EnableTransmit(uint8_t channel, uint8_t tx_enable);


private:
uint8_t device_address_sspin;
Expand All @@ -158,7 +160,7 @@ class SC16IS752
uint8_t FIFOAvailableSpace(uint8_t channel);
void WriteByte(uint8_t channel, uint8_t val);
int ReadByte(uint8_t channel);
void EnableTransmit(uint8_t channel, uint8_t tx_enable);
//void EnableTransmit(uint8_t channel, uint8_t tx_enable);
int peek_buf;
uint8_t peek_flag;

Expand Down

0 comments on commit b425c94

Please sign in to comment.