Skip to content

Commit 56ca37e

Browse files
committed
Update to MicroChip oa-tc6-lib:v3.1.13.
For details see MicrochipTech/oa-tc6-lib@9138e95 .
1 parent ef28d91 commit 56ca37e

File tree

8 files changed

+341
-215
lines changed

8 files changed

+341
-215
lines changed

Diff for: examples/LAN8651-iperf/LAN8651-iperf.ino

+5-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ void loop()
147147
if ((now - prev_beacon_check) > 1000)
148148
{
149149
prev_beacon_check = now;
150-
tc6_inst->getPlcaStatus(OnPlcaStatus);
150+
if (!tc6_inst->getPlcaStatus(OnPlcaStatus))
151+
Serial.println("getPlcaStatus(...) failed");
151152
}
152153
}
153154

@@ -162,8 +163,10 @@ static void OnPlcaStatus(bool success, bool plcaStatus)
162163

163164
if (plcaStatus)
164165
Serial.println("PLCA Mode active");
165-
else
166+
else {
166167
Serial.println("CSMA/CD fallback");
168+
tc6_inst->enablePlca();
169+
}
167170
}
168171

169172
static bool get_mac_address(uint8_t * p_mac)

Diff for: src/T1SPlcaSettings.h

+13-4
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,28 @@ class T1SPlcaSettings
3939
#endif
4040
{
4141
private:
42-
uint8_t const _node_id;
43-
uint8_t const _node_count;
44-
uint8_t const _burst_count;
45-
uint8_t const _burst_timer;
42+
uint8_t _node_id;
43+
uint8_t _node_count;
44+
uint8_t _burst_count;
45+
uint8_t _burst_timer;
4646

4747
public:
48+
static uint8_t const DEFAULT_NODE_ID = 0;
49+
static uint8_t const DEFAULT_NODE_COUNT = 8;
50+
static uint8_t const DEFAULT_BURST_COUNT = 0;
51+
static uint8_t const DEFAULT_BURST_TIMER = 128;
52+
53+
54+
T1SPlcaSettings() : T1SPlcaSettings(DEFAULT_NODE_ID, DEFAULT_NODE_COUNT, DEFAULT_BURST_COUNT, DEFAULT_BURST_TIMER) { }
4855
T1SPlcaSettings(uint8_t const node_id,
4956
uint8_t const node_count,
5057
uint8_t const burst_count,
5158
uint8_t const burst_timer);
5259

60+
5361
virtual size_t printTo(Print & p) const override;
5462

63+
5564
uint8_t node_id() const { return _node_id; }
5665
uint8_t node_count() const { return _node_count; }
5766
uint8_t burst_count() const { return _burst_count; }

Diff for: src/microchip/TC6_Arduino_10BASE_T1S_UDP.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ bool TC6_Arduino_10BASE_T1S_UDP::begin(IPAddress const ip_addr,
210210

211211
netif_set_link_up(&_lw.ip.netint);
212212

213+
/* Copy the settings for internal usage. */
214+
_t1s_plca_settings = t1s_plca_settings;
215+
213216
return true;
214217
}
215218

@@ -243,6 +246,11 @@ bool TC6_Arduino_10BASE_T1S_UDP::getPlcaStatus(TC6LwIP_On_PlcaStatus on_plca_sta
243246
return TC6_ReadRegister(_lw.tc.tc6, 0x0004CA03, true, OnPlcaStatus, &_lw); /* PLCA_status_register.plca_status */
244247
}
245248

249+
bool TC6_Arduino_10BASE_T1S_UDP::enablePlca()
250+
{
251+
return TC6Regs_SetPlca(_lw.tc.tc6, true, _t1s_plca_settings.node_id(), _t1s_plca_settings.node_count());
252+
}
253+
246254
bool TC6_Arduino_10BASE_T1S_UDP::sendWouldBlock()
247255
{
248256
TC6_RawTxSegment *dummySeg;
@@ -655,9 +663,12 @@ void TC6Regs_CB_OnEvent(TC6_t *pInst, TC6Regs_Event_t event, void *pTag)
655663
case TC6Regs_Event_GINT_Mask:
656664
PRINT(ESC_YELLOW "GINT_Mask" ESC_RESETCOLOR "\r\n");
657665
break;
658-
case TC6Regs_Event_PHY_Not_Trimmed:
666+
case TC6Regs_Event_Chip_Error:
659667
PRINT(ESC_RED "PHY is not trimmed" ESC_RESETCOLOR "\r\n");
660668
break;
669+
case TC6Regs_Event_Unsupported_Hardware:
670+
PRINT(ESC_RED "Unsupported hardware" ESC_RESETCOLOR "\r\n");
671+
break;
661672
}
662673
if (reinit)
663674
{

Diff for: src/microchip/TC6_Arduino_10BASE_T1S_UDP.h

+2
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ class TC6_Arduino_10BASE_T1S_UDP : public Arduino_10BASE_T1S_UDP
9494
void digitalWrite(bool dioa0, bool dioa1, bool dioa2);
9595

9696
bool getPlcaStatus(TC6LwIP_On_PlcaStatus on_plca_status);
97+
bool enablePlca();
9798

9899
bool sendWouldBlock();
99100

100101

101102
private:
102103
TC6_Io * _tc6_io;
103104
TC6LwIP_t _lw;
105+
T1SPlcaSettings _t1s_plca_settings;
104106
};
105107

106108
/**************************************************************************************

Diff for: src/microchip/lib/libtc6/inc/tc6-regs.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ typedef enum
7878
TC6Regs_Event_MAC_Int,
7979
TC6Regs_Event_HMX_Int,
8080
TC6Regs_Event_GINT_Mask,
81-
TC6Regs_Event_PHY_Not_Trimmed
81+
TC6Regs_Event_Chip_Error,
82+
TC6Regs_Event_Unsupported_Hardware
8283
} TC6Regs_Event_t;
8384

8485
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
@@ -112,13 +113,13 @@ bool TC6Regs_GetInitDone(TC6_t *pInst);
112113
void TC6Regs_Reinit(TC6_t *pInst);
113114

114115
/** \brief Sets the PLCA Node ID and the PLCA Node Count and can enable/disable PLCA.
115-
* \param idx - The instance number as returned from the TC6LwIP_Init() function.
116+
* \param pInst - The pointer returned by TC6_Init.
116117
* \param plcaEnable - true, if PLCA shall be enabled. false, if CSMA/CD mode shall be used.
117118
* \param nodeId - The new Node ID
118119
* \param nodeCount - The new Node Count
119120
* \return true, if request could be enqueued, the PLCA parameters will be changed soon. false, request failed, no change.
120121
*/
121-
bool TC6Regs_SetPlca(TC6_t *pTC6, bool plcaEnable, uint8_t nodeId, uint8_t nodeCount);
122+
bool TC6Regs_SetPlca(TC6_t *pInst, bool plcaEnable, uint8_t nodeId, uint8_t nodeCount);
122123

123124
/** \brief Sets DIOAx GPIOs to the desired status.
124125
* \param idx - The instance number as returned from the TC6LwIP_Init() function.

Diff for: src/microchip/lib/libtc6/inc/tc6.h

+12-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Microchip or any third party.
2727
2828
Company:
2929
Microchip Technology Inc.
30-
30+
3131
File Name:
3232
tc6.h
3333
@@ -52,6 +52,11 @@ extern "C" {
5252
/* DEFINITIONS */
5353
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
5454

55+
#define TC6_LIB_VER_MAJOR (3U)
56+
#define TC6_LIB_VER_MINOR (1U)
57+
#define TC6_LIB_VER_BUGFIX (3U)
58+
#define TC6_LIB_VER_STRING "V3.1.3"
59+
5560
struct TC6_t;
5661
typedef struct TC6_t TC6_t;
5762

@@ -182,35 +187,35 @@ bool TC6_SendRawEthernetSegments(TC6_t *pInst, const TC6_RawTxSegment *pSegments
182187
/** \brief Reads from MAC / Phy registers
183188
* \param pInst - The pointer returned by TC6_Init.
184189
* \param addr - The 32 Bit register offset.
185-
* \param is_protected - true, enables is_protected control data transmission (normal + inverted data). false, no protection feature is used.
190+
* \param secure - true, enables protected control data transmission (normal + inverted data). false, no protection feature is used.
186191
* \param rxCallback - Pointer to a callback handler. May left NULL.
187192
* \param pTag - Any pointer. Will be given back in given rxCallback. May left NULL.
188193
* \return true, on success. false, otherwise.
189194
*/
190-
bool TC6_ReadRegister(TC6_t *pInst, uint32_t addr, bool is_protected, TC6_RegCallback_t rxCallback, void *pTag);
195+
bool TC6_ReadRegister(TC6_t *pInst, uint32_t addr, bool secure, TC6_RegCallback_t rxCallback, void *pTag);
191196

192197
/** \brief Writes to MAC / Phy registers
193198
* \param pInst - The pointer returned by TC6_Init.
194199
* \param addr - The 32 Bit register offset.
195200
* \param value - The new 32 Bit register value.
196-
* \param is_protected - true, enables is_protected control data transmission (normal + inverted data). false, no protection feature is used.
201+
* \param secure - true, enables protected control data transmission (normal + inverted data). false, no protection feature is used.
197202
* \param txCallback - Pointer to a callback handler. May left NULL.
198203
* \param pTag - Any pointer. Will be given back in given txCallback. May left NULL.
199204
* \return true, on success. false, otherwise.
200205
*/
201-
bool TC6_WriteRegister(TC6_t *pInst, uint32_t addr, uint32_t value, bool is_protected, TC6_RegCallback_t txCallback, void *pTag);
206+
bool TC6_WriteRegister(TC6_t *pInst, uint32_t addr, uint32_t value, bool secure, TC6_RegCallback_t txCallback, void *pTag);
202207

203208
/** \brief Reads, modifies and writes back the changed value to MAC / Phy registers
204209
* \param pInst - The pointer returned by TC6_Init.
205210
* \param addr - The 32 Bit register offset.
206211
* \param value - The 32 Bit register bit values to be changed. This value will be set to register only if mask on the corresponding position is set to 1.
207212
* \param mask - The 32 Bit register bit mask. Only Bits set to 1 will be changed accordingly to value.
208-
* \param is_protected - true, enables is_protected control data transmission (normal + inverted data). false, no protection feature is used.
213+
* \param secure - true, enables protected control data transmission (normal + inverted data). false, no protection feature is used.
209214
* \param modifyCallback - Pointer to a callback handler. May left NULL.
210215
* \param pTag - Any pointer. Will be given back in given modifyCallback. May left NULL.
211216
* \return true, on success. false, otherwise.
212217
*/
213-
bool TC6_ReadModifyWriteRegister(TC6_t *pInst, uint32_t addr, uint32_t value, uint32_t mask, bool is_protected, TC6_RegCallback_t modifyCallback, void *pTag);
218+
bool TC6_ReadModifyWriteRegister(TC6_t *pInst, uint32_t addr, uint32_t value, uint32_t mask, bool secure, TC6_RegCallback_t modifyCallback, void *pTag);
214219

215220
/** \brief Execute a list of register commands
216221
* \param pInst - The pointer returned by TC6_Init.

0 commit comments

Comments
 (0)