Skip to content

Commit 41438c4

Browse files
author
Andreas Karlsson
committed
Add readback that SM bit is set enabled/disabled
On PDI disable/enable, add polling readback that it is set/cleared. Set 1 is delayed until the end of a frame which is currently processed, ET1100 datasheet. This aligns the code base with SCC behavior.
1 parent 56124c2 commit 41438c4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Diff for: soes/esc.c

+21-1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ void ESC_SMwritepdi (uint8_t n)
162162
ESC_write ((uint16_t)(ESCREG_SM0PDI + (n << 3)), &(sm->ActPDI), 1);
163163
}
164164

165+
/** Read ESC PDI control register 0x807(+ offset to SyncManager n) to ESCvar.SM[n] data.
166+
*
167+
* @param[in] n = Read from Sync Manager no. n
168+
*/
169+
void ESC_SMreadpdi (uint8_t n)
170+
{
171+
_ESCsm2* sm;
172+
sm = (_ESCsm2*)&ESCvar.SM[n];
173+
ESC_read ((uint16_t)(ESCREG_SM0PDI + (n << 3)), &(sm->ActPDI), 1);
174+
}
175+
165176
/** Write 0 to Bit0 in SM PDI control register 0x807(+ offset to SyncManager n) to Activate the Sync Manager n.
166177
*
167178
* @param[in] n = Write to Sync Manager no. n
@@ -172,6 +183,11 @@ void ESC_SMenable (uint8_t n)
172183
sm = (_ESCsm2 *)&ESCvar.SM[n];
173184
sm->ActPDI &= (uint8_t)~ESCREG_SMENABLE_BIT;
174185
ESC_SMwritepdi (n);
186+
/* Read back wait until enabled */
187+
do
188+
{
189+
ESC_SMreadpdi (n);
190+
} while ((sm->ActPDI & ESCREG_SMENABLE_BIT) == 1);
175191
}
176192
/** Write 1 to Bit0 in SM PDI control register 0x807(+ offset to SyncManager n) to De-activte the Sync Manager n.
177193
*
@@ -183,6 +199,11 @@ void ESC_SMdisable (uint8_t n)
183199
sm = (_ESCsm2 *)&ESCvar.SM[n];
184200
sm->ActPDI |= ESCREG_SMENABLE_BIT;
185201
ESC_SMwritepdi (n);
202+
/* Read back wait until disabled */
203+
do
204+
{
205+
ESC_SMreadpdi (n);
206+
} while ((sm->ActPDI & ESCREG_SMENABLE_BIT) == 0);
186207
}
187208
/** Read Configured Station Address register 0x010 assigned by the Master.
188209
*
@@ -321,7 +342,6 @@ uint8_t ESC_startmbx (uint8_t state)
321342
ESCvar.activemb0 = &ESCvar.mb[0];
322343
ESCvar.activemb1 = &ESCvar.mb[1];
323344

324-
325345
ESC_SMenable (0);
326346
ESC_SMenable (1);
327347
ESC_SMstatus (0);

0 commit comments

Comments
 (0)