Skip to content

Commit e0c1bfc

Browse files
committed
Replace pointers in favour of references.
1 parent 4de4604 commit e0c1bfc

File tree

7 files changed

+45
-45
lines changed

7 files changed

+45
-45
lines changed

examples/UDP_Client/UDP_Client.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static uint16_t const UDP_SERVER_PORT = 8888;
3434
* GLOBAL VARIABLES
3535
**************************************************************************************/
3636

37-
auto const tc6_io = new TC6::TC6_Io(
37+
TC6::TC6_Io tc6_io(
3838
#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33)
3939
SPI1
4040
#else
@@ -43,7 +43,7 @@ auto const tc6_io = new TC6::TC6_Io(
4343
, CS_PIN
4444
, RESET_PIN
4545
, IRQ_PIN);
46-
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
46+
TC6::TC6_Arduino_10BASE_T1S tc6_inst(tc6_io);
4747
Arduino_10BASE_T1S_UDP udp_client;
4848

4949
/**************************************************************************************
@@ -61,19 +61,19 @@ void setup()
6161
*/
6262
pinMode(IRQ_PIN, INPUT_PULLUP);
6363
attachInterrupt(digitalPinToInterrupt(IRQ_PIN),
64-
[]() { tc6_io->onInterrupt(); },
64+
[]() { tc6_io.onInterrupt(); },
6565
FALLING);
6666

6767
/* Initialize IO module. */
68-
if (!tc6_io->begin())
68+
if (!tc6_io.begin())
6969
{
7070
Serial.println("'TC6_Io::begin(...)' failed.");
7171
for (;;) { }
7272
}
7373

7474
MacAddress const mac_addr = MacAddress::create_from_uid();
7575

76-
if (!tc6_inst->begin(ip_addr
76+
if (!tc6_inst.begin(ip_addr
7777
, network_mask
7878
, gateway
7979
, mac_addr
@@ -104,7 +104,7 @@ void loop()
104104
/* Services the hardware and the protocol stack.
105105
* Must be called cyclic. The faster the better.
106106
*/
107-
tc6_inst->service();
107+
tc6_inst.service();
108108

109109
static unsigned long prev_beacon_check = 0;
110110
static unsigned long prev_udp_packet_sent = 0;
@@ -114,7 +114,7 @@ void loop()
114114
if ((now - prev_beacon_check) > 1000)
115115
{
116116
prev_beacon_check = now;
117-
if (!tc6_inst->getPlcaStatus(OnPlcaStatus))
117+
if (!tc6_inst.getPlcaStatus(OnPlcaStatus))
118118
Serial.println("getPlcaStatus(...) failed");
119119
}
120120

@@ -189,6 +189,6 @@ static void OnPlcaStatus(bool success, bool plcaStatus)
189189
Serial.println("PLCA Mode active");
190190
else {
191191
Serial.println("CSMA/CD fallback");
192-
tc6_inst->enablePlca();
192+
tc6_inst.enablePlca();
193193
}
194194
}

examples/UDP_Server/UDP_Server.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static uint16_t const UDP_SERVER_LOCAL_PORT = 8888;
3838
* GLOBAL VARIABLES
3939
**************************************************************************************/
4040

41-
auto const tc6_io = new TC6::TC6_Io(
41+
TC6::TC6_Io tc6_io(
4242
#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33)
4343
SPI1
4444
#else
@@ -47,7 +47,7 @@ auto const tc6_io = new TC6::TC6_Io(
4747
, CS_PIN
4848
, RESET_PIN
4949
, IRQ_PIN);
50-
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
50+
TC6::TC6_Arduino_10BASE_T1S tc6_inst(tc6_io);
5151
Arduino_10BASE_T1S_UDP udp_server;
5252

5353
/**************************************************************************************
@@ -65,19 +65,19 @@ void setup()
6565
*/
6666
pinMode(IRQ_PIN, INPUT_PULLUP);
6767
attachInterrupt(digitalPinToInterrupt(IRQ_PIN),
68-
[]() { tc6_io->onInterrupt(); },
68+
[]() { tc6_io.onInterrupt(); },
6969
FALLING);
7070

7171
/* Initialize IO module. */
72-
if (!tc6_io->begin())
72+
if (!tc6_io.begin())
7373
{
7474
Serial.println("'TC6_Io::begin(...)' failed.");
7575
for (;;) { }
7676
}
7777

7878
MacAddress const mac_addr = MacAddress::create_from_uid();
7979

80-
if (!tc6_inst->begin(ip_addr
80+
if (!tc6_inst.begin(ip_addr
8181
, network_mask
8282
, gateway
8383
, mac_addr
@@ -108,7 +108,7 @@ void loop()
108108
/* Services the hardware and the protocol stack.
109109
* Must be called cyclic. The faster the better.
110110
*/
111-
tc6_inst->service();
111+
tc6_inst.service();
112112

113113
static unsigned long prev_beacon_check = 0;
114114

@@ -117,7 +117,7 @@ void loop()
117117
if ((now - prev_beacon_check) > 1000)
118118
{
119119
prev_beacon_check = now;
120-
if (!tc6_inst->getPlcaStatus(OnPlcaStatus))
120+
if (!tc6_inst.getPlcaStatus(OnPlcaStatus))
121121
Serial.println("getPlcaStatus(...) failed");
122122
}
123123

@@ -180,6 +180,6 @@ static void OnPlcaStatus(bool success, bool plcaStatus)
180180
Serial.println("PLCA Mode active");
181181
else {
182182
Serial.println("CSMA/CD fallback");
183-
tc6_inst->enablePlca();
183+
tc6_inst.enablePlca();
184184
}
185185
}

examples/tools/Control-DIOx/Control-DIOx.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static auto const DIO_PIN = TC6::DIO::A0;
3535
* GLOBAL VARIABLES
3636
**************************************************************************************/
3737

38-
auto const tc6_io = new TC6::TC6_Io(
38+
TC6::TC6_Io tc6_io(
3939
#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33)
4040
SPI1
4141
#else
@@ -44,7 +44,7 @@ auto const tc6_io = new TC6::TC6_Io(
4444
, CS_PIN
4545
, RESET_PIN
4646
, IRQ_PIN);
47-
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
47+
TC6::TC6_Arduino_10BASE_T1S tc6_inst(tc6_io);
4848

4949
/**************************************************************************************
5050
* SETUP/LOOP
@@ -61,19 +61,19 @@ void setup()
6161
*/
6262
pinMode(IRQ_PIN, INPUT_PULLUP);
6363
attachInterrupt(digitalPinToInterrupt(IRQ_PIN),
64-
[]() { tc6_io->onInterrupt(); },
64+
[]() { tc6_io.onInterrupt(); },
6565
FALLING);
6666

6767
/* Initialize IO module. */
68-
if (!tc6_io->begin())
68+
if (!tc6_io.begin())
6969
{
7070
Serial.println("'TC6_Io::begin(...)' failed.");
7171
for (;;) { }
7272
}
7373

7474
MacAddress const mac_addr = MacAddress::create_from_uid();
7575

76-
if (!tc6_inst->begin(ip_addr
76+
if (!tc6_inst.begin(ip_addr
7777
, network_mask
7878
, gateway
7979
, mac_addr
@@ -96,7 +96,7 @@ void loop()
9696
/* Services the hardware and the protocol stack.
9797
* Must be called cyclic. The faster the better.
9898
*/
99-
tc6_inst->service();
99+
tc6_inst.service();
100100

101101
static unsigned long prev_dio_toogle = 0;
102102
auto const now = millis();
@@ -112,7 +112,7 @@ void loop()
112112
Serial.print(" = ");
113113
Serial.println(dio_val);
114114

115-
tc6_inst->digitalWrite(DIO_PIN, dio_val);
115+
tc6_inst.digitalWrite(DIO_PIN, dio_val);
116116
dio_val = !dio_val;
117117
}
118118
}

examples/tools/PoDL-Sink-Auto-TurnOff/PoDL-Sink-Auto-TurnOff.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static T1SMacSettings const t1s_default_mac_settings;
3232
* GLOBAL VARIABLES
3333
**************************************************************************************/
3434

35-
auto const tc6_io = new TC6::TC6_Io(
35+
TC6::TC6_Io tc6_io(
3636
#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33)
3737
SPI1
3838
#else
@@ -41,7 +41,7 @@ auto const tc6_io = new TC6::TC6_Io(
4141
, CS_PIN
4242
, RESET_PIN
4343
, IRQ_PIN);
44-
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
44+
TC6::TC6_Arduino_10BASE_T1S tc6_inst(tc6_io);
4545

4646
/**************************************************************************************
4747
* SETUP/LOOP
@@ -58,19 +58,19 @@ void setup()
5858
*/
5959
pinMode(IRQ_PIN, INPUT_PULLUP);
6060
attachInterrupt(digitalPinToInterrupt(IRQ_PIN),
61-
[]() { tc6_io->onInterrupt(); },
61+
[]() { tc6_io.onInterrupt(); },
6262
FALLING);
6363

6464
/* Initialize IO module. */
65-
if (!tc6_io->begin())
65+
if (!tc6_io.begin())
6666
{
6767
Serial.println("'TC6_Io::begin(...)' failed.");
6868
for (;;) { }
6969
}
7070

7171
MacAddress const mac_addr = MacAddress::create_from_uid();
7272

73-
if (!tc6_inst->begin(ip_addr
73+
if (!tc6_inst.begin(ip_addr
7474
, network_mask
7575
, gateway
7676
, mac_addr
@@ -88,9 +88,9 @@ void setup()
8888
Serial.println(t1s_default_mac_settings);
8989

9090
/* A0 -> LOCAL_ENABLE -> DO NOT feed power from board to network. */
91-
tc6_inst->digitalWrite(TC6::DIO::A0, false);
91+
tc6_inst.digitalWrite(TC6::DIO::A0, false);
9292
/* A1 -> T1S_DISABLE -> Open the switch connecting network to board by pulling EN LOW. */
93-
tc6_inst->digitalWrite(TC6::DIO::A1, true);
93+
tc6_inst.digitalWrite(TC6::DIO::A1, true);
9494

9595
Serial.println("PoDL-Sink-Auto-TurnOff");
9696
}
@@ -100,5 +100,5 @@ void loop()
100100
/* Services the hardware and the protocol stack.
101101
* Must be called cyclic. The faster the better.
102102
*/
103-
tc6_inst->service();
103+
tc6_inst.service();
104104
}

examples/tools/PoDL-Source/PoDL-Source.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static T1SMacSettings const t1s_default_mac_settings;
3232
* GLOBAL VARIABLES
3333
**************************************************************************************/
3434

35-
auto const tc6_io = new TC6::TC6_Io(
35+
TC6::TC6_Io tc6_io(
3636
#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33)
3737
SPI1
3838
#else
@@ -41,7 +41,7 @@ auto const tc6_io = new TC6::TC6_Io(
4141
, CS_PIN
4242
, RESET_PIN
4343
, IRQ_PIN);
44-
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
44+
TC6::TC6_Arduino_10BASE_T1S tc6_inst(tc6_io);
4545

4646
/**************************************************************************************
4747
* SETUP/LOOP
@@ -58,19 +58,19 @@ void setup()
5858
*/
5959
pinMode(IRQ_PIN, INPUT_PULLUP);
6060
attachInterrupt(digitalPinToInterrupt(IRQ_PIN),
61-
[]() { tc6_io->onInterrupt(); },
61+
[]() { tc6_io.onInterrupt(); },
6262
FALLING);
6363

6464
/* Initialize IO module. */
65-
if (!tc6_io->begin())
65+
if (!tc6_io.begin())
6666
{
6767
Serial.println("'TC6_Io::begin(...)' failed.");
6868
for (;;) { }
6969
}
7070

7171
MacAddress const mac_addr = MacAddress::create_from_uid();
7272

73-
if (!tc6_inst->begin(ip_addr
73+
if (!tc6_inst.begin(ip_addr
7474
, network_mask
7575
, gateway
7676
, mac_addr
@@ -88,9 +88,9 @@ void setup()
8888
Serial.println(t1s_default_mac_settings);
8989

9090
/* A0 -> LOCAL_ENABLE -> feed power from board to network. */
91-
tc6_inst->digitalWrite(TC6::DIO::A0, true);
91+
tc6_inst.digitalWrite(TC6::DIO::A0, true);
9292
/* A1 -> T1S_DISABLE -> close the switch connecting network to board. */
93-
tc6_inst->digitalWrite(TC6::DIO::A1, true);
93+
tc6_inst.digitalWrite(TC6::DIO::A1, true);
9494

9595
Serial.println("PoDL-Source");
9696
}
@@ -100,5 +100,5 @@ void loop()
100100
/* Services the hardware and the protocol stack.
101101
* Must be called cyclic. The faster the better.
102102
*/
103-
tc6_inst->service();
103+
tc6_inst.service();
104104
}

src/microchip/TC6_Arduino_10BASE_T1S.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ static err_t lwIpOut(struct netif *netif, struct pbuf *p);
103103
* CTOR/DTOR
104104
**************************************************************************************/
105105

106-
TC6_Arduino_10BASE_T1S::TC6_Arduino_10BASE_T1S(TC6_Io * tc6_io)
106+
TC6_Arduino_10BASE_T1S::TC6_Arduino_10BASE_T1S(TC6_Io & tc6_io)
107107
: _tc6_io{tc6_io}
108108
{
109-
_lw.io = tc6_io;
109+
_lw.io = &tc6_io;
110110
}
111111

112112
TC6_Arduino_10BASE_T1S::~TC6_Arduino_10BASE_T1S()
@@ -206,11 +206,11 @@ void TC6_Arduino_10BASE_T1S::service()
206206
{
207207
sys_check_timeouts(); /* LWIP timers - ARP, DHCP, TCP, etc. */
208208

209-
if (_tc6_io->isInterruptActive())
209+
if (_tc6_io.isInterruptActive())
210210
{
211211
if (TC6_Service(_lw.tc.tc6, false))
212212
{
213-
_tc6_io->releaseInterrupt();
213+
_tc6_io.releaseInterrupt();
214214
}
215215
} else if (_lw.tc.tc6NeedService)
216216
{

src/microchip/TC6_Arduino_10BASE_T1S.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum class DIO { A0, A1 };
7474
class TC6_Arduino_10BASE_T1S : public Arduino_10BASE_T1S_PHY_Interface
7575
{
7676
public:
77-
TC6_Arduino_10BASE_T1S(TC6_Io * tc6_io);
77+
TC6_Arduino_10BASE_T1S(TC6_Io & tc6_io);
7878

7979
virtual ~TC6_Arduino_10BASE_T1S();
8080

@@ -98,7 +98,7 @@ class TC6_Arduino_10BASE_T1S : public Arduino_10BASE_T1S_PHY_Interface
9898

9999

100100
private:
101-
TC6_Io * _tc6_io;
101+
TC6_Io & _tc6_io;
102102
TC6LwIP_t _lw;
103103
T1SPlcaSettings _t1s_plca_settings;
104104

0 commit comments

Comments
 (0)